-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Add support for WCH CH32L103 #89451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for WCH CH32L103 #89451
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (c) 2025 Paul Wedeck | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <wch/ch32v208/ch32v208.dtsi> | ||
|
||
|
||
/ { | ||
soc { | ||
dma1: dma@40020000 { | ||
compatible = "wch,wch-dma"; | ||
reg = <0x40020000 0x90>; | ||
clocks = <&rcc CH32V20X_V30X_CLOCK_DMA1>; | ||
#dma-cells = <1>; | ||
interrupt-parent = <&pfic>; | ||
interrupts = <27>, <28>, <29>, <30>, <31>, <32>, <33>, <62>; | ||
dma-channels = <8>; | ||
}; | ||
}; | ||
}; | ||
|
||
&clk_hse { | ||
clock-frequency = <DT_FREQ_M(25)>; | ||
}; | ||
|
||
&clk_lsi { | ||
clock-frequency = <DT_FREQ_K(40)>; | ||
}; | ||
|
||
&sram0 { | ||
reg = <0x20000000 DT_SIZE_K(20)>; | ||
}; | ||
|
||
&flash { | ||
reg = <0x40022000 0x28>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very similar to the definition in ch32v208.dtsi. Is the included file wrong? If so, should this fix be there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, this was already wrong for the v208. Should I include a commit here or add a separate pr? |
||
}; | ||
|
||
&flash0 { | ||
reg = <0 DT_SIZE_K(64)>; | ||
}; | ||
|
||
&gpioa { | ||
ngpios = <16>; | ||
}; | ||
|
||
&gpiob { | ||
ngpios = <16>; | ||
}; | ||
|
||
&gpioc { | ||
gpio-reserved-ranges = <0 13>; | ||
ngpios = <16>; | ||
}; | ||
|
||
&gpiod { | ||
ngpios = <2>; | ||
}; | ||
|
||
&usart4 { | ||
interrupts = <61>; | ||
}; | ||
|
||
&cpu0 { | ||
clock-frequency = <DT_FREQ_M(96)>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright (c) 2025 Paul Wedeck | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <wch/ch32l103/ch32l103.dtsi> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright (c) 2025 Paul Wedeck | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <wch/ch32l103/ch32l103.dtsi> | ||
|
||
&gpioa { | ||
gpio-reserved-ranges = <9, 3>, <15, 1>; | ||
}; | ||
|
||
&gpiob { | ||
gpio-reserved-ranges = <0, 1>, <2, 4>, <9, 7>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright (c) 2025 Paul Wedeck | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <wch/ch32l103/ch32l103.dtsi> | ||
|
||
&gpioa { | ||
gpio-reserved-ranges = <15, 1>; | ||
}; | ||
|
||
&gpiob { | ||
gpio-reserved-ranges = <2, 4>, <8, 2>, <12, 1>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright (c) 2025 Paul Wedeck | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <wch/ch32l103/ch32l103.dtsi> | ||
|
||
&gpioa { | ||
gpio-reserved-ranges = <15, 1>; | ||
}; | ||
|
||
&gpiob { | ||
gpio-reserved-ranges = <2, 1>, <4, 1>, <9, 1>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright (c) 2025 Paul Wedeck | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <wch/ch32l103/ch32l103.dtsi> | ||
|
||
&gpiob { | ||
gpio-reserved-ranges = <10, 5>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) 2025 Paul Wedeck | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
if SOC_CH32L103 | ||
|
||
config VECTOR_TABLE_SIZE | ||
default 68 | ||
|
||
config NUM_IRQS | ||
default 128 | ||
|
||
endif # SOC_CH32L103 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2025 Paul Wedeck | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config SOC_CH32L103 | ||
bool | ||
select SOC_SERIES_QINGKE_V4C | ||
|
||
config SOC | ||
default "ch32l103" if SOC_CH32L103 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ family: | |
- name: qingke-v4c | ||
socs: | ||
- name: ch32v208 | ||
- name: ch32l103 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HSE frequency depends on the crystal on the board, so move this out to the board definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why I set it here is because ch32v208.dtsi sets it to a value larger than is supported by the l103.
The board uses a 8MHz crystal and sets the correct frequency in the board dts, so this rather marks the max value instead of the actual value.
Is is this a valid reasoning (for zephyr) or should I remove this part?