Skip to content

Commit ee0b043

Browse files
soc: add wch/ch32v307
dts: add riscv/wch/ch32v307 and packages wch has provide a ch32v307 soc series Signed-off-by: Thomas Boje <info@andocs.biz>
1 parent 179045e commit ee0b043

File tree

9 files changed

+290
-0
lines changed

9 files changed

+290
-0
lines changed

dts/bindings/vendor-prefixes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ sandisk Sandisk Corporation
595595
satoz Satoz International Co., Ltd
596596
sbs Smart Battery System
597597
sc Space Cubics, LLC
598+
scdz Shenzhen Qiushi IoT Technology Co., Ltd.
598599
schindler Schindler
599600
sciosense Sciosense B.V.
600601
seagate Seagate Technology PLC

dts/riscv/wch/ch32v307/ch32v307.dtsi

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
/*
2+
* Copyright (c) 2025 Thomas Boje
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <freq.h>
8+
#include <mem.h>
9+
#include <wch/qingke-v4f.dtsi>
10+
#include <zephyr/dt-bindings/gpio/gpio.h>
11+
#include <zephyr/dt-bindings/i2c/i2c.h>
12+
#include <zephyr/dt-bindings/clock/ch32v20x_30x-clocks.h>
13+
14+
/ {
15+
clocks {
16+
clk_hse: clk-hse {
17+
#clock-cells = <0>;
18+
compatible = "wch,ch32v00x-hse-clock";
19+
clock-frequency = <DT_FREQ_M(32)>;
20+
status = "disabled";
21+
};
22+
23+
clk_hsi: clk-hsi {
24+
#clock-cells = <0>;
25+
compatible = "wch,ch32v00x-hsi-clock";
26+
clock-frequency = <DT_FREQ_M(8)>;
27+
status = "disabled";
28+
};
29+
30+
clk_lsi: clk-lsi {
31+
#clock-cells = <0>;
32+
compatible = "fixed-clock";
33+
clock-frequency = <DT_FREQ_K(32)>;
34+
status = "disabled";
35+
};
36+
37+
pll: pll {
38+
#clock-cells = <0>;
39+
compatible = "wch,ch32v20x_30x-pll-clock";
40+
mul = <18>;
41+
status = "disabled";
42+
};
43+
};
44+
45+
soc {
46+
sram0: memory@20000000 {
47+
compatible = "mmio-sram";
48+
reg = <0x20000000 DT_SIZE_K(32)>;
49+
};
50+
51+
flash: flash-controller@40022000 {
52+
compatible = "wch,ch32v20x_30x-flash-controller";
53+
reg = <0x40022000 0x400>;
54+
55+
#address-cells = <1>;
56+
#size-cells = <1>;
57+
58+
flash0: flash@8000000 {
59+
compatible = "soc-nv-flash";
60+
reg = <0x08000000 DT_SIZE_K(480)>;
61+
};
62+
};
63+
64+
pwr: pwr@40007000 {
65+
compatible = "wch,pwr";
66+
reg = <0x40007000 16>;
67+
};
68+
69+
pinctrl: pin-controller@40010000 {
70+
compatible = "wch,20x_30x-afio";
71+
reg = <0x40010000 16>;
72+
#address-cells = <1>;
73+
#size-cells = <1>;
74+
clocks = <&rcc CH32V20X_V30X_CLOCK_AFIO>;
75+
76+
gpioa: gpio@40010800 {
77+
compatible = "wch,gpio";
78+
reg = <0x40010800 0x20>;
79+
gpio-controller;
80+
#gpio-cells = <2>;
81+
ngpios = <8>;
82+
clocks = <&rcc CH32V20X_V30X_CLOCK_IOPA>;
83+
};
84+
85+
gpiob: gpio@40010C00 {
86+
compatible = "wch,gpio";
87+
reg = <0x40010C00 0x20>;
88+
gpio-controller;
89+
#gpio-cells = <2>;
90+
ngpios = <8>;
91+
clocks = <&rcc CH32V20X_V30X_CLOCK_IOPB>;
92+
};
93+
94+
gpioc: gpio@40011000 {
95+
compatible = "wch,gpio";
96+
reg = <0x40011000 0x20>;
97+
gpio-controller;
98+
#gpio-cells = <2>;
99+
ngpios = <8>;
100+
clocks = <&rcc CH32V20X_V30X_CLOCK_IOPC>;
101+
};
102+
103+
gpiod: gpio@40011400 {
104+
compatible = "wch,gpio";
105+
reg = <0x40011400 0x20>;
106+
gpio-controller;
107+
#gpio-cells = <2>;
108+
ngpios = <8>;
109+
clocks = <&rcc CH32V20X_V30X_CLOCK_IOPD>;
110+
};
111+
112+
gpioe: gpio@40011800 {
113+
compatible = "wch,gpio";
114+
reg = <0x40011800 0x20>;
115+
gpio-controller;
116+
#gpio-cells = <2>;
117+
ngpios = <8>;
118+
clocks = <&rcc CH32V20X_V30X_CLOCK_IOPE>;
119+
};
120+
};
121+
122+
usart1: uart@40013800 {
123+
compatible = "wch,usart";
124+
reg = <0x40013800 0x20>;
125+
clocks = <&rcc CH32V20X_V30X_CLOCK_USART1>;
126+
interrupt-parent = <&pfic>;
127+
interrupts = <53>;
128+
status = "disabled";
129+
};
130+
131+
usart2: uart@40004400 {
132+
compatible = "wch,usart";
133+
reg = <0x40004400 0x20>;
134+
clocks = <&rcc CH32V20X_V30X_CLOCK_USART2>;
135+
interrupt-parent = <&pfic>;
136+
interrupts = <54>;
137+
status = "disabled";
138+
};
139+
140+
usart3: uart@40004800 {
141+
compatible = "wch,usart";
142+
reg = <0x40004800 0x20>;
143+
clocks = <&rcc CH32V20X_V30X_CLOCK_USART3>;
144+
interrupt-parent = <&pfic>;
145+
interrupts = <55>;
146+
status = "disabled";
147+
};
148+
149+
usart4: uart@40004c00 {
150+
compatible = "wch,usart";
151+
reg = <0x40004C00 0x20>;
152+
clocks = <&rcc CH32V20X_V30X_CLOCK_USART4>;
153+
interrupt-parent = <&pfic>;
154+
interrupts = <68>;
155+
status = "disabled";
156+
};
157+
158+
usart5: uart@40005000 {
159+
compatible = "wch,usart";
160+
reg = <0x40005000 0x20>;
161+
clocks = <&rcc CH32V20X_V30X_CLOCK_USART5>;
162+
interrupt-parent = <&pfic>;
163+
interrupts = <69>;
164+
status = "disabled";
165+
};
166+
167+
usart6: uart@40001800 {
168+
compatible = "wch,usart";
169+
reg = <0x40001800 0x20>;
170+
clocks = <&rcc CH32V20X_V30X_CLOCK_USART6>;
171+
interrupt-parent = <&pfic>;
172+
interrupts = <87>;
173+
status = "disabled";
174+
};
175+
176+
usart7: uart@40001c00 {
177+
compatible = "wch,usart";
178+
reg = <0x40001c00 0x20>;
179+
clocks = <&rcc CH32V20X_V30X_CLOCK_USART7>;
180+
interrupt-parent = <&pfic>;
181+
interrupts = <88>;
182+
status = "disabled";
183+
};
184+
185+
usart8: uart@40002000 {
186+
compatible = "wch,usart";
187+
reg = <0x40002000 0x20>;
188+
clocks = <&rcc CH32V20X_V30X_CLOCK_USART8>;
189+
interrupt-parent = <&pfic>;
190+
interrupts = <89>;
191+
status = "disabled";
192+
};
193+
194+
rcc: rcc@40021000 {
195+
compatible = "wch,rcc";
196+
reg = <0x40021000 16>;
197+
#clock-cells = <1>;
198+
status = "okay";
199+
};
200+
201+
dma1: dma@40020000 {
202+
compatible = "wch,wch-dma";
203+
reg = <0x40020000 0x90>;
204+
clocks = <&rcc CH32V20X_V30X_CLOCK_DMA1>;
205+
#dma-cells = <1>;
206+
interrupt-parent = <&pfic>;
207+
interrupts = <27>, <28>, <29>, <30>, <31>, <32>, <33>;
208+
dma-channels = <7>;
209+
};
210+
211+
dma2: dma@40020400 {
212+
compatible = "wch,wch-dma";
213+
reg = <0x40020400 0x90>;
214+
clocks = <&rcc CH32V20X_V30X_CLOCK_DMA2>;
215+
#dma-cells = <1>;
216+
interrupt-parent = <&pfic>;
217+
interrupts = <72>, <73>, <74>, <75>, <76>, <98>, <99>, <100>,
218+
<101>, <102>, <103>;
219+
dma-channels = <11>;
220+
};
221+
};
222+
};
223+
224+
&cpu0 {
225+
clock-frequency = <DT_FREQ_M(127)>;
226+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2025 Thomas Boje
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <wch/ch32v307/ch32v307.dtsi>
8+
9+
&gpiod {
10+
gpio-reserved-ranges = <3 13>;
11+
};
12+
13+
&gpioe {
14+
gpio-reserved-ranges = <0 16>;
15+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* Copyright (c) 2025 Thomas Boje
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <wch/ch32v307/ch32v307.dtsi>
8+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2025 Thomas Boje
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <wch/ch32v307/ch32v307.dtsi>
8+
9+
&gpiod {
10+
gpio-reserved-ranges = <3 5>, <10 6>;
11+
};
12+
13+
&gpioe {
14+
gpio-reserved-ranges = <1 15>;
15+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) 2025 Thomas Boje
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if SOC_CH32V307
5+
6+
config VECTOR_TABLE_SIZE
7+
default 103
8+
9+
config NUM_IRQS
10+
default 128
11+
12+
endif # SOC_CH32V307
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 Thomas Boje
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SOC_CH32V307
5+
bool
6+
select SOC_SERIES_QINGKE_V4F
7+
8+
config SOC
9+
default "ch32v307" if SOC_CH32V307

soc/wch/ch32v/qingke_v4f/vector.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ GTEXT(__initialize)
1818

1919
SECTION_FUNC(vectors, ivt)
2020
.option norvc
21+
#ifndef SOC_CH32V307
2122
/* Jump to 0x08000008, into the main flash zone where j __start is */
2223
lui x5, 0x8000
2324
jr 0x8(x5)
25+
#endif // SOC_CH32V307
2426
j __start
2527
.rept CONFIG_VECTOR_TABLE_SIZE
2628
.word _isr_wrapper

soc/wch/ch32v/soc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2024 Michael Hope
2+
# Copyright (c) 2025 Thomas Boje
23
# SPDX-License-Identifier: Apache-2.0
34

45
family:
@@ -19,3 +20,4 @@ family:
1920
- name: qingke-v4f
2021
socs:
2122
- name: ch32v303
23+
- name: ch32v307

0 commit comments

Comments
 (0)