diff options
author | Bai Ping <ping.bai@nxp.com> | 2017-06-19 17:01:23 +0800 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:26:58 +0800 |
commit | 189fa44a0b6c899914be4b0faec8185bb0da52b6 (patch) | |
tree | 551f93ee66f7ca26f2e60297ab36ca07daf0ca55 /drivers/thermal | |
parent | 8676db32904f68ffa705c17cf46ad0a6a2aee741 (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>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/imx_thermal.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 56d196c22791..4b1ade83f9b3 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 @@ -239,6 +240,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) @@ -963,6 +965,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); @@ -978,6 +990,16 @@ static int imx_thermal_resume(struct device *dev) ret = clk_prepare_enable(data->thermal_clk); if (ret) return ret; + + /* + * 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); |