Commit b46cce5902def84d35f3b043e89ab764f6c9746e

Authored by Anson Huang
Committed by Zhang Rui
1 parent 60acb3891f

thermal: imx: correct suspend/resume flow

Fixes regression introduced by:

commit 37713a1e8e4c1a1067ad4c99296f78d3c82ed9c4
Author: Philipp Zabel <p.zabel@pengutronix.de>
Date:   Thu Aug 1 18:33:12 2013 +0200

    thermal: imx: implement thermal alarm interrupt handling

The commit 37713a1e8e4 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>

Showing 1 changed file with 17 additions and 14 deletions Side-by-side Diff

drivers/thermal/imx_thermal.c
... ... @@ -490,27 +490,30 @@
490 490 {
491 491 struct imx_thermal_data *data = dev_get_drvdata(dev);
492 492 struct regmap *map = data->tempmon;
493   - u32 val;
494 493  
495   - regmap_read(map, TEMPSENSE0, &val);
496   - if ((val & TEMPSENSE0_POWER_DOWN) == 0) {
497   - /*
498   - * If a measurement is taking place, wait for a long enough
499   - * time for it to finish, and then check again. If it still
500   - * does not finish, something must go wrong.
501   - */
502   - udelay(50);
503   - regmap_read(map, TEMPSENSE0, &val);
504   - if ((val & TEMPSENSE0_POWER_DOWN) == 0)
505   - return -ETIMEDOUT;
506   - }
  494 + /*
  495 + * Need to disable thermal sensor, otherwise, when thermal core
  496 + * try to get temperature before thermal sensor resume, a wrong
  497 + * temperature will be read as the thermal sensor is powered
  498 + * down.
  499 + */
  500 + regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_MEASURE_TEMP);
  501 + regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN);
  502 + data->mode = THERMAL_DEVICE_DISABLED;
507 503  
508 504 return 0;
509 505 }
510 506  
511 507 static int imx_thermal_resume(struct device *dev)
512 508 {
513   - /* Nothing to do for now */
  509 + struct imx_thermal_data *data = dev_get_drvdata(dev);
  510 + struct regmap *map = data->tempmon;
  511 +
  512 + /* Enabled thermal sensor after resume */
  513 + regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN);
  514 + regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_MEASURE_TEMP);
  515 + data->mode = THERMAL_DEVICE_ENABLED;
  516 +
514 517 return 0;
515 518 }
516 519 #endif