Skip to content

Commit 9301575

Browse files
MrVandlezcano
authored andcommitted
thermal/drivers/qoriq: Only enable supported sensors
There are MAX 16 sensors, but not all of them supported. Such as i.MX8MQ, there are only 3 sensors. Enabling all 16 sensors will touch reserved bits from i.MX8MQ reference mannual, and TMU will stuck, temperature will not update anymore. Fixes: 45038e0 ("thermal: qoriq: Enable all sensors before registering them") Signed-off-by: Peng Fan <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5474e98 commit 9301575

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

drivers/thermal/qoriq_thermal.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#define TMR_DISABLE 0x0
3232
#define TMR_ME 0x80000000
3333
#define TMR_ALPF 0x0c000000
34-
#define TMR_MSITE_ALL GENMASK(15, 0)
3534

3635
#define REGS_TMTMIR 0x008 /* Temperature measurement interval Register */
3736
#define TMTMIR_DEFAULT 0x0000000f
@@ -105,6 +104,11 @@ static int tmu_get_temp(struct thermal_zone_device *tz, int *temp)
105104
* within sensor range. TEMP is an 9 bit value representing
106105
* temperature in KelVin.
107106
*/
107+
108+
regmap_read(qdata->regmap, REGS_TMR, &val);
109+
if (!(val & TMR_ME))
110+
return -EAGAIN;
111+
108112
if (regmap_read_poll_timeout(qdata->regmap,
109113
REGS_TRITSR(qsensor->id),
110114
val,
@@ -128,15 +132,7 @@ static const struct thermal_zone_device_ops tmu_tz_ops = {
128132
static int qoriq_tmu_register_tmu_zone(struct device *dev,
129133
struct qoriq_tmu_data *qdata)
130134
{
131-
int id;
132-
133-
if (qdata->ver == TMU_VER1) {
134-
regmap_write(qdata->regmap, REGS_TMR,
135-
TMR_MSITE_ALL | TMR_ME | TMR_ALPF);
136-
} else {
137-
regmap_write(qdata->regmap, REGS_V2_TMSR, TMR_MSITE_ALL);
138-
regmap_write(qdata->regmap, REGS_TMR, TMR_ME | TMR_ALPF_V2);
139-
}
135+
int id, sites = 0;
140136

141137
for (id = 0; id < SITES_MAX; id++) {
142138
struct thermal_zone_device *tzd;
@@ -153,14 +149,26 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev,
153149
if (ret == -ENODEV)
154150
continue;
155151

156-
regmap_write(qdata->regmap, REGS_TMR, TMR_DISABLE);
157152
return ret;
158153
}
159154

155+
if (qdata->ver == TMU_VER1)
156+
sites |= 0x1 << (15 - id);
157+
else
158+
sites |= 0x1 << id;
159+
160160
if (devm_thermal_add_hwmon_sysfs(dev, tzd))
161161
dev_warn(dev,
162162
"Failed to add hwmon sysfs attributes\n");
163+
}
163164

165+
if (sites) {
166+
if (qdata->ver == TMU_VER1) {
167+
regmap_write(qdata->regmap, REGS_TMR, TMR_ME | TMR_ALPF | sites);
168+
} else {
169+
regmap_write(qdata->regmap, REGS_V2_TMSR, sites);
170+
regmap_write(qdata->regmap, REGS_TMR, TMR_ME | TMR_ALPF_V2);
171+
}
164172
}
165173

166174
return 0;

0 commit comments

Comments
 (0)