[PATCH 5/6] riscv: dts: spacemit: k1-bananapi-f3: Add PWM fan

From: Frédéric Mahé

Date: Tue Nov 17 2026 - 16:01:08 EST


The fan header (J27) has a PWM line driven by GPIO 79 in its RCPU2
PWM2 function. Add the pin group, the fan with the vendor's four
levels at 100 kHz, and active trips on the package sensor at 40, 55,
70 and 85 C, as in the vendor DT.

Tested on a BPI-F3: J27 pin 3 averages 0.86, 1.76, 2.74 and 4.66 V
for 25, 50, 75 and 100% duty (multimeter, 0.04 V off), and the fan
goes to level 1 when the package reaches 40 C under load.

Written with help from Claude (Anthropic); reviewed and tested on hardware.

Signed-off-by: Frédéric Mahé <frederic.mahe@xxxxxxxx>
---
.../boot/dts/spacemit/k1-bananapi-f3.dts | 63 +++++++++++++++++++
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 7 +++
2 files changed, 70 insertions(+)

diff --git a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
index 58035d886..e69289cc0 100644
--- a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
+++ b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
@@ -37,6 +37,13 @@ led1 {
};
};

+ fan: pwm-fan {
+ compatible = "pwm-fan";
+ pwms = <&rpwm2 0 10000 0>;
+ cooling-levels = <0 64 128 192 255>;
+ #cooling-cells = <2>;
+ };
+
pcie_vcc_3v3: regulator-pcie-vcc3v3 {
compatible = "regulator-fixed";
regulator-name = "PCIE_VCC3V3";
@@ -427,3 +434,59 @@ &sdhci0 {
sd-uhs-sdr104;
status = "okay";
};
+
+&rpwm2 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&rpwm2_0_cfg>;
+ status = "okay";
+};
+
+&{/thermal-zones/package-thermal} {
+ trips {
+ package_fan0: package-fan0 {
+ temperature = <40000>;
+ hysteresis = <5000>;
+ type = "active";
+ };
+
+ package_fan1: package-fan1 {
+ temperature = <55000>;
+ hysteresis = <5000>;
+ type = "active";
+ };
+
+ package_fan2: package-fan2 {
+ temperature = <70000>;
+ hysteresis = <5000>;
+ type = "active";
+ };
+
+ package_fan3: package-fan3 {
+ temperature = <85000>;
+ hysteresis = <5000>;
+ type = "active";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&package_fan0>;
+ cooling-device = <&fan 0 1>;
+ };
+
+ map1 {
+ trip = <&package_fan1>;
+ cooling-device = <&fan 1 2>;
+ };
+
+ map2 {
+ trip = <&package_fan2>;
+ cooling-device = <&fan 2 3>;
+ };
+
+ map3 {
+ trip = <&package_fan3>;
+ cooling-device = <&fan 3 4>;
+ };
+ };
+};
diff --git a/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi b/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
index 8c57ca05d..1f31f3177 100644
--- a/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
@@ -587,6 +587,13 @@ pwm14-1-pins {
};
};

+ rpwm2_0_cfg: rpwm2-0-cfg {
+ rpwm2-0-pins {
+ pinmux = <K1_PADCONF(79, 2)>;
+ bias-pull-down;
+ };
+ };
+
ssp3_0_cfg: ssp3-0-cfg {
ssp3-0-pins {
pinmux = <K1_PADCONF(75, 2)>, /* SCLK */
--
2.47.3