Skip to contentSkip to conversation

Add thermal sensors support for MT7981

PATCH Superseded Aleksander Jan Bajkowski 4 participants 9 messages Jun 28, 2025 – Jun 30, 2025

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 5cbea9cd411f..c2001a82722a 100644
@@ -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
#2 lore raw

PATCH 2/3 thermal/drivers/mediatek: Add support for MT7981 SoC

In reply to Aleksander Jan Bajkowski

The 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
index 9ee2e7283435..020324901505 100644
@@ -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
maintainer
#3 lore raw

Re: [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.

---
 drivers/thermal/mediatek/auxadc_thermal.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/thermal/mediatek/auxadc_thermal.c +0 -0
index 9ee2e7283435..020324901505 100644

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,
#4 lore raw

Re: [PATCH 2/3] thermal/drivers/mediatek: Add support for MT7981 SoC

In reply to Aleksander Jan Bajkowski

Il 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
---
  drivers/thermal/mediatek/auxadc_thermal.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/thermal/mediatek/auxadc_thermal.c +4 -0
index 9ee2e7283435..020324901505 100644
@@ -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,
#5 lore raw

PATCH 3/3 dt-bindings: iio: adc: Add support for MT7981

In reply to Aleksander Jan Bajkowski

The 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
index b489c984c1bb..ceb914dde15b 100644
@@ -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
reviewer
#6 lore raw

Re: [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
---
 .../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
index b489c984c1bb..ceb914dde15b 100644
@@ -26,6 +26,7 @@ properties:
           - mediatek,mt2712-auxadc
           - mediatek,mt6765-auxadc
           - mediatek,mt7622-auxadc
+          - mediatek,mt7981-auxadc
           - mediatek,mt7986-auxadc
           - mediatek,mt8173-auxadc
       - items:
reviewer
#8 lore raw
In reply to Aleksander Jan Bajkowski
Quoted 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(-)