Skip to contentSkip to conversation

arm64: tegra: Add Tegra234 thermal support

PATCH In review Thierry Reding 2 participants 5 messages Jun 9, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 arm64: tegra: Add Tegra234 thermal support

From: Thierry Reding <[email protected]>

Add device tree node for the BPMP thermal node on Tegra234 and add thermal zone definitions.

---
 arch/arm64/boot/dts/nvidia/tegra234.dtsi      | 53 +++++++++++++++++++
 .../thermal/tegra234-bpmp-thermal.h           | 19 +++++++
 2 files changed, 72 insertions(+)
 create mode 100644 include/dt-bindings/thermal/tegra234-bpmp-thermal.h
arch/arm64/boot/dts/nvidia/tegra234.dtsi +53 -0
index 6e66f41695c0..c17abe054dab 100644
@@ -8,6 +8,7 @@
 #include <dt-bindings/pinctrl/pinctrl-tegra-io-pad.h>
 #include <dt-bindings/power/tegra234-powergate.h>
 #include <dt-bindings/reset/tegra234-reset.h>
+#include <dt-bindings/thermal/tegra234-bpmp-thermal.h>
 
 / {
 	compatible = "nvidia,tegra234";
@@ -3163,6 +3164,11 @@ bpmp_i2c: i2c {
 			#address-cells = <1>;
 			#size-cells = <0>;
 		};
+
+		bpmp_thermal: thermal {
+			compatible = "nvidia,tegra186-bpmp-thermal";
+			#thermal-sensor-cells = <1>;
+		};
 	};
 
 	cpus {
@@ -3653,6 +3659,53 @@ sound {
 					 <&bpmp TEGRA234_CLK_PLLA_OUT0>;
 	};
 
+	thermal-zones {
+		cpu-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_CPU>;
+			status = "disabled";
+		};
+
+		gpu-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_GPU>;
+			status = "disabled";
+		};
+
+		cv0-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_CV0>;
+			status = "disabled";
+		};
+
+		cv1-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_CV1>;
+			status = "disabled";
+		};
+
+		cv2-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_CV2>;
+			status = "disabled";
+		};
+
+		soc0-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_SOC0>;
+			status = "disabled";
+		};
+
+		soc1-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_SOC1>;
+			status = "disabled";
+		};
+
+		soc2-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_SOC2>;
+			status = "disabled";
+		};
+
+		tj-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_TJ_MAX>;
+			status = "disabled";
+		};
+	};
+
 	timer {
 		compatible = "arm,armv8-timer";
 		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
include/dt-bindings/thermal/tegra234-bpmp-thermal.h new file +19 -0
new file mode 100644
index 000000000000..934787950932
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * This header provides constants for binding nvidia,tegra234-bpmp-thermal.
+ */
+
+#ifndef _DT_BINDINGS_THERMAL_TEGRA234_BPMP_THERMAL_H
+#define _DT_BINDINGS_THERMAL_TEGRA234_BPMP_THERMAL_H
+
+#define TEGRA234_BPMP_THERMAL_ZONE_CPU		0
+#define TEGRA234_BPMP_THERMAL_ZONE_GPU		1
+#define TEGRA234_BPMP_THERMAL_ZONE_CV0		2
+#define TEGRA234_BPMP_THERMAL_ZONE_CV1		3
+#define TEGRA234_BPMP_THERMAL_ZONE_CV2		4
+#define TEGRA234_BPMP_THERMAL_ZONE_SOC0		5
+#define TEGRA234_BPMP_THERMAL_ZONE_SOC1		6
+#define TEGRA234_BPMP_THERMAL_ZONE_SOC2		7
+#define TEGRA234_BPMP_THERMAL_ZONE_TJ_MAX	8
+
+#endif
Signature · 1 line
2.40.1
#1 lore raw

PATCH 2/4 arm64: tegra: Add thermal support on Jetson AGX Orin

From: Thierry Reding <[email protected]>

Add thermal zone details and enable the PWM fan as cooling device.

---
 .../boot/dts/nvidia/tegra234-p3701-0000.dtsi  | 22 +++++++++++++++++++
 .../nvidia/tegra234-p3737-0000+p3701-0000.dts | 22 ++++++++++++++-----
 .../boot/dts/nvidia/tegra234-p3737-0000.dtsi  |  6 +++++
 3 files changed, 45 insertions(+), 5 deletions(-)
arch/arm64/boot/dts/nvidia/tegra234-p3701-0000.dtsi +22 -0
index 812499918085..319b3a9cff24 100644
@@ -139,4 +139,26 @@ vdd_12v_pcie: regulator-vdd-12v-pcie {
 		gpio = <&gpio TEGRA234_MAIN_GPIO(A, 1) GPIO_ACTIVE_LOW>;
 		regulator-boot-on;
 	};
+
+	thermal-zones {
+		tj-thermal {
+			polling-delay = <1000>;
+			polling-delay-passive = <1000>;
+			status = "okay";
+
+			trips {
+				tj_trip_active0: active-0 {
+					temperature = <75000>;
+					hysteresis = <4000>;
+					type = "active";
+				};
+
+				tj_trip_active1: active-1 {
+					temperature = <95000>;
+					hysteresis = <4000>;
+					type = "active";
+				};
+			};
+		};
+	};
 };
arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts +17 -5
index 303c142303a5..188f6b5ae94c 100644
@@ -2339,11 +2339,7 @@ key-suspend {
 	};
 
 	pwm-fan {
-		compatible = "pwm-fan";
-		pwms = <&pwm3 0 45334>;
-
-		cooling-levels = <0 95 178 255>;
-		#cooling-cells = <2>;
+		cooling-levels = <66 215 255>;
 	};
 
 	serial {
@@ -2430,4 +2426,20 @@ sound {
 			  "CVB-RT DMIC1",		"CVB-RT MIC",
 			  "CVB-RT DMIC2",		"CVB-RT MIC";
 	};
+
+	thermal-zones {
+		tj-thermal {
+			cooling-maps {
+				map-active-0 {
+					cooling-device = <&fan 0 1>;
+					trip = <&tj_trip_active0>;
+				};
+
+				map-active-1 {
+					cooling-device = <&fan 1 2>;
+					trip = <&tj_trip_active1>;
+				};
+			};
+		};
+	};
 };
arch/arm64/boot/dts/nvidia/tegra234-p3737-0000.dtsi +6 -0
index 022a5408d869..d94147f22ebf 100644
@@ -33,6 +33,12 @@ pwm@32f0000 {
 		};
 	};
 
+	fan: pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm3 0 45334>;
+		#cooling-cells = <2>;
+	};
+
 	vdd_1v8_sys: regulator-vdd-1v8-sys {
 		compatible = "regulator-fixed";
 		regulator-name = "VDD_1V8_SYS";
Signature · 1 line
2.40.1
#2 lore raw

PATCH 3/4 arm64: tegra: Enable thermal support on Jetson Orin NX

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Enable the TJ thermal zone and hook up cooling maps for the PWM- controlled fan and two trip points.

---
 .../arm64/boot/dts/nvidia/tegra234-p3767.dtsi | 60 ++-----------------
 .../nvidia/tegra234-p3768-0000+p3767-0000.dts | 23 +++++--
 .../boot/dts/nvidia/tegra234-p3768-0000.dtsi  |  1 -
 3 files changed, 23 insertions(+), 61 deletions(-)
arch/arm64/boot/dts/nvidia/tegra234-p3767.dtsi +5 -55
index bd60478fa75e..a8aa6e7d8fbc 100644
@@ -99,74 +99,24 @@ vdd_3v3_ao: regulator-vdd-3v3-ao {
 	};
 
 	thermal-zones {
-		/*
-		 * This monitoring is far from optimal, but it's good enough
-		 * at this stage.
-		 */
-		cpu-thermal {
+		tj-thermal {
 			polling-delay = <1000>;
 			polling-delay-passive = <1000>;
 			status = "okay";
 
 			trips {
-				critical {
-					temperature = <104500>;
-					hysteresis = <0>;
-					type = "critical";
-				};
-
-				hot {
-					temperature = <99000>;
-					hysteresis = <1000>;
-					type = "hot";
-				};
-
-				board_trip_passive: passive {
-					temperature = <95000>;
-					hysteresis = <2000>;
-					type = "passive";
-				};
-
-				board_trip_active2: active-2 {
-					temperature = <80000>;
+				tj_trip_active0: active-0 {
+					temperature = <74000>;
 					hysteresis = <4000>;
 					type = "active";
 				};
 
-				board_trip_active1: active-1 {
-					temperature = <65000>;
-					hysteresis = <4000>;
-					type = "active";
-				};
-
-				board_trip_active0: active-0 {
-					temperature = <50000>;
+				tj_trip_active1: active-1 {
+					temperature = <95000>;
 					hysteresis = <4000>;
 					type = "active";
 				};
 			};
-
-			cooling-maps {
-				passive {
-					cooling-device = <&fan 3 3>;
-					trip = <&board_trip_passive>;
-				};
-
-				active2 {
-					cooling-device = <&fan 2 3>;
-					trip = <&board_trip_active2>;
-				};
-
-				active1 {
-					cooling-device = <&fan 1 2>;
-					trip = <&board_trip_active1>;
-				};
-
-				active0 {
-					cooling-device = <&fan 0 1>;
-					trip = <&board_trip_active0>;
-				};
-			};
 		};
 	};
 };
arch/arm64/boot/dts/nvidia/tegra234-p3768-0000+p3767-0000.dts +18 -5
index 7dfbc38eb3c4..65e4b51b79c1 100644
@@ -112,11 +112,8 @@ key-suspend {
 		};
 	};
 
-	fan: pwm-fan {
-		compatible = "pwm-fan";
-		pwms = <&pwm3 0 45334>;
-		cooling-levels = <0 95 178 255>;
-		#cooling-cells = <2>;
+	pwm-fan {
+		cooling-levels = <0 187 255>;
 	};
 
 	vdd_3v3_pcie: regulator-vdd-3v3-pcie {
@@ -131,4 +128,20 @@ vdd_3v3_pcie: regulator-vdd-3v3-pcie {
 	serial {
 		status = "okay";
 	};
+
+	thermal-zones {
+		tj-thermal {
+			cooling-maps {
+				map-active-0 {
+					cooling-device = <&fan 0 1>;
+					trip = <&tj_trip_active0>;
+				};
+
+				map-active-1 {
+					cooling-device = <&fan 1 2>;
+					trip = <&tj_trip_active1>;
+				};
+			};
+		};
+	};
 };
arch/arm64/boot/dts/nvidia/tegra234-p3768-0000.dtsi +0 -1
index bbd68ef93d97..c7291ba27cfa 100644
@@ -209,7 +209,6 @@ key-suspend {
 	fan: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm3 0 45334>;
-		cooling-levels = <0 95 178 255>;
 		#cooling-cells = <2>;
 	};
 
Signature · 1 line
2.40.1
#3 lore raw

PATCH 4/4 arm64: tegra: Enable thermal support on Jetson Orin Nano

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Enable the TJ thermal zone and hook up cooling maps for the PWM- controlled fan and two trip points.

---
 .../nvidia/tegra234-p3768-0000+p3767-0005.dts | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm64/boot/dts/nvidia/tegra234-p3768-0000+p3767-0005.dts +20 -0
index ba66c1845f75..9b86aa6f7dbe 100644
@@ -10,4 +10,24 @@
 / {
 	compatible = "nvidia,p3768-0000+p3767-0005", "nvidia,p3767-0005", "nvidia,tegra234";
 	model = "NVIDIA Jetson Orin Nano Developer Kit";
+
+	pwm-fan {
+		cooling-levels = <0 187 255>;
+	};
+
+	thermal-zones {
+		tj-thermal {
+			cooling-maps {
+				map-active-0 {
+					cooling-device = <&fan 0 1>;
+					trip = <&tj_trip_active0>;
+				};
+
+				map-active-1 {
+					cooling-device = <&fan 1 2>;
+					trip = <&tj_trip_active1>;
+				};
+			};
+		};
+	};
 };
Signature · 1 line
2.40.1
maintainer Acked-by on v1 1/4
#4 lore raw
In reply to Thierry Reding
Quoted 105 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Add device tree node for the BPMP thermal node on Tegra234 and add thermal zone definitions.

---
  arch/arm64/boot/dts/nvidia/tegra234.dtsi      | 53 +++++++++++++++++++
  .../thermal/tegra234-bpmp-thermal.h           | 19 +++++++
  2 files changed, 72 insertions(+)

create mode 100644 include/dt-bindings/thermal/tegra234-bpmp-thermal.h

arch/arm64/boot/dts/nvidia/tegra234.dtsi +53 -0
index 6e66f41695c0..c17abe054dab 100644
@@ -8,6 +8,7 @@
  #include <dt-bindings/pinctrl/pinctrl-tegra-io-pad.h>
  #include <dt-bindings/power/tegra234-powergate.h>
  #include <dt-bindings/reset/tegra234-reset.h>
+#include <dt-bindings/thermal/tegra234-bpmp-thermal.h>
 
  / {
  	compatible = "nvidia,tegra234";
@@ -3163,6 +3164,11 @@ bpmp_i2c: i2c {
  			#address-cells = <1>;
  			#size-cells = <0>;
  		};
+
+		bpmp_thermal: thermal {
+			compatible = "nvidia,tegra186-bpmp-thermal";
+			#thermal-sensor-cells = <1>;
+		};
  	};
 
  	cpus {
@@ -3653,6 +3659,53 @@ sound {
  					 <&bpmp TEGRA234_CLK_PLLA_OUT0>;
  	};
 
+	thermal-zones {
+		cpu-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_CPU>;
+			status = "disabled";
+		};
+
+		gpu-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_GPU>;
+			status = "disabled";
+		};
+
+		cv0-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_CV0>;
+			status = "disabled";
+		};
+
+		cv1-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_CV1>;
+			status = "disabled";
+		};
+
+		cv2-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_CV2>;
+			status = "disabled";
+		};
+
+		soc0-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_SOC0>;
+			status = "disabled";
+		};
+
+		soc1-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_SOC1>;
+			status = "disabled";
+		};
+
+		soc2-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_SOC2>;
+			status = "disabled";
+		};
+
+		tj-thermal {
+			thermal-sensors = <&{/bpmp/thermal} TEGRA234_BPMP_THERMAL_ZONE_TJ_MAX>;
+			status = "disabled";
+		};
+	};
+
  	timer {
  		compatible = "arm,armv8-timer";
  		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
include/dt-bindings/thermal/tegra234-bpmp-thermal.h new file +9 -0
new file mode 100644
index 000000000000..934787950932
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * This header provides constants for binding nvidia,tegra234-bpmp-thermal.
+ */
+
+#ifndef _DT_BINDINGS_THERMAL_TEGRA234_BPMP_THERMAL_H
+#define _DT_BINDINGS_THERMAL_TEGRA234_BPMP_THERMAL_H
+
+#define TEGRA234_BPMP_THERMAL_ZONE_CPU		0

include/dt-bindings/thermal/tegra234-bpmp-thermal.h line 19

Quoted 10 lines
include/dt-bindings/thermal/tegra234-bpmp-thermal.h new file +10 -0
+#define TEGRA234_BPMP_THERMAL_ZONE_GPU		1
+#define TEGRA234_BPMP_THERMAL_ZONE_CV0		2
+#define TEGRA234_BPMP_THERMAL_ZONE_CV1		3
+#define TEGRA234_BPMP_THERMAL_ZONE_CV2		4
+#define TEGRA234_BPMP_THERMAL_ZONE_SOC0		5
+#define TEGRA234_BPMP_THERMAL_ZONE_SOC1		6
+#define TEGRA234_BPMP_THERMAL_ZONE_SOC2		7
+#define TEGRA234_BPMP_THERMAL_ZONE_TJ_MAX	8
+
+#endif

Looks good to me. For this series ...

Jon

Signature · 1 line
nvpublic