Add thermal sensors support for MT7981
Subsystems (4)
cover Add thermal sensors support for MT7981
This patch adds support for the temperature sensor in the MT7981 SoC. This sensor is exactly the same as the one in the MT7986.
Aleksander Jan Bajkowski (3):
arm64: dts: mediatek: add thermal sensor support on mt7981 thermal/drivers/mediatek: Add support for MT7981 SoC
dt-bindings: iio: adc: Add support for MT7981
.../iio/adc/mediatek,mt2701-auxadc.yaml | 1 + arch/arm64/boot/dts/mediatek/mt7981b.dtsi | 29 ++++++++++++++++++- drivers/thermal/mediatek/auxadc_thermal.c | 4 +++ 3 files changed, 33 insertions(+), 1 deletion(-)
Signature · 1 line
2.39.5
PATCH 1/3 arm64: dts: mediatek: add thermal sensor support on mt7981
The temperature sensor in the MT7981 is same as in the MT7986.
--- arch/arm64/boot/dts/mediatek/mt7981b.dtsi | 29 ++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt7981b.dtsi +28 -1
@@ -76,7 +76,7 @@ watchdog: watchdog@1001c000 { #reset-cells = <1>; }; - clock-controller@1001e000 { + apmixedsys: clock-controller@1001e000 { compatible = "mediatek,mt7981-apmixedsys"; reg = <0 0x1001e000 0 0x1000>; #clock-cells = <1>;
@@ -184,6 +184,29 @@ spi@1100b000 { status = "disabled"; }; + thermal@1100c800 { + compatible = "mediatek,mt7981-thermal"; + reg = <0 0x1100c800 0 0x800>; + interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&infracfg CLK_INFRA_THERM_CK>, + <&infracfg CLK_INFRA_ADC_26M_CK>; + clock-names = "therm", "auxadc"; + nvmem-cells = <&thermal_calibration>; + nvmem-cell-names = "calibration-data"; + #thermal-sensor-cells = <1>; + mediatek,auxadc = <&auxadc>; + mediatek,apmixedsys = <&apmixedsys>; + }; + + auxadc: adc@1100d000 { + compatible = "mediatek,mt7981-auxadc"; + reg = <0 0x1100d000 0 0x1000>; + clocks = <&infracfg CLK_INFRA_ADC_26M_CK>; + clock-names = "main"; + #io-channel-cells = <1>; + status = "disabled"; + }; + pio: pinctrl@11d00000 { compatible = "mediatek,mt7981-pinctrl"; reg = <0 0x11d00000 0 0x1000>,
@@ -211,6 +234,10 @@ efuse@11f20000 { reg = <0 0x11f20000 0 0x1000>; #address-cells = <1>; #size-cells = <1>; + + thermal_calibration: calib@274 { + reg = <0x274 0xc>; + }; }; clock-controller@15000000 {
Signature · 1 line
2.39.5
PATCH 2/3 thermal/drivers/mediatek: Add support for MT7981 SoC
In reply to Aleksander Jan BajkowskiThe temperature sensor support on the MT7981 is exactly the same as on the MT7986.
--- drivers/thermal/mediatek/auxadc_thermal.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/thermal/mediatek/auxadc_thermal.c +4 -0
@@ -1149,6 +1149,10 @@ static const struct of_device_id mtk_thermal_of_match[] = { .compatible = "mediatek,mt7622-thermal", .data = (void *)&mt7622_thermal_data, }, + { + .compatible = "mediatek,mt7981-thermal", + .data = (void *)&mt7986_thermal_data, + }, { .compatible = "mediatek,mt7986-thermal", .data = (void *)&mt7986_thermal_data,
Signature · 1 line
2.39.5
Jonathan Cameron
maintainerRe: [PATCH 2/3] thermal/drivers/mediatek: Add support for MT7981 SoC
Quoted 13 lines · On Sun, 29 Jun 2025 00:38:36 +0200 Aleksander Jan Bajkowski <[email protected]> wrote:
The temperature sensor support on the MT7981 is exactly the same as on the MT7986.
Signed-off-by Aleksander Jan Bajkowski <[email protected]>--- drivers/thermal/mediatek/auxadc_thermal.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/thermal/mediatek/auxadc_thermal.c +0
-0
drivers/thermal/mediatek/auxadc_thermal.c static const struct of_device_id mtk_thermal_of_match[] = { · line 1154
Quoted 6 lines
drivers/thermal/mediatek/auxadc_thermal.c +3
-0@@ -1149,6 +1149,10 @@ static const struct of_device_id mtk_thermal_of_match[] = { .compatible = "mediatek,mt7622-thermal", .data = (void *)&mt7622_thermal_data, }, + { + .compatible = "mediatek,mt7981-thermal", + .data = (void *)&mt7986_thermal_data,
Random drive by question. Why the (void *) casts?
static const struct mtk_thermal_data mt7986_thermal_data; is the definition and data is a const void * so you should be able to assign directly without a cast and not have the casting away of const only to assign it to a const void *
Quoted 4 lines
drivers/thermal/mediatek/auxadc_thermal.c +1
-0+ }, { .compatible = "mediatek,mt7986-thermal", .data = (void *)&mt7986_thermal_data,
AngeloGioacchino Del Regno
maintainerRe: [PATCH 2/3] thermal/drivers/mediatek: Add support for MT7981 SoC
In reply to Aleksander Jan BajkowskiIl 29/06/25 00:38, Aleksander Jan Bajkowski ha scritto:
Quoted 3 lines
The temperature sensor support on the MT7981 is exactly the same as on the MT7986.
If it is exactly the same, great! ... but then this change is wrong :-) You should, instead, change the bindings to allow you to specify
compatible = "mediatek,mt7981-thermal", "mediatek,mt7986-thermal";
...and that's about it, no driver changes to be done.
Cheers,
Angelo
Quoted 20 lines
Signed-off-by Aleksander Jan Bajkowski <[email protected]>--- drivers/thermal/mediatek/auxadc_thermal.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/thermal/mediatek/auxadc_thermal.c +4
-0@@ -1149,6 +1149,10 @@ static const struct of_device_id mtk_thermal_of_match[] = { .compatible = "mediatek,mt7622-thermal", .data = (void *)&mt7622_thermal_data, }, + { + .compatible = "mediatek,mt7981-thermal", + .data = (void *)&mt7986_thermal_data, + }, { .compatible = "mediatek,mt7986-thermal", .data = (void *)&mt7986_thermal_data,
PATCH 3/3 dt-bindings: iio: adc: Add support for MT7981
In reply to Aleksander Jan BajkowskiThe temperature sensor in the MT7981 is same as in the MT7986. Add compatible string for mt7981.
--- .../devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml +1 -0
@@ -26,6 +26,7 @@ properties: - mediatek,mt2712-auxadc - mediatek,mt6765-auxadc - mediatek,mt7622-auxadc + - mediatek,mt7981-auxadc - mediatek,mt7986-auxadc - mediatek,mt8173-auxadc - items:
Signature · 1 line
2.39.5
David Lechner
reviewerRe: [PATCH 3/3] dt-bindings: iio: adc: Add support for MT7981
Quoted 3 lines · Aleksander Jan Bajkowski
The temperature sensor in the MT7981 is same as in the MT7986. Add compatible string for mt7981.
If they are exactly the same, then we would want to include fallback to the existing identical compatible string rather than adding a new standalone compatible.
Quoted 17 lines
Signed-off-by Aleksander Jan Bajkowski <[email protected]>--- .../devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml +1
-0@@ -26,6 +26,7 @@ properties: - mediatek,mt2712-auxadc - mediatek,mt6765-auxadc - mediatek,mt7622-auxadc + - mediatek,mt7981-auxadc - mediatek,mt7986-auxadc - mediatek,mt8173-auxadc - items:
Re: [PATCH 3/3] dt-bindings: iio: adc: Add support for MT7981
In reply to Aleksander Jan BajkowskiIl 29/06/25 00:38, Aleksander Jan Bajkowski ha scritto:
Quoted 4 lines
The temperature sensor in the MT7981 is same as in the MT7986. Add compatible string for mt7981.
Signed-off-by Aleksander Jan Bajkowski <[email protected]>
David Lechner
reviewerQuoted 7 lines · Aleksander Jan Bajkowski
This patch adds support for the temperature sensor in the MT7981 SoC. This sensor is exactly the same as the one in the MT7986.
Aleksander Jan Bajkowski (3):
arm64: dts: mediatek: add thermal sensor support on mt7981 thermal/drivers/mediatek: Add support for MT7981 SoC
dt-bindings: iio: adc: Add support for MT7981
When considering building and testing at each commit, it would make sense to reverse the order of these patches to reduce the possibility of errors.
Quoted 6 lines
.../iio/adc/mediatek,mt2701-auxadc.yaml | 1 + arch/arm64/boot/dts/mediatek/mt7981b.dtsi | 29 ++++++++++++++++++- drivers/thermal/mediatek/auxadc_thermal.c | 4 +++ 3 files changed, 33 insertions(+), 1 deletion(-)