* [PATCH v2 0/9] Add thermal sensor driver support for Mediatek MT8196
@ 2025-07-30 15:21 Laura Nao
2025-07-30 15:21 ` [PATCH v2 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196 Laura Nao
` (8 more replies)
0 siblings, 9 replies; 31+ messages in thread
From: Laura Nao @ 2025-07-30 15:21 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel,
Laura Nao
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 v1: https://lore.kernel.org/all/20250721081459.16278-1-laura.nao@collabora.com/
Changes in v2:
- Added a warning in the probe function for temp_factor==0
- Reworded message for commit adding the lvts_temp_to_raw() variant
- Replaced mode macros with an enum
- Fixed eFuse binding to reflect compatibility with MT8186
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 | 1 +
.../thermal/mediatek,lvts-thermal.yaml | 2 +
drivers/thermal/mediatek/lvts_thermal.c | 326 ++++++++++++++++--
.../thermal/mediatek,lvts-thermal.h | 26 ++
4 files changed, 333 insertions(+), 22 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196
2025-07-30 15:21 [PATCH v2 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
@ 2025-07-30 15:21 ` Laura Nao
2025-07-31 7:31 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable Laura Nao
` (7 subsequent siblings)
8 siblings, 1 reply; 31+ messages in thread
From: Laura Nao @ 2025-07-30 15:21 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel,
Laura Nao, Krzysztof Kozlowski
Add LVTS thermal controller binding for MediaTek MT8196.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
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] 31+ messages in thread
* [PATCH v2 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable
2025-07-30 15:21 [PATCH v2 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
2025-07-30 15:21 ` [PATCH v2 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196 Laura Nao
@ 2025-07-30 15:21 ` Laura Nao
2025-07-31 3:10 ` Fei Shao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp Laura Nao
` (6 subsequent siblings)
8 siblings, 2 replies; 31+ messages in thread
From: Laura Nao @ 2025-07-30 15:21 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel,
Laura Nao
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.
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] 31+ messages in thread
* [PATCH v2 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp
2025-07-30 15:21 [PATCH v2 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
2025-07-30 15:21 ` [PATCH v2 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196 Laura Nao
2025-07-30 15:21 ` [PATCH v2 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable Laura Nao
@ 2025-07-30 15:21 ` Laura Nao
2025-07-31 3:46 ` Fei Shao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic Laura Nao
` (5 subsequent siblings)
8 siblings, 2 replies; 31+ messages in thread
From: Laura Nao @ 2025-07-30 15:21 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel,
Laura Nao
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>
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] 31+ messages in thread
* [PATCH v2 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic
2025-07-30 15:21 [PATCH v2 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (2 preceding siblings ...)
2025-07-30 15:21 ` [PATCH v2 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp Laura Nao
@ 2025-07-30 15:21 ` Laura Nao
2025-07-31 4:03 ` Fei Shao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant Laura Nao
` (4 subsequent siblings)
8 siblings, 2 replies; 31+ messages in thread
From: Laura Nao @ 2025-07-30 15:21 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel,
Laura Nao
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.
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 46 +++++++++++++++++++++++--
1 file changed, 43 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 8398af657ba2..6e4a35ecaf34 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;
+ 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;
@@ -1774,6 +1782,10 @@ 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_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw,
+ }
};
static const struct lvts_data mt8186_lvts_data = {
@@ -1788,6 +1800,10 @@ static const struct lvts_data mt8186_lvts_data = {
.gt_calib_bit_offset = 24,
.def_calibration = 19000,
.num_cal_offsets = 3,
+ .ops = {
+ .lvts_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw,
+ }
};
static const struct lvts_data mt8188_lvts_mcu_data = {
@@ -1802,6 +1818,10 @@ static const struct lvts_data mt8188_lvts_mcu_data = {
.gt_calib_bit_offset = 20,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = {
+ .lvts_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw,
+ }
};
static const struct lvts_data mt8188_lvts_ap_data = {
@@ -1816,6 +1836,10 @@ static const struct lvts_data mt8188_lvts_ap_data = {
.gt_calib_bit_offset = 20,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = {
+ .lvts_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw,
+ }
};
static const struct lvts_data mt8192_lvts_mcu_data = {
@@ -1830,6 +1854,10 @@ static const struct lvts_data mt8192_lvts_mcu_data = {
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = {
+ .lvts_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw,
+ }
};
static const struct lvts_data mt8192_lvts_ap_data = {
@@ -1844,6 +1872,10 @@ static const struct lvts_data mt8192_lvts_ap_data = {
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = {
+ .lvts_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw,
+ }
};
static const struct lvts_data mt8195_lvts_mcu_data = {
@@ -1858,6 +1890,10 @@ static const struct lvts_data mt8195_lvts_mcu_data = {
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = {
+ .lvts_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw,
+ }
};
static const struct lvts_data mt8195_lvts_ap_data = {
@@ -1872,6 +1908,10 @@ static const struct lvts_data mt8195_lvts_ap_data = {
.gt_calib_bit_offset = 24,
.def_calibration = 35000,
.num_cal_offsets = 3,
+ .ops = {
+ .lvts_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw,
+ }
};
static const struct of_device_id lvts_of_match[] = {
--
2.39.5
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant
2025-07-30 15:21 [PATCH v2 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (3 preceding siblings ...)
2025-07-30 15:21 ` [PATCH v2 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic Laura Nao
@ 2025-07-30 15:21 ` Laura Nao
2025-07-31 4:06 ` Fei Shao
` (2 more replies)
2025-07-30 15:21 ` [PATCH v2 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode Laura Nao
` (3 subsequent siblings)
8 siblings, 3 replies; 31+ messages in thread
From: Laura Nao @ 2025-07-30 15:21 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel,
Laura Nao
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.
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 6e4a35ecaf34..750345465f00 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] 31+ messages in thread
* [PATCH v2 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode
2025-07-30 15:21 [PATCH v2 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (4 preceding siblings ...)
2025-07-30 15:21 ` [PATCH v2 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant Laura Nao
@ 2025-07-30 15:21 ` Laura Nao
2025-07-31 4:25 ` Fei Shao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 7/9] thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data Laura Nao
` (2 subsequent siblings)
8 siblings, 2 replies; 31+ messages in thread
From: Laura Nao @ 2025-07-30 15:21 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel,
Laura Nao
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>
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 750345465f00..fbe735e4fd77 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] 31+ messages in thread
* [PATCH v2 7/9] thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data
2025-07-30 15:21 [PATCH v2 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (5 preceding siblings ...)
2025-07-30 15:21 ` [PATCH v2 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode Laura Nao
@ 2025-07-30 15:21 ` Laura Nao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 8/9] thermal/drivers/mediatek/lvts_thermal: Add MT8196 support Laura Nao
2025-07-30 15:21 ` [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196 Laura Nao
8 siblings, 1 reply; 31+ messages in thread
From: Laura Nao @ 2025-07-30 15:21 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel,
Laura Nao
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@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 fbe735e4fd77..a45f18ce85eb 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] 31+ messages in thread
* [PATCH v2 8/9] thermal/drivers/mediatek/lvts_thermal: Add MT8196 support
2025-07-30 15:21 [PATCH v2 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (6 preceding siblings ...)
2025-07-30 15:21 ` [PATCH v2 7/9] thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data Laura Nao
@ 2025-07-30 15:21 ` Laura Nao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196 Laura Nao
8 siblings, 1 reply; 31+ messages in thread
From: Laura Nao @ 2025-07-30 15:21 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel,
Laura Nao
Add LVTS driver support for MT8196.
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 166 ++++++++++++++++++++++++
1 file changed, 166 insertions(+)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index a45f18ce85eb..4e0c0b04fb1e 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,6 +1866,103 @@ 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_data mt7988_lvts_ap_data = {
.lvts_ctrl = mt7988_lvts_ap_data_ctrl,
.conn_cmd = mt7988_conn_cmds,
@@ -1972,6 +2106,36 @@ static const struct lvts_data mt8195_lvts_ap_data = {
}
};
+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_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw_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_raw_to_temp = lvts_raw_to_temp,
+ .lvts_temp_to_raw = lvts_temp_to_raw_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 },
@@ -1981,6 +2145,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] 31+ messages in thread
* [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196
2025-07-30 15:21 [PATCH v2 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
` (7 preceding siblings ...)
2025-07-30 15:21 ` [PATCH v2 8/9] thermal/drivers/mediatek/lvts_thermal: Add MT8196 support Laura Nao
@ 2025-07-30 15:21 ` Laura Nao
2025-07-30 23:54 ` Rob Herring
` (2 more replies)
8 siblings, 3 replies; 31+ messages in thread
From: Laura Nao @ 2025-07-30 15:21 UTC (permalink / raw)
To: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel,
Laura Nao
The MT8196 eFuse layout is compatible with MT8186 and shares the same
decoding scheme for the gpu-speedbin cell.
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
index 4dc0d42df3e6..455b96c1e1f4 100644
--- a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
+++ b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
@@ -25,6 +25,7 @@ properties:
compatible:
oneOf:
- items:
+ - const: mediatek,mt8196-efuse
- const: mediatek,mt8188-efuse
- const: mediatek,mt8186-efuse
- const: mediatek,mt8186-efuse
--
2.39.5
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196
2025-07-30 15:21 ` [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196 Laura Nao
@ 2025-07-30 23:54 ` Rob Herring
2025-07-31 10:26 ` Laura Nao
2025-07-31 7:26 ` AngeloGioacchino Del Regno
2025-07-31 7:28 ` AngeloGioacchino Del Regno
2 siblings, 1 reply; 31+ messages in thread
From: Rob Herring @ 2025-07-30 23:54 UTC (permalink / raw)
To: Laura Nao
Cc: srini, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno, wenst,
nfraprado, arnd, colin.i.king, u.kleine-koenig, andrew-ct.chen,
lala.lin, bchihi, frank-w, devicetree, linux-kernel, linux-pm,
linux-arm-kernel, linux-mediatek, kernel
On Wed, Jul 30, 2025 at 05:21:28PM +0200, Laura Nao wrote:
> The MT8196 eFuse layout is compatible with MT8186 and shares the same
> decoding scheme for the gpu-speedbin cell.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
> ---
> Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
> index 4dc0d42df3e6..455b96c1e1f4 100644
> --- a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
> +++ b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
> @@ -25,6 +25,7 @@ properties:
> compatible:
> oneOf:
> - items:
> + - const: mediatek,mt8196-efuse
> - const: mediatek,mt8188-efuse
> - const: mediatek,mt8186-efuse
You just broke mt8188 as it had 2 entries and now has 3. I think
(based on the commit msg) you want to change 8188 entry to an enum with
mediatek,mt8196-efuse and mediatek,mt8188-efuse.
> - const: mediatek,mt8186-efuse
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable
2025-07-30 15:21 ` [PATCH v2 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable Laura Nao
@ 2025-07-31 3:10 ` Fei Shao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 31+ messages in thread
From: Fei Shao @ 2025-07-31 3:10 UTC (permalink / raw)
To: Laura Nao
Cc: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno,
andrew-ct.chen, kernel, nfraprado, arnd, linux-pm, linux-kernel,
devicetree, u.kleine-koenig, linux-arm-kernel, wenst,
linux-mediatek, bchihi, colin.i.king, lala.lin
On Wed, Jul 30, 2025 at 11:30 PM Laura Nao <laura.nao@collabora.com> wrote:
>
> 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.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reviewed-by: Fei Shao <fshao@chromium.org>
> ---
> 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 [flat|nested] 31+ messages in thread
* Re: [PATCH v2 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp
2025-07-30 15:21 ` [PATCH v2 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp Laura Nao
@ 2025-07-31 3:46 ` Fei Shao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 31+ messages in thread
From: Fei Shao @ 2025-07-31 3:46 UTC (permalink / raw)
To: Laura Nao
Cc: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno,
andrew-ct.chen, kernel, nfraprado, arnd, linux-pm, linux-kernel,
devicetree, u.kleine-koenig, linux-arm-kernel, wenst,
linux-mediatek, bchihi, colin.i.king, lala.lin
On Wed, Jul 30, 2025 at 11:32 PM Laura Nao <laura.nao@collabora.com> wrote:
>
> 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>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reviewed-by: Fei Shao <fshao@chromium.org>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic
2025-07-30 15:21 ` [PATCH v2 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic Laura Nao
@ 2025-07-31 4:03 ` Fei Shao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 31+ messages in thread
From: Fei Shao @ 2025-07-31 4:03 UTC (permalink / raw)
To: Laura Nao
Cc: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno,
andrew-ct.chen, kernel, nfraprado, arnd, linux-pm, linux-kernel,
devicetree, u.kleine-koenig, linux-arm-kernel, wenst,
linux-mediatek, bchihi, colin.i.king, lala.lin
On Wed, Jul 30, 2025 at 11:35 PM Laura Nao <laura.nao@collabora.com> wrote:
>
> 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.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
> ---
> drivers/thermal/mediatek/lvts_thermal.c | 46 +++++++++++++++++++++++--
> 1 file changed, 43 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> index 8398af657ba2..6e4a35ecaf34 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;
> + struct lvts_platform_ops ops;
nit: I think this can also be a const struct, since ops are all
initialized in the platform data and never change.
Anyway, the changes look good IMO, so
Reviewed-by: Fei Shao <fshao@chromium.org>
> const u32 *conn_cmd;
> const u32 *init_cmd;
> int num_cal_offsets;
[...]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant
2025-07-30 15:21 ` [PATCH v2 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant Laura Nao
@ 2025-07-31 4:06 ` Fei Shao
2025-07-31 9:10 ` Chen-Yu Tsai
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2 siblings, 0 replies; 31+ messages in thread
From: Fei Shao @ 2025-07-31 4:06 UTC (permalink / raw)
To: Laura Nao
Cc: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno,
andrew-ct.chen, kernel, nfraprado, arnd, linux-pm, linux-kernel,
devicetree, u.kleine-koenig, linux-arm-kernel, wenst,
linux-mediatek, bchihi, colin.i.king, lala.lin
On Wed, Jul 30, 2025 at 11:37 PM Laura Nao <laura.nao@collabora.com> wrote:
>
> 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.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reviewed-by: Fei Shao <fshao@chromium.org>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode
2025-07-30 15:21 ` [PATCH v2 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode Laura Nao
@ 2025-07-31 4:25 ` Fei Shao
2025-07-31 10:14 ` Laura Nao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
1 sibling, 1 reply; 31+ messages in thread
From: Fei Shao @ 2025-07-31 4:25 UTC (permalink / raw)
To: Laura Nao
Cc: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno,
andrew-ct.chen, kernel, nfraprado, arnd, linux-pm, linux-kernel,
devicetree, u.kleine-koenig, linux-arm-kernel, wenst,
linux-mediatek, bchihi, colin.i.king, lala.lin
On Wed, Jul 30, 2025 at 11:40 PM Laura Nao <laura.nao@collabora.com> wrote:
>
> 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>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
It's not visible in this patch, but a heads-up that I see
lvts_ctrl_start() also depends on whether lvts is in immediate mode. I
wonder if anything is needed there for ATP mode e.g. a new
sensor_atp_bitmap.
Feel free to ignore if this is a false alarm.
Regards,
Fei
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196
2025-07-30 15:21 ` [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196 Laura Nao
2025-07-30 23:54 ` Rob Herring
@ 2025-07-31 7:26 ` AngeloGioacchino Del Regno
2025-07-31 7:28 ` AngeloGioacchino Del Regno
2 siblings, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-07-31 7:26 UTC (permalink / raw)
To: Laura Nao, srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano,
rui.zhang, lukasz.luba, matthias.bgg
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel
Il 30/07/25 17:21, Laura Nao ha scritto:
> The MT8196 eFuse layout is compatible with MT8186 and shares the same
> decoding scheme for the gpu-speedbin cell.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196
2025-07-30 15:21 ` [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196 Laura Nao
2025-07-30 23:54 ` Rob Herring
2025-07-31 7:26 ` AngeloGioacchino Del Regno
@ 2025-07-31 7:28 ` AngeloGioacchino Del Regno
2 siblings, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-07-31 7:28 UTC (permalink / raw)
To: Laura Nao, srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano,
rui.zhang, lukasz.luba, matthias.bgg
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel
Il 30/07/25 17:21, Laura Nao ha scritto:
> The MT8196 eFuse layout is compatible with MT8186 and shares the same
> decoding scheme for the gpu-speedbin cell.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
> ---
> Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
> index 4dc0d42df3e6..455b96c1e1f4 100644
> --- a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
> +++ b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
> @@ -25,6 +25,7 @@ properties:
> compatible:
> oneOf:
> - items:
> + - const: mediatek,mt8196-efuse
Oh wow wait. This is not an enum.
You broke MT8188 like that...!
Cheers,
Angelo
> - const: mediatek,mt8188-efuse
> - const: mediatek,mt8186-efuse
> - const: mediatek,mt8186-efuse
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196
2025-07-30 15:21 ` [PATCH v2 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196 Laura Nao
@ 2025-07-31 7:31 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-07-31 7:31 UTC (permalink / raw)
To: Laura Nao, srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano,
rui.zhang, lukasz.luba, matthias.bgg
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel,
Krzysztof Kozlowski
Il 30/07/25 17:21, Laura Nao ha scritto:
> Add LVTS thermal controller binding for MediaTek MT8196.
>
> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@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 */
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant
2025-07-30 15:21 ` [PATCH v2 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant Laura Nao
2025-07-31 4:06 ` Fei Shao
@ 2025-07-31 9:10 ` Chen-Yu Tsai
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2 siblings, 0 replies; 31+ messages in thread
From: Chen-Yu Tsai @ 2025-07-31 9:10 UTC (permalink / raw)
To: Laura Nao
Cc: srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano, rui.zhang,
lukasz.luba, matthias.bgg, angelogioacchino.delregno, nfraprado,
arnd, colin.i.king, u.kleine-koenig, andrew-ct.chen, lala.lin,
bchihi, frank-w, devicetree, linux-kernel, linux-pm,
linux-arm-kernel, linux-mediatek, kernel
On Wed, Jul 30, 2025 at 11:22 PM Laura Nao <laura.nao@collabora.com> wrote:
>
> 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.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode
2025-07-31 4:25 ` Fei Shao
@ 2025-07-31 10:14 ` Laura Nao
2025-08-01 4:44 ` Fei Shao
0 siblings, 1 reply; 31+ messages in thread
From: Laura Nao @ 2025-07-31 10:14 UTC (permalink / raw)
To: fshao
Cc: andrew-ct.chen, angelogioacchino.delregno, arnd, bchihi,
colin.i.king, conor+dt, daniel.lezcano, devicetree, kernel,
krzk+dt, lala.lin, laura.nao, linux-arm-kernel, linux-kernel,
linux-mediatek, linux-pm, lukasz.luba, matthias.bgg, nfraprado,
rafael, robh, rui.zhang, srini, u.kleine-koenig, wenst
Hi Fei,
On 7/31/25 06:25, Fei Shao wrote:
> On Wed, Jul 30, 2025 at 11:40 PM Laura Nao <laura.nao@collabora.com> wrote:
>>
>> 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>
>> Signed-off-by: Laura Nao <laura.nao@collabora.com>
>
> It's not visible in this patch, but a heads-up that I see
> lvts_ctrl_start() also depends on whether lvts is in immediate mode. I
> wonder if anything is needed there for ATP mode e.g. a new
> sensor_atp_bitmap.
> Feel free to ignore if this is a false alarm.
>
Thanks for the heads up - the bitmap for ATP mode is the same as
sensor_filt_bitmap, so the function is already working as intended.
Best,
Laura
> Regards,
> Fei
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196
2025-07-30 23:54 ` Rob Herring
@ 2025-07-31 10:26 ` Laura Nao
2025-08-03 8:18 ` Krzysztof Kozlowski
0 siblings, 1 reply; 31+ messages in thread
From: Laura Nao @ 2025-07-31 10:26 UTC (permalink / raw)
To: robh
Cc: andrew-ct.chen, angelogioacchino.delregno, arnd, bchihi,
colin.i.king, conor+dt, daniel.lezcano, devicetree, frank-w,
kernel, krzk+dt, lala.lin, laura.nao, linux-arm-kernel,
linux-kernel, linux-mediatek, linux-pm, lukasz.luba, matthias.bgg,
nfraprado, rafael, rui.zhang, srini, u.kleine-koenig, wenst
Hi Rob,
On 7/31/25 01:54, Rob Herring wrote:
> On Wed, Jul 30, 2025 at 05:21:28PM +0200, Laura Nao wrote:
>> The MT8196 eFuse layout is compatible with MT8186 and shares the same
>> decoding scheme for the gpu-speedbin cell.
>>
>> Signed-off-by: Laura Nao <laura.nao@collabora.com>
>> ---
>> Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
>> index 4dc0d42df3e6..455b96c1e1f4 100644
>> --- a/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
>> +++ b/Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml
>> @@ -25,6 +25,7 @@ properties:
>> compatible:
>> oneOf:
>> - items:
>> + - const: mediatek,mt8196-efuse
>> - const: mediatek,mt8188-efuse
>> - const: mediatek,mt8186-efuse
>
> You just broke mt8188 as it had 2 entries and now has 3. I think
> (based on the commit msg) you want to change 8188 entry to an enum with
> mediatek,mt8196-efuse and mediatek,mt8188-efuse.
>
You're absolutely right, not sure how I missed that.
It should be:
compatible:
oneOf:
- items:
- enum:
- mediatek,mt8196-efuse
- mediatek,mt8188-efuse
- const: mediatek,mt8186-efuse
- const: mediatek,mt8186-efuse
[...]
I'll address it in v3.
Thanks!
Laura
>> - const: mediatek,mt8186-efuse
>> --
>> 2.39.5
>>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode
2025-07-31 10:14 ` Laura Nao
@ 2025-08-01 4:44 ` Fei Shao
0 siblings, 0 replies; 31+ messages in thread
From: Fei Shao @ 2025-08-01 4:44 UTC (permalink / raw)
To: Laura Nao
Cc: andrew-ct.chen, angelogioacchino.delregno, arnd, bchihi,
colin.i.king, conor+dt, daniel.lezcano, devicetree, kernel,
krzk+dt, lala.lin, linux-arm-kernel, linux-kernel, linux-mediatek,
linux-pm, lukasz.luba, matthias.bgg, nfraprado, rafael, robh,
rui.zhang, srini, u.kleine-koenig, wenst
On Thu, Jul 31, 2025 at 6:15 PM Laura Nao <laura.nao@collabora.com> wrote:
>
> Hi Fei,
>
> On 7/31/25 06:25, Fei Shao wrote:
> > On Wed, Jul 30, 2025 at 11:40 PM Laura Nao <laura.nao@collabora.com> wrote:
> >>
> >> 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>
> >> Signed-off-by: Laura Nao <laura.nao@collabora.com>
> >
> > It's not visible in this patch, but a heads-up that I see
> > lvts_ctrl_start() also depends on whether lvts is in immediate mode. I
> > wonder if anything is needed there for ATP mode e.g. a new
> > sensor_atp_bitmap.
> > Feel free to ignore if this is a false alarm.
> >
>
> Thanks for the heads up - the bitmap for ATP mode is the same as
> sensor_filt_bitmap, so the function is already working as intended.
Acknowledged, thanks for the clarification.
Reviewed-by: Fei Shao <fshao@chromium.org>
>
> Best,
>
> Laura
>
> > Regards,
> > Fei
>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 7/9] thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data
2025-07-30 15:21 ` [PATCH v2 7/9] thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data Laura Nao
@ 2025-08-01 7:28 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-08-01 7:28 UTC (permalink / raw)
To: Laura Nao, srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano,
rui.zhang, lukasz.luba, matthias.bgg
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel
Il 30/07/25 17:21, Laura Nao ha scritto:
> 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@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode
2025-07-30 15:21 ` [PATCH v2 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode Laura Nao
2025-07-31 4:25 ` Fei Shao
@ 2025-08-01 7:28 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-08-01 7:28 UTC (permalink / raw)
To: Laura Nao, srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano,
rui.zhang, lukasz.luba, matthias.bgg
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel
Il 30/07/25 17:21, Laura Nao ha scritto:
> 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>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant
2025-07-30 15:21 ` [PATCH v2 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant Laura Nao
2025-07-31 4:06 ` Fei Shao
2025-07-31 9:10 ` Chen-Yu Tsai
@ 2025-08-01 7:28 ` AngeloGioacchino Del Regno
2 siblings, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-08-01 7:28 UTC (permalink / raw)
To: Laura Nao, srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano,
rui.zhang, lukasz.luba, matthias.bgg
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel
Il 30/07/25 17:21, Laura Nao ha scritto:
> 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.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp
2025-07-30 15:21 ` [PATCH v2 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp Laura Nao
2025-07-31 3:46 ` Fei Shao
@ 2025-08-01 7:28 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-08-01 7:28 UTC (permalink / raw)
To: Laura Nao, srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano,
rui.zhang, lukasz.luba, matthias.bgg
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel
Il 30/07/25 17:21, Laura Nao ha scritto:
> 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>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable
2025-07-30 15:21 ` [PATCH v2 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable Laura Nao
2025-07-31 3:10 ` Fei Shao
@ 2025-08-01 7:28 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-08-01 7:28 UTC (permalink / raw)
To: Laura Nao, srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano,
rui.zhang, lukasz.luba, matthias.bgg
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel
Il 30/07/25 17:21, Laura Nao ha scritto:
> 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.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic
2025-07-30 15:21 ` [PATCH v2 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic Laura Nao
2025-07-31 4:03 ` Fei Shao
@ 2025-08-01 7:28 ` AngeloGioacchino Del Regno
1 sibling, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-08-01 7:28 UTC (permalink / raw)
To: Laura Nao, srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano,
rui.zhang, lukasz.luba, matthias.bgg
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel
Il 30/07/25 17:21, Laura Nao ha scritto:
> 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.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
> ---
> drivers/thermal/mediatek/lvts_thermal.c | 46 +++++++++++++++++++++++--
> 1 file changed, 43 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> index 8398af657ba2..6e4a35ecaf34 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;
> + struct lvts_platform_ops ops;
You can constify this one - but then there's something else that we can do here
to waste a bit less memory.
const struct lvts_platform_ops *ops;
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 mt8195_lvts_mcu_data = {
[..... stuff .....],
.ops = lvts_platform_ops_v1,
};
....and goes on the same for all the others.
> 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;
...then here, and everywhere else, it would be just
const struct lvts_platform_ops *ops = lvts_data->ops;
After implementing the proposed change, exactly how I wrote them:
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cheers,
Angelo
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 8/9] thermal/drivers/mediatek/lvts_thermal: Add MT8196 support
2025-07-30 15:21 ` [PATCH v2 8/9] thermal/drivers/mediatek/lvts_thermal: Add MT8196 support Laura Nao
@ 2025-08-01 7:28 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-08-01 7:28 UTC (permalink / raw)
To: Laura Nao, srini, robh, krzk+dt, conor+dt, rafael, daniel.lezcano,
rui.zhang, lukasz.luba, matthias.bgg
Cc: wenst, nfraprado, arnd, colin.i.king, u.kleine-koenig,
andrew-ct.chen, lala.lin, bchihi, frank-w, devicetree,
linux-kernel, linux-pm, linux-arm-kernel, linux-mediatek, kernel
Il 30/07/25 17:21, Laura Nao ha scritto:
> Add LVTS driver support for MT8196.
>
> Signed-off-by: Laura Nao <laura.nao@collabora.com>
When changing commit 4/9, this also needs to follow with
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,
};
and
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,
};
After which:
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196
2025-07-31 10:26 ` Laura Nao
@ 2025-08-03 8:18 ` Krzysztof Kozlowski
0 siblings, 0 replies; 31+ messages in thread
From: Krzysztof Kozlowski @ 2025-08-03 8:18 UTC (permalink / raw)
To: Laura Nao, robh
Cc: andrew-ct.chen, angelogioacchino.delregno, arnd, bchihi,
colin.i.king, conor+dt, daniel.lezcano, devicetree, frank-w,
kernel, krzk+dt, lala.lin, linux-arm-kernel, linux-kernel,
linux-mediatek, linux-pm, lukasz.luba, matthias.bgg, nfraprado,
rafael, rui.zhang, srini, u.kleine-koenig, wenst
On 31/07/2025 12:26, Laura Nao wrote:
>>> - items:
>>> + - const: mediatek,mt8196-efuse
>>> - const: mediatek,mt8188-efuse
>>> - const: mediatek,mt8186-efuse
>>
>> You just broke mt8188 as it had 2 entries and now has 3. I think
>> (based on the commit msg) you want to change 8188 entry to an enum with
>> mediatek,mt8196-efuse and mediatek,mt8188-efuse.
>>
>
> You're absolutely right, not sure how I missed that.
Please test your bindings and DTS BEFORE you send. The testing would
point you new warnings.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2025-08-03 8:18 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-30 15:21 [PATCH v2 0/9] Add thermal sensor driver support for Mediatek MT8196 Laura Nao
2025-07-30 15:21 ` [PATCH v2 1/9] dt-bindings: thermal: mediatek: Add LVTS thermal controller support for MT8196 Laura Nao
2025-07-31 7:31 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 2/9] thermal/drivers/mediatek/lvts: Make number of calibration offsets configurable Laura Nao
2025-07-31 3:10 ` Fei Shao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 3/9] thermal/drivers/mediatek/lvts: Guard against zero temp_factor in lvts_raw_to_temp Laura Nao
2025-07-31 3:46 ` Fei Shao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 4/9] thermal: mediatek: lvts: Add platform ops to support alternative conversion logic Laura Nao
2025-07-31 4:03 ` Fei Shao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 5/9] thermal/drivers/mediatek/lvts: Add lvts_temp_to_raw variant Laura Nao
2025-07-31 4:06 ` Fei Shao
2025-07-31 9:10 ` Chen-Yu Tsai
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 6/9] thermal/drivers/mediatek/lvts: Add support for ATP mode Laura Nao
2025-07-31 4:25 ` Fei Shao
2025-07-31 10:14 ` Laura Nao
2025-08-01 4:44 ` Fei Shao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 7/9] thermal/drivers/mediatek/lvts: Support MSR offset for 16-bit calibration data Laura Nao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 8/9] thermal/drivers/mediatek/lvts_thermal: Add MT8196 support Laura Nao
2025-08-01 7:28 ` AngeloGioacchino Del Regno
2025-07-30 15:21 ` [PATCH v2 9/9] dt-bindings: nvmem: mediatek: efuse: Add support for MT8196 Laura Nao
2025-07-30 23:54 ` Rob Herring
2025-07-31 10:26 ` Laura Nao
2025-08-03 8:18 ` Krzysztof Kozlowski
2025-07-31 7:26 ` AngeloGioacchino Del Regno
2025-07-31 7:28 ` AngeloGioacchino Del Regno
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).