dt-bindings: thermal: mediatek: Add MT8189 LVTS bindings
Subsystems (3)
PATCH 1/2 dt-bindings: thermal: mediatek: Add MT8189 LVTS bindings
From: Kuanfu Lu <[email protected]>
Add support for the MediaTek MT8189 LVTS thermal controller to the device tree bindings. This includes new compatible strings and required properties for MT8189.
--- .../thermal/mediatek,lvts-thermal.yaml | 27 +++++++++++++++++-- .../thermal/mediatek,lvts-thermal.h | 20 ++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml +25 -2
@@ -23,6 +23,8 @@ properties: - mediatek,mt8186-lvts - mediatek,mt8188-lvts-ap - mediatek,mt8188-lvts-mcu + - mediatek,mt8189-lvts-ap + - mediatek,mt8189-lvts-mcu - mediatek,mt8192-lvts-ap - mediatek,mt8192-lvts-mcu - mediatek,mt8195-lvts-ap
@@ -61,6 +63,21 @@ properties: allOf: - $ref: thermal-sensor.yaml# + - if: + properties: + compatible: + contains: + enum: + - mediatek,mt8189-lvts-ap + - mediatek,mt8189-lvts-mcu + then: + properties: + nvmem-cells: + minItems: 2 + + nvmem-cell-names: + minItems: 2 + - if: properties: compatible:
@@ -78,6 +95,10 @@ allOf: nvmem-cell-names: maxItems: 1 + required: + - clocks + - resets + - if: properties: compatible:
@@ -94,12 +115,14 @@ allOf: nvmem-cell-names: minItems: 2 + required: + - clocks + - resets + required: - compatible - reg - interrupts - - clocks - - resets - nvmem-cells - nvmem-cell-names
include/dt-bindings/thermal/mediatek,lvts-thermal.h +20 -0
@@ -45,6 +45,26 @@#define MT8188_AP_CAM1 6#define MT8188_AP_CAM2 7 +#define MT8189_MCU_BIG_CPU1 0 +#define MT8189_MCU_BIG_CPU2 1 +#define MT8189_MCU_BIG_CPU3 2 +#define MT8189_MCU_BIG_CPU4 3 +#define MT8189_MCU_LITTLE_CPU1 4 +#define MT8189_MCU_LITTLE_CPU2 5 +#define MT8189_MCU_LITTLE_CPU3 6 +#define MT8189_MCU_LITTLE_CPU4 7 +#define MT8189_MCU_LITTLE_CPU5 8 +#define MT8189_MCU_LITTLE_CPU6 9 +#define MT8189_MCU_LITTLE_CPU7 10 +#define MT8189_MCU_LITTLE_CPU8 11 + +#define MT8189_AP_SOC1 12 +#define MT8189_AP_SOC2 13 +#define MT8189_AP_SOC3 14 +#define MT8189_AP_APU 15 +#define MT8189_AP_GPU1 16 +#define MT8189_AP_GPU2 17 +#define MT8195_MCU_BIG_CPU0 0#define MT8195_MCU_BIG_CPU1 1#define MT8195_MCU_BIG_CPU2 2
Signature · 1 line
2.45.2
PATCH 2/2 thermal: mediatek: lvts: Add MT8189 support
From: Kuanfu Lu <[email protected]>
Add LVTS thermal support for MediaTek MT8189 by adding MT8189-specific controller/sensor topology and platform data for the MCU and AP domains.
MT8189 differs from previous SoCs in a few aspects, so extend the driver to handle these variations:
- Program the hardware thermal shutdown threshold (tshut) using raw units.
- Add per-SoC feature flags to skip clock gating and reset control when they are not required, and to enable Stage-3 monitor interrupt setup.
- Pass SoC data into lvts_irq_init() and lvts_ctrl_configure() so the initialization can be configured per platform.
This enables monitoring of MT8189 CPU clusters and AP domain sensors (SOC/APU/GPU) with the existing LVTS driver.
--- drivers/thermal/mediatek/lvts_thermal.c | 142 +++++++++++++++++++++--- 1 file changed, 129 insertions(+), 13 deletions(-)
drivers/thermal/mediatek/lvts_thermal.c +129 -13
@@ -70,6 +70,7 @@#define LVTS_HW_FILTER 0x0#define LVTS_TSSEL_CONF 0x13121110#define LVTS_CALSCALE_CONF 0x300 +#define LVTS_MONINT_CONF_STAGE3 BIT(31)#define LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR0 BIT(3)#define LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR1 BIT(8)
@@ -159,6 +160,9 @@ struct lvts_data {int temp_offset;int gt_calib_bit_offset;unsigned int def_calibration; +bool clock_gate_no_need; +bool reset_no_need; +bool conf_stage3_need;u16 msr_offset; };
@@ -1044,7 +1048,7 @@ static void lvts_write_config(struct lvts_ctrl *lvts_ctrl, const u32 *cmds, int } } -static int lvts_irq_init (struct lvts_ctrl *lvts_ctrl) +static int lvts_irq_init (struct lvts_ctrl *lvts_ctrl,const struct lvts_data *lvts_data) {/* * LVTS_PROTCTL : Thermal Protection Sensor Selection
@@ -1079,7 +1083,11 @@ static int lvts_irq_init(struct lvts_ctrl *lvts_ctrl)* The LVTS_MONINT register layout is the same as the LVTS_MONINTSTS * register, except we set the bits to enable the interrupt. */ -writel (0 ,LVTS_MONINT (lvts_ctrl->base)); + +if (lvts_data->conf_stage3_need) +writel (LVTS_MONINT_CONF_STAGE3 ,LVTS_MONINT (lvts_ctrl->base)); +else +writel (0 ,LVTS_MONINT (lvts_ctrl->base));return 0 ; }
@@ -1177,7 +1185,8 @@ static int lvts_ctrl_calibrate(struct device *dev, struct lvts_ctrl *lvts_ctrl)return 0 ; } -static int lvts_ctrl_configure (struct device *dev,struct lvts_ctrl *lvts_ctrl) +static int lvts_ctrl_configure (struct device *dev,struct lvts_ctrl *lvts_ctrl, +const struct lvts_data *lvts_data) {u32 value;
@@ -1279,7 +1288,7 @@ static int lvts_ctrl_configure(struct device *dev, struct lvts_ctrl *lvts_ctrl) value =LVTS_FILTER_INTERVAL <<16 |LVTS_SENSOR_INTERVAL ;writel (value,LVTS_MONCTL2 (lvts_ctrl->base)); -return lvts_irq_init (lvts_ctrl); +return lvts_irq_init (lvts_ctrl, lvts_data); }static int lvts_ctrl_start (struct device *dev,struct lvts_ctrl *lvts_ctrl)
@@ -1420,13 +1429,13 @@ static int lvts_domain_init(struct device *dev, struct lvts_domain *lvts_td,return ret; } - ret =lvts_ctrl_calibrate (dev, lvts_ctrl); + ret =lvts_ctrl_calibrate (dev, lvts_ctrl, lvts_data);if (ret) {dev_dbg (dev,"Failed to calibrate controller" );return ret; } - ret =lvts_ctrl_configure (dev, lvts_ctrl); + ret =lvts_ctrl_configure (dev, lvts_ctrl, lvts_data);if (ret) {dev_dbg (dev,"Failed to configure controller" );return ret;
@@ -1458,9 +1467,12 @@ static int lvts_probe(struct platform_device *pdev)if (!lvts_data)return -ENODEV ; - lvts_td->clk =devm_clk_get_enabled (dev,NULL ); -if (IS_ERR (lvts_td->clk)) -return dev_err_probe (dev,PTR_ERR (lvts_td->clk),"Failed to retrieve clock\n" ); +if (!lvts_data->clock_gate_no_need) { + lvts_td->clk =devm_clk_get_enabled (dev,NULL ); +if (IS_ERR (lvts_td->clk)) +return dev_err_probe (dev,PTR_ERR (lvts_td->clk), +"Failed to retrieve clock\n" ); + } res =platform_get_mem_or_io (pdev,0 );if (!res)
@@ -1470,10 +1482,12 @@ static int lvts_probe(struct platform_device *pdev)if (IS_ERR (lvts_td->base))return dev_err_probe (dev,PTR_ERR (lvts_td->base),"Failed to map io resource\n" ); - lvts_td->reset =devm_reset_control_get_by_index (dev,0 ); -if (IS_ERR (lvts_td->reset)) -return dev_err_probe (dev,PTR_ERR (lvts_td->reset),"Failed to get reset control\n" ); - +if (!lvts_data->reset_no_need) { + lvts_td->reset =devm_reset_control_get_by_index (dev,0 ); +if (IS_ERR (lvts_td->reset)) +return dev_err_probe (dev,PTR_ERR (lvts_td->reset), +"Failed to get reset control\n" ); + } irq =platform_get_irq (pdev,0 );if (irq <0 )return irq;
@@ -1742,6 +1756,78 @@ static const struct lvts_ctrl_data mt8188_lvts_ap_data_ctrl[] = { } }; +static const struct lvts_ctrl_data mt8189_lvts_mcu_data_ctrl[] = { + { + .lvts_sensor = { + { .dt_id =MT8189_MCU_LITTLE_CPU1 , + .cal_offsets = {4 ,5 ,6 } }, + { .dt_id =MT8189_MCU_LITTLE_CPU2 , + .cal_offsets = {8 ,9 ,10 } }, + { .dt_id =MT8189_MCU_LITTLE_CPU3 , + .cal_offsets = {12 ,13 ,14 } }, + { .dt_id =MT8189_MCU_LITTLE_CPU4 , + .cal_offsets = {16 ,17 ,18 } } + }, +VALID_SENSOR_MAP (1 ,1 ,1 ,1 ), + .offset =0x0 , + }, + { + .lvts_sensor = { + { .dt_id =MT8189_MCU_LITTLE_CPU5 , + .cal_offsets = {24 ,25 ,26 } }, + { .dt_id =MT8189_MCU_LITTLE_CPU6 , + .cal_offsets = {28 ,29 ,30 } }, + { .dt_id =MT8189_MCU_LITTLE_CPU7 , + .cal_offsets = {32 ,33 ,34 } }, + { .dt_id =MT8189_MCU_LITTLE_CPU8 , + .cal_offsets = {36 ,37 ,38 } } + }, +VALID_SENSOR_MAP (1 ,1 ,1 ,1 ), + .offset =0x100 , + }, + { + .lvts_sensor = { + { .dt_id =MT8189_MCU_BIG_CPU1 , + .cal_offsets = {44 ,45 ,46 } }, + { .dt_id =MT8189_MCU_BIG_CPU2 , + .cal_offsets = {48 ,49 ,50 } }, + { .dt_id =MT8189_MCU_BIG_CPU3 , + .cal_offsets = {52 ,53 ,54 } }, + { .dt_id =MT8189_MCU_BIG_CPU4 , + .cal_offsets = {56 ,57 ,58 } } + }, +VALID_SENSOR_MAP (1 ,1 ,1 ,1 ), + .offset =0x200 , + } +}; + +static const struct lvts_ctrl_data mt8189_lvts_ap_data_ctrl[] = { + { + .lvts_sensor = { + { .dt_id =MT8189_AP_SOC1 , + .cal_offsets = {64 ,65 ,66 } }, + { .dt_id =MT8189_AP_SOC2 , + .cal_offsets = {68 ,69 ,70 } }, + { .dt_id =MT8189_AP_SOC3 , + .cal_offsets = {72 ,73 ,74 } }, + { .dt_id =MT8189_AP_APU , + .cal_offsets = {76 ,77 ,78 } } + }, +VALID_SENSOR_MAP (1 ,1 ,1 ,1 ), + .offset =0x0 , + }, + { + .lvts_sensor = { + { .dt_id =MT8189_AP_GPU1 , + .cal_offsets = {84 ,85 ,86 } }, + { .dt_id =MT8189_AP_GPU2 , + .cal_offsets = {88 ,89 ,90 } } + }, +VALID_SENSOR_MAP (1 ,1 ,0 ,0 ), + .offset =0x100 , + } +}; +static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = { { .lvts_sensor = {
@@ -2087,6 +2173,34 @@ static const struct lvts_data mt8188_lvts_ap_data = { .ops = &lvts_platform_ops_mt7988, }; +static const struct lvts_data mt8189_lvts_ap_data = { + .lvts_ctrl = mt8189_lvts_ap_data_ctrl, + .conn_cmd = default_conn_cmds, + .init_cmd = default_init_cmds, + .num_lvts_ctrl =ARRAY_SIZE (mt8189_lvts_ap_data_ctrl), + .num_conn_cmd =ARRAY_SIZE (default_conn_cmds), + .num_init_cmd =ARRAY_SIZE (default_init_cmds), + .temp_factor =LVTS_COEFF_A_MT8195 , + .temp_offset =LVTS_COEFF_B_MT8195 , + .gt_calib_bit_offset =0 , + .def_calibration =35000 , + .clock_gate_no_need = true, + .reset_no_need = true, + .conf_stage3_need = true, +}; + +static const struct lvts_data mt8189_lvts_mcu_data = { + .lvts_ctrl = mt8189_lvts_mcu_data_ctrl, + .num_lvts_ctrl =ARRAY_SIZE (mt8189_lvts_mcu_data_ctrl), + .temp_factor =LVTS_COEFF_A_MT8195 , + .temp_offset =LVTS_COEFF_B_MT8195 , + .gt_calib_bit_offset =0 , + .def_calibration =35000 , + .clock_gate_no_need = true, + .reset_no_need = true, + .conf_stage3_need = true, +}; +static const struct lvts_data mt8192_lvts_mcu_data = { .lvts_ctrl = mt8192_lvts_mcu_data_ctrl, .conn_cmd = default_conn_cmds,
@@ -2177,6 +2291,8 @@ static const struct of_device_id lvts_of_match[] = { { .compatible = "mediatek,mt8186-lvts", .data = &mt8186_lvts_data }, { .compatible = "mediatek,mt8188-lvts-mcu", .data = &mt8188_lvts_mcu_data }, { .compatible = "mediatek,mt8188-lvts-ap", .data = &mt8188_lvts_ap_data }, + { .compatible = "mediatek,mt8189-lvts-mcu", .data = &mt8189_lvts_mcu_data }, + { .compatible = "mediatek,mt8189-lvts-ap", .data = &mt8189_lvts_ap_data }, { .compatible = "mediatek,mt8192-lvts-mcu", .data = &mt8192_lvts_mcu_data }, { .compatible = "mediatek,mt8192-lvts-ap", .data = &mt8192_lvts_ap_data }, { .compatible = "mediatek,mt8195-lvts-mcu", .data = &mt8195_lvts_mcu_data },
Signature · 1 line
2.45.2
Re: [PATCH 2/2] thermal: mediatek: lvts: Add MT8189 support
Quoted 25 lines · On Mo, 2026-04-27 at 14:48 +0800, mtk36707 wrote:
From: Kuanfu Lu <[email protected]>
Add LVTS thermal support for MediaTek MT8189 by adding MT8189-specific controller/sensor topology and platform data for the MCU and AP domains.
MT8189 differs from previous SoCs in a few aspects, so extend the driver to handle these variations:
- Program the hardware thermal shutdown threshold (tshut) using raw units.
- Add per-SoC feature flags to skip clock gating and reset control when they are not required, and to enable Stage-3 monitor interrupt setup.
- Pass SoC data intolvts_irq_init()andlvts_ctrl_configure()so the initialization can be configured per platform.This enables monitoring of MT8189 CPU clusters and AP domain sensors (SOC/APU/GPU) with the existing LVTS driver.
Signed-off-by Kuanfu Lu <[email protected]>--- drivers/thermal/mediatek/lvts_thermal.c | 142 +++++++++++++++++++++--- 1 file changed, 129 insertions(+), 13 deletions(-)drivers/thermal/mediatek/lvts_thermal.c +0
-0
[...]
drivers/thermal/mediatek/lvts_thermal.c static int lvts_probe(struct platform_device *pdev) · line 1473
Quoted 5 lines
drivers/thermal/mediatek/lvts_thermal.c +0
-1@@ -1470,10 +1482,12 @@ static int lvts_probe(struct platform_device *pdev)if (IS_ERR (lvts_td->base))return dev_err_probe (dev,PTR_ERR (lvts_td->base),"Failed to map io resource\n" ); - lvts_td->reset =devm_reset_control_get_by_index (dev,0 );
First of all, this should have been:
lvts_td->reset = devm_reset_control_get_exclusive(dev, NULL);
since there is only a single reset control defined in the binding.
drivers/thermal/mediatek/lvts_thermal.c static int lvts_probe(struct platform_device *pdev) · line 1486
Quoted 5 lines
drivers/thermal/mediatek/lvts_thermal.c +2
-3-if (IS_ERR (lvts_td->reset)) -return dev_err_probe (dev,PTR_ERR (lvts_td->reset),"Failed to get reset control\n" ); - +if (!lvts_data->reset_no_need) { + lvts_td->reset =devm_reset_control_get_by_index (dev,0 );
So this can be changed to
lvts_td->reset = devm_reset_control_get_optional_exclusive(dev, NULL);
instead. There is no need for the reset_no_need parameter at all. Whether the reset control is required or not is already specified in the device tree bindings.
drivers/thermal/mediatek/lvts_thermal.c static int lvts_probe(struct platform_device *pdev) · line 1493
Quoted 7 lines
drivers/thermal/mediatek/lvts_thermal.c +4
-0+if (IS_ERR (lvts_td->reset)) +return dev_err_probe (dev,PTR_ERR (lvts_td->reset), +"Failed to get reset control\n" ); + } irq =platform_get_irq (pdev,0 );if (irq <0 )return irq;
regards
Philipp
Rob Herring (Arm)
maintainerQuoted 6 lines · On Mon, 27 Apr 2026 14:48:29 +0800, mtk36707 wrote:
From: Kuanfu Lu <[email protected]>
Add support for the MediaTek MT8189 LVTS thermal controller to the device tree bindings. This includes new compatible strings and required properties for MT8189.
Quoted 6 lines
Signed-off-by Kuanfu Lu <[email protected]>--- .../thermal/mediatek,lvts-thermal.yaml | 27 +++++++++++++++++-- .../thermal/mediatek,lvts-thermal.h | 20 ++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-)
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:./Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml:99:11: [warning] wrong indentation: expected 8 but found 10 (indentation) ./Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml:119:11: [warning] wrong indentation: expected 8 but found 10 (indentation)
dtschema/dtc warnings/errors:
doc reference errors (make refcheckdocs):
See https://patchwork.kernel.org/project/devicetree/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.