* [PATCH v3 0/9] Add thermal sensor driver support for Mediatek MT8196
@ 2025-08-04 13:30 Laura Nao
2025-08-04 13:30 ` [PATCH v3 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196 Laura Nao
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: Laura Nao @ 2025-08-04 13:30 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: andrew-ct.chen, lala.lin, arnd, linux-pm, Laura Nao, linux-kernel,
nfraprado, devicetree, u.kleine-koenig, linux-arm-kernel,
linux-mediatek, kernel, colin.i.king, bchihi
This patch series extends the MediaTek LVTS thermal driver to support the
MT8196 SoC.
MT8196 requires a different implementation of the lvts_temp_to_raw()
function.
To support this, the series introduces:
- A new struct lvts_platform_ops to allow platform-specific
conversion logic between raw sensor values and temperature
- A variant of the lvts_temp_to_raw() implementation
- Platform data and controller definitions for MT8196
Link to v2: https://lore.kernel.org/all/20250730152128.311109-1-laura.nao@collabora.com/
Changes in v3:
- Make ops in struct lvts_data a pointer to const struct lvts_platform_ops
- Changed mediatek,mt8188-efuse const entry in eFuse binding to an enum
with mediatek,mt8196-efuse and mediatek,mt8188-efuse, dropped mediatek,mt8196-efuse
const entry
Laura Nao (9):
dt-bindings: thermal: mediatek: Add LVTS thermal controller support
for MT8196
thermal/drivers/mediatek/lvts: Make number of calibration offsets
configurable
thermal/drivers/mediatek/lvts: Guard against zero temp_factor in
lvts_raw_to_temp
thermal: mediatek: lvts: Add platform ops to support alternative
conversion logic
thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant
thermal/drivers/mediatek/lvts: Add support for ATP mode
thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit
calibration data
thermal/drivers/mediatek/lvts_thermal: Add MT8196 support
dt-bindings: nvmem: mediatek: efuse: Add support for MT8196
.../bindings/nvmem/mediatek,efuse.yaml | 4 +-
.../thermal/mediatek,lvts-thermal.yaml | 2 +
drivers/thermal/mediatek/lvts_thermal.c | 305 ++++++++++++++++--
.../thermal/mediatek,lvts-thermal.h | 26 ++
4 files changed, 314 insertions(+), 23 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196
2025-08-04 13:30 [PATCH v3 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
@ 2025-08-04 13:30 ` Laura Nao
2025-08-04 13:30 ` [PATCH v3 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable Laura Nao
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Laura Nao @ 2025-08-04 13:30 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: andrew-ct.chen, lala.lin, arnd, linux-pm, Laura Nao, linux-kernel,
nfraprado, Krzysztof Kozlowski, devicetree, u.kleine-koenig,
linux-arm-kernel, linux-mediatek, kernel, colin.i.king, bchihi
Add LVTS thermal controller binding for MediaTek MT8196.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
.../thermal/mediatek,lvts-thermal.yaml | 2 ++
.../thermal/mediatek,lvts-thermal.h | 26 +++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml b/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
index 0259cd3ce9c5..beccdabe110b 100644
--- a/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
+++ b/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
@@ -26,6 +26,8 @@ properties:
- mediatek,mt8192-lvts-mcu
- mediatek,mt8195-lvts-ap
- mediatek,mt8195-lvts-mcu
+ - mediatek,mt8196-lvts-ap
+ - mediatek,mt8196-lvts-mcu
reg:
maxItems: 1
diff --git a/include/dt-bindings/thermal/mediatek,lvts-thermal.h b/include/dt-bindings/thermal/mediatek,lvts-thermal.h
index ddc7302a510a..0ec8ad184d47 100644
--- a/include/dt-bindings/thermal/mediatek,lvts-thermal.h
+++ b/include/dt-bindings/thermal/mediatek,lvts-thermal.h
@@ -80,4 +80,30 @@
#define MT8192_AP_MD1 15
#define MT8192_AP_MD2 16
+#define MT8196_MCU_MEDIUM_CPU6_0 0
+#define MT8196_MCU_MEDIUM_CPU6_1 1
+#define MT8196_MCU_DSU2 2
+#define MT8196_MCU_DSU3 3
+#define MT8196_MCU_LITTLE_CPU3 4
+#define MT8196_MCU_LITTLE_CPU0 5
+#define MT8196_MCU_LITTLE_CPU1 6
+#define MT8196_MCU_LITTLE_CPU2 7
+#define MT8196_MCU_MEDIUM_CPU4_0 8
+#define MT8196_MCU_MEDIUM_CPU4_1 9
+#define MT8196_MCU_MEDIUM_CPU5_0 10
+#define MT8196_MCU_MEDIUM_CPU5_1 11
+#define MT8196_MCU_DSU0 12
+#define MT8196_MCU_DSU1 13
+#define MT8196_MCU_BIG_CPU7_0 14
+#define MT8196_MCU_BIG_CPU7_1 15
+
+#define MT8196_AP_TOP0 0
+#define MT8196_AP_TOP1 1
+#define MT8196_AP_TOP2 2
+#define MT8196_AP_TOP3 3
+#define MT8196_AP_BOT0 4
+#define MT8196_AP_BOT1 5
+#define MT8196_AP_BOT2 6
+#define MT8196_AP_BOT3 7
+
#endif /* __MEDIATEK_LVTS_DT_H */
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable
2025-08-04 13:30 [PATCH v3 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
2025-08-04 13:30 ` [PATCH v3 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196 Laura Nao
@ 2025-08-04 13:30 ` Laura Nao
2025-08-04 13:30 ` [PATCH v3 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp Laura Nao
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Laura Nao @ 2025-08-04 13:30 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: andrew-ct.chen, lala.lin, arnd, linux-pm, Laura Nao, linux-kernel,
nfraprado, devicetree, u.kleine-koenig, linux-arm-kernel,
linux-mediatek, kernel, colin.i.king, bchihi
MT8196/MT6991 use 2-byte eFuse calibration data, whereas other SoCs
supported by the driver rely on 3 bytes. Make the number of calibration
bytes per sensor configurable, enabling support for SoCs with varying
calibration formats.
Reviewed-by: Fei Shao <fshao@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 32 +++++++++++++++++--------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index f4d1e66d7db9..05aa8895ccce 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -96,12 +96,14 @@
#define LVTS_MINIMUM_THRESHOLD 20000
+#define LVTS_MAX_CAL_OFFSETS 3
+
static int golden_temp = LVTS_GOLDEN_TEMP_DEFAULT;
static int golden_temp_offset;
struct lvts_sensor_data {
int dt_id;
- u8 cal_offsets[3];
+ u8 cal_offsets[LVTS_MAX_CAL_OFFSETS];
};
struct lvts_ctrl_data {
@@ -127,6 +129,7 @@ struct lvts_data {
const struct lvts_ctrl_data *lvts_ctrl;
const u32 *conn_cmd;
const u32 *init_cmd;
+ int num_cal_offsets;
int num_lvts_ctrl;
int num_conn_cmd;
int num_init_cmd;
@@ -711,7 +714,7 @@ static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl
u8 *efuse_calibration,
size_t calib_len)
{
- int i;
+ int i, j;
u32 gt;
/* A zero value for gt means that device has invalid efuse data */
@@ -720,17 +723,18 @@ static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl
lvts_for_each_valid_sensor(i, lvts_ctrl_data) {
const struct lvts_sensor_data *sensor =
&lvts_ctrl_data->lvts_sensor[i];
+ u32 calib = 0;
- if (sensor->cal_offsets[0] >= calib_len ||
- sensor->cal_offsets[1] >= calib_len ||
- sensor->cal_offsets[2] >= calib_len)
- return -EINVAL;
+ for (j = 0; j < lvts_ctrl->lvts_data->num_cal_offsets; j++) {
+ u8 offset = sensor->cal_offsets[j];
+
+ if (offset >= calib_len)
+ return -EINVAL;
+ calib |= efuse_calibration[offset] << (8 * j);
+ }
if (gt) {
- lvts_ctrl->calibration[i] =
- (efuse_calibration[sensor->cal_offsets[0]] << 0) +
- (efuse_calibration[sensor->cal_offsets[1]] << 8) +
- (efuse_calibration[sensor->cal_offsets[2]] << 16);
+ lvts_ctrl->calibration[i] = calib;
} else if (lvts_ctrl->lvts_data->def_calibration) {
lvts_ctrl->calibration[i] = lvts_ctrl->lvts_data->def_calibration;
} else {
@@ -1763,6 +1767,7 @@ static const struct lvts_data mt7988_lvts_ap_data = {
.temp_factor = LVTS_COEFF_A_MT7988,
.temp_offset = LVTS_COEFF_B_MT7988,
.gt_calib_bit_offset = 24,
+ .num_cal_offsets = 3,
};
static const struct lvts_data mt8186_lvts_data = {
@@ -1776,6 +1781,7 @@ static const struct lvts_data mt8186_lvts_data = {
.temp_offset = LVTS_COEFF_B_MT7988,
.gt_calib_bit_offset = 24,
.def_calibration = 19000,
+ .num_cal_offsets = 3,
};
static const struct lvts_data mt8188_lvts_mcu_data = {
@@ -1789,6 +1795,7 @@ static const struct lvts_data mt8188_lvts_mcu_data = {
.temp_offset = LVTS_COEFF_B_MT8195,
.gt_calib_bit_offset = 20,
.def_calibration = 35000,
+ .num_cal_offsets = 3,
};
static const struct lvts_data mt8188_lvts_ap_data = {
@@ -1802,6 +1809,7 @@ static const struct lvts_data mt8188_lvts_ap_data = {
.temp_offset = LVTS_COEFF_B_MT8195,
.gt_calib_bit_offset = 20,
.def_calibration = 35000,
+ .num_cal_offsets = 3,
};
static const struct lvts_data mt8192_lvts_mcu_data = {
@@ -1815,6 +1823,7 @@ static const struct lvts_data mt8192_lvts_mcu_data = {
.temp_offset = LVTS_COEFF_B_MT8195,
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
+ .num_cal_offsets = 3,
};
static const struct lvts_data mt8192_lvts_ap_data = {
@@ -1828,6 +1837,7 @@ static const struct lvts_data mt8192_lvts_ap_data = {
.temp_offset = LVTS_COEFF_B_MT8195,
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
+ .num_cal_offsets = 3,
};
static const struct lvts_data mt8195_lvts_mcu_data = {
@@ -1841,6 +1851,7 @@ static const struct lvts_data mt8195_lvts_mcu_data = {
.temp_offset = LVTS_COEFF_B_MT8195,
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
+ .num_cal_offsets = 3,
};
static const struct lvts_data mt8195_lvts_ap_data = {
@@ -1854,6 +1865,7 @@ static const struct lvts_data mt8195_lvts_ap_data = {
.temp_offset = LVTS_COEFF_B_MT8195,
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
+ .num_cal_offsets = 3,
};
static const struct of_device_id lvts_of_match[] = {
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp
2025-08-04 13:30 [PATCH v3 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
2025-08-04 13:30 ` [PATCH v3 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196 Laura Nao
2025-08-04 13:30 ` [PATCH v3 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable Laura Nao
@ 2025-08-04 13:30 ` Laura Nao
2025-08-04 13:30 ` [PATCH v3 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic Laura Nao
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Laura Nao @ 2025-08-04 13:30 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: andrew-ct.chen, lala.lin, arnd, linux-pm, Laura Nao, linux-kernel,
nfraprado, devicetree, u.kleine-koenig, linux-arm-kernel,
Chen-Yu Tsai, linux-mediatek, kernel, colin.i.king, bchihi
Add a guard against zero temp_factor in lvts_raw_to_temp() to prevent
division by zero and ensure safe conversion.
Fixes: 6725a29321e4 ("thermal/drivers/mediatek/lvts_thermal: Make coeff configurable")
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Fei Shao <fshao@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 05aa8895ccce..8398af657ba2 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -284,11 +284,14 @@ static int lvts_raw_to_temp(u32 raw_temp, int temp_factor)
static u32 lvts_temp_to_raw(int temperature, int temp_factor)
{
- u32 raw_temp = ((s64)(golden_temp_offset - temperature)) << 14;
+ u32 raw_temp;
- raw_temp = div_s64(raw_temp, -temp_factor);
+ if (temp_factor == 0)
+ return temperature;
- return raw_temp;
+ raw_temp = ((s64)(golden_temp_offset - temperature)) << 14;
+
+ return div_s64(raw_temp, -temp_factor);
}
static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
@@ -1346,6 +1349,9 @@ static int lvts_probe(struct platform_device *pdev)
if (irq < 0)
return irq;
+ if (!lvts_data->temp_factor)
+ dev_warn(dev, "temp_factor should never be zero; check platform data.\n");
+
golden_temp_offset = lvts_data->temp_offset;
ret = lvts_domain_init(dev, lvts_td, lvts_data);
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic
2025-08-04 13:30 [PATCH v3 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (2 preceding siblings ...)
2025-08-04 13:30 ` [PATCH v3 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp Laura Nao
@ 2025-08-04 13:30 ` Laura Nao
2025-08-04 13:30 ` [PATCH v3 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant Laura Nao
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Laura Nao @ 2025-08-04 13:30 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: andrew-ct.chen, lala.lin, arnd, linux-pm, Laura Nao, linux-kernel,
nfraprado, devicetree, u.kleine-koenig, linux-arm-kernel,
linux-mediatek, kernel, colin.i.king, bchihi
Introduce lvts_platform_ops struct to support SoC-specific versions of
lvts_raw_to_temp() and lvts_temp_to_raw() conversion functions.
This is in preparation for supporting SoCs like MT8196/MT6991, which
require a different lvts_temp_to_raw() implementation.
Reviewed-by: Fei Shao <fshao@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 27 ++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 8398af657ba2..47124d33ca2e 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -125,8 +125,14 @@ struct lvts_ctrl_data {
continue; \
else
+struct lvts_platform_ops {
+ int (*lvts_raw_to_temp)(u32 raw_temp, int temp_factor);
+ u32 (*lvts_temp_to_raw)(int temperature, int temp_factor);
+};
+
struct lvts_data {
const struct lvts_ctrl_data *lvts_ctrl;
+ const struct lvts_platform_ops *ops;
const u32 *conn_cmd;
const u32 *init_cmd;
int num_cal_offsets;
@@ -300,6 +306,7 @@ static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
struct lvts_ctrl *lvts_ctrl = container_of(lvts_sensor, struct lvts_ctrl,
sensors[lvts_sensor->id]);
const struct lvts_data *lvts_data = lvts_ctrl->lvts_data;
+ const struct lvts_platform_ops *ops = lvts_data->ops;
void __iomem *msr = lvts_sensor->msr;
u32 value;
int rc;
@@ -332,7 +339,7 @@ static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
if (rc)
return -EAGAIN;
- *temp = lvts_raw_to_temp(value & 0xFFFF, lvts_data->temp_factor);
+ *temp = ops->lvts_raw_to_temp(value & 0xFFFF, lvts_data->temp_factor);
return 0;
}
@@ -400,10 +407,11 @@ static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high)
struct lvts_ctrl *lvts_ctrl = container_of(lvts_sensor, struct lvts_ctrl,
sensors[lvts_sensor->id]);
const struct lvts_data *lvts_data = lvts_ctrl->lvts_data;
+ const struct lvts_platform_ops *ops = lvts_data->ops;
void __iomem *base = lvts_sensor->base;
- u32 raw_low = lvts_temp_to_raw(low != -INT_MAX ? low : LVTS_MINIMUM_THRESHOLD,
+ u32 raw_low = ops->lvts_temp_to_raw(low != -INT_MAX ? low : LVTS_MINIMUM_THRESHOLD,
lvts_data->temp_factor);
- u32 raw_high = lvts_temp_to_raw(high, lvts_data->temp_factor);
+ u32 raw_high = ops->lvts_temp_to_raw(high, lvts_data->temp_factor);
bool should_update_thresh;
lvts_sensor->low_thresh = low;
@@ -1763,6 +1771,11 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
}
};
+static const struct lvts_platform_ops lvts_platform_ops_v1 = {
+ .lvts_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw,
+};
+
static const struct lvts_data mt7988_lvts_ap_data = {
.lvts_ctrl = mt7988_lvts_ap_data_ctrl,
.conn_cmd = mt7988_conn_cmds,
@@ -1774,6 +1787,7 @@ static const struct lvts_data mt7988_lvts_ap_data = {
.temp_offset = LVTS_COEFF_B_MT7988,
.gt_calib_bit_offset = 24,
.num_cal_offsets = 3,
+ .ops = &lvts_platform_ops_v1,
};
static const struct lvts_data mt8186_lvts_data = {
@@ -1788,6 +1802,7 @@ static const struct lvts_data mt8186_lvts_data = {
.gt_calib_bit_offset = 24,
.def_calibration = 19000,
.num_cal_offsets = 3,
+ .ops = &lvts_platform_ops_v1,
};
static const struct lvts_data mt8188_lvts_mcu_data = {
@@ -1802,6 +1817,7 @@ static const struct lvts_data mt8188_lvts_mcu_data = {
.gt_calib_bit_offset = 20,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = &lvts_platform_ops_v1,
};
static const struct lvts_data mt8188_lvts_ap_data = {
@@ -1816,6 +1832,7 @@ static const struct lvts_data mt8188_lvts_ap_data = {
.gt_calib_bit_offset = 20,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = &lvts_platform_ops_v1,
};
static const struct lvts_data mt8192_lvts_mcu_data = {
@@ -1830,6 +1847,7 @@ static const struct lvts_data mt8192_lvts_mcu_data = {
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = &lvts_platform_ops_v1,
};
static const struct lvts_data mt8192_lvts_ap_data = {
@@ -1844,6 +1862,7 @@ static const struct lvts_data mt8192_lvts_ap_data = {
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = &lvts_platform_ops_v1,
};
static const struct lvts_data mt8195_lvts_mcu_data = {
@@ -1858,6 +1877,7 @@ static const struct lvts_data mt8195_lvts_mcu_data = {
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = &lvts_platform_ops_v1,
};
static const struct lvts_data mt8195_lvts_ap_data = {
@@ -1872,6 +1892,7 @@ static const struct lvts_data mt8195_lvts_ap_data = {
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = &lvts_platform_ops_v1,
};
static const struct of_device_id lvts_of_match[] = {
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant
2025-08-04 13:30 [PATCH v3 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (3 preceding siblings ...)
2025-08-04 13:30 ` [PATCH v3 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic Laura Nao
@ 2025-08-04 13:30 ` Laura Nao
2025-08-04 13:30 ` [PATCH v3 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode Laura Nao
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Laura Nao @ 2025-08-04 13:30 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: andrew-ct.chen, lala.lin, arnd, linux-pm, Laura Nao, linux-kernel,
nfraprado, devicetree, u.kleine-koenig, linux-arm-kernel,
Chen-Yu Tsai, linux-mediatek, kernel, colin.i.king, bchihi
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>
Signed-off-by: Laura Nao <laura.nao@collabora.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 47124d33ca2e..e29664f1316a 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -300,6 +300,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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode
2025-08-04 13:30 [PATCH v3 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (4 preceding siblings ...)
2025-08-04 13:30 ` [PATCH v3 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant Laura Nao
@ 2025-08-04 13:30 ` Laura Nao
2025-08-04 13:30 ` [PATCH v3 7/9] thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data Laura Nao
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Laura Nao @ 2025-08-04 13:30 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: andrew-ct.chen, lala.lin, arnd, linux-pm, Laura Nao, linux-kernel,
nfraprado, devicetree, u.kleine-koenig, linux-arm-kernel,
Chen-Yu Tsai, linux-mediatek, kernel, colin.i.king, bchihi
MT8196/MT6991 uses ATP (Abnormal Temperature Prevention) mode to detect
abnormal temperature conditions, which involves reading temperature data
from a dedicated set of registers separate from the ones used for
immediate and filtered modes.
Add support for ATP mode and its relative registers to ensure accurate
temperature readings and proper thermal management on MT8196/MT6991
devices.
While at it, convert mode defines to enum.
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Fei Shao <fshao@chromium.org>
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 44 +++++++++++++++++++++----
1 file changed, 37 insertions(+), 7 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index e29664f1316a..dcfcb1be5a09 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -44,6 +44,10 @@
#define LVTS_EDATA01(__base) (__base + 0x0058)
#define LVTS_EDATA02(__base) (__base + 0x005C)
#define LVTS_EDATA03(__base) (__base + 0x0060)
+#define LVTS_ATP0(__base) (__base + 0x0070)
+#define LVTS_ATP1(__base) (__base + 0x0074)
+#define LVTS_ATP2(__base) (__base + 0x0078)
+#define LVTS_ATP3(__base) (__base + 0x007C)
#define LVTS_MSR0(__base) (__base + 0x0090)
#define LVTS_MSR1(__base) (__base + 0x0094)
#define LVTS_MSR2(__base) (__base + 0x0098)
@@ -88,9 +92,6 @@
#define LVTS_COEFF_A_MT7988 -204650
#define LVTS_COEFF_B_MT7988 204650
-#define LVTS_MSR_IMMEDIATE_MODE 0
-#define LVTS_MSR_FILTERED_MODE 1
-
#define LVTS_MSR_READ_TIMEOUT_US 400
#define LVTS_MSR_READ_WAIT_US (LVTS_MSR_READ_TIMEOUT_US / 2)
@@ -101,6 +102,12 @@
static int golden_temp = LVTS_GOLDEN_TEMP_DEFAULT;
static int golden_temp_offset;
+enum lvts_msr_mode {
+ LVTS_MSR_IMMEDIATE_MODE,
+ LVTS_MSR_FILTERED_MODE,
+ LVTS_MSR_ATP_MODE,
+};
+
struct lvts_sensor_data {
int dt_id;
u8 cal_offsets[LVTS_MAX_CAL_OFFSETS];
@@ -110,7 +117,7 @@ struct lvts_ctrl_data {
struct lvts_sensor_data lvts_sensor[LVTS_SENSOR_MAX];
u8 valid_sensor_mask;
int offset;
- int mode;
+ enum lvts_msr_mode mode;
};
#define VALID_SENSOR_MAP(s0, s1, s2, s3) \
@@ -211,6 +218,10 @@ 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_ATP0),
+ LVTS_DEBUG_FS_REGS(LVTS_ATP1),
+ LVTS_DEBUG_FS_REGS(LVTS_ATP2),
+ LVTS_DEBUG_FS_REGS(LVTS_ATP3),
LVTS_DEBUG_FS_REGS(LVTS_MSR0),
LVTS_DEBUG_FS_REGS(LVTS_MSR1),
LVTS_DEBUG_FS_REGS(LVTS_MSR2),
@@ -625,6 +636,13 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
LVTS_IMMD3(lvts_ctrl->base)
};
+ void __iomem *atp_regs[] = {
+ LVTS_ATP0(lvts_ctrl->base),
+ LVTS_ATP1(lvts_ctrl->base),
+ LVTS_ATP2(lvts_ctrl->base),
+ LVTS_ATP3(lvts_ctrl->base)
+ };
+
int i;
lvts_for_each_valid_sensor(i, lvts_ctrl_data) {
@@ -660,8 +678,20 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
/*
* Each sensor has its own register address to read from.
*/
- lvts_sensor[i].msr = lvts_ctrl_data->mode == LVTS_MSR_IMMEDIATE_MODE ?
- imm_regs[i] : msr_regs[i];
+ switch (lvts_ctrl_data->mode) {
+ case LVTS_MSR_IMMEDIATE_MODE:
+ lvts_sensor[i].msr = imm_regs[i];
+ break;
+ case LVTS_MSR_FILTERED_MODE:
+ lvts_sensor[i].msr = msr_regs[i];
+ break;
+ case LVTS_MSR_ATP_MODE:
+ lvts_sensor[i].msr = atp_regs[i];
+ break;
+ default:
+ lvts_sensor[i].msr = imm_regs[i];
+ break;
+ }
lvts_sensor[i].low_thresh = INT_MIN;
lvts_sensor[i].high_thresh = INT_MIN;
@@ -911,7 +941,7 @@ static void lvts_ctrl_monitor_enable(struct device *dev, struct lvts_ctrl *lvts_
u32 sensor_map = 0;
int i;
- if (lvts_ctrl->mode != LVTS_MSR_FILTERED_MODE)
+ if (lvts_ctrl->mode == LVTS_MSR_IMMEDIATE_MODE)
return;
if (enable) {
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 7/9] thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data
2025-08-04 13:30 [PATCH v3 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (5 preceding siblings ...)
2025-08-04 13:30 ` [PATCH v3 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode Laura Nao
@ 2025-08-04 13:30 ` Laura Nao
2025-08-04 13:30 ` [PATCH v3 8/9] thermal/drivers/mediatek/lvts_thermal: Add MT8196 support Laura Nao
2025-08-04 13:30 ` [PATCH v3 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196 Laura Nao
8 siblings, 0 replies; 11+ messages in thread
From: Laura Nao @ 2025-08-04 13:30 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: andrew-ct.chen, lala.lin, arnd, linux-pm, Laura Nao, linux-kernel,
nfraprado, devicetree, u.kleine-koenig, linux-arm-kernel,
linux-mediatek, kernel, colin.i.king, bchihi
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>
Signed-off-by: Laura Nao <laura.nao@collabora.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 dcfcb1be5a09..481ca133902d 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)
@@ -150,6 +151,7 @@ struct lvts_data {
int temp_offset;
int gt_calib_bit_offset;
unsigned int def_calibration;
+ u16 msr_offset;
};
struct lvts_sensor {
@@ -218,6 +220,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),
@@ -788,6 +791,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 {
@@ -1095,6 +1100,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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 8/9] thermal/drivers/mediatek/lvts_thermal: Add MT8196 support
2025-08-04 13:30 [PATCH v3 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (6 preceding siblings ...)
2025-08-04 13:30 ` [PATCH v3 7/9] thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data Laura Nao
@ 2025-08-04 13:30 ` Laura Nao
2025-08-04 13:30 ` [PATCH v3 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196 Laura Nao
8 siblings, 0 replies; 11+ messages in thread
From: Laura Nao @ 2025-08-04 13:30 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: andrew-ct.chen, lala.lin, arnd, linux-pm, Laura Nao, linux-kernel,
nfraprado, devicetree, u.kleine-koenig, linux-arm-kernel,
linux-mediatek, kernel, colin.i.king, bchihi
Add LVTS driver support for MT8196.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 164 ++++++++++++++++++++++++
1 file changed, 164 insertions(+)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 481ca133902d..51a0fd22c2a2 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -92,6 +92,10 @@
#define LVTS_COEFF_B_MT8195 250460
#define LVTS_COEFF_A_MT7988 -204650
#define LVTS_COEFF_B_MT7988 204650
+#define LVTS_COEFF_A_MT8196 391460
+#define LVTS_COEFF_B_MT8196 -391460
+
+#define LVTS_MSR_OFFSET_MT8196 -984
#define LVTS_MSR_READ_TIMEOUT_US 400
#define LVTS_MSR_READ_WAIT_US (LVTS_MSR_READ_TIMEOUT_US / 2)
@@ -761,6 +765,39 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
* <-----ap--tc#3-----> <-----sensor#7-----> <-----sensor#8----->
* 0x40 | 0x41 | 0x42 | 0x43 | 0x44 | 0x45 | 0x46 | 0x47 | 0x48
*
+ * MT8196 :
+ * Stream index map for MCU Domain mt8196 :
+ *
+ * <-sensor#1--> <-sensor#0--> <-sensor#3--> <-sensor#2-->
+ * 0x04 | 0x05 | 0x06 | 0x07 | 0x08 | 0x09 | 0x0A | 0x0B
+ *
+ * <-sensor#5--> <-sensor#4--> <-sensor#7--> <-sensor#6-->
+ * 0x0C | 0x0D | 0x0E | 0x0F | 0x10 | 0x11 | 0x12 | 0x13
+ *
+ * <-sensor#9--> <-sensor#8--> <-sensor#11-> <-sensor#10->
+ * 0x14 | 0x15 | 0x16 | 0x17 | 0x18 | 0x19 | 0x1A | 0X1B
+ *
+ * <-sensor#13-> <-sensor#12-> <-sensor#15-> <-sensor#14->
+ * 0x1C | 0x1D | 0x1E | 0x1F | 0x20 | 0x21 | 0x22 | 0x23
+ *
+ * Stream index map for APU Domain mt8196 :
+ *
+ * <-sensor#1--> <-sensor#0--> <-sensor#3--> <-sensor#2-->
+ * 0x24 | 0x25 | 0x26 | 0x27 | 0x28 | 0x29 | 0x2A | 0x2B
+ *
+ * Stream index map for GPU Domain mt8196 :
+ *
+ * <-sensor#1--> <-sensor#0-->
+ * 0x2C | 0x2D | 0x2E | 0x2F
+ *
+ * Stream index map for AP Domain mt8196 :
+ *
+ * <-sensor#1--> <-sensor#0--> <-sensor#3--> <-sensor#2-->
+ * 0x30 | 0x31 | 0x32 | 0x33 | 0x34 | 0x35 | 0x36 | 0x37
+ *
+ * <-sensor#5--> <-sensor#4--> <-sensor#6--> <-sensor#7-->
+ * 0x38 | 0x39 | 0x3A | 0x3B | 0x3C | 0x3D | 0x3E | 0x3F
+ *
* Note: In some cases, values don't strictly follow a little endian ordering.
* The data description gives byte offsets constituting each calibration value
* for each sensor.
@@ -1829,11 +1866,112 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
}
};
+static const struct lvts_ctrl_data mt8196_lvts_mcu_data_ctrl[] = {
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8196_MCU_MEDIUM_CPU6_0,
+ .cal_offsets = { 0x06, 0x07 } },
+ { .dt_id = MT8196_MCU_MEDIUM_CPU6_1,
+ .cal_offsets = { 0x04, 0x05 } },
+ { .dt_id = MT8196_MCU_DSU2,
+ .cal_offsets = { 0x0A, 0x0B } },
+ { .dt_id = MT8196_MCU_DSU3,
+ .cal_offsets = { 0x08, 0x09 } }
+ },
+ VALID_SENSOR_MAP(1, 1, 1, 1),
+ .offset = 0x0,
+ .mode = LVTS_MSR_ATP_MODE,
+ },
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8196_MCU_LITTLE_CPU3,
+ .cal_offsets = { 0x0E, 0x0F } },
+ { .dt_id = MT8196_MCU_LITTLE_CPU0,
+ .cal_offsets = { 0x0C, 0x0D } },
+ { .dt_id = MT8196_MCU_LITTLE_CPU1,
+ .cal_offsets = { 0x12, 0x13 } },
+ { .dt_id = MT8196_MCU_LITTLE_CPU2,
+ .cal_offsets = { 0x10, 0x11 } }
+ },
+ VALID_SENSOR_MAP(1, 1, 1, 1),
+ .offset = 0x100,
+ .mode = LVTS_MSR_ATP_MODE,
+ },
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8196_MCU_MEDIUM_CPU4_0,
+ .cal_offsets = { 0x16, 0x17 } },
+ { .dt_id = MT8196_MCU_MEDIUM_CPU4_1,
+ .cal_offsets = { 0x14, 0x15 } },
+ { .dt_id = MT8196_MCU_MEDIUM_CPU5_0,
+ .cal_offsets = { 0x1A, 0x1B } },
+ { .dt_id = MT8196_MCU_MEDIUM_CPU5_1,
+ .cal_offsets = { 0x18, 0x19 } }
+ },
+ VALID_SENSOR_MAP(1, 1, 1, 1),
+ .offset = 0x200,
+ .mode = LVTS_MSR_ATP_MODE,
+ },
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8196_MCU_DSU0,
+ .cal_offsets = { 0x1E, 0x1F } },
+ { .dt_id = MT8196_MCU_DSU1,
+ .cal_offsets = { 0x1C, 0x1D } },
+ { .dt_id = MT8196_MCU_BIG_CPU7_0,
+ .cal_offsets = { 0x22, 0x23 } },
+ { .dt_id = MT8196_MCU_BIG_CPU7_1,
+ .cal_offsets = { 0x20, 0x21 } }
+ },
+ VALID_SENSOR_MAP(1, 1, 1, 1),
+ .offset = 0x300,
+ .mode = LVTS_MSR_ATP_MODE,
+ }
+};
+
+static const struct lvts_ctrl_data mt8196_lvts_ap_data_ctrl[] = {
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8196_AP_TOP0,
+ .cal_offsets = { 0x32, 0x33 } },
+ { .dt_id = MT8196_AP_TOP1,
+ .cal_offsets = { 0x30, 0x31 } },
+ { .dt_id = MT8196_AP_TOP2,
+ .cal_offsets = { 0x36, 0x37 } },
+ { .dt_id = MT8196_AP_TOP3,
+ .cal_offsets = { 0x34, 0x35 } }
+ },
+ VALID_SENSOR_MAP(1, 1, 1, 1),
+ .offset = 0x0,
+ .mode = LVTS_MSR_ATP_MODE,
+ },
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8196_AP_BOT0,
+ .cal_offsets = { 0x3A, 0x3B } },
+ { .dt_id = MT8196_AP_BOT1,
+ .cal_offsets = { 0x38, 0x39 } },
+ { .dt_id = MT8196_AP_BOT2,
+ .cal_offsets = { 0x3E, 0x3F } },
+ { .dt_id = MT8196_AP_BOT3,
+ .cal_offsets = { 0x3C, 0x3D } }
+ },
+ VALID_SENSOR_MAP(1, 1, 1, 1),
+ .offset = 0x100,
+ .mode = LVTS_MSR_ATP_MODE,
+ }
+};
+
static const struct lvts_platform_ops lvts_platform_ops_v1 = {
.lvts_raw_to_temp = lvts_raw_to_temp,
.lvts_temp_to_raw = lvts_temp_to_raw,
};
+static const struct lvts_platform_ops lvts_platform_ops_v2 = {
+ .lvts_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw_v2,
+};
+
static const struct lvts_data mt7988_lvts_ap_data = {
.lvts_ctrl = mt7988_lvts_ap_data_ctrl,
.conn_cmd = mt7988_conn_cmds,
@@ -1953,6 +2091,30 @@ static const struct lvts_data mt8195_lvts_ap_data = {
.ops = &lvts_platform_ops_v1,
};
+static const struct lvts_data mt8196_lvts_mcu_data = {
+ .lvts_ctrl = mt8196_lvts_mcu_data_ctrl,
+ .num_lvts_ctrl = ARRAY_SIZE(mt8196_lvts_mcu_data_ctrl),
+ .temp_factor = LVTS_COEFF_A_MT8196,
+ .temp_offset = LVTS_COEFF_B_MT8196,
+ .gt_calib_bit_offset = 0,
+ .def_calibration = 14437,
+ .num_cal_offsets = 2,
+ .msr_offset = LVTS_MSR_OFFSET_MT8196,
+ .ops = &lvts_platform_ops_v2,
+};
+
+static const struct lvts_data mt8196_lvts_ap_data = {
+ .lvts_ctrl = mt8196_lvts_ap_data_ctrl,
+ .num_lvts_ctrl = ARRAY_SIZE(mt8196_lvts_ap_data_ctrl),
+ .temp_factor = LVTS_COEFF_A_MT8196,
+ .temp_offset = LVTS_COEFF_B_MT8196,
+ .gt_calib_bit_offset = 0,
+ .def_calibration = 14437,
+ .num_cal_offsets = 2,
+ .msr_offset = LVTS_MSR_OFFSET_MT8196,
+ .ops = &lvts_platform_ops_v2,
+};
+
static const struct of_device_id lvts_of_match[] = {
{ .compatible = "mediatek,mt7988-lvts-ap", .data = &mt7988_lvts_ap_data },
{ .compatible = "mediatek,mt8186-lvts", .data = &mt8186_lvts_data },
@@ -1962,6 +2124,8 @@ static const struct of_device_id lvts_of_match[] = {
{ .compatible = "mediatek,mt8192-lvts-ap", .data = &mt8192_lvts_ap_data },
{ .compatible = "mediatek,mt8195-lvts-mcu", .data = &mt8195_lvts_mcu_data },
{ .compatible = "mediatek,mt8195-lvts-ap", .data = &mt8195_lvts_ap_data },
+ { .compatible = "mediatek,mt8196-lvts-mcu", .data = &mt8196_lvts_mcu_data },
+ { .compatible = "mediatek,mt8196-lvts-ap", .data = &mt8196_lvts_ap_data },
{},
};
MODULE_DEVICE_TABLE(of, lvts_of_match);
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196
2025-08-04 13:30 [PATCH v3 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (7 preceding siblings ...)
2025-08-04 13:30 ` [PATCH v3 8/9] thermal/drivers/mediatek/lvts_thermal: Add MT8196 support Laura Nao
@ 2025-08-04 13:30 ` Laura Nao
2025-08-05 17:17 ` Rob Herring (Arm)
8 siblings, 1 reply; 11+ messages in thread
From: Laura Nao @ 2025-08-04 13:30 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: andrew-ct.chen, lala.lin, arnd, linux-pm, Laura Nao, linux-kernel,
nfraprado, devicetree, u.kleine-koenig, linux-arm-kernel,
linux-mediatek, kernel, colin.i.king, bchihi
The MT8196 eFuse layout is compatible with MT8186 and shares the same
decoding scheme for the gpu-speedbin cell.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
index 4dc0d42df3e6..c90b026e40bd 100644
--- a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
+++ b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
@@ -25,7 +25,9 @@ properties:
compatible:
oneOf:
- items:
- - const: mediatek,mt8188-efuse
+ - enum:
+ - mediatek,mt8196-efuse
+ - mediatek,mt8188-efuse
- const: mediatek,mt8186-efuse
- const: mediatek,mt8186-efuse
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v3 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196
2025-08-04 13:30 ` [PATCH v3 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196 Laura Nao
@ 2025-08-05 17:17 ` Rob Herring (Arm)
0 siblings, 0 replies; 11+ messages in thread
From: Rob Herring (Arm) @ 2025-08-05 17:17 UTC (permalink / raw)
To: Laura Nao
Cc: andrew-ct.chen, lala.lin, rafael, kernel, bchihi, arnd,
daniel.lezcano, rui.zhang, colin.i.king, devicetree, conor+dt,
nfraprado, linux-pm, linux-mediatek, matthias.bgg,
linux-arm-kernel, angelogioacchino.delregno, linux-kernel, srini,
u.kleine-koenig, krzk+dt, lukasz.luba
On Mon, 04 Aug 2025 15:30:35 +0200, Laura Nao wrote:
> The MT8196 eFuse layout is compatible with MT8186 and shares the same
> decoding scheme for the gpu-speedbin cell.
>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
> ---
> Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-08-05 17:48 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-04 13:30 [PATCH v3 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
2025-08-04 13:30 ` [PATCH v3 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196 Laura Nao
2025-08-04 13:30 ` [PATCH v3 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable Laura Nao
2025-08-04 13:30 ` [PATCH v3 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp Laura Nao
2025-08-04 13:30 ` [PATCH v3 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic Laura Nao
2025-08-04 13:30 ` [PATCH v3 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant Laura Nao
2025-08-04 13:30 ` [PATCH v3 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode Laura Nao
2025-08-04 13:30 ` [PATCH v3 7/9] thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data Laura Nao
2025-08-04 13:30 ` [PATCH v3 8/9] thermal/drivers/mediatek/lvts_thermal: Add MT8196 support Laura Nao
2025-08-04 13:30 ` [PATCH v3 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196 Laura Nao
2025-08-05 17:17 ` Rob Herring (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).