* [PATCH 1/6] dt-bindings: clock: spacemit: k1: Add RCPU2 PWM clocks
2026-11-17 20:59 [PATCH 0/6] riscv: spacemit: k1: RCPU2 PWM clocks and the BPI-F3 fan Frédéric Mahé
@ 2026-11-17 20:59 ` Frédéric Mahé
2026-11-17 20:59 ` [PATCH 2/6] clk: spacemit: k1: Keep pll1_aud_245p7 enabled Frédéric Mahé
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Frédéric Mahé @ 2026-11-17 20:59 UTC (permalink / raw)
To: Stephen Boyd, Yixun Lan
Cc: Brian Masney, Jerome Brunet, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Troy Mitchell, Haylen Chu, Hung-Chun Tseng,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
linux-clk, devicetree, linux-riscv, spacemit, linux-kernel,
Frédéric Mahé
Add IDs for the ten PWM clocks of the K1 RCPU2 system controller.
Written with help from Claude (Anthropic); reviewed and tested on hardware.
Signed-off-by: Frédéric Mahé <frederic.mahe@cirad.fr>
---
include/dt-bindings/clock/spacemit,k1-syscon.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/dt-bindings/clock/spacemit,k1-syscon.h b/include/dt-bindings/clock/spacemit,k1-syscon.h
index 0f8b59d67..29d478774 100644
--- a/include/dt-bindings/clock/spacemit,k1-syscon.h
+++ b/include/dt-bindings/clock/spacemit,k1-syscon.h
@@ -370,6 +370,18 @@
#define RESET_RCPU_UART0 5
#define RESET_RCPU_HDMI_AUDIO 6
+/* RCPU2 clocks */
+#define CLK_RCPU2_PWM0 0
+#define CLK_RCPU2_PWM1 1
+#define CLK_RCPU2_PWM2 2
+#define CLK_RCPU2_PWM3 3
+#define CLK_RCPU2_PWM4 4
+#define CLK_RCPU2_PWM5 5
+#define CLK_RCPU2_PWM6 6
+#define CLK_RCPU2_PWM7 7
+#define CLK_RCPU2_PWM8 8
+#define CLK_RCPU2_PWM9 9
+
/* RCPU2 resets */
#define RESET_RCPU2_PWM0 0
#define RESET_RCPU2_PWM1 1
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 2/6] clk: spacemit: k1: Keep pll1_aud_245p7 enabled
2026-11-17 20:59 [PATCH 0/6] riscv: spacemit: k1: RCPU2 PWM clocks and the BPI-F3 fan Frédéric Mahé
2026-11-17 20:59 ` [PATCH 1/6] dt-bindings: clock: spacemit: k1: Add RCPU2 PWM clocks Frédéric Mahé
@ 2026-11-17 20:59 ` Frédéric Mahé
2026-11-17 21:18 ` sashiko-bot
2026-11-17 20:59 ` [PATCH 3/6] clk: spacemit: k1: Add RCPU2 PWM clocks Frédéric Mahé
` (4 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: Frédéric Mahé @ 2026-11-17 20:59 UTC (permalink / raw)
To: Stephen Boyd, Yixun Lan
Cc: Brian Masney, Jerome Brunet, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Troy Mitchell, Haylen Chu, Hung-Chun Tseng,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
linux-clk, devicetree, linux-riscv, spacemit, linux-kernel,
Frédéric Mahé
Accesses to the RCPU2 block (0xc0888000) hang once pll1_aud_245p7 is
gated: the CPU stops responding, even to NMIs. Nothing claims this
clock in mainline, so clk_disable_unused() turns it off at boot, and
probing an RCPU2 PWM afterwards hangs the board. The RCPU2 clock and
reset registers live in the same block.
Mark it critical, as was done for the K3 RCPU clock.
Tested on a BPI-F3: without this, probing an RCPU2 PWM hangs the
board; with it, no hang, also with no PWM in use.
Written with help from Claude (Anthropic); reviewed and tested on hardware.
Signed-off-by: Frédéric Mahé <frederic.mahe@cirad.fr>
---
drivers/clk/spacemit/ccu-k1.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
index dee14d25f..364388ff8 100644
--- a/drivers/clk/spacemit/ccu-k1.c
+++ b/drivers/clk/spacemit/ccu-k1.c
@@ -60,7 +60,8 @@ CCU_FACTOR_GATE_DEFINE(pll1_d11_223p4, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT
CCU_FACTOR_GATE_DEFINE(pll1_d13_189, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(16), 13, 1);
CCU_FACTOR_GATE_DEFINE(pll1_d23_106p8, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(20), 23, 1);
CCU_FACTOR_GATE_DEFINE(pll1_d64_38p4, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(0), 64, 1);
-CCU_FACTOR_GATE_DEFINE(pll1_aud_245p7, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(10), 10, 1);
+CCU_FACTOR_GATE_FLAGS_DEFINE(pll1_aud_245p7, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(10), 10, 1,
+ CLK_IS_CRITICAL);
CCU_FACTOR_GATE_DEFINE(pll1_aud_24p5, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(11), 100, 1);
CCU_FACTOR_GATE_DEFINE(pll2_d1, CCU_PARENT_HW(pll2), APBS_PLL2_SWCR2, BIT(0), 1, 1);
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 2/6] clk: spacemit: k1: Keep pll1_aud_245p7 enabled
2026-11-17 20:59 ` [PATCH 2/6] clk: spacemit: k1: Keep pll1_aud_245p7 enabled Frédéric Mahé
@ 2026-11-17 21:18 ` sashiko-bot
0 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-11-17 21:18 UTC (permalink / raw)
To: Frédéric Mahé; +Cc: linux-clk, devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] clk: spacemit: k1: missing Fixes trailer for pll1_aud_245p7
critical clock fix
--
commit 83873cc8722c58b6ef8102ec78a68b9664559a72
Author: Frédéric Mahé <frederic.mahe@cirad.fr>
> clk: spacemit: k1: Keep pll1_aud_245p7 enabled
>
> Accesses to the RCPU2 block (0xc0888000) hang once pll1_aud_245p7 is
> gated: the CPU stops responding, even to NMIs. Nothing claims this
> clock in mainline, so clk_disable_unused() turns it off at boot, and
> probing an RCPU2 PWM afterwards hangs the board. The RCPU2 clock and
> reset registers live in the same block.
>
> Mark it critical, as was done for the K3 RCPU clock.
>
> Tested on a BPI-F3: without this, probing an RCPU2 PWM hangs the
> board; with it, no hang, also with no PWM in use.
>
> Written with help from Claude (Anthropic); reviewed and tested on hardware.
>
> Signed-off-by: Frédéric Mahé <frederic.mahe@cirad.fr>
[Severity: Low]
Since this fixes a hardware hang when clk_disable_unused() gates
pll1_aud_245p7, should this include a Fixes tag?
Fixes: 1b72c59db0ad ("clk: spacemit: Add clock support for SpacemiT K1 SoC")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117205951.140146-1-frederic.mahe@cirad.fr?part=2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/6] clk: spacemit: k1: Add RCPU2 PWM clocks
2026-11-17 20:59 [PATCH 0/6] riscv: spacemit: k1: RCPU2 PWM clocks and the BPI-F3 fan Frédéric Mahé
2026-11-17 20:59 ` [PATCH 1/6] dt-bindings: clock: spacemit: k1: Add RCPU2 PWM clocks Frédéric Mahé
2026-11-17 20:59 ` [PATCH 2/6] clk: spacemit: k1: Keep pll1_aud_245p7 enabled Frédéric Mahé
@ 2026-11-17 20:59 ` Frédéric Mahé
2026-11-17 20:59 ` [PATCH 4/6] riscv: dts: spacemit: k1: Add RCPU2 PWM nodes Frédéric Mahé
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Frédéric Mahé @ 2026-11-17 20:59 UTC (permalink / raw)
To: Stephen Boyd, Yixun Lan
Cc: Brian Masney, Jerome Brunet, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Troy Mitchell, Haylen Chu, Hung-Chun Tseng,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
linux-clk, devicetree, linux-riscv, spacemit, linux-kernel,
Frédéric Mahé
The ten RCPU2 PWMs each have a mux/divider/gate clock in the RCPU2
system controller, fed by pll1_aud_24p5 or pll1_aud_245p7. Register
layout from the vendor kernel.
Written with help from Claude (Anthropic); reviewed and tested on hardware.
Signed-off-by: Frédéric Mahé <frederic.mahe@cirad.fr>
---
drivers/clk/spacemit/ccu-k1.c | 42 +++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
index 364388ff8..25be335eb 100644
--- a/drivers/clk/spacemit/ccu-k1.c
+++ b/drivers/clk/spacemit/ccu-k1.c
@@ -705,6 +705,33 @@ CCU_GATE_DEFINE(emac1_ptp_clk, CCU_PARENT_HW(pll2_d6), APMU_EMAC1_CLK_RES_CTRL,
CCU_GATE_DEFINE(emmc_bus_clk, CCU_PARENT_HW(pmua_aclk), APMU_PMUA_EM_CLK_RES_CTRL, BIT(3), 0);
/* APMU clocks end */
+/* RCPU2 clocks start */
+static const struct clk_parent_data rcpu2_pwm_parents[] = {
+ CCU_PARENT_HW(pll1_aud_24p5),
+ CCU_PARENT_HW(pll1_aud_245p7),
+};
+CCU_MUX_DIV_GATE_DEFINE(rcpu2_pwm0_clk, rcpu2_pwm_parents, RCPU2_PWM0_CLK_RST, 8, 11, 4, 2,
+ BIT(1), 0);
+CCU_MUX_DIV_GATE_DEFINE(rcpu2_pwm1_clk, rcpu2_pwm_parents, RCPU2_PWM1_CLK_RST, 8, 11, 4, 2,
+ BIT(1), 0);
+CCU_MUX_DIV_GATE_DEFINE(rcpu2_pwm2_clk, rcpu2_pwm_parents, RCPU2_PWM2_CLK_RST, 8, 11, 4, 2,
+ BIT(1), 0);
+CCU_MUX_DIV_GATE_DEFINE(rcpu2_pwm3_clk, rcpu2_pwm_parents, RCPU2_PWM3_CLK_RST, 8, 11, 4, 2,
+ BIT(1), 0);
+CCU_MUX_DIV_GATE_DEFINE(rcpu2_pwm4_clk, rcpu2_pwm_parents, RCPU2_PWM4_CLK_RST, 8, 11, 4, 2,
+ BIT(1), 0);
+CCU_MUX_DIV_GATE_DEFINE(rcpu2_pwm5_clk, rcpu2_pwm_parents, RCPU2_PWM5_CLK_RST, 8, 11, 4, 2,
+ BIT(1), 0);
+CCU_MUX_DIV_GATE_DEFINE(rcpu2_pwm6_clk, rcpu2_pwm_parents, RCPU2_PWM6_CLK_RST, 8, 11, 4, 2,
+ BIT(1), 0);
+CCU_MUX_DIV_GATE_DEFINE(rcpu2_pwm7_clk, rcpu2_pwm_parents, RCPU2_PWM7_CLK_RST, 8, 11, 4, 2,
+ BIT(1), 0);
+CCU_MUX_DIV_GATE_DEFINE(rcpu2_pwm8_clk, rcpu2_pwm_parents, RCPU2_PWM8_CLK_RST, 8, 11, 4, 2,
+ BIT(1), 0);
+CCU_MUX_DIV_GATE_DEFINE(rcpu2_pwm9_clk, rcpu2_pwm_parents, RCPU2_PWM9_CLK_RST, 8, 11, 4, 2,
+ BIT(1), 0);
+/* RCPU2 clocks end */
+
static struct clk_hw *k1_ccu_pll_hws[] = {
[CLK_PLL1] = &pll1.common.hw,
[CLK_PLL2] = &pll2.common.hw,
@@ -981,8 +1008,23 @@ static const struct spacemit_ccu_data k1_ccu_rcpu_data = {
.reset_name = "k1-rcpu-reset",
};
+static struct clk_hw *k1_ccu_rcpu2_hws[] = {
+ [CLK_RCPU2_PWM0] = &rcpu2_pwm0_clk.common.hw,
+ [CLK_RCPU2_PWM1] = &rcpu2_pwm1_clk.common.hw,
+ [CLK_RCPU2_PWM2] = &rcpu2_pwm2_clk.common.hw,
+ [CLK_RCPU2_PWM3] = &rcpu2_pwm3_clk.common.hw,
+ [CLK_RCPU2_PWM4] = &rcpu2_pwm4_clk.common.hw,
+ [CLK_RCPU2_PWM5] = &rcpu2_pwm5_clk.common.hw,
+ [CLK_RCPU2_PWM6] = &rcpu2_pwm6_clk.common.hw,
+ [CLK_RCPU2_PWM7] = &rcpu2_pwm7_clk.common.hw,
+ [CLK_RCPU2_PWM8] = &rcpu2_pwm8_clk.common.hw,
+ [CLK_RCPU2_PWM9] = &rcpu2_pwm9_clk.common.hw,
+};
+
static const struct spacemit_ccu_data k1_ccu_rcpu2_data = {
.reset_name = "k1-rcpu2-reset",
+ .hws = k1_ccu_rcpu2_hws,
+ .num = ARRAY_SIZE(k1_ccu_rcpu2_hws),
};
static const struct spacemit_ccu_data k1_ccu_apbc2_data = {
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 4/6] riscv: dts: spacemit: k1: Add RCPU2 PWM nodes
2026-11-17 20:59 [PATCH 0/6] riscv: spacemit: k1: RCPU2 PWM clocks and the BPI-F3 fan Frédéric Mahé
` (2 preceding siblings ...)
2026-11-17 20:59 ` [PATCH 3/6] clk: spacemit: k1: Add RCPU2 PWM clocks Frédéric Mahé
@ 2026-11-17 20:59 ` Frédéric Mahé
2026-11-17 20:59 ` [PATCH 5/6] riscv: dts: spacemit: k1-bananapi-f3: Add PWM fan Frédéric Mahé
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Frédéric Mahé @ 2026-11-17 20:59 UTC (permalink / raw)
To: Stephen Boyd, Yixun Lan
Cc: Brian Masney, Jerome Brunet, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Troy Mitchell, Haylen Chu, Hung-Chun Tseng,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
linux-clk, devicetree, linux-riscv, spacemit, linux-kernel,
Frédéric Mahé
Add the ten PWM controllers of the RCPU2 block, and make the RCPU2
system controller a clock provider for them.
Written with help from Claude (Anthropic); reviewed and tested on hardware.
Signed-off-by: Frédéric Mahé <frederic.mahe@cirad.fr>
---
arch/riscv/boot/dts/spacemit/k1.dtsi | 91 ++++++++++++++++++++++++++++
1 file changed, 91 insertions(+)
diff --git a/arch/riscv/boot/dts/spacemit/k1.dtsi b/arch/riscv/boot/dts/spacemit/k1.dtsi
index 542bfc0d1..3339ff56c 100644
--- a/arch/riscv/boot/dts/spacemit/k1.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k1.dtsi
@@ -456,9 +456,100 @@ syscon_rcpu: system-controller@c0880000 {
syscon_rcpu2: system-controller@c0888000 {
compatible = "spacemit,k1-syscon-rcpu2";
reg = <0x0 0xc0888000 0x0 0x28>;
+ #clock-cells = <1>;
#reset-cells = <1>;
};
+ rpwm0: pwm@c0888100 {
+ compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm";
+ reg = <0x0 0xc0888100 0x0 0x10>;
+ #pwm-cells = <3>;
+ clocks = <&syscon_rcpu2 CLK_RCPU2_PWM0>;
+ resets = <&syscon_rcpu2 RESET_RCPU2_PWM0>;
+ status = "disabled";
+ };
+
+ rpwm1: pwm@c0888200 {
+ compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm";
+ reg = <0x0 0xc0888200 0x0 0x10>;
+ #pwm-cells = <3>;
+ clocks = <&syscon_rcpu2 CLK_RCPU2_PWM1>;
+ resets = <&syscon_rcpu2 RESET_RCPU2_PWM1>;
+ status = "disabled";
+ };
+
+ rpwm2: pwm@c0888300 {
+ compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm";
+ reg = <0x0 0xc0888300 0x0 0x10>;
+ #pwm-cells = <3>;
+ clocks = <&syscon_rcpu2 CLK_RCPU2_PWM2>;
+ resets = <&syscon_rcpu2 RESET_RCPU2_PWM2>;
+ status = "disabled";
+ };
+
+ rpwm3: pwm@c0888400 {
+ compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm";
+ reg = <0x0 0xc0888400 0x0 0x10>;
+ #pwm-cells = <3>;
+ clocks = <&syscon_rcpu2 CLK_RCPU2_PWM3>;
+ resets = <&syscon_rcpu2 RESET_RCPU2_PWM3>;
+ status = "disabled";
+ };
+
+ rpwm4: pwm@c0888500 {
+ compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm";
+ reg = <0x0 0xc0888500 0x0 0x10>;
+ #pwm-cells = <3>;
+ clocks = <&syscon_rcpu2 CLK_RCPU2_PWM4>;
+ resets = <&syscon_rcpu2 RESET_RCPU2_PWM4>;
+ status = "disabled";
+ };
+
+ rpwm5: pwm@c0888600 {
+ compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm";
+ reg = <0x0 0xc0888600 0x0 0x10>;
+ #pwm-cells = <3>;
+ clocks = <&syscon_rcpu2 CLK_RCPU2_PWM5>;
+ resets = <&syscon_rcpu2 RESET_RCPU2_PWM5>;
+ status = "disabled";
+ };
+
+ rpwm6: pwm@c0888700 {
+ compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm";
+ reg = <0x0 0xc0888700 0x0 0x10>;
+ #pwm-cells = <3>;
+ clocks = <&syscon_rcpu2 CLK_RCPU2_PWM6>;
+ resets = <&syscon_rcpu2 RESET_RCPU2_PWM6>;
+ status = "disabled";
+ };
+
+ rpwm7: pwm@c0888800 {
+ compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm";
+ reg = <0x0 0xc0888800 0x0 0x10>;
+ #pwm-cells = <3>;
+ clocks = <&syscon_rcpu2 CLK_RCPU2_PWM7>;
+ resets = <&syscon_rcpu2 RESET_RCPU2_PWM7>;
+ status = "disabled";
+ };
+
+ rpwm8: pwm@c0888900 {
+ compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm";
+ reg = <0x0 0xc0888900 0x0 0x10>;
+ #pwm-cells = <3>;
+ clocks = <&syscon_rcpu2 CLK_RCPU2_PWM8>;
+ resets = <&syscon_rcpu2 RESET_RCPU2_PWM8>;
+ status = "disabled";
+ };
+
+ rpwm9: pwm@c0888a00 {
+ compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm";
+ reg = <0x0 0xc0888a00 0x0 0x10>;
+ #pwm-cells = <3>;
+ clocks = <&syscon_rcpu2 CLK_RCPU2_PWM9>;
+ resets = <&syscon_rcpu2 RESET_RCPU2_PWM9>;
+ status = "disabled";
+ };
+
usbphy2: phy@c0a30000 {
compatible = "spacemit,k1-usb2-phy";
reg = <0x0 0xc0a30000 0x0 0x200>;
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 5/6] riscv: dts: spacemit: k1-bananapi-f3: Add PWM fan
2026-11-17 20:59 [PATCH 0/6] riscv: spacemit: k1: RCPU2 PWM clocks and the BPI-F3 fan Frédéric Mahé
` (3 preceding siblings ...)
2026-11-17 20:59 ` [PATCH 4/6] riscv: dts: spacemit: k1: Add RCPU2 PWM nodes Frédéric Mahé
@ 2026-11-17 20:59 ` Frédéric Mahé
2026-11-17 20:59 ` [PATCH 6/6] riscv: defconfig: Enable PWM fan support Frédéric Mahé
2026-11-17 21:16 ` [PATCH 0/6] riscv: spacemit: k1: RCPU2 PWM clocks and the BPI-F3 fan Frédéric Mahé
6 siblings, 0 replies; 9+ messages in thread
From: Frédéric Mahé @ 2026-11-17 20:59 UTC (permalink / raw)
To: Stephen Boyd, Yixun Lan
Cc: Brian Masney, Jerome Brunet, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Troy Mitchell, Haylen Chu, Hung-Chun Tseng,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
linux-clk, devicetree, linux-riscv, spacemit, linux-kernel,
Frédéric Mahé
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@cirad.fr>
---
.../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
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 6/6] riscv: defconfig: Enable PWM fan support
2026-11-17 20:59 [PATCH 0/6] riscv: spacemit: k1: RCPU2 PWM clocks and the BPI-F3 fan Frédéric Mahé
` (4 preceding siblings ...)
2026-11-17 20:59 ` [PATCH 5/6] riscv: dts: spacemit: k1-bananapi-f3: Add PWM fan Frédéric Mahé
@ 2026-11-17 20:59 ` Frédéric Mahé
2026-11-17 21:16 ` [PATCH 0/6] riscv: spacemit: k1: RCPU2 PWM clocks and the BPI-F3 fan Frédéric Mahé
6 siblings, 0 replies; 9+ messages in thread
From: Frédéric Mahé @ 2026-11-17 20:59 UTC (permalink / raw)
To: Stephen Boyd, Yixun Lan
Cc: Brian Masney, Jerome Brunet, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Troy Mitchell, Haylen Chu, Hung-Chun Tseng,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
linux-clk, devicetree, linux-riscv, spacemit, linux-kernel,
Frédéric Mahé
Build pwm-fan as a module, used by the Banana Pi BPI-F3 fan.
Written with help from Claude (Anthropic); reviewed and tested on hardware.
Signed-off-by: Frédéric Mahé <frederic.mahe@cirad.fr>
---
arch/riscv/configs/defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig
index 04ae305d5..d244e806f 100644
--- a/arch/riscv/configs/defconfig
+++ b/arch/riscv/configs/defconfig
@@ -178,6 +178,7 @@ CONFIG_GPIO_SPACEMIT_K1=y
CONFIG_GPIO_PCA953X=m
CONFIG_GPIO_PCA953X_IRQ=y
CONFIG_POWER_RESET_GPIO_RESTART=y
+CONFIG_SENSORS_PWM_FAN=m
CONFIG_SENSORS_SFCTEMP=m
CONFIG_CPU_THERMAL=y
CONFIG_DEVFREQ_THERMAL=y
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 0/6] riscv: spacemit: k1: RCPU2 PWM clocks and the BPI-F3 fan
2026-11-17 20:59 [PATCH 0/6] riscv: spacemit: k1: RCPU2 PWM clocks and the BPI-F3 fan Frédéric Mahé
` (5 preceding siblings ...)
2026-11-17 20:59 ` [PATCH 6/6] riscv: defconfig: Enable PWM fan support Frédéric Mahé
@ 2026-11-17 21:16 ` Frédéric Mahé
6 siblings, 0 replies; 9+ messages in thread
From: Frédéric Mahé @ 2026-11-17 21:16 UTC (permalink / raw)
To: Stephen Boyd, Yixun Lan
Cc: Frédéric Mahé, Troy Mitchell, Brian Masney,
Jerome Brunet, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Haylen Chu, Hung-Chun Tseng, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, linux-clk, devicetree, linux-riscv,
spacemit, linux-kernel
Adding Troy, whose address I mistyped in the series (sorry). When
replying, please drop troy.mitchell@linux.spacemit.co.
Frédéric
^ permalink raw reply [flat|nested] 9+ messages in thread