arm64: dts: rockchip: add thermal fan control to rockpro64
Subsystems (2)
PATCH v2 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:
v2:
Adjusted fan setpoints for less noise
.../boot/dts/rockchip/rk3399-rockpro64.dtsi | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +57 -0
@@ -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"; };
@@ -281,6 +310,34 @@ &gpu { status = "okay"; }; +&gpu_thermal { + trips { + gpu_warm: gpu_warm { + temperature = <55000>; + hysteresis = <2000>; + type = "active"; + }; + + gpu_hot: gpu_hot { + temperature = <65000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map1 { + trip = <&gpu_warm>; + cooling-device = <&fan THERMAL_NO_LIMIT 1>; + }; + + map2 { + trip = <&gpu_hot>; + cooling-device = <&fan 2 THERMAL_NO_LIMIT>; + }; + }; +}; + &i2c0 { clock-frequency = <400000>; i2c-scl-rising-time-ns = <168>;
Signature · 1 line
2.25.1
Hi Peter,
Quoted 31 lines · Peter Geis
The rockpro64 had a fan node since
commit5882d65c1691("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).Signed-off-by Peter Geis <[email protected]>---
Changelog:
v2:
Adjusted fan setpoints for less noise.../boot/dts/rockchip/rk3399-rockpro64.dtsi | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+)arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +1
-0@@ -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>;
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi &cpu_b1 { · line 255
Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +7
-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"; + };
(Heh, it still tickles me to see these points I arbitrarily made up being faithfully copied around - I guess that means I got them right!)
Quoted 45 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +38
-0+ + 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"; };@@ -281,6 +310,34 @@ &gpu { status = "okay"; }; +&gpu_thermal { + trips { + gpu_warm: gpu_warm { + temperature = <55000>; + hysteresis = <2000>; + type = "active"; + }; + + gpu_hot: gpu_hot { + temperature = <65000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map1 {
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi &gpu { · line 339
Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +10
-0+ trip = <&gpu_warm>; + cooling-device = <&fan THERMAL_NO_LIMIT 1>; + }; + + map2 { + trip = <&gpu_hot>; + cooling-device = <&fan 2 THERMAL_NO_LIMIT>; + }; + }; +};
Unless something's changed since commit a793e19c15f2 ("arm64: dts: rockchip: Fix NanoPC-T4 cooling maps"), multiple cooling maps don't actually share a singe cooling device properly[1]. The Khadas Edge DT dates from right around the same time so I guess it crossed over with that discussion and never got fixed.
In hindsight, I do seem to remember my fan being a bit more jumpy around the trip points than it is today, which may well have been the two maps fighting each other...
Robin.
[1] https://lore.kernel.org/linux-rockchip/[email protected]/
Quoted 5 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +1
-0+ &i2c0 { clock-frequency = <400000>; i2c-scl-rising-time-ns = <168>;
Quoted 38 lines · Robin Murphy
Hi Peter,
Quoted 34 lines · Peter Geis
The rockpro64 had a fan node since
commit5882d65c1691("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).Signed-off-by Peter Geis <[email protected]>---
Changelog:
v2:
Adjusted fan setpoints for less noise.../boot/dts/rockchip/rk3399-rockpro64.dtsi | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+)arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +1
-0@@ -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>; };
Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi &cpu_b1 { · line 255
Quoted 7 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +7
-0+&cpu_thermal { + trips { + cpu_warm: cpu_warm { + temperature = <55000>; + hysteresis = <2000>; + type = "active"; + };(Heh, it still tickles me to see these points I arbitrarily made up being faithfully copied around - I guess that means I got them right!)
On the rockpro64 these points work quite nicely, I compile the kernel natively so I hit the first one easily.
Quoted 63 lines
Quoted 46 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +38
-0+ + 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"; };@@ -281,6 +310,34 @@ &gpu { status = "okay"; }; +&gpu_thermal { + trips { + gpu_warm: gpu_warm { + temperature = <55000>; + hysteresis = <2000>; + type = "active"; + }; + + gpu_hot: gpu_hot { + temperature = <65000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map1 {arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi &gpu { · line 339
Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +10
-0+ trip = <&gpu_warm>; + cooling-device = <&fan THERMAL_NO_LIMIT 1>; + }; + + map2 { + trip = <&gpu_hot>; + cooling-device = <&fan 2 THERMAL_NO_LIMIT>; + }; + }; +};Unless something's changed since commit
a793e19c15f2("arm64: dts:
rockchip: Fix NanoPC-T4 cooling maps"), multiple cooling maps don't actually share a singe cooling device properly[1]. The Khadas Edge DT dates from right around the same time so I guess it crossed over with that discussion and never got fixed.
Quoted 8 lines
In hindsight, I do seem to remember my fan being a bit more jumpy around the trip points than it is today, which may well have been the two maps fighting each other...
Robin.
[1]
https://lore.kernel.org/linux-rockchip/[email protected]/
Interesting, so instead of "or-ing" the signals to the fan, the thermal just fights with itself?
That explains interesting states where it can't decide if it wants to run or not.
I'll pull the gpu portion and submit a v3, thanks!
Quoted 6 lines
Quoted 6 lines
arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtsi +1
-0+ &i2c0 { clock-frequency = <400000>; i2c-scl-rising-time-ns = <168>;