* [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é
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ 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 [flat|nested] 11+ 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-18 11:15 ` Yixun Lan
2026-11-17 20:59 ` [PATCH 3/6] clk: spacemit: k1: Add RCPU2 PWM clocks Frédéric Mahé
` (5 subsequent siblings)
7 siblings, 1 reply; 11+ 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 [flat|nested] 11+ 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-18 11:15 ` Yixun Lan
2026-11-18 15:57 ` Yao Zi
0 siblings, 1 reply; 11+ messages in thread
From: Yixun Lan @ 2026-11-18 11:15 UTC (permalink / raw)
To: Frédéric Mahé
Cc: Stephen Boyd, 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
Hi Frédéric,
I will forward to SpacemiT people, and ask them to clarify..
On 21:59 Tue 17 Nov , Frédéric Mahé wrote:
> Accesses to the RCPU2 block (0xc0888000) hang once pll1_aud_245p7 is
Access which register? is the PWM register in RCPU2?
> 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.
>
Usually access IP block with clock gated off will cause system bus hang,
exactly the same scenario as you see here..
> Mark it critical, as was done for the K3 RCPU clock.
>
It just happen to fix the issue, but doesn't sound like a correct fix,
usually, it can be fixed with correct clock topology
> 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.
>
maybe just "Assisted-by: LLM"
> 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
>
--
Yixun Lan (dlan)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/6] clk: spacemit: k1: Keep pll1_aud_245p7 enabled
2026-11-18 11:15 ` Yixun Lan
@ 2026-11-18 15:57 ` Yao Zi
0 siblings, 0 replies; 11+ messages in thread
From: Yao Zi @ 2026-11-18 15:57 UTC (permalink / raw)
To: Yixun Lan, Frédéric Mahé
Cc: Stephen Boyd, 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, Yao Zi
On Wed, Nov 18, 2026 at 11:15:28AM +0000, Yixun Lan wrote:
> Hi Frédéric,
>
> I will forward to SpacemiT people, and ask them to clarify..
>
> On 21:59 Tue 17 Nov , Frédéric Mahé wrote:
> > Accesses to the RCPU2 block (0xc0888000) hang once pll1_aud_245p7 is
> Access which register? is the PWM register in RCPU2?
>
> > 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.
> >
> Usually access IP block with clock gated off will cause system bus hang,
> exactly the same scenario as you see here..
>
> > Mark it critical, as was done for the K3 RCPU clock.
> >
> It just happen to fix the issue, but doesn't sound like a correct fix,
> usually, it can be fixed with correct clock topology
>
> > 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.
> >
> maybe just "Assisted-by: LLM"
I think this tag has been deprecated in commit 1e035297ffda ("docs:
remove Assisted-by references"), but mentioning code origin is still
required by process/generated-content.rst.
The notice could indeed be moved to the cover letter instead.
--
Thanks,
Yao Zi
Meow-mrrp-mrow, I'm a cat.
^ permalink raw reply [flat|nested] 11+ 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é
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ 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 [flat|nested] 11+ 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é
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ 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 [flat|nested] 11+ 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é
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ 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 [flat|nested] 11+ 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é
2026-11-18 16:02 ` Yao Zi
7 siblings, 0 replies; 11+ 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 [flat|nested] 11+ 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é
2026-11-18 16:02 ` Yao Zi
7 siblings, 0 replies; 11+ 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] 11+ 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é
` (6 preceding siblings ...)
2026-11-17 21:16 ` [PATCH 0/6] riscv: spacemit: k1: RCPU2 PWM clocks and the BPI-F3 fan Frédéric Mahé
@ 2026-11-18 16:02 ` Yao Zi
7 siblings, 0 replies; 11+ messages in thread
From: Yao Zi @ 2026-11-18 16:02 UTC (permalink / raw)
To: Frédéric Mahé, 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,
Yao Zi
On Tue, Nov 17, 2026 at 09:59:45PM +0100, Frédéric Mahé wrote:
> The BPI-F3 fan header (J27) has a PWM line driven by an RCPU2 PWM
> (GPIO 79). This series adds the RCPU2 PWM clocks and DT nodes and
> enables the fan on the BPI-F3.
>
> Patch 2 keeps pll1_aud_245p7 enabled: once clk_disable_unused() gates
> it, accesses to the RCPU2 block hang the CPU (the vendor kernel keeps
> it on through its RCPU firmware). It may be better tied to a power
> domain once the K1 power domain driver lands; comments welcome.
>
> Tested on a BPI-F3 on v7.4-rc1 (no fan with a PWM input at hand, so
> with a multimeter on J27 pin 3): 0.86, 1.76, 2.74 and 4.66 V at 25,
> 50, 75 and 100% duty (0.04 V off), as with the vendor kernel, and
> the fan goes to level 1 when the package reaches 40 C under load.
>
> Trees: 1-3 clk, 4-5 SpacemiT DT (4 needs the IDs from 1), 6 riscv
> defconfig. Depends on "reset: spacemit: Fix the RCPU2 PWM reset
> registers" (reset/fixes).
>
> Written with help from Claude (Anthropic); reviewed and tested on
> hardware.
>
> Signed-off-by: Frédéric Mahé <frederic.mahe@cirad.fr>
>
>
> Frédéric Mahé (6):
> dt-bindings: clock: spacemit: k1: Add RCPU2 PWM clocks
> clk: spacemit: k1: Keep pll1_aud_245p7 enabled
> clk: spacemit: k1: Add RCPU2 PWM clocks
> riscv: dts: spacemit: k1: Add RCPU2 PWM nodes
> riscv: dts: spacemit: k1-bananapi-f3: Add PWM fan
> riscv: defconfig: Enable PWM fan support
>
> .../boot/dts/spacemit/k1-bananapi-f3.dts | 63 +++++++++++++
> arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 7 ++
> arch/riscv/boot/dts/spacemit/k1.dtsi | 91 +++++++++++++++++++
> arch/riscv/configs/defconfig | 1 +
> drivers/clk/spacemit/ccu-k1.c | 45 ++++++++-
> .../dt-bindings/clock/spacemit,k1-syscon.h | 12 +++
> 6 files changed, 218 insertions(+), 1 deletion(-)
I think spacemit,k1-syscon.yaml should probably be updated to make
'#clock-cells' property mandatory for rcpu2 node? And probably also
the other blocks capable of clock stuff as fix...
--
Thanks,
Yao Zi
Meow-mrrp-mrow, I'm a cat.
^ permalink raw reply [flat|nested] 11+ messages in thread