linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: Anson Huang <b20788@freescale.com>
Cc: shawn.guo@linaro.org, eduardo.valentin@ti.com,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2] thermal: imx: correct suspend/resume flow
Date: Thu, 02 Jan 2014 10:01:51 +0800	[thread overview]
Message-ID: <1388628111.3739.68.camel@rzhang1-mobl4> (raw)
In-Reply-To: <1387896204-31754-1-git-send-email-b20788@freescale.com>

On Tue, 2013-12-24 at 09:43 -0500, Anson Huang wrote:
> 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>

applied. BTW, this should also be a stable material for 3.12, right?

thanks,
rui
> ---
>  drivers/thermal/imx_thermal.c |   31 +++++++++++++++++--------------
>  1 file changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index cbb16f3..9a9a6c2 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -510,27 +510,30 @@ static int imx_thermal_suspend(struct device *dev)
>  {
>  	struct imx_thermal_data *data = dev_get_drvdata(dev);
>  	struct regmap *map = data->tempmon;
> -	u32 val;
>  
> -	regmap_read(map, TEMPSENSE0, &val);
> -	if ((val & TEMPSENSE0_POWER_DOWN) == 0) {
> -		/*
> -		 * If a measurement is taking place, wait for a long enough
> -		 * time for it to finish, and then check again.  If it still
> -		 * does not finish, something must go wrong.
> -		 */
> -		udelay(50);
> -		regmap_read(map, TEMPSENSE0, &val);
> -		if ((val & TEMPSENSE0_POWER_DOWN) == 0)
> -			return -ETIMEDOUT;
> -	}
> +	/*
> +	 * Need to disable thermal sensor, otherwise, when thermal core
> +	 * try to get temperature before thermal sensor resume, a wrong
> +	 * temperature will be read as the thermal sensor is powered
> +	 * down.
> +	 */
> +	regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_MEASURE_TEMP);
> +	regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN);
> +	data->mode = THERMAL_DEVICE_DISABLED;
>  
>  	return 0;
>  }
>  
>  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;
>  }
>  #endif

  parent reply	other threads:[~2014-01-02  2:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-24 14:43 [PATCH V2] thermal: imx: correct suspend/resume flow Anson Huang
2013-12-24  3:09 ` Shawn Guo
2014-01-02  2:01 ` Zhang Rui [this message]
2014-01-02  2:16   ` Shawn Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1388628111.3739.68.camel@rzhang1-mobl4 \
    --to=rui.zhang@intel.com \
    --cc=b20788@freescale.com \
    --cc=eduardo.valentin@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=shawn.guo@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).