Skip to content

Commit 77354ea

Browse files
nfrapradodlezcano
authored andcommitted
thermal/drivers/mediatek/lvts_thermal: Don't leave threshold zeroed
The thermal framework might leave the low threshold unset if there aren't any lower trip points. This leaves the register zeroed, which translates to a very high temperature for the low threshold. The interrupt for this threshold is then immediately triggered, and the state machine gets stuck, preventing any other temperature monitoring interrupts to ever trigger. (The same happens by not setting the Cold or Hot to Normal thresholds when using those) Set the unused threshold to a valid low value. This value was chosen so that for any valid golden temperature read from the efuse, when the value is converted to raw and back again to milliCelsius, the result doesn't underflow. Fixes: f5f633b ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver") Signed-off-by: Nícolas F. R. A. Prado <[email protected]> Reviewed-by: Alexandre Mergnat <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 487bf09 commit 77354ea

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/thermal/mediatek/lvts_thermal.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383

8484
#define LVTS_HW_SHUTDOWN_MT8195 105000
8585

86+
#define LVTS_MINIMUM_THRESHOLD 20000
87+
8688
static int golden_temp = LVTS_GOLDEN_TEMP_DEFAULT;
8789
static int coeff_b = LVTS_COEFF_B;
8890

@@ -294,7 +296,7 @@ static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high)
294296
{
295297
struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz);
296298
void __iomem *base = lvts_sensor->base;
297-
u32 raw_low = lvts_temp_to_raw(low);
299+
u32 raw_low = lvts_temp_to_raw(low != -INT_MAX ? low : LVTS_MINIMUM_THRESHOLD);
298300
u32 raw_high = lvts_temp_to_raw(high);
299301

300302
/*
@@ -306,11 +308,9 @@ static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high)
306308
*
307309
* 14-0 : Raw temperature for threshold
308310
*/
309-
if (low != -INT_MAX) {
310-
pr_debug("%s: Setting low limit temperature interrupt: %d\n",
311-
thermal_zone_device_type(tz), low);
312-
writel(raw_low, LVTS_OFFSETL(base));
313-
}
311+
pr_debug("%s: Setting low limit temperature interrupt: %d\n",
312+
thermal_zone_device_type(tz), low);
313+
writel(raw_low, LVTS_OFFSETL(base));
314314

315315
/*
316316
* High offset temperature threshold

0 commit comments

Comments
 (0)