diff options
Diffstat (limited to 'target/linux/ipq806x/patches-5.4/0063-1-ipq806x-tsens-driver.patch')
-rw-r--r-- | target/linux/ipq806x/patches-5.4/0063-1-ipq806x-tsens-driver.patch | 156 |
1 files changed, 79 insertions, 77 deletions
diff --git a/target/linux/ipq806x/patches-5.4/0063-1-ipq806x-tsens-driver.patch b/target/linux/ipq806x/patches-5.4/0063-1-ipq806x-tsens-driver.patch index 9ee88533aa..80954c17fd 100644 --- a/target/linux/ipq806x/patches-5.4/0063-1-ipq806x-tsens-driver.patch +++ b/target/linux/ipq806x/patches-5.4/0063-1-ipq806x-tsens-driver.patch @@ -27,11 +27,13 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> --- a/drivers/thermal/qcom/Makefile +++ b/drivers/thermal/qcom/Makefile -@@ -1,2 +1,3 @@ +@@ -2,5 +2,5 @@ obj-$(CONFIG_QCOM_TSENS) += qcom_tsens.o --qcom_tsens-y += tsens.o tsens-common.o tsens-8916.o tsens-8974.o tsens-8960.o tsens-v2.o -+qcom_tsens-y += tsens.o tsens-common.o tsens-8916.o tsens-8974.o tsens-8960.o tsens-v2.o \ -+ tsens-ipq8064.o + + qcom_tsens-y += tsens.o tsens-common.o tsens-v0_1.o \ +- tsens-8960.o tsens-v2.o tsens-v1.o ++ tsens-8960.o tsens-v2.o tsens-v1.o tsens-ipq8064.o + obj-$(CONFIG_QCOM_SPMI_TEMP_ALARM) += qcom-spmi-temp-alarm.o --- /dev/null +++ b/drivers/thermal/qcom/tsens-ipq8064.c @@ -0,0 +1,551 @@ @@ -187,17 +189,17 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + return code; +} + -+static int suspend_ipq8064(struct tsens_device *tmdev) ++static int suspend_ipq8064(struct tsens_priv *priv) +{ + int ret; + unsigned int mask; -+ struct regmap *map = tmdev->map; ++ struct regmap *map = priv->tm_map; + -+ ret = regmap_read(map, THRESHOLD_ADDR, &tmdev->ctx.threshold); ++ ret = regmap_read(map, THRESHOLD_ADDR, &priv->ctx.threshold); + if (ret) + return ret; + -+ ret = regmap_read(map, CNTL_ADDR, &tmdev->ctx.control); ++ ret = regmap_read(map, CNTL_ADDR, &priv->ctx.control); + if (ret) + return ret; + @@ -210,10 +212,10 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + return 0; +} + -+static int resume_ipq8064(struct tsens_device *tmdev) ++static int resume_ipq8064(struct tsens_priv *priv) +{ + int ret; -+ struct regmap *map = tmdev->map; ++ struct regmap *map = priv->tm_map; + + ret = regmap_update_bits(map, CNTL_ADDR, SW_RST, SW_RST); + if (ret) @@ -223,11 +225,11 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + if (ret) + return ret; + -+ ret = regmap_write(map, THRESHOLD_ADDR, tmdev->ctx.threshold); ++ ret = regmap_write(map, THRESHOLD_ADDR, priv->ctx.threshold); + if (ret) + return ret; + -+ ret = regmap_write(map, CNTL_ADDR, tmdev->ctx.control); ++ ret = regmap_write(map, CNTL_ADDR, priv->ctx.control); + if (ret) + return ret; + @@ -244,23 +246,23 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + +static void tsens_scheduler_fn(struct work_struct *work) +{ -+ struct tsens_device *tmdev = container_of(work, struct tsens_device, ++ struct tsens_priv *priv = container_of(work, struct tsens_priv, + tsens_work); + unsigned int threshold, threshold_low, code, reg, sensor, mask; + unsigned int sensor_addr; + bool upper_th_x, lower_th_x; + int adc_code, ret; + -+ ret = regmap_read(tmdev->map, STATUS_CNTL_8064, ®); ++ ret = regmap_read(priv->tm_map, STATUS_CNTL_8064, ®); + if (ret) + return; + reg = reg | LOWER_STATUS_CLR | UPPER_STATUS_CLR; -+ ret = regmap_write(tmdev->map, STATUS_CNTL_8064, reg); ++ ret = regmap_write(priv->tm_map, STATUS_CNTL_8064, reg); + if (ret) + return; + + mask = ~(LOWER_STATUS_CLR | UPPER_STATUS_CLR); -+ ret = regmap_read(tmdev->map, THRESHOLD_ADDR, &threshold); ++ ret = regmap_read(priv->tm_map, THRESHOLD_ADDR, &threshold); + if (ret) + return; + threshold_low = (threshold & THRESHOLD_LOWER_LIMIT_MASK) @@ -268,11 +270,11 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + threshold = (threshold & THRESHOLD_UPPER_LIMIT_MASK) + >> THRESHOLD_UPPER_LIMIT_SHIFT; + -+ ret = regmap_read(tmdev->map, STATUS_CNTL_8064, ®); ++ ret = regmap_read(priv->tm_map, STATUS_CNTL_8064, ®); + if (ret) + return; + -+ ret = regmap_read(tmdev->map, CNTL_ADDR, &sensor); ++ ret = regmap_read(priv->tm_map, CNTL_ADDR, &sensor); + if (ret) + return; + sensor &= (uint32_t) TSENS_8064_SENSORS_EN; @@ -286,7 +288,7 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + + /* Skip if the sensor is disabled */ + if (sensor & 1) { -+ ret = regmap_read(tmdev->map, tmdev->sensor[0].status, &code); ++ ret = regmap_read(priv->tm_map, priv->sensor[0].status, &code); + if (ret) + return; + upper_th_x = code >= threshold; @@ -297,13 +299,13 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + mask |= LOWER_STATUS_CLR; + if (upper_th_x || lower_th_x) { + /* Notify user space */ -+ schedule_work(&tmdev->sensor[0].notify_work); -+ regmap_read(tmdev->map, sensor_addr, &adc_code); ++ schedule_work(&priv->sensor[0].notify_work); ++ regmap_read(priv->tm_map, sensor_addr, &adc_code); + pr_debug("Trigger (%d degrees) for sensor %d\n", -+ code_to_degC(adc_code, &tmdev->sensor[0]), 0); ++ code_to_degC(adc_code, &priv->sensor[0]), 0); + } + } -+ regmap_write(tmdev->map, STATUS_CNTL_8064, reg & mask); ++ regmap_write(priv->tm_map, STATUS_CNTL_8064, reg & mask); + + /* force memory to sync */ + mb(); @@ -311,59 +313,59 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + +static irqreturn_t tsens_isr(int irq, void *data) +{ -+ struct tsens_device *tmdev = data; ++ struct tsens_priv *priv = data; + -+ schedule_work(&tmdev->tsens_work); ++ schedule_work(&priv->tsens_work); + return IRQ_HANDLED; +} + -+static void hw_init(struct tsens_device *tmdev) ++static void hw_init(struct tsens_priv *priv) +{ + int ret; + unsigned int reg_cntl = 0, reg_cfg = 0, reg_thr = 0; + unsigned int reg_status_cntl = 0; + -+ regmap_read(tmdev->map, CNTL_ADDR, ®_cntl); -+ regmap_write(tmdev->map, CNTL_ADDR, reg_cntl | TSENS_SW_RST); ++ regmap_read(priv->tm_map, CNTL_ADDR, ®_cntl); ++ regmap_write(priv->tm_map, CNTL_ADDR, reg_cntl | TSENS_SW_RST); + + reg_cntl |= SLP_CLK_ENA | (MEASURE_PERIOD << 18) -+ | (((1 << tmdev->num_sensors) - 1) << SENSOR0_SHIFT); -+ regmap_write(tmdev->map, CNTL_ADDR, reg_cntl); -+ regmap_read(tmdev->map, STATUS_CNTL_8064, ®_status_cntl); ++ | (((1 << priv->num_sensors) - 1) << SENSOR0_SHIFT); ++ regmap_write(priv->tm_map, CNTL_ADDR, reg_cntl); ++ regmap_read(priv->tm_map, STATUS_CNTL_8064, ®_status_cntl); + reg_status_cntl |= LOWER_STATUS_CLR | UPPER_STATUS_CLR + | MIN_STATUS_MASK | MAX_STATUS_MASK; -+ regmap_write(tmdev->map, STATUS_CNTL_8064, reg_status_cntl); ++ regmap_write(priv->tm_map, STATUS_CNTL_8064, reg_status_cntl); + reg_cntl |= TSENS_EN; -+ regmap_write(tmdev->map, CNTL_ADDR, reg_cntl); ++ regmap_write(priv->tm_map, CNTL_ADDR, reg_cntl); + -+ regmap_read(tmdev->map, CONFIG_ADDR, ®_cfg); ++ regmap_read(priv->tm_map, CONFIG_ADDR, ®_cfg); + reg_cfg = (reg_cfg & ~CONFIG_MASK) | (CONFIG << CONFIG_SHIFT); -+ regmap_write(tmdev->map, CONFIG_ADDR, reg_cfg); ++ regmap_write(priv->tm_map, CONFIG_ADDR, reg_cfg); + + reg_thr |= (LOWER_LIMIT_TH << THRESHOLD_LOWER_LIMIT_SHIFT) + | (UPPER_LIMIT_TH << THRESHOLD_UPPER_LIMIT_SHIFT) + | (MIN_LIMIT_TH << THRESHOLD_MIN_LIMIT_SHIFT) + | (MAX_LIMIT_TH << THRESHOLD_MAX_LIMIT_SHIFT); + -+ regmap_write(tmdev->map, THRESHOLD_ADDR, reg_thr); ++ regmap_write(priv->tm_map, THRESHOLD_ADDR, reg_thr); + -+ ret = devm_request_irq(tmdev->dev, tmdev->tsens_irq, tsens_isr, -+ IRQF_TRIGGER_RISING, "tsens_interrupt", tmdev); ++ ret = devm_request_irq(priv->dev, priv->tsens_irq, tsens_isr, ++ IRQF_TRIGGER_RISING, "tsens_interrupt", priv); + if (ret < 0) { + pr_err("%s: request_irq FAIL: %d\n", __func__, ret); + return; + } + -+ INIT_WORK(&tmdev->tsens_work, tsens_scheduler_fn); ++ INIT_WORK(&priv->tsens_work, tsens_scheduler_fn); +} + -+static int init_ipq8064(struct tsens_device *tmdev) ++static int init_ipq8064(struct tsens_priv *priv) +{ + int ret, i; + u32 reg_cntl, offset = 0; + -+ init_common(tmdev); -+ if (!tmdev->map) ++ init_common(priv); ++ if (!priv->tm_map) + return -ENODEV; + + /* @@ -372,55 +374,55 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + * but the control registers stay in the same place, i.e + * directly after the first 5 status registers. + */ -+ for (i = 0; i < tmdev->num_sensors; i++) { ++ for (i = 0; i < priv->num_sensors; i++) { + if (i >= TSENS_8064_SEQ_SENSORS) + offset = TSENS_8064_S4_S5_OFFSET; + -+ tmdev->sensor[i].status = S0_STATUS_ADDR + offset ++ priv->sensor[i].status = S0_STATUS_ADDR + offset + + (i << STATUS_ADDR_OFFSET); -+ tmdev->sensor[i].slope = tsens_8064_slope[i]; -+ INIT_WORK(&tmdev->sensor[i].notify_work, ++ priv->sensor[i].slope = tsens_8064_slope[i]; ++ INIT_WORK(&priv->sensor[i].notify_work, + notify_uspace_tsens_fn); + } + + reg_cntl = SW_RST; -+ ret = regmap_update_bits(tmdev->map, CNTL_ADDR, SW_RST, reg_cntl); ++ ret = regmap_update_bits(priv->tm_map, CNTL_ADDR, SW_RST, reg_cntl); + if (ret) + return ret; + + reg_cntl |= SLP_CLK_ENA | (MEASURE_PERIOD << 18); + reg_cntl &= ~SW_RST; -+ ret = regmap_update_bits(tmdev->map, CONFIG_ADDR, ++ ret = regmap_update_bits(priv->tm_map, CONFIG_ADDR, + CONFIG_MASK, CONFIG); + -+ reg_cntl |= GENMASK(tmdev->num_sensors - 1, 0) << SENSOR0_SHIFT; -+ ret = regmap_write(tmdev->map, CNTL_ADDR, reg_cntl); ++ reg_cntl |= GENMASK(priv->num_sensors - 1, 0) << SENSOR0_SHIFT; ++ ret = regmap_write(priv->tm_map, CNTL_ADDR, reg_cntl); + if (ret) + return ret; + + reg_cntl |= EN; -+ ret = regmap_write(tmdev->map, CNTL_ADDR, reg_cntl); ++ ret = regmap_write(priv->tm_map, CNTL_ADDR, reg_cntl); + if (ret) + return ret; + + return 0; +} + -+static int calibrate_ipq8064(struct tsens_device *tmdev) ++static int calibrate_ipq8064(struct tsens_priv *priv) +{ + int i; + char *data, *data_backup; + -+ ssize_t num_read = tmdev->num_sensors; -+ struct tsens_sensor *s = tmdev->sensor; ++ ssize_t num_read = priv->num_sensors; ++ struct tsens_sensor *s = priv->sensor; + -+ data = qfprom_read(tmdev->dev, "calib"); ++ data = qfprom_read(priv->dev, "calib"); + if (IS_ERR(data)) { + pr_err("Calibration not found.\n"); + return PTR_ERR(data); + } + -+ data_backup = qfprom_read(tmdev->dev, "calib_backup"); ++ data_backup = qfprom_read(priv->dev, "calib_backup"); + if (IS_ERR(data_backup)) { + pr_err("Backup calibration not found.\n"); + return PTR_ERR(data_backup); @@ -440,26 +442,26 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + s[i].offset = CAL_MDEGC - (s[i].calib_data * s[i].slope); + } + -+ hw_init(tmdev); ++ hw_init(priv); + + return 0; +} + -+static int get_temp_ipq8064(struct tsens_device *tmdev, int id, int *temp) ++static int get_temp_ipq8064(struct tsens_priv *priv, int id, int *temp) +{ + int ret; + u32 code, trdy; -+ const struct tsens_sensor *s = &tmdev->sensor[id]; ++ const struct tsens_sensor *s = &priv->sensor[id]; + unsigned long timeout; + + timeout = jiffies + usecs_to_jiffies(TIMEOUT_US); + do { -+ ret = regmap_read(tmdev->map, INT_STATUS_ADDR, &trdy); ++ ret = regmap_read(priv->tm_map, INT_STATUS_ADDR, &trdy); + if (ret) + return ret; + if (!(trdy & TRDY_MASK)) + continue; -+ ret = regmap_read(tmdev->map, s->status, &code); ++ ret = regmap_read(priv->tm_map, s->status, &code); + if (ret) + return ret; + *temp = code_to_degC(code, s); @@ -474,18 +476,18 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + unsigned int reg_th, reg_cntl; + int ret, code, code_chk, hi_code, lo_code; + const struct tsens_sensor *s = data; -+ struct tsens_device *tmdev = s->tmdev; ++ struct tsens_priv *priv = s->priv; + + code_chk = code = degC_to_code(temp, s); + + if (code < THRESHOLD_MIN_CODE || code > THRESHOLD_MAX_CODE) + return -EINVAL; + -+ ret = regmap_read(tmdev->map, STATUS_CNTL_8064, ®_cntl); ++ ret = regmap_read(priv->tm_map, STATUS_CNTL_8064, ®_cntl); + if (ret) + return ret; + -+ ret = regmap_read(tmdev->map, THRESHOLD_ADDR, ®_th); ++ ret = regmap_read(priv->tm_map, THRESHOLD_ADDR, ®_th); + if (ret) + return ret; + @@ -519,7 +521,7 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + return -EINVAL; + } + -+ ret = regmap_write(tmdev->map, THRESHOLD_ADDR, reg_th | code); ++ ret = regmap_write(priv->tm_map, THRESHOLD_ADDR, reg_th | code); + if (ret) + return ret; + @@ -531,13 +533,13 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> +{ + unsigned int reg_cntl, mask, val; + const struct tsens_sensor *s = data; -+ struct tsens_device *tmdev = s->tmdev; ++ struct tsens_priv *priv = s->priv; + int ret; + -+ if (!tmdev || trip < 0) ++ if (!priv || trip < 0) + return -EINVAL; + -+ ret = regmap_read(tmdev->map, STATUS_CNTL_8064, ®_cntl); ++ ret = regmap_read(priv->tm_map, STATUS_CNTL_8064, ®_cntl); + if (ret) + return ret; + @@ -563,7 +565,7 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + else + val = reg_cntl & ~mask; + -+ ret = regmap_write(tmdev->map, STATUS_CNTL_8064, val); ++ ret = regmap_write(priv->tm_map, STATUS_CNTL_8064, val); + if (ret) + return ret; + @@ -582,13 +584,13 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> + .set_trip_activate = set_trip_activate_ipq8064, +}; + -+const struct tsens_data data_ipq8064 = { ++const struct tsens_plat_data data_ipq8064 = { + .num_sensors = 11, + .ops = &ops_ipq8064, +}; --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c -@@ -75,8 +75,11 @@ static const struct of_device_id tsens_t +@@ -69,8 +69,11 @@ static const struct of_device_id tsens_t }, { .compatible = "qcom,tsens-v2", .data = &data_tsens_v2, @@ -603,12 +605,12 @@ Signed-off-by: Rajith Cherian <rajith@codeaurora.org> --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h -@@ -89,7 +89,7 @@ int init_common(struct tsens_device *); - int get_temp_common(struct tsens_device *, int, int *); +@@ -324,7 +324,7 @@ extern const struct tsens_plat_data data + extern const struct tsens_plat_data data_8916, data_8974; /* TSENS v1 targets */ --extern const struct tsens_data data_8916, data_8974, data_8960; -+extern const struct tsens_data data_8916, data_8974, data_8960, data_ipq8064; - /* TSENS v2 targets */ - extern const struct tsens_data data_8996, data_tsens_v2; +-extern const struct tsens_plat_data data_tsens_v1; ++extern const struct tsens_plat_data data_tsens_v1, data_ipq8064; + /* TSENS v2 targets */ + extern const struct tsens_plat_data data_8996, data_tsens_v2; |