From 3b7ad216e26567342162722fca7b2e142e694d0f Mon Sep 17 00:00:00 2001 From: Tim Harvey Date: Tue, 9 Jun 2015 06:40:22 -0700 Subject: thermal:imx_thermal: enter busywait cooling loop when over max CPU temp Remove the check for temperature being within the min/max range and enter the busywait cooling loop whenever the CPU temperature is over the critical temp. This fixes the issue where if a board was booted at a temp greater than the CPU temperature max, it would skip the loop and never indicate or try to address the overtemp issue. Cc: Ye Li Cc: Jason Liu Signed-off-by: Tim Harvey --- drivers/thermal/imx_thermal.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'drivers/thermal/imx_thermal.c') diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 0d893c9d06..42ca8d0b6b 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -130,16 +130,12 @@ int imx_thermal_get_temp(struct udevice *dev, int *temp) int cpu_tmp = 0; cpu_tmp = read_cpu_temperature(dev); - while (cpu_tmp > priv->minc && cpu_tmp < priv->maxc) { - if (cpu_tmp >= priv->critical) { - printf("CPU Temperature (%dC) too close to max (%dC)", - cpu_tmp, priv->maxc); - puts(" waiting...\n"); - udelay(5000000); - cpu_tmp = read_cpu_temperature(dev); - } else { - break; - } + while (cpu_tmp >= priv->critical) { + printf("CPU Temperature (%dC) too close to max (%dC)", + cpu_tmp, priv->maxc); + puts(" waiting...\n"); + udelay(5000000); + cpu_tmp = read_cpu_temperature(dev); } *temp = cpu_tmp; -- cgit From 425640256a7c5e9259f7583ee4eca1f3b70f8032 Mon Sep 17 00:00:00 2001 From: Tim Harvey Date: Wed, 8 Jul 2015 15:49:43 -0700 Subject: thermal: imx_thermal: fix busywait if IMX6 temp <0C The temperature calculation must be typecasted to keep the compiler from sign extending a negative value prior to division. This fixes an issue where if the CPU temperature is <0C it will get stuck in the busywait loop until the CPU heats up to 0C. Cc: Ye Li Cc: Jason Liu Signed-off-by: Tim Harvey --- drivers/thermal/imx_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/thermal/imx_thermal.c') diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 42ca8d0b6b..3c6c9679f9 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -115,7 +115,7 @@ static int read_cpu_temperature(struct udevice *dev) writel(TEMPSENSE0_FINISHED, &anatop->tempsense0_clr); /* milli_Tmeas = c2 - Nmeas * c1 */ - temperature = (c2 - n_meas * c1)/1000; + temperature = (long)(c2 - n_meas * c1)/1000; /* power down anatop thermal sensor */ writel(TEMPSENSE0_POWER_DOWN, &anatop->tempsense0_set); -- cgit