Skip to contentSkip to conversation

arm64: dts: rockchip: add thermal fan control to rockpro64

PATCH Applied Peter Geis 4 participants 7 messages Jul 30, 2021 – Aug 13, 2021

Subsystems (2)
lore
Share & tools
lore

Peter Geis

author
#0 lore raw

PATCH v3 1/1 arm64: dts: rockchip: add thermal fan control to rockpro64

The rockpro64 had a fan node since
commit 5882d65c1691 ("arm64: dts: rockchip: Add PWM fan for RockPro64") however it was never tied into the thermal driver for automatic control.

Add the links to the thermal node to permit the kernel to handle this automatically.
Borrowed from the (rk3399-khadas-edge.dtsi).

---

Changelog:
v3:
Removed the gpu nodes to prevent in-fighting (thanks Robin!)

v2:
Adjusted fan setpoints for less noise

 .../boot/dts/rockchip/rk3399-rockpro64.dtsi   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +29 -0
index 6bff8db7d33e..83db4ca67334 100644
@@ -69,6 +69,7 @@ diy_led: led-1 {
 
 	fan: pwm-fan {
 		compatible = "pwm-fan";
+		cooling-levels = <0 100 150 200 255>;
 		#cooling-cells = <2>;
 		fan-supply = <&vcc12v_dcin>;
 		pwms = <&pwm1 0 50000 0>;
@@ -245,6 +246,34 @@ &cpu_b1 {
 	cpu-supply = <&vdd_cpu_b>;
 };
 
+&cpu_thermal {
+	trips {
+		cpu_warm: cpu_warm {
+			temperature = <55000>;
+			hysteresis = <2000>;
+			type = "active";
+		};
+
+		cpu_hot: cpu_hot {
+			temperature = <65000>;
+			hysteresis = <2000>;
+			type = "active";
+		};
+	};
+
+	cooling-maps {
+		map2 {
+			trip = <&cpu_warm>;
+			cooling-device = <&fan THERMAL_NO_LIMIT 1>;
+		};
+
+		map3 {
+			trip = <&cpu_hot>;
+			cooling-device = <&fan 2 THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
 &emmc_phy {
 	status = "okay";
 };
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 7 lines · Peter Geis

The rockpro64 had a fan node since
commit 5882d65c1691 ("arm64: dts: rockchip: Add PWM fan for RockPro64") however it was never tied into the thermal driver for automatic control.

Add the links to the thermal node to permit the kernel to handle this automatically.
Borrowed from the (rk3399-khadas-edge.dtsi).

Applied, thanks!

[1/1] arm64: dts: rockchip: add thermal fan control to rockpro64

      commit: 440f361af90acff36eb3d89c1f03debeab7b3fb8

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>
#2 lore raw
In reply to Peter Geis
Quoted 42 lines · Peter Geis

The rockpro64 had a fan node since
commit 5882d65c1691 ("arm64: dts: rockchip: Add PWM fan for RockPro64") however it was never tied into the thermal driver for automatic control.

Add the links to the thermal node to permit the kernel to handle this automatically.
Borrowed from the (rk3399-khadas-edge.dtsi).

---

Changelog:
v3:
Removed the gpu nodes to prevent in-fighting (thanks Robin!)

v2:
Adjusted fan setpoints for less noise

 .../boot/dts/rockchip/rk3399-rockpro64.dtsi   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +6 -0
index 6bff8db7d33e..83db4ca67334 100644
@@ -69,6 +69,7 @@ diy_led: led-1 {
 
 	fan: pwm-fan {
 		compatible = "pwm-fan";
+		cooling-levels = <0 100 150 200 255>;
 		#cooling-cells = <2>;
 		fan-supply = <&vcc12v_dcin>;
 		pwms = <&pwm1 0 50000 0>;
@@ -245,6 +246,34 @@ &cpu_b1 {
 	cpu-supply = <&vdd_cpu_b>;
 };
 
+&cpu_thermal {
+	trips {
+		cpu_warm: cpu_warm {
+			temperature = <55000>;
+			hysteresis = <2000>;

arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi &cpu_b1 { · line 263

Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +10 -0
+			type = "active";
+		};
+
+		cpu_hot: cpu_hot {
+			temperature = <65000>;
+			hysteresis = <2000>;
+			type = "active";
+		};
+	};
+

Why two trip points ?

Why not one functioning temperature and no lower / upper limits for the cooling maps ?

Quoted 17 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +13 -0
+	cooling-maps {
+		map2 {
+			trip = <&cpu_warm>;
+			cooling-device = <&fan THERMAL_NO_LIMIT 1>;
+		};
+
+		map3 {
+			trip = <&cpu_hot>;
+			cooling-device = <&fan 2 THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
 &emmc_phy {
 	status = "okay";
 };
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#3 lore raw
Quoted 56 lines · Daniel Lezcano
Quoted 42 lines · Peter Geis

The rockpro64 had a fan node since
commit 5882d65c1691 ("arm64: dts: rockchip: Add PWM fan for RockPro64") however it was never tied into the thermal driver for automatic control.

Add the links to the thermal node to permit the kernel to handle this automatically.
Borrowed from the (rk3399-khadas-edge.dtsi).

---

Changelog:
v3:
Removed the gpu nodes to prevent in-fighting (thanks Robin!)

v2:
Adjusted fan setpoints for less noise

  .../boot/dts/rockchip/rk3399-rockpro64.dtsi   | 29 +++++++++++++++++++
  1 file changed, 29 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +6 -0
index 6bff8db7d33e..83db4ca67334 100644
@@ -69,6 +69,7 @@ diy_led: led-1 {
 
  	fan: pwm-fan {
  		compatible = "pwm-fan";
+		cooling-levels = <0 100 150 200 255>;
  		#cooling-cells = <2>;
  		fan-supply = <&vcc12v_dcin>;
  		pwms = <&pwm1 0 50000 0>;
@@ -245,6 +246,34 @@ &cpu_b1 {
  	cpu-supply = <&vdd_cpu_b>;
  };
 
+&cpu_thermal {
+	trips {
+		cpu_warm: cpu_warm {
+			temperature = <55000>;
+			hysteresis = <2000>;

arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi &cpu_b1 { · line 263

Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +10 -0
+			type = "active";
+		};
+
+		cpu_hot: cpu_hot {
+			temperature = <65000>;
+			hysteresis = <2000>;
+			type = "active";
+		};
+	};
+

Why two trip points ?

Quoted 2 lines

Why not one functioning temperature and no lower / upper limits for the cooling maps ?

Certainly when I first did this for NanoPC-T4, IIRC it was to avoid the fan ramping up too eagerly, since level 1 for my fan is effectively silent but still cools enough to let a moderate load eventually settle to a steady state below the second trip.

Robin.

Quoted 19 lines
Quoted 17 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +13 -0
+	cooling-maps {
+		map2 {
+			trip = <&cpu_warm>;
+			cooling-device = <&fan THERMAL_NO_LIMIT 1>;
+		};
+
+		map3 {
+			trip = <&cpu_hot>;
+			cooling-device = <&fan 2 THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
  &emmc_phy {
  	status = "okay";
  };
#4 lore raw

Hi Robin,

Quoted 11 lines · Robin Murphy
Quoted 10 lines · Daniel Lezcano
Quoted 9 lines · Peter Geis

The rockpro64 had a fan node since
commit 5882d65c1691 ("arm64: dts: rockchip: Add PWM fan for RockPro64") however it was never tied into the thermal driver for automatic control.

Add the links to the thermal node to permit the kernel to handle this automatically.
Borrowed from the (rk3399-khadas-edge.dtsi).

[ ... ]

Quoted 18 lines
Quoted 18 lines
Quoted 7 lines

  +&cpu_thermal {
+    trips {
+        cpu_warm: cpu_warm {
+            temperature = <55000>;
+            hysteresis = <2000>;
+            type = "active";
+        };

arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi &cpu_b1 { · line 263

Quoted 8 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +8 -0
+
+        cpu_hot: cpu_hot {
+            temperature = <65000>;
+            hysteresis = <2000>;
+            type = "active";
+        };
+    };
+

Why two trip points ?

Quoted 7 lines
Quoted 2 lines

Why not one functioning temperature and no lower / upper limits for the cooling maps ?

Certainly when I first did this for NanoPC-T4, IIRC it was to avoid the fan ramping up too eagerly, since level 1 for my fan is effectively silent but still cools enough to let a moderate load eventually settle to a steady state below the second trip.

Thanks for your answer.

What would be the governor for this setup ?

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
author
#5 lore raw
Quoted 12 lines · Daniel Lezcano

Hi Robin,

Quoted 6 lines · Robin Murphy
Quoted 5 lines · Daniel Lezcano
Quoted 4 lines · Peter Geis

The rockpro64 had a fan node since
commit 5882d65c1691 ("arm64: dts: rockchip: Add PWM fan for RockPro64") however it was never tied into the thermal driver for automatic control.

Quoted 33 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Add the links to the thermal node to permit the kernel to handle this automatically.
Borrowed from the (rk3399-khadas-edge.dtsi).

[ ... ]

Quoted 25 lines
Quoted 18 lines
Quoted 5 lines
  +&cpu_thermal {
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +4 -0
+    trips {
+        cpu_warm: cpu_warm {
+            temperature = <55000>;
+            hysteresis = <2000>;

arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi &cpu_b1 { · line 263

Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +10 -0
+            type = "active";
+        };
+
+        cpu_hot: cpu_hot {
+            temperature = <65000>;
+            hysteresis = <2000>;
+            type = "active";
+        };
+    };
+

Why two trip points ?

Quoted 2 lines

Why not one functioning temperature and no lower / upper limits for the cooling maps ?

Certainly when I first did this for NanoPC-T4, IIRC it was to avoid the fan ramping up too eagerly, since level 1 for my fan is effectively silent but still cools enough to let a moderate load eventually settle to a steady state below the second trip.

That's the same issue I had on the rockpro64.

Quoted 5 lines

Thanks for your answer.

What would be the governor for this setup ?

The default governor when using arm64_defconfig is step_wise.

Quoted 9 lines

--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#6 lore raw
Quoted 51 lines · Peter Geis
Quoted 12 lines · Daniel Lezcano

Hi Robin,

Quoted 6 lines · Robin Murphy
Quoted 5 lines · Daniel Lezcano
Quoted 4 lines · Peter Geis

The rockpro64 had a fan node since
commit 5882d65c1691 ("arm64: dts: rockchip: Add PWM fan for RockPro64") however it was never tied into the thermal driver for automatic control.

Quoted 33 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Add the links to the thermal node to permit the kernel to handle this automatically.
Borrowed from the (rk3399-khadas-edge.dtsi).

[ ... ]

Quoted 25 lines
Quoted 18 lines
Quoted 5 lines
  +&cpu_thermal {
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +4 -0
+    trips {
+        cpu_warm: cpu_warm {
+            temperature = <55000>;
+            hysteresis = <2000>;

arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi &cpu_b1 { · line 263

Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +10 -0
+            type = "active";
+        };
+
+        cpu_hot: cpu_hot {
+            temperature = <65000>;
+            hysteresis = <2000>;
+            type = "active";
+        };
+    };
+

Why two trip points ?

Quoted 2 lines

Why not one functioning temperature and no lower / upper limits for the cooling maps ?

Certainly when I first did this for NanoPC-T4, IIRC it was to avoid the fan ramping up too eagerly, since level 1 for my fan is effectively silent but still cools enough to let a moderate load eventually settle to a steady state below the second trip.

That's the same issue I had on the rockpro64.

Quoted 1 line
Quoted 6 lines
Quoted 4 lines

Thanks for your answer.

What would be the governor for this setup ?

The default governor when using arm64_defconfig is step_wise.

Ok, thanks

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog