Skip to content
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 CH56x series SoC #64472

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

xingrz
Copy link
Member

@xingrz xingrz commented Oct 27, 2023

QingKe is a series of RISC-V cores developed by WCH, consisting with V2A, V3A and V4B/C/F series of MCUs.

CH569/CH565 are 2 of the members of the QingKe V3A series. This PR brings initial support for these two SoCs to Zephyr.

In summary, this PR includes:

  • An interrupt controller for all QingKe MCUs.
  • A systick driver for the QingKe V3 series.
  • Clock controller and GPIO, UART driver specifically for the CH56x MCUs.
  • Configurations for the official CH565W-EVT and CH569W-EVT evaluation boards

Support for other series members will be submit in future PRs.

References:

TODOs

@xingrz
Copy link
Member Author

xingrz commented May 20, 2024

@xingrz I will output the uart0 of ch592f as the console, with a baud rate of 115200. However, the actual baud rate seen on the oscilloscope is 114khz. I am not sure where the problem is and how to modify it. I look forward to your prompt. Thank you!

Maybe you need to revert the latest [WIP] TICKLESS] commit from that branch.

We're off-topic. You can contact me from the official Discord.

@Colt-Ma

This comment was marked as off-topic.

Copy link

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.

@xingrz xingrz force-pushed the wch/pr/ch56x-bringup branch 2 times, most recently from cc6495c to e6ed4e0 Compare September 4, 2024 14:58
NOTE: Duplicated with an existing PR. Leaving this commit here just as
a placeholder. Will be rebased soon after that existing PR get merged.

==========================================================================

In certain cases, platforms may have their own implemented interrupt
controllers (e.g., the PFIC on WCH MCUs) that require the ability to
implement the irq_enable/disable functions at the SoC level.

Similar support already exists for ARM and ARM64. This commit adds support
for RISC-V as well.

Signed-off-by: Chen Xingyu <[email protected]>

# Conflicts:
#	include/zephyr/arch/riscv/irq.h
QingKe V3 is an RV32IMAC core developed by WCH

Signed-off-by: Chen Xingyu <[email protected]>
Based on QingKe V3A core, CH569/5 are members of the CH56x series.

Signed-off-by: Chen Xingyu <[email protected]>
PFIC (Programmable Fast Interrupt Controller) is the interrupt controller
implmentation in WCH QingKe series RISC-V MCUs.

Signed-off-by: Chen Xingyu <[email protected]>

# Conflicts:
#	drivers/interrupt_controller/CMakeLists.txt
#	drivers/interrupt_controller/Kconfig
This driver is shared across QingKe V3A series, including CH32V103,
CH569/5 and CH573/1.

Signed-off-by: Chen Xingyu <[email protected]>
This commit describes the system control block of the CH56x in DTS. This
block will be utilized in future drivers for functions such as pin
remapping, clock control, and interrupt management.

Additionally, macros has been added to facilitate easy access to the block.

Signed-off-by: Chen Xingyu <[email protected]>
The CH56x can be configured to run on a 30MHz external oscillator or a
480MHz PLL generated by the USB PHY.

This commit introduces a clock controller that can automatically select
one of the two available clock sources and determine the appropriate
divisor based on the given frequency.

The `CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC` value is also updated with the
selected frequency.

Signed-off-by: Chen Xingyu <[email protected]>

# Conflicts:
#	drivers/clock_control/Kconfig
#	soc/riscv/riscv-privileged/wch_ch32v/Kconfig.defconfig.ch56x
This commit implements a GPIO driver for CH56x series.

The 2 instances of GPIO share a same IRQ line on this chip. So the config
`SHARED_IRQ` is selected as well.

Signed-off-by: Chen Xingyu <[email protected]>
This commit introduces a pinctrl driver for the CH5xx series.

The limitations of pin multiplexing of WCH CH5xx series are described
in the binding configuration.

Signed-off-by: Chen Xingyu <[email protected]>
This commit introduces UART driver for CH5xx series, supporting both
polling and interrupt-driven mode.

Signed-off-by: Chen Xingyu <[email protected]>
`WCHISPTool_CMD` is the commandline version of WCHISPTool, which is a USB
flashing tool for WCH series MCUs.

Signed-off-by: Chen Xingyu <[email protected]>
CH565W-EVT and CH569W-EVT are boards by WCH for the evaluation of
CH565W and CH569W chips.

Signed-off-by: Chen Xingyu <[email protected]>
* Add `WCH Platforms` section
* Add `xingrz` to maintainers of `WCH Platform`

Signed-off-by: Chen Xingyu <[email protected]>
@goutnet
Copy link

goutnet commented Oct 15, 2024

I am very interested to follow this PR, how can I help @xingrz

@soburi
Copy link
Member

soburi commented Oct 15, 2024

@xingrz

#66505 seems like a long-term task to finish.
I propose this PR progressing with the current ISR implementation.
What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.