]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/thermal/imx_thermal.c
ddr: altera: sequencer: Zap bogus redefinition of RW_MGR_MEM_NUMBER_OF_RANKS
[karo-tx-uboot.git] / drivers / thermal / imx_thermal.c
index b5dab630ff96dd9d0504743fa654312ebfba74a7..3c6c9679f97a89b30a30caf8b8bafb9238a41213 100644 (file)
@@ -19,6 +19,8 @@
 #include <thermal.h>
 #include <imx_thermal.h>
 
+/* board will busyloop until this many degrees C below CPU max temperature */
+#define TEMPERATURE_HOT_DELTA   5 /* CPU maxT - 5C */
 #define FACTOR0                        10000000
 #define FACTOR1                        15976
 #define FACTOR2                        4297157
@@ -34,7 +36,7 @@
 
 struct thermal_data {
        unsigned int fuse;
-       int passive;
+       int critical;
        int minc;
        int maxc;
 };
@@ -113,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);
@@ -128,15 +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->passive) {
-                       printf("CPU Temperature is %d C, too hot to boot, waiting...\n",
-                              cpu_tmp);
-                       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;
@@ -164,9 +163,9 @@ static int imx_thermal_probe(struct udevice *dev)
                return -EPERM;
        }
 
-       /* set passive cooling temp to max - 20C */
+       /* set critical cooling temp */
        get_cpu_temp_grade(&priv->minc, &priv->maxc);
-       priv->passive = priv->maxc - 20;
+       priv->critical = priv->maxc - TEMPERATURE_HOT_DELTA;
        priv->fuse = fuse;
 
        enable_thermal_clk();