.../devicetree/bindings/clock/canaan,k230-clk.yaml | 59 + arch/riscv/boot/dts/canaan/k230-canmv.dts | 11 + arch/riscv/boot/dts/canaan/k230-evb.dts | 11 + arch/riscv/boot/dts/canaan/k230.dtsi | 26 +- drivers/clk/Kconfig | 6 + drivers/clk/Makefile | 1 + drivers/clk/clk-k230.c | 2452 ++++++++++++++++++++ include/dt-bindings/clock/canaan,k230-clk.h | 220 ++ 8 files changed, 2778 insertions(+), 8 deletions(-)
This patch series adds clock controller support for the Canaan Kendryte
K230 SoC. The K230 SoC includes an external 24MHz OSC, 4 internal
PLLs and an external pulse input, with the controller managing these
sources and their derived clocks.
The clock tree and hardware-specific definition can be found in the
vendor's DTS [1],
and this series is based on the K230 initial series [2].
Link: https://github.com/ruyisdk/linux-xuantie-kernel/blob/linux-6.6.36/arch/riscv/boot/dts/canaan/k230_clock_provider.dtsi [1]
Link: https://lore.kernel.org/linux-clk/tencent_F76EB8D731C521C18D5D7C4F8229DAA58E08@qq.com/ [2]
Co-developed-by: Troy Mitchell <TroyMitchell988@gmail.com>
Signed-off-by: Troy Mitchell <TroyMitchell988@gmail.com>
Signed-off-by: Xukai Wang <kingxukai@zohomail.com>
---
Changes in v12:
- Rebase onto linux-next (next-20260421).
- Migrate from deprecated round_rate() clk_ops to determine_rate() API.
- dt-bindings: Drop redundant "bindings for" in commit subject.
- Link to v11: https://lore.kernel.org/r/20260214-b4-k230-clk-v11-0-6de365489b89@zohomail.com
Changes in v11:
- Rename hs_hclk_high_src to hs_hclk_high and hs_hclk_src to hs_hclk.
- Rebase base-commit to linux-next.
- Update prerequisite-patch-id.
- Link to v10: https://lore.kernel.org/r/20260116-b4-k230-clk-v10-0-de59033c5d30@zohomail.com
Changes in v10:
- Drop clock node: cpu1_apb_rate.
- Rename hs_ospi_src to hs_ssi0.
- Rename fixed clocks format in dts.
- Fix missing clk member registration in driver.
- Fix incorrect clk ID: k230_cpu1_src_rate → K230_CPU1_SRC_RATE.
- Fix bit index of hs_hclk_src_gate: 1 → 0.
- Add CLK_IS_CRITICAL to CPU-related gate clocks.
- Update parent clocks: display_clkext_rate, sec_apb_gate, ai_axi_gate,
cpu1_src_mux and hs_sd_card_src_rate.
- Link to v9: https://lore.kernel.org/r/20251127-b4-k230-clk-v9-0-3aa09e17faf5@zohomail.com
Changes in v9:
- Rebase base-commit to v6.18-rc1
- Simplified PLL field extraction with FIELD_GET() macro
- Drop MODULE_DEVICE_TABLE for k230_clk_ids
- Replace k230_clk_find_approximate_mul_div's step with
Rational_best_approximation
- Reorder declaration and defination for clk_ops
- Link to v8: https://lore.kernel.org/r/20250905-b4-k230-clk-v8-0-96caa02d5428@zohomail.com
Changes in v8:
- Rename dts node name "timer_pulse_in" to "clock-50m"
- Drop redundant comment and 'minItems' of hardware in dt-binding.
- Link to v7: https://lore.kernel.org/r/20250730-b4-k230-clk-v7-0-c57d3bb593d3@zohomail.com
Changes in v7:
- Rename K230_PLL_STATUS_MASK to K230_PLL_LOCK_STATUS_MASK
- Add clkdev for PLLs to register lookup
- Add macros to generate repeat variables definition
- Refine the definitions of k230 clocks
- Split composite clks into rate, gate, mux, fixed_factor clk
- Replace k230_clk_hw_onecell_get with of_clk_hw_onecell_get for
clock provider
- Drop k230_sysclk and use clk_mux, clk_gate and clk_fixed_factor
as the data structures.
- Replace one loop registration with individual registration for
each type.
- Link to v6: https://lore.kernel.org/r/20250415-b4-k230-clk-v6-0-7fd89f427250@zohomail.com
Changes in v6:
- Remove some redundant comments in struct declaration.
- Replace the Vendor's code source link with a new one.
- Link to v5: https://lore.kernel.org/r/20250320-b4-k230-clk-v5-0-0e9d089c5488@zohomail.com
Changes in v5:
- Fix incorrect base-commit and add prerequisite-patch-id.
- Replace dummy apb_clk with real ones for UARTs.
- Add IDs of UARTs clock and DMA clocks in the binding header.
- Replace k230_clk_cfgs[] array with corresponding named variables.
- Remove some redundant checks in clk_ops.
- Drop the unnecessary parenthesis and type casts.
- Modify return value handling in probe path to avoid redundant print.
- Link to v4: https://lore.kernel.org/r/20250217-b4-k230-clk-v4-0-5a95a3458691@zohomail.com
Changes in v4:
- Remove redundant onecell_get callback and add_provider function
for pll_divs.
- Modify the base-commit in cover letter.
- Link to v3: https://lore.kernel.org/r/20250203-b4-k230-clk-v3-0-362c79124572@zohomail.com
Changes in v3:
- Reorder the defination and declaration in drivers code.
- Reorder the properties in dts node.
- Replace global variable `k230_sysclk` with dynamic memory allocation.
- Rename the macro K230_NUM_CLKS to K230_CLK_NUM.
- Use dev_err_probe for error handling.
- Remove unused includes.
- Link to v2: https://lore.kernel.org/r/20250108-b4-k230-clk-v2-0-27b30a2ca52d@zohomail.com
Changes in v2:
- Add items and description.
- Rename k230-clk.h to canaan,k230-clk.h
- Link to v1: https://lore.kernel.org/r/20241229-b4-k230-clk-v1-0-221a917e80ed@zohomail.com
---
Xukai Wang (3):
dt-bindings: clock: Add Canaan K230 clock controller
clk: canaan: Add clock driver for Canaan K230
riscv: dts: canaan: Add clock definition for K230
.../devicetree/bindings/clock/canaan,k230-clk.yaml | 59 +
arch/riscv/boot/dts/canaan/k230-canmv.dts | 11 +
arch/riscv/boot/dts/canaan/k230-evb.dts | 11 +
arch/riscv/boot/dts/canaan/k230.dtsi | 26 +-
drivers/clk/Kconfig | 6 +
drivers/clk/Makefile | 1 +
drivers/clk/clk-k230.c | 2452 ++++++++++++++++++++
include/dt-bindings/clock/canaan,k230-clk.h | 220 ++
8 files changed, 2778 insertions(+), 8 deletions(-)
---
base-commit: af98e93c5c39e6d0b87b42f0a32dd3066f795718
change-id: 20241206-b4-k230-clk-925f33fed6c2
prerequisite-patch-id: 9a2d01f55574b538dad572e193f81c44661f0853
Best regards,
--
Xukai Wang <kingxukai@zohomail.com>
Hey, On Sat, Apr 25, 2026 at 05:29:30PM +0800, Xukai Wang wrote: > This patch series adds clock controller support for the Canaan Kendryte > K230 SoC. The K230 SoC includes an external 24MHz OSC, 4 internal > PLLs and an external pulse input, with the controller managing these > sources and their derived clocks. > > The clock tree and hardware-specific definition can be found in the > vendor's DTS [1], > and this series is based on the K230 initial series [2]. > > Link: https://github.com/ruyisdk/linux-xuantie-kernel/blob/linux-6.6.36/arch/riscv/boot/dts/canaan/k230_clock_provider.dtsi [1] > Link: https://lore.kernel.org/linux-clk/tencent_F76EB8D731C521C18D5D7C4F8229DAA58E08@qq.com/ [2] > > Co-developed-by: Troy Mitchell <TroyMitchell988@gmail.com> > Signed-off-by: Troy Mitchell <TroyMitchell988@gmail.com> > Signed-off-by: Xukai Wang <kingxukai@zohomail.com> I applied this with the intent of sending a PR to Stephen, but lkp reported some problems during randconfigs: https://lore.kernel.org/oe-kbuild-all/202605220724.j4ZeM3KI-lkp@intel.com/ These showed up on microblaze, but I think as they're all from sparse you should be able to see them on riscv too. Should all be pretty easy to fix, send a patch and I will squash them in. Cheers, Conor.
Fix all sparse warnings detected during LKP randconfig testing:
- Replace plain integer 0 with NULL.
- Add static modifier to k230_plls and k230_pll_divs.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605220724.j4ZeM3KI-lkp@intel.com/
Signed-off-by: Xukai Wang <kingxukai@zohomail.com>
---
drivers/clk/clk-k230.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/clk/clk-k230.c b/drivers/clk/clk-k230.c
index d883a1e1118e..cfc437038e4e 100644
--- a/drivers/clk/clk-k230.c
+++ b/drivers/clk/clk-k230.c
@@ -270,12 +270,12 @@ static const struct clk_ops k230_clk_ops_mul_div = {
.recalc_rate = k230_clk_get_rate_mul_div,
};
-K230_CLK_PLL_FORMAT(pll0, 0, CLK_IS_CRITICAL, 0);
-K230_CLK_PLL_FORMAT(pll1, 1, CLK_IS_CRITICAL, 0);
-K230_CLK_PLL_FORMAT(pll2, 2, CLK_IS_CRITICAL, 0);
-K230_CLK_PLL_FORMAT(pll3, 3, CLK_IS_CRITICAL, 0);
+K230_CLK_PLL_FORMAT(pll0, 0, CLK_IS_CRITICAL, NULL);
+K230_CLK_PLL_FORMAT(pll1, 1, CLK_IS_CRITICAL, NULL);
+K230_CLK_PLL_FORMAT(pll2, 2, CLK_IS_CRITICAL, NULL);
+K230_CLK_PLL_FORMAT(pll3, 3, CLK_IS_CRITICAL, NULL);
-struct k230_pll *k230_plls[] = {
+static struct k230_pll *k230_plls[] = {
&pll0,
&pll1,
&pll2,
@@ -296,7 +296,7 @@ K230_CLK_FIXED_FACTOR_FORMAT(pll3_div2, 1, 2, 0, &pll3.hw);
K230_CLK_FIXED_FACTOR_FORMAT(pll3_div3, 1, 3, 0, &pll3.hw);
K230_CLK_FIXED_FACTOR_FORMAT(pll3_div4, 1, 4, 0, &pll3.hw);
-struct clk_fixed_factor *k230_pll_divs[] = {
+static struct clk_fixed_factor *k230_pll_divs[] = {
&pll0_div2,
&pll0_div3,
&pll0_div4,
--
2.34.1
On Fri, May 22, 2026 at 08:59:12PM +0800, Xukai Wang wrote: > Fix all sparse warnings detected during LKP randconfig testing: > - Replace plain integer 0 with NULL. > - Add static modifier to k230_plls and k230_pll_divs. > > Reported-by: kernel test robot <lkp@intel.com> > Closes: https://lore.kernel.org/oe-kbuild-all/202605220724.j4ZeM3KI-lkp@intel.com/ > Signed-off-by: Xukai Wang <kingxukai@zohomail.com> Forgot to reply earlier, but I went and squashed this in. Cheers, Conor.
On 2026/5/23 04:39, Conor Dooley wrote: > On Fri, May 22, 2026 at 08:59:12PM +0800, Xukai Wang wrote: >> Fix all sparse warnings detected during LKP randconfig testing: >> - Replace plain integer 0 with NULL. >> - Add static modifier to k230_plls and k230_pll_divs. >> >> Reported-by: kernel test robot <lkp@intel.com> >> Closes: https://lore.kernel.org/oe-kbuild-all/202605220724.j4ZeM3KI-lkp@intel.com/ >> Signed-off-by: Xukai Wang <kingxukai@zohomail.com> > Forgot to reply earlier, but I went and squashed this in. Thanks Conor! -- Best regards, Xukai Wang
On Sat, May 23, 2026 at 03:00:15PM +0800, Xukai Wang wrote: > > On 2026/5/23 04:39, Conor Dooley wrote: > > On Fri, May 22, 2026 at 08:59:12PM +0800, Xukai Wang wrote: > >> Fix all sparse warnings detected during LKP randconfig testing: > >> - Replace plain integer 0 with NULL. > >> - Add static modifier to k230_plls and k230_pll_divs. > >> > >> Reported-by: kernel test robot <lkp@intel.com> > >> Closes: https://lore.kernel.org/oe-kbuild-all/202605220724.j4ZeM3KI-lkp@intel.com/ > >> Signed-off-by: Xukai Wang <kingxukai@zohomail.com> > > Forgot to reply earlier, but I went and squashed this in. > Thanks Conor! I dunno if you saw my message about giving what I have in my branches a go, but if you could try what's in the riscv-soc-for-next branch, that'd be great. Just to make sure that I have all the bits in place. Cheers, Conor.
On 2026/5/23 22:02, Conor Dooley wrote: > On Sat, May 23, 2026 at 03:00:15PM +0800, Xukai Wang wrote: >> On 2026/5/23 04:39, Conor Dooley wrote: >>> On Fri, May 22, 2026 at 08:59:12PM +0800, Xukai Wang wrote: >>>> Fix all sparse warnings detected during LKP randconfig testing: >>>> - Replace plain integer 0 with NULL. >>>> - Add static modifier to k230_plls and k230_pll_divs. >>>> >>>> Reported-by: kernel test robot <lkp@intel.com> >>>> Closes: https://lore.kernel.org/oe-kbuild-all/202605220724.j4ZeM3KI-lkp@intel.com/ >>>> Signed-off-by: Xukai Wang <kingxukai@zohomail.com> >>> Forgot to reply earlier, but I went and squashed this in. >> Thanks Conor! > I dunno if you saw my message about giving what I have in my > branches a go, but if you could try what's in the riscv-soc-for-next > branch, that'd be great. Just to make sure that I have all the bits in > place. I have successfully tested your riscv-soc-for-next branch on K230 hardware. The clock controller probes correctly, and clk_summary shows all PLLs and clocks are running as expected. -- Best regards, Xukai Wang
于 2026年5月23日 GMT+08:00 22:02:31,Conor Dooley <conor@kernel.org> 写道: >On Sat, May 23, 2026 at 03:00:15PM +0800, Xukai Wang wrote: >> >> On 2026/5/23 04:39, Conor Dooley wrote: >> > On Fri, May 22, 2026 at 08:59:12PM +0800, Xukai Wang wrote: >> >> Fix all sparse warnings detected during LKP randconfig testing: >> >> - Replace plain integer 0 with NULL. >> >> - Add static modifier to k230_plls and k230_pll_divs. >> >> >> >> Reported-by: kernel test robot <lkp@intel.com> >> >> Closes: https://lore.kernel.org/oe-kbuild-all/202605220724.j4ZeM3KI-lkp@intel.com/ >> >> Signed-off-by: Xukai Wang <kingxukai@zohomail.com> >> > Forgot to reply earlier, but I went and squashed this in. >> Thanks Conor! > >I dunno if you saw my message about giving what I have in my >branches a go, but if you could try what's in the riscv-soc-for-next >branch, that'd be great. Just to make sure that I have all the bits in >place. OK, I will pull riscv-soc-for-next branch and test it on K230 hardware immediately. And then report back the test results as soon as possible.
On 2026/4/25 17:29, Xukai Wang wrote: > This patch series adds clock controller support for the Canaan Kendryte > K230 SoC. The K230 SoC includes an external 24MHz OSC, 4 internal > PLLs and an external pulse input, with the controller managing these > sources and their derived clocks. > > The clock tree and hardware-specific definition can be found in the > vendor's DTS [1], > and this series is based on the K230 initial series [2]. > > Link: https://github.com/ruyisdk/linux-xuantie-kernel/blob/linux-6.6.36/arch/riscv/boot/dts/canaan/k230_clock_provider.dtsi [1] > Link: https://lore.kernel.org/linux-clk/tencent_F76EB8D731C521C18D5D7C4F8229DAA58E08@qq.com/ [2] > > Co-developed-by: Troy Mitchell <TroyMitchell988@gmail.com> > Signed-off-by: Troy Mitchell <TroyMitchell988@gmail.com> > Signed-off-by: Xukai Wang <kingxukai@zohomail.com> > > --- > Changes in v12: > - Rebase onto linux-next (next-20260421). > - Migrate from deprecated round_rate() clk_ops to determine_rate() API. > - dt-bindings: Drop redundant "bindings for" in commit subject. > - Link to v11: https://lore.kernel.org/r/20260214-b4-k230-clk-v11-0-6de365489b89@zohomail.com Hi Stephen, I hope this email finds you well. I am writing to politely inquire about the status of the Canaan K230 clock controller driver patch series. It has been approximately one and a half years since I first submitted this series, and it has now reached version 12. Most of the intermediate versions contained only minor adjustments and rebases, and I have been resending it periodically without receiving any review feedback. I would greatly appreciate it if you could let me know whether this series is ready for merging, or if there are any specific issues that need to be addressed. I am ready to make any required changes immediately. I apologize for the intrusion and thank you for your time and hard work maintaining the clock subsystem. -- Best regards, Xukai Wang
On 2026/4/25 17:29, Xukai Wang wrote: > This patch series adds clock controller support for the Canaan Kendryte > K230 SoC. The K230 SoC includes an external 24MHz OSC, 4 internal > PLLs and an external pulse input, with the controller managing these > sources and their derived clocks. > > The clock tree and hardware-specific definition can be found in the > vendor's DTS [1], > and this series is based on the K230 initial series [2]. > > Link: https://github.com/ruyisdk/linux-xuantie-kernel/blob/linux-6.6.36/arch/riscv/boot/dts/canaan/k230_clock_provider.dtsi [1] > Link: https://lore.kernel.org/linux-clk/tencent_F76EB8D731C521C18D5D7C4F8229DAA58E08@qq.com/ [2] > > Co-developed-by: Troy Mitchell <TroyMitchell988@gmail.com> > Signed-off-by: Troy Mitchell <TroyMitchell988@gmail.com> > Signed-off-by: Xukai Wang <kingxukai@zohomail.com> > > --- > Changes in v12: > - Rebase onto linux-next (next-20260421). > - Migrate from deprecated round_rate() clk_ops to determine_rate() API. > - dt-bindings: Drop redundant "bindings for" in commit subject. > - Link to v11: https://lore.kernel.org/r/20260214-b4-k230-clk-v11-0-6de365489b89@zohomail.com Hi Stephen, I hope this email finds you well. I am writing to politely inquire about the status of the Canaan K230 clock controller driver patch series. It has been approximately one and a half years since I first submitted this series, and it has now reached version 12. Most of the intermediate versions contained only minor adjustments and rebases, and I have been resending it periodically without receiving any review feedback. I would greatly appreciate it if you could let me know whether this series is ready for merging, or if there are any specific issues that need to be addressed. I am ready to make any required changes immediately. I apologize for the intrusion and thank you for your time and hard work maintaining the clock subsystem. > > Changes in v11: > - Rename hs_hclk_high_src to hs_hclk_high and hs_hclk_src to hs_hclk. > - Rebase base-commit to linux-next. > - Update prerequisite-patch-id. > - Link to v10: https://lore.kernel.org/r/20260116-b4-k230-clk-v10-0-de59033c5d30@zohomail.com > > Changes in v10: > - Drop clock node: cpu1_apb_rate. > - Rename hs_ospi_src to hs_ssi0. > - Rename fixed clocks format in dts. > - Fix missing clk member registration in driver. > - Fix incorrect clk ID: k230_cpu1_src_rate → K230_CPU1_SRC_RATE. > - Fix bit index of hs_hclk_src_gate: 1 → 0. > - Add CLK_IS_CRITICAL to CPU-related gate clocks. > - Update parent clocks: display_clkext_rate, sec_apb_gate, ai_axi_gate, > cpu1_src_mux and hs_sd_card_src_rate. > - Link to v9: https://lore.kernel.org/r/20251127-b4-k230-clk-v9-0-3aa09e17faf5@zohomail.com > > Changes in v9: > - Rebase base-commit to v6.18-rc1 > - Simplified PLL field extraction with FIELD_GET() macro > - Drop MODULE_DEVICE_TABLE for k230_clk_ids > - Replace k230_clk_find_approximate_mul_div's step with > Rational_best_approximation > - Reorder declaration and defination for clk_ops > - Link to v8: https://lore.kernel.org/r/20250905-b4-k230-clk-v8-0-96caa02d5428@zohomail.com > > Changes in v8: > - Rename dts node name "timer_pulse_in" to "clock-50m" > - Drop redundant comment and 'minItems' of hardware in dt-binding. > - Link to v7: https://lore.kernel.org/r/20250730-b4-k230-clk-v7-0-c57d3bb593d3@zohomail.com > > Changes in v7: > - Rename K230_PLL_STATUS_MASK to K230_PLL_LOCK_STATUS_MASK > - Add clkdev for PLLs to register lookup > - Add macros to generate repeat variables definition > - Refine the definitions of k230 clocks > - Split composite clks into rate, gate, mux, fixed_factor clk > - Replace k230_clk_hw_onecell_get with of_clk_hw_onecell_get for > clock provider > - Drop k230_sysclk and use clk_mux, clk_gate and clk_fixed_factor > as the data structures. > - Replace one loop registration with individual registration for > each type. > - Link to v6: https://lore.kernel.org/r/20250415-b4-k230-clk-v6-0-7fd89f427250@zohomail.com > > Changes in v6: > - Remove some redundant comments in struct declaration. > - Replace the Vendor's code source link with a new one. > - Link to v5: https://lore.kernel.org/r/20250320-b4-k230-clk-v5-0-0e9d089c5488@zohomail.com > > Changes in v5: > - Fix incorrect base-commit and add prerequisite-patch-id. > - Replace dummy apb_clk with real ones for UARTs. > - Add IDs of UARTs clock and DMA clocks in the binding header. > - Replace k230_clk_cfgs[] array with corresponding named variables. > - Remove some redundant checks in clk_ops. > - Drop the unnecessary parenthesis and type casts. > - Modify return value handling in probe path to avoid redundant print. > - Link to v4: https://lore.kernel.org/r/20250217-b4-k230-clk-v4-0-5a95a3458691@zohomail.com > > Changes in v4: > - Remove redundant onecell_get callback and add_provider function > for pll_divs. > - Modify the base-commit in cover letter. > - Link to v3: https://lore.kernel.org/r/20250203-b4-k230-clk-v3-0-362c79124572@zohomail.com > > Changes in v3: > - Reorder the defination and declaration in drivers code. > - Reorder the properties in dts node. > - Replace global variable `k230_sysclk` with dynamic memory allocation. > - Rename the macro K230_NUM_CLKS to K230_CLK_NUM. > - Use dev_err_probe for error handling. > - Remove unused includes. > - Link to v2: https://lore.kernel.org/r/20250108-b4-k230-clk-v2-0-27b30a2ca52d@zohomail.com > > Changes in v2: > - Add items and description. > - Rename k230-clk.h to canaan,k230-clk.h > - Link to v1: https://lore.kernel.org/r/20241229-b4-k230-clk-v1-0-221a917e80ed@zohomail.com > > --- > Xukai Wang (3): > dt-bindings: clock: Add Canaan K230 clock controller > clk: canaan: Add clock driver for Canaan K230 > riscv: dts: canaan: Add clock definition for K230 > > .../devicetree/bindings/clock/canaan,k230-clk.yaml | 59 + > arch/riscv/boot/dts/canaan/k230-canmv.dts | 11 + > arch/riscv/boot/dts/canaan/k230-evb.dts | 11 + > arch/riscv/boot/dts/canaan/k230.dtsi | 26 +- > drivers/clk/Kconfig | 6 + > drivers/clk/Makefile | 1 + > drivers/clk/clk-k230.c | 2452 ++++++++++++++++++++ > include/dt-bindings/clock/canaan,k230-clk.h | 220 ++ > 8 files changed, 2778 insertions(+), 8 deletions(-) > --- > base-commit: af98e93c5c39e6d0b87b42f0a32dd3066f795718 > change-id: 20241206-b4-k230-clk-925f33fed6c2 > prerequisite-patch-id: 9a2d01f55574b538dad572e193f81c44661f0853 > > Best regards, > -- > Xukai Wang <kingxukai@zohomail.com> > -- Best regards, Xukai Wang
© 2016 - 2026 Red Hat, Inc.