Commit e4ab28d1b28a23a96f7cf9bcb6b947410335d771
1 parent
37da0261a2
Exists in
smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga
and in
4 other branches
MLK-20966 TMU: Fix for temperature out of range
When the temperature is out of sensor's range, the Valid bit won't be set in TRITSR register. So the polling loop won't go out. Change the codes to retry 10 times with 100ms interval for the Valid bit. If the timeout, we give a warning for the invalid data. Signed-off-by: Ye Li <ye.li@nxp.com> Reviewed-by: Bai Ping <ping.bai@nxp.com> (cherry picked from commit 7ea2168e06d4f77a872f51a167ee1ed6bf2b0632)
Showing 1 changed file with 18 additions and 7 deletions Side-by-side Diff
drivers/thermal/nxp_tmu.c
... | ... | @@ -106,17 +106,24 @@ |
106 | 106 | struct nxp_tmu_plat *pdata = dev_get_platdata(dev); |
107 | 107 | ulong drv_data = dev_get_driver_data(dev); |
108 | 108 | u32 val; |
109 | + u32 retry = 10; | |
109 | 110 | |
110 | 111 | do { |
112 | + mdelay(100); | |
113 | + retry--; | |
114 | + | |
111 | 115 | if (drv_data & FLAGS_VER2) |
112 | 116 | val = readl(&pdata->regs->regs_v2.tritsr); |
113 | 117 | else |
114 | 118 | val = readl(&pdata->regs->regs_v1.site[pdata->id].tritsr); |
115 | - } while (!(val & 0x80000000)); | |
119 | + } while (!(val & 0x80000000) && retry > 0); | |
116 | 120 | |
117 | - *temp = (val & 0xff) * 1000; | |
118 | - | |
119 | - return 0; | |
121 | + if (retry > 0) { | |
122 | + *temp = (val & 0xff) * 1000; | |
123 | + return 0; | |
124 | + } else { | |
125 | + return -EINVAL; | |
126 | + } | |
120 | 127 | } |
121 | 128 | |
122 | 129 | int nxp_tmu_get_temp(struct udevice *dev, int *temp) |
123 | 130 | |
... | ... | @@ -126,8 +133,10 @@ |
126 | 133 | int ret; |
127 | 134 | |
128 | 135 | ret = read_temperature(dev, &cpu_tmp); |
129 | - if (ret) | |
136 | + if (ret) { | |
137 | + printf("invalid data\n"); | |
130 | 138 | return ret; |
139 | + } | |
131 | 140 | |
132 | 141 | while (cpu_tmp >= pdata->alert) { |
133 | 142 | printf("CPU Temperature (%dC) has beyond alert (%dC), close to critical (%dC)", |
134 | 143 | |
... | ... | @@ -135,8 +144,10 @@ |
135 | 144 | puts(" waiting...\n"); |
136 | 145 | mdelay(pdata->polling_delay); |
137 | 146 | ret = read_temperature(dev, &cpu_tmp); |
138 | - if (ret) | |
147 | + if (ret) { | |
148 | + printf("invalid data\n"); | |
139 | 149 | return ret; |
150 | + } | |
140 | 151 | } |
141 | 152 | |
142 | 153 | *temp = cpu_tmp / 1000; |