summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorBai Ping <ping.bai@nxp.com>2015-12-23 16:52:57 +0800
committerOctavian Purdila <octavian.purdila@nxp.com>2017-02-23 14:21:42 +0200
commit7888ccda80ebb33ff1d71329fb2ea5cbd019e11e (patch)
tree41f963b419048053f20e92106538a3f572b49cc6 /drivers/thermal
parentd2263c1e5fee7b1508d740770b2c8c932f4f162e (diff)
MLK-12072 thermal: imx: enable tempmon finish bit check on imx7d TO1.1
On i.MX7D TO1.0, the finish bit in tempmon module used for verify the temp value is broken, so it can NOT be used for checking the temp value. On TO1.1, this issue has been fixed, so we can use this bit to verify if the temp value is valid. Signed-off-by: Bai Ping <ping.bai@nxp.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/imx_thermal.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 1ae06c5f81a8..a4fb898ef0b1 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -63,6 +63,7 @@
#define OCOTP_ANA1 0x04e0
/* i.MX7D specific */
+#define IMX7_ANADIG_DIGPROG 0x800
#define IMX7_TEMPSENSE0 0X300
#define IMX7_TEMPSENSE0_PANIC_ALARM_SHIFT 18
#define IMX7_TEMPSENSE0_PANIC_ALARM_MASK (0x1ff << 18)
@@ -235,6 +236,7 @@ struct imx_thermal_data {
};
static struct imx_thermal_data *imx_thermal_data;
+static int skip_finish_check;
static void imx_set_panic_temp(struct imx_thermal_data *data,
int panic_temp)
@@ -308,13 +310,13 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
* to complete a measurement.
*/
if (wait) {
-
- /* On i.MX7, according to the design team, the finished bit can
- * only keep 1us after the measured data available. It is hard
- * for software to polling this bit. So wait for 20ms to make
- * sure the measured data is valid.
+ /*
+ * On i.MX7 TO1.0, the finish bit can only keep 1us after
+ * the measured data available. It is hard for software to
+ * polling this bit. So wait for 20ms to make sure the
+ * measured data is valid.
*/
- if (data->socdata->version == TEMPMON_IMX7)
+ if (data->socdata->version == TEMPMON_IMX7 && skip_finish_check)
msleep(20);
else
usleep_range(20, 50);
@@ -329,8 +331,7 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
clk_disable_unprepare(data->thermal_clk);
}
- if (data->socdata->version != TEMPMON_IMX7 &&
- ((val & soc_data->temp_valid_mask) == 0)) {
+ if (!skip_finish_check && ((val & soc_data->temp_valid_mask) == 0)) {
dev_dbg(&tz->device, "temp measurement never finished\n");
mutex_unlock(&data->mutex);
return -EAGAIN;
@@ -739,7 +740,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
struct imx_thermal_data *data;
struct regmap *map;
int measure_freq;
- int ret;
+ int ret, revision;
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data)
@@ -780,6 +781,14 @@ static int imx_thermal_probe(struct platform_device *pdev)
return ret;
}
+ /*
+ * for i.MX7D TO1.0, finish bit is not available, check the
+ * SOC revision to skip checking the finish bit status.
+ */
+ regmap_read(map, IMX7_ANADIG_DIGPROG, &revision);
+ if ((revision & 0xff) == 0x10)
+ skip_finish_check = 1;
+
/* Make sure sensor is in known good state for measurements */
regmap_write(map, data->socdata->sensor_ctrl + REG_CLR,
data->socdata->power_down_mask);