Skip to content

Commit b5468be

Browse files
laura-naodlezcano
authored andcommitted
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. Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 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-6-6db7eb903fb7@collabora.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent 6cd9a3b commit b5468be

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

drivers/thermal/mediatek/lvts_thermal.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#define LVTS_EDATA01(__base) (__base + 0x0058)
4545
#define LVTS_EDATA02(__base) (__base + 0x005C)
4646
#define LVTS_EDATA03(__base) (__base + 0x0060)
47+
#define LVTS_MSROFT(__base) (__base + 0x006C)
4748
#define LVTS_ATP0(__base) (__base + 0x0070)
4849
#define LVTS_ATP1(__base) (__base + 0x0074)
4950
#define LVTS_ATP2(__base) (__base + 0x0078)
@@ -151,6 +152,7 @@ struct lvts_data {
151152
int temp_offset;
152153
int gt_calib_bit_offset;
153154
unsigned int def_calibration;
155+
u16 msr_offset;
154156
};
155157

156158
struct lvts_sensor {
@@ -219,6 +221,7 @@ static const struct debugfs_reg32 lvts_regs[] = {
219221
LVTS_DEBUG_FS_REGS(LVTS_EDATA01),
220222
LVTS_DEBUG_FS_REGS(LVTS_EDATA02),
221223
LVTS_DEBUG_FS_REGS(LVTS_EDATA03),
224+
LVTS_DEBUG_FS_REGS(LVTS_MSROFT),
222225
LVTS_DEBUG_FS_REGS(LVTS_ATP0),
223226
LVTS_DEBUG_FS_REGS(LVTS_ATP1),
224227
LVTS_DEBUG_FS_REGS(LVTS_ATP2),
@@ -811,6 +814,8 @@ static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl
811814

812815
if (gt) {
813816
lvts_ctrl->calibration[i] = calib;
817+
if (lvts_ctrl->lvts_data->msr_offset)
818+
lvts_ctrl->calibration[i] += lvts_ctrl->lvts_data->msr_offset;
814819
} else if (lvts_ctrl->lvts_data->def_calibration) {
815820
lvts_ctrl->calibration[i] = lvts_ctrl->lvts_data->def_calibration;
816821
} else {
@@ -1118,6 +1123,17 @@ static int lvts_ctrl_calibrate(struct device *dev, struct lvts_ctrl *lvts_ctrl)
11181123
for (i = 0; i < LVTS_SENSOR_MAX; i++)
11191124
writel(lvts_ctrl->calibration[i], lvts_edata[i]);
11201125

1126+
/* LVTS_MSROFT : Constant offset applied to MSR values
1127+
* for post-processing
1128+
*
1129+
* Bits:
1130+
*
1131+
* 20-0 : Constant data added to MSR values
1132+
*/
1133+
if (lvts_ctrl->lvts_data->msr_offset)
1134+
writel(lvts_ctrl->lvts_data->msr_offset,
1135+
LVTS_MSROFT(lvts_ctrl->base));
1136+
11211137
return 0;
11221138
}
11231139

0 commit comments

Comments
 (0)