summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2019-02-27 23:50:39 -0800
committerYe Li <ye.li@nxp.com>2019-03-03 17:34:47 -0800
commitfe41c5fa6af88cce7f5a9723c82d6ad4e61357ce (patch)
tree7dcbf622fda8620a6953b2e88e9d7a03e6d833e2 /drivers
parente79209e4174054bb328bae441bf8ab3c1312ee4e (diff)
MLK-21019 TMU: Check the TEMP range for iMX8MM
On iMX8MM, the V flag in TRISTR register only reflect the state of SNSR value, not the calibrated TEMP value. So checking this flag is not reliable. Per IC suggestion, change to read the TEMP/AVG_TEMP directly and check whether it in valid range 10-125C. Signed-off-by: Ye Li <ye.li@nxp.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/thermal/nxp_tmu.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/thermal/nxp_tmu.c b/drivers/thermal/nxp_tmu.c
index e9a3fe9f6f..c170c9857b 100644
--- a/drivers/thermal/nxp_tmu.c
+++ b/drivers/thermal/nxp_tmu.c
@@ -107,16 +107,24 @@ static int read_temperature(struct udevice *dev, int *temp)
ulong drv_data = dev_get_driver_data(dev);
u32 val;
u32 retry = 10;
+ u32 valid = 0;
do {
mdelay(100);
retry--;
- if (drv_data & FLAGS_VER2)
+ if (drv_data & FLAGS_VER2) {
val = readl(&pdata->regs->regs_v2.tritsr);
- else
+
+ /* Check if TEMP is in valid range, the V bit in TRITSR
+ * only reflects the RAW uncalibrated data
+ */
+ valid = ((val & 0xff) < 10 || (val & 0xff) > 125) ? 0 : 1;
+ } else {
val = readl(&pdata->regs->regs_v1.site[pdata->id].tritsr);
- } while (!(val & 0x80000000) && retry > 0);
+ valid = val & 0x80000000;
+ }
+ } while (!valid && retry > 0);
if (retry > 0) {
*temp = (val & 0xff) * 1000;
@@ -146,7 +154,7 @@ int nxp_tmu_get_temp(struct udevice *dev, int *temp)
ret = read_temperature(dev, &cpu_tmp);
if (ret) {
printf("invalid data\n");
- return ret;
+ return ret;
}
}