Skip to content

Commit 65594b3

Browse files
nfrapradodlezcano
authored andcommitted
thermal/drivers/mediatek/lvts: Disable monitor mode during suspend
When configured in filtered mode, the LVTS thermal controller will monitor the temperature from the sensors and trigger an interrupt once a thermal threshold is crossed. Currently this is true even during suspend and resume. The problem with that is that when enabling the internal clock of the LVTS controller in lvts_ctrl_set_enable() during resume, the temperature reading can glitch and appear much higher than the real one, resulting in a spurious interrupt getting generated. Disable the temperature monitoring and give some time for the signals to stabilize during suspend in order to prevent such spurious interrupts. Cc: [email protected] Reported-by: Hsin-Te Yuan <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Fixes: 8137bb9 ("thermal/drivers/mediatek/lvts_thermal: Add suspend and resume") Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Nícolas F. R. A. Prado <[email protected]> Link: https://lore.kernel.org/r/20250113-mt8192-lvts-filtered-suspend-fix-v2-1-07a25200c7c6@collabora.com Signed-off-by: Daniel Lezcano <[email protected]>
1 parent 9e6ec8c commit 65594b3

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

drivers/thermal/mediatek/lvts_thermal.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,32 @@ static int lvts_ctrl_init(struct device *dev, struct lvts_domain *lvts_td,
860860
return 0;
861861
}
862862

863+
static void lvts_ctrl_monitor_enable(struct device *dev, struct lvts_ctrl *lvts_ctrl, bool enable)
864+
{
865+
/*
866+
* Bitmaps to enable each sensor on filtered mode in the MONCTL0
867+
* register.
868+
*/
869+
static const u8 sensor_filt_bitmap[] = { BIT(0), BIT(1), BIT(2), BIT(3) };
870+
u32 sensor_map = 0;
871+
int i;
872+
873+
if (lvts_ctrl->mode != LVTS_MSR_FILTERED_MODE)
874+
return;
875+
876+
if (enable) {
877+
lvts_for_each_valid_sensor(i, lvts_ctrl)
878+
sensor_map |= sensor_filt_bitmap[i];
879+
}
880+
881+
/*
882+
* Bits:
883+
* 9: Single point access flow
884+
* 0-3: Enable sensing point 0-3
885+
*/
886+
writel(sensor_map | BIT(9), LVTS_MONCTL0(lvts_ctrl->base));
887+
}
888+
863889
/*
864890
* At this point the configuration register is the only place in the
865891
* driver where we write multiple values. Per hardware constraint,
@@ -1381,8 +1407,11 @@ static int lvts_suspend(struct device *dev)
13811407

13821408
lvts_td = dev_get_drvdata(dev);
13831409

1384-
for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
1410+
for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
1411+
lvts_ctrl_monitor_enable(dev, &lvts_td->lvts_ctrl[i], false);
1412+
usleep_range(100, 200);
13851413
lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], false);
1414+
}
13861415

13871416
clk_disable_unprepare(lvts_td->clk);
13881417

@@ -1400,8 +1429,11 @@ static int lvts_resume(struct device *dev)
14001429
if (ret)
14011430
return ret;
14021431

1403-
for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
1432+
for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
14041433
lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], true);
1434+
usleep_range(100, 200);
1435+
lvts_ctrl_monitor_enable(dev, &lvts_td->lvts_ctrl[i], true);
1436+
}
14051437

14061438
return 0;
14071439
}

0 commit comments

Comments
 (0)