Skip to contentSkip to conversation

arm64: dts: rockchip: Add PWM fan and WWAN overlay for Radxa ROCK 3B

PATCH Applied Adam Wermuth 2 participants 4 messages Sep 25 – Sep 30

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

v2 cover arm64: dts: rockchip: Add PWM fan and WWAN overlay for Radxa ROCK 3B

The Radxa ROCK 3B has a 2-pin fan header and an M.2 B-key slot intended for 4G/5G modules, neither of which is currently described in the mainline device tree.

Patch 1 adds the PWM fan and ties it to the CPU thermal zone. Patch 2 adds a device tree overlay for the B-key slot, enabling the USB 2.0 host controller serving the slot as well as its power, RESET# and W_DISABLE1# controls.

Pin assignments were checked against the ROCK 3B V1.51 schematic. Tested on a ROCK 3B with a SIMCom SIM7600G-H module and a 5V fan, running Linux 6.12 (OpenWrt) with the same changes applied.

Changes in v2:
- Move the USB host1 enablement and the WWAN slot handling into a new rk3568-rock-3b-wwan.dtso overlay, as the slot is not always populated (Jonas)
- Drop phy-supply from usb2phy1_host, as the M.2 slot has no VBUS
- Put the fan patch first, as it no longer depends on the others

v1: https://lore.kernel.org/linux-rockchip/[email protected]/

Adam Wermuth (2):
arm64: dts: rockchip: Add PWM fan to Radxa ROCK 3B
arm64: dts: rockchip: Add WWAN overlay for Radxa ROCK 3B

 arch/arm64/boot/dts/rockchip/Makefile         |  5 ++
 .../dts/rockchip/rk3568-rock-3b-wwan.dtso     | 65 +++++++++++++++++++
 .../boot/dts/rockchip/rk3568-rock-3b.dts      | 51 +++++++++++++++
 3 files changed, 121 insertions(+)
 create mode 100644 arch/arm64/boot/dts/rockchip/rk3568-rock-3b-wwan.dtso

base-commit: 23d8f49fcae5d72b77744c7f349c12462c3bb748

Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/2 arm64: dts: rockchip: Add PWM fan to Radxa ROCK 3B

The ROCK 3B has a 2-pin fan header powered from vcc5v0_sys and switched by a MOSFET driven from PWM8 (pwm8m0 pins). Enable the PWM controller, describe the fan as a pwm-fan cooling device and add active trip points to the CPU thermal zone:

- 50 C: fan at 25%
- 60 C: fan at 50-75%
- 70 C: fan at 100%

each with 5 C hysteresis. The existing passive and critical trip points are left unchanged.

---
 .../boot/dts/rockchip/rk3568-rock-3b.dts      | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/arm64/boot/dts/rockchip/rk3568-rock-3b.dts +51 -0
index 149a5306bb03..b9f09087b176 100644
@@ -24,6 +24,14 @@ chosen {
 		stdout-path = "serial2:1500000n8";
 	};
 
+	fan: fan {
+		compatible = "pwm-fan";
+		cooling-levels = <0 64 128 192 255>;
+		fan-supply = <&vcc5v0_sys>;
+		pwms = <&pwm8 0 10000 0>;
+		#cooling-cells = <2>;
+	};
+
 	hdmi-con {
 		compatible = "hdmi-connector";
 		type = "a";
@@ -186,6 +194,45 @@ &cpu3 {
 	cpu-supply = <&vdd_cpu>;
 };
 
+&cpu_thermal {
+	trips {
+		cpu_fan0: cpu-fan0 {
+			hysteresis = <5000>;
+			temperature = <50000>;
+			type = "active";
+		};
+
+		cpu_fan1: cpu-fan1 {
+			hysteresis = <5000>;
+			temperature = <60000>;
+			type = "active";
+		};
+
+		cpu_fan2: cpu-fan2 {
+			hysteresis = <5000>;
+			temperature = <70000>;
+			type = "active";
+		};
+	};
+
+	cooling-maps {
+		map1 {
+			trip = <&cpu_fan0>;
+			cooling-device = <&fan THERMAL_NO_LIMIT 1>;
+		};
+
+		map2 {
+			trip = <&cpu_fan1>;
+			cooling-device = <&fan 2 3>;
+		};
+
+		map3 {
+			trip = <&cpu_fan2>;
+			cooling-device = <&fan 4 THERMAL_NO_LIMIT>;
+		};
+	};
+};
+
 &gmac0 {
 	assigned-clocks = <&cru SCLK_GMAC0_RX_TX>, <&cru SCLK_GMAC0>;
 	assigned-clock-parents = <&cru SCLK_GMAC0_RGMII_SPEED>, <&cru CLK_MAC0_2TOP>;
@@ -670,6 +717,10 @@ &pmu_io_domains {
 	status = "okay";
 };
 
+&pwm8 {
+	status = "okay";
+};
+
 &saradc {
 	vref-supply = <&vcca_1v8>;
 	status = "okay";
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/2 arm64: dts: rockchip: Add WWAN overlay for Radxa ROCK 3B

In reply to Adam Wermuth

The M.2 B-key slot on the ROCK 3B is intended for 4G/5G modules and is not always populated. Add a device tree overlay which enables the slot when a module is fitted:

- The USB 2.0 data lines of the slot are routed to USB2_HOST3, served by usb_host1_ehci/ohci through the host port of usb2phy1. The slot has no VBUS, so no supply is attached to the PHY port.
- GPIO0_C6 (4G_PWREN_H) enables the 3.3V supply of the slot, which is generated from vcc5v0_sys by a dedicated buck converter.
- GPIO0_D6 (4G_RESET) drives RESET# and GPIO1_B0 (4G_DISABLE) drives W_DISABLE1# of the slot. Both are hogged in their inactive state.

Tested with a SIMCom SIM7600G-H module.

---
 arch/arm64/boot/dts/rockchip/Makefile         |  5 ++
 .../dts/rockchip/rk3568-rock-3b-wwan.dtso     | 65 +++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 arch/arm64/boot/dts/rockchip/rk3568-rock-3b-wwan.dtso
arch/arm64/boot/dts/rockchip/Makefile +5 -0
index b677914cd3f1..8a1f24ccaa32 100644
@@ -165,6 +165,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-radxa-e25.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-roc-pc.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-rock-3a.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-rock-3b.dtb
+dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-rock-3b-wwan.dtbo
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-wolfvision-pf5.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-wolfvision-pf5-display-vz.dtbo
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-wolfvision-pf5-io-expander.dtbo
@@ -300,6 +301,10 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-qnap-ts433-pcb-12-10.dtb
 rk3568-qnap-ts433-pcb-12-10-dtbs := rk3568-qnap-ts433.dtb \
 	rk3568-qnap-ts433-pcb-12-10.dtbo
 
+dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-rock-3b-wwan.dtb
+rk3568-rock-3b-wwan-dtbs := rk3568-rock-3b.dtb \
+	rk3568-rock-3b-wwan.dtbo
+
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-wolfvision-pf5-vz-2-uhd.dtb
 rk3568-wolfvision-pf5-vz-2-uhd-dtbs := rk3568-wolfvision-pf5.dtb \
 	rk3568-wolfvision-pf5-display-vz.dtbo \
arch/arm64/boot/dts/rockchip/rk3568-rock-3b-wwan.dtso new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer Applied
#3 lore raw

Re: (subset) [PATCH v2 0/2] arm64: dts: rockchip: Add PWM fan and WWAN overlay for Radxa ROCK 3B

In reply to Adam Wermuth
Quoted 10 lines · Adam Wermuth

The Radxa ROCK 3B has a 2-pin fan header and an M.2 B-key slot intended for 4G/5G modules, neither of which is currently described in the mainline device tree.

Patch 1 adds the PWM fan and ties it to the CPU thermal zone. Patch 2 adds a device tree overlay for the B-key slot, enabling the USB 2.0 host controller serving the slot as well as its power, RESET# and W_DISABLE1# controls.

[...]

Applied, thanks!

[1/2] arm64: dts: rockchip: Add PWM fan to Radxa ROCK 3B

      commit: afcfb6982a13fb4b3e0045f96c7aa6d64063a034

Only took patch1 as the discussion in v2 did not seem finished and doing it correctly trumps intermediate solutions, especially adding overlays we might have trouble removing in the future.

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>