-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
base: main
Are you sure you want to change the base?
Add support for WCH CH32L103 #89451
Conversation
Fix clock selection for CH32L103 because it requires setting flash wait states for higher frequencies. Signed-off-by: Paul Wedeck <paulwedeck@gmail.com>
Introduces V4C-based CH32L103 SoC similar to CH32V208.
This board features a 32bit CH32L103C8T6 microcontroller similar to other CH32 systems. Signed-off-by: Paul Wedeck <paulwedeck@gmail.com>
Thanks! |
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.
LGTM, thanks!
@@ -132,6 +132,16 @@ static int clock_control_wch_rcc_init(const struct device *dev) | |||
} | |||
} | |||
|
|||
#if defined(CONFIG_SOC_CH32L103) | |||
if(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC > 72*1000*1000) { |
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.
optional: I have something similar in 51cc459
If you want, please pull the change in and make this match the same style.
I'm not worried if you don't as I can fix it when I send my PR out for review.
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.
I would like to but the l103 is not yet supported by ch32fun.
I just use the headers for the v208 which does not include the necessary defines (probably because it doesn't apply to the v208).
}; | ||
|
||
&clk_hse { | ||
clock-frequency = <DT_FREQ_M(25)>; |
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?
}; | ||
|
||
&flash { | ||
reg = <0x40022000 0x28>; |
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.
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 comment
The 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?
@@ -0,0 +1,21 @@ | |||
/* | |||
* Copyright (c) 2024 Michael Hope <michaelh@juju.nz> |
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.
I"m fine if you want to rewrite the copyright here.
drive-push-pull; | ||
slew-rate = "max-speed-10mhz"; | ||
}; | ||
group2 { |
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.
newline gap between child nodes
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.
put through https://tinypng.com/
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This pr adds support for the ch32l103 SoC and ch32l103evt board.
The code is mostly based on the ch32v208.