This patch describes the clock controller integrated in K230 SoC
and replace dummy clocks with the real ones for UARTs.
For k230-canmv and k230-evb, they provide an additional external
pulse input through a pin to serve as clock source.
Co-developed-by: Troy Mitchell <TroyMitchell988@gmail.com>
Signed-off-by: Troy Mitchell <TroyMitchell988@gmail.com>
Signed-off-by: Xukai Wang <kingxukai@zohomail.com>
---
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 ++++++++++++++++++--------
3 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/arch/riscv/boot/dts/canaan/k230-canmv.dts b/arch/riscv/boot/dts/canaan/k230-canmv.dts
index 9565915cead6ad2381ea8249b616e79575feb896..6579d39e2c1690d9e9c2b9c884db528c37473204 100644
--- a/arch/riscv/boot/dts/canaan/k230-canmv.dts
+++ b/arch/riscv/boot/dts/canaan/k230-canmv.dts
@@ -17,8 +17,19 @@ ddr: memory@0 {
device_type = "memory";
reg = <0x0 0x0 0x0 0x20000000>;
};
+
+ timerx_pulse_in: timer_pulse_in {
+ compatible = "fixed-clock";
+ clock-frequency = <50000000>;
+ #clock-cells = <0>;
+ };
};
&uart0 {
status = "okay";
};
+
+&sysclk {
+ clocks = <&osc24m>, <&timerx_pulse_in>;
+ clock-names = "osc24m", "timer-pulse-in";
+};
diff --git a/arch/riscv/boot/dts/canaan/k230-evb.dts b/arch/riscv/boot/dts/canaan/k230-evb.dts
index f898b8e62368c3740d6795fd1e3cb0b261a460ac..64fbb5036b6e919662c8d66adb8f102a698318bf 100644
--- a/arch/riscv/boot/dts/canaan/k230-evb.dts
+++ b/arch/riscv/boot/dts/canaan/k230-evb.dts
@@ -17,8 +17,19 @@ ddr: memory@0 {
device_type = "memory";
reg = <0x0 0x0 0x0 0x20000000>;
};
+
+ timerx_pulse_in: timer_pulse_in {
+ compatible = "fixed-clock";
+ clock-frequency = <50000000>;
+ #clock-cells = <0>;
+ };
};
&uart0 {
status = "okay";
};
+
+&sysclk {
+ clocks = <&osc24m>, <&timerx_pulse_in>;
+ clock-names = "osc24m", "timer-pulse-in";
+};
diff --git a/arch/riscv/boot/dts/canaan/k230.dtsi b/arch/riscv/boot/dts/canaan/k230.dtsi
index 95c1a3d8fb1192e30113d96d3e96329545bc6ae7..5a7a13117a779637fa33e91dce47430455c0f949 100644
--- a/arch/riscv/boot/dts/canaan/k230.dtsi
+++ b/arch/riscv/boot/dts/canaan/k230.dtsi
@@ -3,6 +3,7 @@
* Copyright (C) 2024 Yangyu Chen <cyy@cyyself.name>
*/
+#include <dt-bindings/clock/canaan,k230-clk.h>
#include <dt-bindings/interrupt-controller/irq.h>
/dts-v1/;
@@ -58,10 +59,10 @@ l2_cache: l2-cache {
};
};
- apb_clk: apb-clk-clock {
+ osc24m: clock-24m {
compatible = "fixed-clock";
- clock-frequency = <50000000>;
- clock-output-names = "apb_clk";
+ clock-frequency = <24000000>;
+ clock-output-names = "osc24m";
#clock-cells = <0>;
};
@@ -89,10 +90,19 @@ clint: timer@f04000000 {
interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
};
+ sysclk: clock-controller@91102000 {
+ compatible = "canaan,k230-clk";
+ reg = <0x0 0x91102000 0x0 0x40>,
+ <0x0 0x91100000 0x0 0x108>;
+ clocks = <&osc24m>;
+ clock-names = "osc24m";
+ #clock-cells = <1>;
+ };
+
uart0: serial@91400000 {
compatible = "snps,dw-apb-uart";
reg = <0x0 0x91400000 0x0 0x1000>;
- clocks = <&apb_clk>;
+ clocks = <&sysclk K230_LS_UART0_RATE>;
interrupts = <16 IRQ_TYPE_LEVEL_HIGH>;
reg-io-width = <4>;
reg-shift = <2>;
@@ -102,7 +112,7 @@ uart0: serial@91400000 {
uart1: serial@91401000 {
compatible = "snps,dw-apb-uart";
reg = <0x0 0x91401000 0x0 0x1000>;
- clocks = <&apb_clk>;
+ clocks = <&sysclk K230_LS_UART1_RATE>;
interrupts = <17 IRQ_TYPE_LEVEL_HIGH>;
reg-io-width = <4>;
reg-shift = <2>;
@@ -112,7 +122,7 @@ uart1: serial@91401000 {
uart2: serial@91402000 {
compatible = "snps,dw-apb-uart";
reg = <0x0 0x91402000 0x0 0x1000>;
- clocks = <&apb_clk>;
+ clocks = <&sysclk K230_LS_UART2_RATE>;
interrupts = <18 IRQ_TYPE_LEVEL_HIGH>;
reg-io-width = <4>;
reg-shift = <2>;
@@ -122,7 +132,7 @@ uart2: serial@91402000 {
uart3: serial@91403000 {
compatible = "snps,dw-apb-uart";
reg = <0x0 0x91403000 0x0 0x1000>;
- clocks = <&apb_clk>;
+ clocks = <&sysclk K230_LS_UART3_RATE>;
interrupts = <19 IRQ_TYPE_LEVEL_HIGH>;
reg-io-width = <4>;
reg-shift = <2>;
@@ -132,7 +142,7 @@ uart3: serial@91403000 {
uart4: serial@91404000 {
compatible = "snps,dw-apb-uart";
reg = <0x0 0x91404000 0x0 0x1000>;
- clocks = <&apb_clk>;
+ clocks = <&sysclk K230_LS_UART4_RATE>;
interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
reg-io-width = <4>;
reg-shift = <2>;
--
2.34.1
On Wed, Jul 30, 2025 at 02:43:53AM +0800, Xukai Wang wrote: > This patch describes the clock controller integrated in K230 SoC > and replace dummy clocks with the real ones for UARTs. > > For k230-canmv and k230-evb, they provide an additional external > pulse input through a pin to serve as clock source. > > Co-developed-by: Troy Mitchell <TroyMitchell988@gmail.com> > Signed-off-by: Troy Mitchell <TroyMitchell988@gmail.com> > Signed-off-by: Xukai Wang <kingxukai@zohomail.com> > --- > 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 ++++++++++++++++++-------- > 3 files changed, 40 insertions(+), 8 deletions(-) > > diff --git a/arch/riscv/boot/dts/canaan/k230-canmv.dts b/arch/riscv/boot/dts/canaan/k230-canmv.dts > index 9565915cead6ad2381ea8249b616e79575feb896..6579d39e2c1690d9e9c2b9c884db528c37473204 100644 > --- a/arch/riscv/boot/dts/canaan/k230-canmv.dts > +++ b/arch/riscv/boot/dts/canaan/k230-canmv.dts > @@ -17,8 +17,19 @@ ddr: memory@0 { > device_type = "memory"; > reg = <0x0 0x0 0x0 0x20000000>; > }; > + > + timerx_pulse_in: timer_pulse_in { Follow DTS coding style. Please use name for all fixed clocks which matches current format recommendation: 'clock-<freq>' (see also the pattern in the binding for any other options). https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/clock/fixed-clock.yaml?h=v6.11-rc1 Best regards, Krzysztof
On 2025/7/30 15:06, Krzysztof Kozlowski wrote: > On Wed, Jul 30, 2025 at 02:43:53AM +0800, Xukai Wang wrote: >> This patch describes the clock controller integrated in K230 SoC >> and replace dummy clocks with the real ones for UARTs. >> >> For k230-canmv and k230-evb, they provide an additional external >> pulse input through a pin to serve as clock source. >> >> Co-developed-by: Troy Mitchell <TroyMitchell988@gmail.com> >> Signed-off-by: Troy Mitchell <TroyMitchell988@gmail.com> >> Signed-off-by: Xukai Wang <kingxukai@zohomail.com> >> --- >> 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 ++++++++++++++++++-------- >> 3 files changed, 40 insertions(+), 8 deletions(-) >> >> diff --git a/arch/riscv/boot/dts/canaan/k230-canmv.dts b/arch/riscv/boot/dts/canaan/k230-canmv.dts >> index 9565915cead6ad2381ea8249b616e79575feb896..6579d39e2c1690d9e9c2b9c884db528c37473204 100644 >> --- a/arch/riscv/boot/dts/canaan/k230-canmv.dts >> +++ b/arch/riscv/boot/dts/canaan/k230-canmv.dts >> @@ -17,8 +17,19 @@ ddr: memory@0 { >> device_type = "memory"; >> reg = <0x0 0x0 0x0 0x20000000>; >> }; >> + >> + timerx_pulse_in: timer_pulse_in { > Follow DTS coding style. > > Please use name for all fixed clocks which matches current format > recommendation: 'clock-<freq>' (see also the pattern in the binding for > any other options). > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/clock/fixed-clock.yaml?h=v6.11-rc1 Got it, I'll update it to clock-50m as recommended. Thanks for pointing it out. > > Best regards, > Krzysztof >
© 2016 - 2025 Red Hat, Inc.