Skip to content

Commit 45038e0

Browse files
ndreysdlezcano
authored andcommitted
thermal: qoriq: Enable all sensors before registering them
Tmu_get_temp will get called as a part of sensor registration via devm_thermal_zone_of_sensor_register(). To prevent it from retruning bogus data we need to enable sensor monitoring before that. Looking at the datasheet (i.MX8MQ RM) there doesn't seem to be any harm in enabling them all, so, for the sake of simplicity, change the code to do just that. Signed-off-by: Andrey Smirnov <[email protected]> Tested-by: Lucas Stach <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: Eduardo Valentin <[email protected]> Cc: Daniel Lezcano <[email protected]> Cc: Angus Ainslie (Purism) <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4316237 commit 45038e0

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

drivers/thermal/qoriq_thermal.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define TMR_DISABLE 0x0
3131
#define TMR_ME 0x80000000
3232
#define TMR_ALPF 0x0c000000
33+
#define TMR_MSITE_ALL GENMASK(15, 0)
3334

3435
#define REGS_TMTMIR 0x008 /* Temperature measurement interval Register */
3536
#define TMTMIR_DEFAULT 0x0000000f
@@ -94,7 +95,15 @@ static const struct thermal_zone_of_device_ops tmu_tz_ops = {
9495
static int qoriq_tmu_register_tmu_zone(struct device *dev,
9596
struct qoriq_tmu_data *qdata)
9697
{
97-
int id, sites = 0;
98+
int id;
99+
100+
if (qdata->ver == TMU_VER1) {
101+
regmap_write(qdata->regmap, REGS_TMR,
102+
TMR_MSITE_ALL | TMR_ME | TMR_ALPF);
103+
} else {
104+
regmap_write(qdata->regmap, REGS_V2_TMSR, TMR_MSITE_ALL);
105+
regmap_write(qdata->regmap, REGS_TMR, TMR_ME | TMR_ALPF_V2);
106+
}
98107

99108
for (id = 0; id < SITES_MAX; id++) {
100109
struct thermal_zone_device *tzd;
@@ -110,25 +119,9 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev,
110119
if (ret) {
111120
if (ret == -ENODEV)
112121
continue;
113-
else
114-
return ret;
115-
}
116122

117-
if (qdata->ver == TMU_VER1)
118-
sites |= 0x1 << (15 - id);
119-
else
120-
sites |= 0x1 << id;
121-
}
122-
123-
/* Enable monitoring */
124-
if (sites != 0) {
125-
if (qdata->ver == TMU_VER1) {
126-
regmap_write(qdata->regmap, REGS_TMR,
127-
sites | TMR_ME | TMR_ALPF);
128-
} else {
129-
regmap_write(qdata->regmap, REGS_V2_TMSR, sites);
130-
regmap_write(qdata->regmap, REGS_TMR,
131-
TMR_ME | TMR_ALPF_V2);
123+
regmap_write(qdata->regmap, REGS_TMR, TMR_DISABLE);
124+
return ret;
132125
}
133126
}
134127

0 commit comments

Comments
 (0)