[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250721081459.16278-8-laura.nao@collabora.com>
Date: Mon, 21 Jul 2025 10:14:57 +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 7/9] thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data
On MT8196/MT6991, per-sensor calibration data read from eFuses is
16-bit. When the LVTS controller operates in 16-bit mode, a fixed offset
must be added to MSR values during post-processing to obtain correct
temperature readings. Introduce a new msr_offset field in lvts_data,
program the respective register and apply the offset to the calibration
data read from eFuses.
Signed-off-by: Laura Nao <laura.nao@...labora.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 8f9da0d5b886..81c8309ff9df 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -44,6 +44,7 @@
#define LVTS_EDATA01(__base) (__base + 0x0058)
#define LVTS_EDATA02(__base) (__base + 0x005C)
#define LVTS_EDATA03(__base) (__base + 0x0060)
+#define LVTS_MSROFT(__base) (__base + 0x006C)
#define LVTS_ATP0(__base) (__base + 0x0070)
#define LVTS_ATP1(__base) (__base + 0x0074)
#define LVTS_ATP2(__base) (__base + 0x0078)
@@ -144,6 +145,7 @@ struct lvts_data {
int temp_offset;
int gt_calib_bit_offset;
unsigned int def_calibration;
+ u16 msr_offset;
};
struct lvts_sensor {
@@ -212,6 +214,7 @@ static const struct debugfs_reg32 lvts_regs[] = {
LVTS_DEBUG_FS_REGS(LVTS_EDATA01),
LVTS_DEBUG_FS_REGS(LVTS_EDATA02),
LVTS_DEBUG_FS_REGS(LVTS_EDATA03),
+ LVTS_DEBUG_FS_REGS(LVTS_MSROFT),
LVTS_DEBUG_FS_REGS(LVTS_ATP0),
LVTS_DEBUG_FS_REGS(LVTS_ATP1),
LVTS_DEBUG_FS_REGS(LVTS_ATP2),
@@ -782,6 +785,8 @@ static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl
if (gt) {
lvts_ctrl->calibration[i] = calib;
+ if (lvts_ctrl->lvts_data->msr_offset)
+ lvts_ctrl->calibration[i] += lvts_ctrl->lvts_data->msr_offset;
} else if (lvts_ctrl->lvts_data->def_calibration) {
lvts_ctrl->calibration[i] = lvts_ctrl->lvts_data->def_calibration;
} else {
@@ -1096,6 +1101,17 @@ static int lvts_ctrl_calibrate(struct device *dev, struct lvts_ctrl *lvts_ctrl)
for (i = 0; i < LVTS_SENSOR_MAX; i++)
writel(lvts_ctrl->calibration[i], lvts_edata[i]);
+ /* LVTS_MSROFT : Constant offset applied to MSR values
+ * for post-processing
+ *
+ * Bits:
+ *
+ * 20-0 : Constant data added to MSR values
+ */
+ if (lvts_ctrl->lvts_data->msr_offset)
+ writel(lvts_ctrl->lvts_data->msr_offset,
+ LVTS_MSROFT(lvts_ctrl->base));
+
return 0;
}
--
2.39.5
Powered by blists - more mailing lists