Skip to contentSkip to conversation

Subject: [PATCH v2 0/4] Add mt7986 thermal and pwm

PATCH Superseded Frank Wunderlich 2 participants 8 messages May 29, 2023 – May 30, 2023

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

From: Frank Wunderlich <[email protected]>

This series add thermal related devicetree-nodes and necessary dt-bindings.

I left pwm-fan for r3 for now as i cannot test this completely due to missing 2 pin-jack and 3v3 pwm-level which my fan cannot handle (starts spinning at ~3V). Only checked voltage of pwm there.

changes in v2:
- drop highest 2 trip points as they are not yet used
- leave already applied patches

Daniel Golle (3):
arm64: dts: mt7986: add thermal and efuse
arm64: dts: mt7986: add thermal-zones
arm64: dts: mt7986: add pwm-fan and cooling-maps to BPI-R3 dts

Frank Wunderlich (1):
dt-bindings: nvmem: mediatek: efuse: add support for mt7986

 .../bindings/nvmem/mediatek,efuse.yaml        |  1 +
 .../dts/mediatek/mt7986a-bananapi-bpi-r3.dts  | 31 +++++++++
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi     | 63 +++++++++++++++++++
 3 files changed, 95 insertions(+)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/4 dt-bindings: nvmem: mediatek: efuse: add support for mt7986

From: Frank Wunderlich <[email protected]>

Add compatible string for mt7986 SoC.

---
 Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/nvmem/mediatek,efuse.yaml +1 -0
index d16d42fb98b6..7ec2988b597e 100644
@@ -27,6 +27,7 @@ properties:
           - enum:
               - mediatek,mt7622-efuse
               - mediatek,mt7623-efuse
+              - mediatek,mt7986-efuse
               - mediatek,mt8173-efuse
               - mediatek,mt8183-efuse
               - mediatek,mt8186-efuse
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/4 arm64: dts: mt7986: add thermal and efuse

In reply to Frank Wunderlich

From: Daniel Golle <[email protected]>

Add thermal related nodes to mt7986 devicetree.

---
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 37 ++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +36 -1
index aa9e679b78e2..a409d5e845c2 100644
@@ -337,6 +337,15 @@ spi1: spi@1100b000 {
 			status = "disabled";
 		};
 
+		auxadc: adc@1100d000 {
+			compatible = "mediatek,mt7986-auxadc";
+			reg = <0 0x1100d000 0 0x1000>;
+			clocks = <&infracfg CLK_INFRA_ADC_26M_CK>;
+			clock-names = "main";
+			#io-channel-cells = <1>;
+			status = "disabled";
+		};
+
 		ssusb: usb@11200000 {
 			compatible = "mediatek,mt7986-xhci",
 				     "mediatek,mtk-xhci";
@@ -375,6 +384,21 @@ mmc0: mmc@11230000 {
 			status = "disabled";
 		};
 
+		thermal: thermal@1100c800 {
+			#thermal-sensor-cells = <1>;
+			compatible = "mediatek,mt7986-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>,
+				 <&infracfg CLK_INFRA_ADC_FRC_CK>;
+			clock-names = "therm", "auxadc", "adc_32k";
+			mediatek,auxadc = <&auxadc>;
+			mediatek,apmixedsys = <&apmixedsys>;
+			nvmem-cells = <&thermal_calibration>;
+			nvmem-cell-names = "calibration-data";
+		};
+
 		pcie: pcie@11280000 {
 			compatible = "mediatek,mt7986-pcie",
 				     "mediatek,mt8192-pcie";
@@ -426,6 +450,18 @@ pcie_port: pcie-phy@11c00000 {
 			};
 		};
 
+		efuse: efuse@11d00000 {
+			compatible = "mediatek,mt7986-efuse",
+				     "mediatek,efuse";
+			reg = <0 0x11d00000 0 0x1000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			thermal_calibration: calib@274 {
+				reg = <0x274 0xc>;
+			};
+		};
+
 		usb_phy: t-phy@11e10000 {
 			compatible = "mediatek,mt7986-tphy",
 				     "mediatek,generic-tphy-v2";
@@ -567,5 +603,4 @@ wifi: wifi@18000000 {
 			memory-region = <&wmcpu_emi>;
 		};
 	};
-
 };
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 2/4
#3 lore raw

Re: [PATCH v2 2/4] arm64: dts: mt7986: add thermal and efuse

Il 29/05/23 22:42, Frank Wunderlich ha scritto:

Quoted 53 lines

From: Daniel Golle <[email protected]>

Add thermal related nodes to mt7986 devicetree.

---
  arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 37 ++++++++++++++++++++++-
  1 file changed, 36 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +24 -0
index aa9e679b78e2..a409d5e845c2 100644
@@ -337,6 +337,15 @@ spi1: spi@1100b000 {
  			status = "disabled";
  		};
 
+		auxadc: adc@1100d000 {
+			compatible = "mediatek,mt7986-auxadc";
+			reg = <0 0x1100d000 0 0x1000>;
+			clocks = <&infracfg CLK_INFRA_ADC_26M_CK>;
+			clock-names = "main";
+			#io-channel-cells = <1>;
+			status = "disabled";
+		};
+
  		ssusb: usb@11200000 {
  			compatible = "mediatek,mt7986-xhci",
  				     "mediatek,mtk-xhci";
@@ -375,6 +384,21 @@ mmc0: mmc@11230000 {
  			status = "disabled";
  		};
 
+		thermal: thermal@1100c800 {
+			#thermal-sensor-cells = <1>;
+			compatible = "mediatek,mt7986-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>,
+				 <&infracfg CLK_INFRA_ADC_FRC_CK>;
+			clock-names = "therm", "auxadc", "adc_32k";
+			mediatek,auxadc = <&auxadc>;
+			mediatek,apmixedsys = <&apmixedsys>;
+			nvmem-cells = <&thermal_calibration>;
+			nvmem-cell-names = "calibration-data";
+		};
+
  		pcie: pcie@11280000 {
  			compatible = "mediatek,mt7986-pcie",
  				     "mediatek,mt8192-pcie";

arch/arm64/boot/dts/mediatek/mt7986a.dtsi pcie_port: pcie-phy@11c00000 { · line 455

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +3 -0
@@ -426,6 +450,18 @@ pcie_port: pcie-phy@11c00000 {
  			};
  		};
 
+		efuse: efuse@11d00000 {
+			compatible = "mediatek,mt7986-efuse",
+				     "mediatek,efuse";

Fits in one single line. After which:

#4 lore raw

PATCH v2 3/4 arm64: dts: mt7986: add thermal-zones

In reply to Frank Wunderlich

From: Daniel Golle <[email protected]>

Add thermal-zones to mt7986 devicetree.

---
changes in v2:
- drop top 2 thermal trips as suggested by matthias

---
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 28 +++++++++++++++++++++++
 1 file changed, 28 insertions(+)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +28 -0
index a409d5e845c2..a059fcdaa8b7 100644
@@ -603,4 +603,32 @@ wifi: wifi@18000000 {
 			memory-region = <&wmcpu_emi>;
 		};
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			polling-delay-passive = <1000>;
+			polling-delay = <1000>;
+			thermal-sensors = <&thermal 0>;
+
+			trips {
+				cpu_trip_active_high: active-high {
+					temperature = <115000>;
+					hysteresis = <2000>;
+					type = "active";
+				};
+
+				cpu_trip_active_low: active-low {
+					temperature = <85000>;
+					hysteresis = <2000>;
+					type = "active";
+				};
+
+				cpu_trip_passive: passive {
+					temperature = <40000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+			};
+		};
+	};
 };
Signature · 1 line
2.34.1
#6 lore raw

PATCH v2 4/4 arm64: dts: mt7986: add pwm-fan and cooling-maps to BPI-R3 dts

In reply to Frank Wunderlich

From: Daniel Golle <[email protected]>

Add pwm-fan and cooling-maps to BananaPi-R3 devicetree.

---
this is based on Patch from openwrt. as my PWM-fan seems to need 5v pwm signal and r3 only provides 3v3 on 3pin-socket it does not work for me.

---
 .../dts/mediatek/mt7986a-bananapi-bpi-r3.dts  | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts +31 -0
index 782519429497..29c018bbf29d 100644
@@ -37,6 +37,15 @@ dcin: regulator-12vd {
 		regulator-always-on;
 	};
 
+	fan: pwm-fan {
+		compatible = "pwm-fan";
+		#cooling-cells = <2>;
+		/* cooling level (0, 1, 2) - pwm inverted */
+		cooling-levels = <255 96 0>;
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+
 	gpio-keys {
 		compatible = "gpio-keys";
 
@@ -132,6 +141,28 @@ sfp2: sfp-2 {
 	};
 };
 
+&cpu_thermal {
+	cooling-maps {
+		cpu-active-high {
+			/* active: set fan to cooling level 2 */
+			cooling-device = <&fan 2 2>;
+			trip = <&cpu_trip_active_high>;
+		};
+
+		cpu-active-low {
+			/* active: set fan to cooling level 1 */
+			cooling-device = <&fan 1 1>;
+			trip = <&cpu_trip_active_low>;
+		};
+
+		cpu-passive {
+			/* passive: set fan to cooling level 0 */
+			cooling-device = <&fan 0 0>;
+			trip = <&cpu_trip_passive>;
+		};
+	};
+};
+
 &crypto {
 	status = "okay";
 };
Signature · 1 line
2.34.1