Skip to content

Commit 6d0fc79

Browse files
laura-naodlezcano
authored andcommitted
thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant
MT8196/MT6991 require a different version of lvts_temp_to_raw(), specifically the multiplicative inverse of the existing implementation. Introduce a variant of the function with inverted calculation logic to match this requirement. This ensures accurate raw value generation for temperature thresholds, avoiding spurious thermal interrupts or unintended hardware resets on MT8196/MT6991. Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Fei Shao <fshao@chromium.org> Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Tested-by: Frank Wunderlich <frank-w@public-files.de> Signed-off-by: Laura Nao <laura.nao@collabora.com> Link: https://patch.msgid.link/20251125-mt8196-lvts-v4-v5-4-6db7eb903fb7@collabora.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent a4c4055 commit 6d0fc79

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

drivers/thermal/mediatek/lvts_thermal.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,15 @@ static u32 lvts_temp_to_raw_mt7988(int temperature, int temp_factor)
308308
return raw_temp;
309309
}
310310

311+
static u32 lvts_temp_to_raw_mt8196(int temperature, int temp_factor)
312+
{
313+
u32 raw_temp;
314+
315+
raw_temp = temperature - golden_temp_offset;
316+
317+
return div_s64((s64)temp_factor << 14, raw_temp);
318+
}
319+
311320
static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
312321
{
313322
struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz);

0 commit comments

Comments
 (0)