[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250721081459.16278-6-laura.nao@collabora.com>
Date: Mon, 21 Jul 2025 10:14:55 +0200
From: Laura Nao <laura.nao@...labora.com>
To: srini@...nel.org,
robh@...nel.org,
krzk+dt@...nel.org,
conor+dt@...nel.org,
rafael@...nel.org,
daniel.lezcano@...aro.org,
rui.zhang@...el.com,
lukasz.luba@....com,
matthias.bgg@...il.com,
angelogioacchino.delregno@...labora.com
Cc: nfraprado@...labora.com,
arnd@...db.de,
colin.i.king@...il.com,
u.kleine-koenig@...libre.com,
andrew-ct.chen@...iatek.com,
lala.lin@...iatek.com,
bchihi@...libre.com,
frank-w@...lic-files.de,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org,
kernel@...labora.com,
Laura Nao <laura.nao@...labora.com>
Subject: [PATCH 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant for positive temp_factor
The current lvts_temp_to_raw() implementation assumes a negative
temperature-to-raw slope (temp_factor), which holds for the SoCs
currently supported by the driver. However, this assumption breaks on
MT8196/MT6991, where the slope is positive.
Add a variant of the function that inverts the calculation logic
accordingly. This ensures accurate raw value generation for temperature
thresholds,avoiding spurious thermal interrupts or unintended hardware
resets on MT8196/MT6991.
Signed-off-by: Laura Nao <laura.nao@...labora.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index db83137c7537..3c34956e37c1 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -296,6 +296,18 @@ static u32 lvts_temp_to_raw(int temperature, int temp_factor)
return div_s64(raw_temp, -temp_factor);
}
+static u32 lvts_temp_to_raw_v2(int temperature, int temp_factor)
+{
+ u32 raw_temp;
+
+ if (temp_factor == 0)
+ return temperature;
+
+ 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);
--
2.39.5
Powered by blists - more mailing lists