diff mbox

Thermal: imx: correct critical trip temperature setting

Message ID 1403247786-19899-1-git-send-email-b20788@freescale.com (mailing list archive)
State Accepted, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Anson Huang June 20, 2014, 7:03 a.m. UTC
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(-)

Comments

Shawn Guo June 30, 2014, 2:21 a.m. UTC | #1
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>
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhang Rui June 30, 2014, 2:24 a.m. UTC | #2
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;
>  }


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhang Rui July 1, 2014, 1:22 a.m. UTC | #3
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


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;
 }