thermal: imx: correct suspend/resume flow
Fixes regression introduced by: commit37713a1e8e
Author: Philipp Zabel <p.zabel@pengutronix.de> Date: Thu Aug 1 18:33:12 2013 +0200 thermal: imx: implement thermal alarm interrupt handling The commit37713a1e8e
makes imx thermal sensor always powered up as alarm function is enabled, but the suspend callback of imx thermal returns success only if thermal sensor is powered down, so it will always returns fail hence break system's suspend, this patch disables imx thermal sensor before suspend and re-enable it after resume. Signed-off-by: Anson Huang <b20788@freescale.com> Acked-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
This commit is contained in:
parent
60acb3891f
commit
b46cce5902
|
@ -490,27 +490,30 @@ static int imx_thermal_suspend(struct device *dev)
|
||||||
{
|
{
|
||||||
struct imx_thermal_data *data = dev_get_drvdata(dev);
|
struct imx_thermal_data *data = dev_get_drvdata(dev);
|
||||||
struct regmap *map = data->tempmon;
|
struct regmap *map = data->tempmon;
|
||||||
u32 val;
|
|
||||||
|
|
||||||
regmap_read(map, TEMPSENSE0, &val);
|
/*
|
||||||
if ((val & TEMPSENSE0_POWER_DOWN) == 0) {
|
* Need to disable thermal sensor, otherwise, when thermal core
|
||||||
/*
|
* try to get temperature before thermal sensor resume, a wrong
|
||||||
* If a measurement is taking place, wait for a long enough
|
* temperature will be read as the thermal sensor is powered
|
||||||
* time for it to finish, and then check again. If it still
|
* down.
|
||||||
* does not finish, something must go wrong.
|
*/
|
||||||
*/
|
regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_MEASURE_TEMP);
|
||||||
udelay(50);
|
regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN);
|
||||||
regmap_read(map, TEMPSENSE0, &val);
|
data->mode = THERMAL_DEVICE_DISABLED;
|
||||||
if ((val & TEMPSENSE0_POWER_DOWN) == 0)
|
|
||||||
return -ETIMEDOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int imx_thermal_resume(struct device *dev)
|
static int imx_thermal_resume(struct device *dev)
|
||||||
{
|
{
|
||||||
/* Nothing to do for now */
|
struct imx_thermal_data *data = dev_get_drvdata(dev);
|
||||||
|
struct regmap *map = data->tempmon;
|
||||||
|
|
||||||
|
/* Enabled thermal sensor after resume */
|
||||||
|
regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN);
|
||||||
|
regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_MEASURE_TEMP);
|
||||||
|
data->mode = THERMAL_DEVICE_ENABLED;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue