public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Thermal: imx: correct critical trip temperature setting
@ 2014-06-20  7:03 Anson Huang
  2014-06-30  2:24 ` Zhang Rui
  0 siblings, 1 reply; 4+ messages in thread
From: Anson Huang @ 2014-06-20  7:03 UTC (permalink / raw)
  To: rui.zhang, eduardo.valentin; +Cc: linux-pm

On latest i.MX6 SOC with thermal calibration data of 0x5A100000,
the critical trip temperature will be an invalid value and
cause system auto shutdown as below log:

thermal thermal_zone0: critical temperature reached(42 C),shutting down

So, with universal formula for thermal sensor, only room
temperature point is calibrated, which means the calibration
data read from fuse only has valid data of bit [31:20], others
are all 0, the critical trip point temperature can NOT depend
on the hot point calibration data, here we set it to 20 C higher
than default passive temperature.

Signed-off-by: Anson Huang <b20788@freescale.com>
---
 drivers/thermal/imx_thermal.c |   18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index a99c631..2c516f2 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -306,7 +306,7 @@ static int imx_get_sensor_data(struct platform_device *pdev)
 {
 	struct imx_thermal_data *data = platform_get_drvdata(pdev);
 	struct regmap *map;
-	int t1, t2, n1, n2;
+	int t1, n1;
 	int ret;
 	u32 val;
 	u64 temp64;
@@ -333,14 +333,10 @@ static int imx_get_sensor_data(struct platform_device *pdev)
 	/*
 	 * Sensor data layout:
 	 *   [31:20] - sensor value @ 25C
-	 *    [19:8] - sensor value of hot
-	 *     [7:0] - hot temperature value
 	 * Use universal formula now and only need sensor value @ 25C
 	 * slope = 0.4297157 - (0.0015976 * 25C fuse)
 	 */
 	n1 = val >> 20;
-	n2 = (val & 0xfff00) >> 8;
-	t2 = val & 0xff;
 	t1 = 25; /* t1 always 25C */
 
 	/*
@@ -366,16 +362,16 @@ static int imx_get_sensor_data(struct platform_device *pdev)
 	data->c2 = n1 * data->c1 + 1000 * t1;
 
 	/*
-	 * Set the default passive cooling trip point to 20 °C below the
-	 * maximum die temperature. Can be changed from userspace.
+	 * Set the default passive cooling trip point,
+	 * can be changed from userspace.
 	 */
-	data->temp_passive = 1000 * (t2 - 20);
+	data->temp_passive = IMX_TEMP_PASSIVE;
 
 	/*
-	 * The maximum die temperature is t2, let's give 5 °C cushion
-	 * for noise and possible temperature rise between measurements.
+	 * The maximum die temperature set to 20 C higher than
+	 * IMX_TEMP_PASSIVE.
 	 */
-	data->temp_critical = 1000 * (t2 - 5);
+	data->temp_critical = 1000 * 20 + data->temp_passive;
 
 	return 0;
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Thermal: imx: correct critical trip temperature setting
  2014-06-30  2:24 ` Zhang Rui
@ 2014-06-30  2:21   ` Shawn Guo
  2014-07-01  1:22     ` Zhang Rui
  0 siblings, 1 reply; 4+ messages in thread
From: Shawn Guo @ 2014-06-30  2:21 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Anson Huang, eduardo.valentin, linux-pm

On Mon, Jun 30, 2014 at 10:24:27AM +0800, Zhang Rui wrote:
> On Fri, 2014-06-20 at 15:03 +0800, Anson Huang wrote:
> > On latest i.MX6 SOC with thermal calibration data of 0x5A100000,
> > the critical trip temperature will be an invalid value and
> > cause system auto shutdown as below log:
> > 
> > thermal thermal_zone0: critical temperature reached(42 C),shutting down
> > 
> > So, with universal formula for thermal sensor, only room
> > temperature point is calibrated, which means the calibration
> > data read from fuse only has valid data of bit [31:20], others
> > are all 0, the critical trip point temperature can NOT depend
> > on the hot point calibration data, here we set it to 20 C higher
> > than default passive temperature.
> > 
> > Signed-off-by: Anson Huang <b20788@freescale.com>
> 
> Shawn,
> what do you think of this patch?

I'm fine the with patch.

Acked-by: Shawn Guo <shawn.guo@linaro.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Thermal: imx: correct critical trip temperature setting
  2014-06-20  7:03 [PATCH] Thermal: imx: correct critical trip temperature setting Anson Huang
@ 2014-06-30  2:24 ` Zhang Rui
  2014-06-30  2:21   ` Shawn Guo
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang Rui @ 2014-06-30  2:24 UTC (permalink / raw)
  To: Anson Huang; +Cc: eduardo.valentin, linux-pm, Shawn Guo

On Fri, 2014-06-20 at 15:03 +0800, Anson Huang wrote:
> On latest i.MX6 SOC with thermal calibration data of 0x5A100000,
> the critical trip temperature will be an invalid value and
> cause system auto shutdown as below log:
> 
> thermal thermal_zone0: critical temperature reached(42 C),shutting down
> 
> So, with universal formula for thermal sensor, only room
> temperature point is calibrated, which means the calibration
> data read from fuse only has valid data of bit [31:20], others
> are all 0, the critical trip point temperature can NOT depend
> on the hot point calibration data, here we set it to 20 C higher
> than default passive temperature.
> 
> Signed-off-by: Anson Huang <b20788@freescale.com>

Shawn,
what do you think of this patch?

Eduardo,
have you picked this patch? If not, I will queue it for rc4.

thanks,
rui
> ---
>  drivers/thermal/imx_thermal.c |   18 +++++++-----------
>  1 file changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index a99c631..2c516f2 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -306,7 +306,7 @@ static int imx_get_sensor_data(struct platform_device *pdev)
>  {
>  	struct imx_thermal_data *data = platform_get_drvdata(pdev);
>  	struct regmap *map;
> -	int t1, t2, n1, n2;
> +	int t1, n1;
>  	int ret;
>  	u32 val;
>  	u64 temp64;
> @@ -333,14 +333,10 @@ static int imx_get_sensor_data(struct platform_device *pdev)
>  	/*
>  	 * Sensor data layout:
>  	 *   [31:20] - sensor value @ 25C
> -	 *    [19:8] - sensor value of hot
> -	 *     [7:0] - hot temperature value
>  	 * Use universal formula now and only need sensor value @ 25C
>  	 * slope = 0.4297157 - (0.0015976 * 25C fuse)
>  	 */
>  	n1 = val >> 20;
> -	n2 = (val & 0xfff00) >> 8;
> -	t2 = val & 0xff;
>  	t1 = 25; /* t1 always 25C */
>  
>  	/*
> @@ -366,16 +362,16 @@ static int imx_get_sensor_data(struct platform_device *pdev)
>  	data->c2 = n1 * data->c1 + 1000 * t1;
>  
>  	/*
> -	 * Set the default passive cooling trip point to 20 °C below the
> -	 * maximum die temperature. Can be changed from userspace.
> +	 * Set the default passive cooling trip point,
> +	 * can be changed from userspace.
>  	 */
> -	data->temp_passive = 1000 * (t2 - 20);
> +	data->temp_passive = IMX_TEMP_PASSIVE;
>  
>  	/*
> -	 * The maximum die temperature is t2, let's give 5 °C cushion
> -	 * for noise and possible temperature rise between measurements.
> +	 * The maximum die temperature set to 20 C higher than
> +	 * IMX_TEMP_PASSIVE.
>  	 */
> -	data->temp_critical = 1000 * (t2 - 5);
> +	data->temp_critical = 1000 * 20 + data->temp_passive;
>  
>  	return 0;
>  }



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Thermal: imx: correct critical trip temperature setting
  2014-06-30  2:21   ` Shawn Guo
@ 2014-07-01  1:22     ` Zhang Rui
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang Rui @ 2014-07-01  1:22 UTC (permalink / raw)
  To: Shawn Guo; +Cc: Anson Huang, eduardo.valentin, linux-pm

On Mon, 2014-06-30 at 10:21 +0800, Shawn Guo wrote:
> On Mon, Jun 30, 2014 at 10:24:27AM +0800, Zhang Rui wrote:
> > On Fri, 2014-06-20 at 15:03 +0800, Anson Huang wrote:
> > > On latest i.MX6 SOC with thermal calibration data of 0x5A100000,
> > > the critical trip temperature will be an invalid value and
> > > cause system auto shutdown as below log:
> > > 
> > > thermal thermal_zone0: critical temperature reached(42 C),shutting down
> > > 
> > > So, with universal formula for thermal sensor, only room
> > > temperature point is calibrated, which means the calibration
> > > data read from fuse only has valid data of bit [31:20], others
> > > are all 0, the critical trip point temperature can NOT depend
> > > on the hot point calibration data, here we set it to 20 C higher
> > > than default passive temperature.
> > > 
> > > Signed-off-by: Anson Huang <b20788@freescale.com>
> > 
> > Shawn,
> > what do you think of this patch?
> 
> I'm fine the with patch.
> 
> Acked-by: Shawn Guo <shawn.guo@linaro.org>

applied, thanks!

-rui



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-01  1:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-20  7:03 [PATCH] Thermal: imx: correct critical trip temperature setting Anson Huang
2014-06-30  2:24 ` Zhang Rui
2014-06-30  2:21   ` Shawn Guo
2014-07-01  1:22     ` Zhang Rui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox