summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBai Ping <ping.bai@nxp.com>2017-06-19 17:01:23 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commit36b908e2be9959375d0244bd42a989e0ea7db32d (patch)
tree6ab099671d1d086b9238735b64e2c1a3cc193435
parent86435f3ea73a67ffeff6ae760f35ee47d907d770 (diff)
MLK-15075 thermal: imx: fix temp read failure on i.mx7d
On i.MX7D, if the system enter LPSR mode, the tempmon module will be power down, so the regiter's value is lost, so we need to save the registers before suspend and restore the register after resume back. Signed-off-by: Bai Ping <ping.bai@nxp.com>
-rw-r--r--drivers/thermal/imx_thermal.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 569a5e05f48c..f926b94966e5 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -1,5 +1,6 @@
/*
* Copyright 2013-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -237,6 +238,7 @@ struct imx_thermal_data {
static struct imx_thermal_data *imx_thermal_data;
static int skip_finish_check;
+static u32 imx7_lpsr_save[2];
static void imx_set_panic_temp(struct imx_thermal_data *data,
int panic_temp)
@@ -946,6 +948,16 @@ static int imx_thermal_suspend(struct device *dev)
data->socdata->measure_temp_mask);
regmap_write(map, data->socdata->sensor_ctrl + REG_SET,
data->socdata->power_down_mask);
+
+ /*
+ * Save the temp sensor registers of i.MX7D as the tempmon
+ * will lost power in LPSR mode
+ */
+ if (data->socdata->version == TEMPMON_IMX7) {
+ regmap_read(map, data->socdata->sensor_ctrl, &imx7_lpsr_save[0]);
+ regmap_read(map, data->socdata->high_alarm_ctrl, &imx7_lpsr_save[1]);
+ }
+
data->mode = THERMAL_DEVICE_DISABLED;
clk_disable_unprepare(data->thermal_clk);
@@ -958,6 +970,16 @@ static int imx_thermal_resume(struct device *dev)
struct regmap *map = data->tempmon;
clk_prepare_enable(data->thermal_clk);
+
+ /*
+ * restore the temp sensor registers of i.MX7D as the tempmon
+ * will lost power in LPSR mode
+ */
+ if (data->socdata->version == TEMPMON_IMX7) {
+ regmap_write(map, data->socdata->sensor_ctrl, imx7_lpsr_save[0]);
+ regmap_write(map, data->socdata->high_alarm_ctrl, imx7_lpsr_save[1]);
+ }
+
/* Enabled thermal sensor after resume */
regmap_write(map, data->socdata->sensor_ctrl + REG_CLR,
data->socdata->power_down_mask);