summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorBai Ping <ping.bai@nxp.com>2017-06-19 17:01:23 +0800
committerBai Ping <ping.bai@nxp.com>2017-06-19 18:44:38 +0800
commitbc2b893a489f50378ae7bce846a2e7b0feb9d463 (patch)
treed7ff115f4096f247349de0183bc43243a4630e11 /drivers/thermal
parent570e1a4a6751101cfbf20346cce8ab3e8792a428 (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> (cherry picked from commit 72e6a05b52d24b4976c5f012a185c049f0e6ffa6)
Diffstat (limited to 'drivers/thermal')
-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 1e37ffc275c9..4b6ba999e983 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);