summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPeng Fan <Peng.Fan@freescale.com>2015-05-06 14:39:46 +0800
committerYe Li <ye.li@nxp.com>2017-03-14 21:27:09 +0800
commit52a95d753328ce4df03ca7acae3295ceab53c66b (patch)
tree32685aff5d04460e798aea880b912fda1fcfee34 /drivers
parent88c32ab51fdc54fe029f03b1da80f58d0f0f78a6 (diff)
downloadu-boot-imx-52a95d753328ce4df03ca7acae3295ceab53c66b.zip
u-boot-imx-52a95d753328ce4df03ca7acae3295ceab53c66b.tar.gz
u-boot-imx-52a95d753328ce4df03ca7acae3295ceab53c66b.tar.bz2
MLK-10827 imx: mx6 update thermal driver according new equation
From IC guys: " After a thorough accuracy study of the Temp sense circuit, we found that with our current equation, an average part can read 7 degrees lower than a known forced temperature. We also found out that the standard variance was around 2C; which is the tightest distribution that we could create. We need to change the temp sense equation to center the average part around the target temperature. Old Equation: Temp = Troom,cal – slope*(Count measured – Count room fuse) Where Troom,cal = 25C and Slope = 0.4297157 – (0.0015974 * Count room fuse) New Equation: Temp = Troom,cal – slope*(Count measured – Count room fuse) +offset Where Troom,cal = 25C and Slope = 0.4445388 – (0.0016549 * Count room fuse) Offset = 3.580661 " According the new equation, update the thermal driver. c1 and c2 changed to u64 type and update comments. Signed-off-by: Peng Fan <Peng.Fan@freescale.com> (cherry picked from commit 87723f903454aaf17336e0fe9098ea7911c19f3c) (cherry picked from commit 3392203fc3ae2f0701461143094cfbb112f7bc04)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/thermal/imx_thermal.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 0509094..741a3f7 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -1,5 +1,5 @@
/*
- * (C) Copyright 2014 Freescale Semiconductor, Inc.
+ * (C) Copyright 2014-2016 Freescale Semiconductor, Inc.
* Author: Nitin Garg <nitin.garg@freescale.com>
* Ye Li <Ye.Li@freescale.com>
*
@@ -22,8 +22,9 @@
/* 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
+#define FACTOR1 16549
+#define FACTOR2 4445388
+#define OFFSET 3580661
#define MEASURE_FREQ 327
#define TEMPERATURE_MIN -40
#define TEMPERATURE_HOT 85
@@ -54,39 +55,42 @@ static int read_cpu_temperature(struct udevice *dev)
struct thermal_data *priv = dev_get_priv(dev);
u32 fuse = priv->fuse;
int t1, n1;
- u32 c1, c2;
+ u64 c1, c2;
u64 temp64;
/*
* Sensor data layout:
* [31:20] - sensor value @ 25C
* We use universal formula now and only need sensor value @ 25C
- * slope = 0.4297157 - (0.0015976 * 25C fuse)
+ * slope = 0.4445388 - (0.0016549 * 25C fuse)
*/
n1 = fuse >> 20;
t1 = 25; /* t1 always 25C */
/*
* Derived from linear interpolation:
- * slope = 0.4297157 - (0.0015976 * 25C fuse)
+ * slope = 0.4445388 - (0.0016549 * 25C fuse)
* slope = (FACTOR2 - FACTOR1 * n1) / FACTOR0
+ * offset = 3.580661
+ * offset = OFFSET / 1000000
* (Nmeas - n1) / (Tmeas - t1) = slope
* We want to reduce this down to the minimum computation necessary
* for each temperature read. Also, we want Tmeas in millicelsius
* and we don't want to lose precision from integer division. So...
- * Tmeas = (Nmeas - n1) / slope + t1
- * milli_Tmeas = 1000 * (Nmeas - n1) / slope + 1000 * t1
- * milli_Tmeas = -1000 * (n1 - Nmeas) / slope + 1000 * t1
- * Let constant c1 = (-1000 / slope)
- * milli_Tmeas = (n1 - Nmeas) * c1 + 1000 * t1
- * Let constant c2 = n1 *c1 + 1000 * t1
- * milli_Tmeas = c2 - Nmeas * c1
+ * Tmeas = (Nmeas - n1) / slope + t1 + offset
+ * milli_Tmeas = 1000000 * (Nmeas - n1) / slope + 1000000 * t1 + OFFSET
+ * milli_Tmeas = -1000000 * (n1 - Nmeas) / slope + 1000000 * t1 + OFFSET
+ * Let constant c1 = (-1000000 / slope)
+ * milli_Tmeas = (n1 - Nmeas) * c1 + 1000000 * t1 + OFFSET
+ * Let constant c2 = n1 *c1 + 1000000 * t1
+ * milli_Tmeas = (c2 - Nmeas * c1) / 1000000 + OFFSET
+ * Tmeas = ((c2 - Nmeas * c1) + OFFSET) / 1000000
*/
temp64 = FACTOR0;
- temp64 *= 1000;
+ temp64 *= 1000000;
do_div(temp64, FACTOR1 * n1 - FACTOR2);
c1 = temp64;
- c2 = n1 * c1 + 1000 * t1;
+ c2 = n1 * c1 + 1000000 * t1;
/*
* now we only use single measure, every time we read
@@ -118,8 +122,8 @@ static int read_cpu_temperature(struct udevice *dev)
>> TEMPSENSE0_TEMP_CNT_SHIFT;
writel(TEMPSENSE0_FINISHED, &anatop->tempsense0_clr);
- /* milli_Tmeas = c2 - Nmeas * c1 */
- temperature = (long)(c2 - n_meas * c1)/1000;
+ /* Tmeas = (c2 - Nmeas * c1 + OFFSET) / 1000000 */
+ temperature = lldiv(c2 - n_meas * c1 + OFFSET, 1000000);
/* power down anatop thermal sensor */
writel(TEMPSENSE0_POWER_DOWN, &anatop->tempsense0_set);