[PATCH 3/6] clk: spacemit: k1: Add RCPU2 PWM clocks

Frédéric Mahé frederic.mahe at cirad.fr
Tue Nov 17 12:59:48 PST 2026


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 at 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




More information about the linux-riscv mailing list