]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant
authorLaura Nao <laura.nao@collabora.com>
Tue, 25 Nov 2025 16:16:54 +0000 (17:16 +0100)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Tue, 20 Jan 2026 19:41:49 +0000 (20:41 +0100)
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>
drivers/thermal/mediatek/lvts_thermal.c

index a684f73d369845f208e6051a54141ff5237d3020..e9b9c1c35020498c7741dcdbb12d176d5105bf79 100644 (file)
@@ -308,6 +308,15 @@ static u32 lvts_temp_to_raw_mt7988(int temperature, int temp_factor)
        return raw_temp;
 }
 
+static u32 lvts_temp_to_raw_mt8196(int temperature, int temp_factor)
+{
+       u32 raw_temp;
+
+       raw_temp = temperature - golden_temp_offset;
+
+       return div_s64((s64)temp_factor << 14, raw_temp);
+}
+
 static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
 {
        struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz);