soc: wch: Introduce Qingke V4B
Introduces the Soc for ch32v203 Signed-off-by: Camille BAUD <mail@massdriver.space>
This commit is contained in:
parent
88b108d201
commit
72dadd3242
10 changed files with 162 additions and 0 deletions
10
soc/wch/ch32v/qingke_v4b/CMakeLists.txt
Normal file
10
soc/wch/ch32v/qingke_v4b/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Copyright (c) 2024 Michael Hope
|
||||||
|
# Copyright (c) 2024 Jianxiong Gu
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
zephyr_sources(
|
||||||
|
soc_irq.S
|
||||||
|
vector.S
|
||||||
|
)
|
||||||
|
|
||||||
|
zephyr_include_directories(.)
|
10
soc/wch/ch32v/qingke_v4b/Kconfig
Normal file
10
soc/wch/ch32v/qingke_v4b/Kconfig
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Copyright (c) 2025 MASSDRIVER EI (massdriver.space)
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
config SOC_SERIES_QINGKE_V4B
|
||||||
|
select RISCV_ISA_RV32I
|
||||||
|
select RISCV_ISA_EXT_M
|
||||||
|
select RISCV_ISA_EXT_A
|
||||||
|
select RISCV_ISA_EXT_C
|
||||||
|
select RISCV_ISA_EXT_ZICSR
|
||||||
|
select RISCV_ISA_EXT_ZIFENCEI
|
14
soc/wch/ch32v/qingke_v4b/Kconfig.defconfig
Normal file
14
soc/wch/ch32v/qingke_v4b/Kconfig.defconfig
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Copyright (c) 2025 MASSDRIVER EI (massdriver.space)
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
if SOC_SERIES_QINGKE_V4B
|
||||||
|
|
||||||
|
config SYS_CLOCK_HW_CYCLES_PER_SEC
|
||||||
|
default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)
|
||||||
|
|
||||||
|
config CLOCK_CONTROL
|
||||||
|
default y
|
||||||
|
|
||||||
|
rsource "Kconfig.defconfig.*"
|
||||||
|
|
||||||
|
endif # SOC_SERIES_QINGKE_V4B
|
12
soc/wch/ch32v/qingke_v4b/Kconfig.defconfig.ch32v203
Normal file
12
soc/wch/ch32v/qingke_v4b/Kconfig.defconfig.ch32v203
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# Copyright (c) 2025 MASSDRIVER EI (massdriver.space)
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
if SOC_CH32V203
|
||||||
|
|
||||||
|
config VECTOR_TABLE_SIZE
|
||||||
|
default 103
|
||||||
|
|
||||||
|
config NUM_IRQS
|
||||||
|
default 128
|
||||||
|
|
||||||
|
endif # SOC_CH32V203
|
11
soc/wch/ch32v/qingke_v4b/Kconfig.soc
Normal file
11
soc/wch/ch32v/qingke_v4b/Kconfig.soc
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# Copyright (c) 2025 MASSDRIVER EI (massdriver.space)
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
config SOC_SERIES_QINGKE_V4B
|
||||||
|
bool
|
||||||
|
select SOC_FAMILY_CH32V
|
||||||
|
|
||||||
|
config SOC_SERIES
|
||||||
|
default "qingke_v4b" if SOC_SERIES_QINGKE_V4B
|
||||||
|
|
||||||
|
rsource "Kconfig.soc.*"
|
9
soc/wch/ch32v/qingke_v4b/Kconfig.soc.ch32v203
Normal file
9
soc/wch/ch32v/qingke_v4b/Kconfig.soc.ch32v203
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Copyright (c) 2025 MASSDRIVER EI (massdriver.space)
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
config SOC_CH32V203
|
||||||
|
bool
|
||||||
|
select SOC_SERIES_QINGKE_V4B
|
||||||
|
|
||||||
|
config SOC
|
||||||
|
default "ch32v203" if SOC_CH32V203
|
42
soc/wch/ch32v/qingke_v4b/pinctrl_soc.h
Normal file
42
soc/wch/ch32v/qingke_v4b/pinctrl_soc.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 Michael Hope
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __PINCTRL_SOC_H__
|
||||||
|
#define __PINCTRL_SOC_H__
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type to hold a pin's pinctrl configuration.
|
||||||
|
*/
|
||||||
|
struct ch32v203_pinctrl_soc_pin {
|
||||||
|
uint32_t config: 22;
|
||||||
|
bool bias_pull_up: 1;
|
||||||
|
bool bias_pull_down: 1;
|
||||||
|
bool drive_open_drain: 1;
|
||||||
|
bool drive_push_pull: 1;
|
||||||
|
bool output_high: 1;
|
||||||
|
bool output_low: 1;
|
||||||
|
uint8_t slew_rate: 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct ch32v203_pinctrl_soc_pin pinctrl_soc_pin_t;
|
||||||
|
|
||||||
|
#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \
|
||||||
|
{ \
|
||||||
|
.config = DT_PROP_BY_IDX(node_id, prop, idx), \
|
||||||
|
.bias_pull_up = DT_PROP(node_id, bias_pull_up), \
|
||||||
|
.bias_pull_down = DT_PROP(node_id, bias_pull_down), \
|
||||||
|
.drive_open_drain = DT_PROP(node_id, drive_open_drain), \
|
||||||
|
.drive_push_pull = DT_PROP(node_id, drive_push_pull), \
|
||||||
|
.output_high = DT_PROP(node_id, output_high), \
|
||||||
|
.output_low = DT_PROP(node_id, output_low), \
|
||||||
|
.slew_rate = DT_ENUM_IDX(node_id, slew_rate), \
|
||||||
|
},
|
||||||
|
|
||||||
|
#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \
|
||||||
|
{DT_FOREACH_CHILD_VARGS(DT_PHANDLE(node_id, prop), DT_FOREACH_PROP_ELEM, pinmux, \
|
||||||
|
Z_PINCTRL_STATE_PIN_INIT)}
|
||||||
|
|
||||||
|
#endif
|
19
soc/wch/ch32v/qingke_v4b/soc_irq.S
Normal file
19
soc/wch/ch32v/qingke_v4b/soc_irq.S
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
/* Copyright (c) 2024 Michael Hope
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <offsets.h>
|
||||||
|
#include <zephyr/toolchain.h>
|
||||||
|
|
||||||
|
/* Exports */
|
||||||
|
GTEXT(__soc_is_irq)
|
||||||
|
GTEXT(__soc_handle_irq)
|
||||||
|
|
||||||
|
SECTION_FUNC(exception.other, __soc_is_irq)
|
||||||
|
csrr a0, mcause
|
||||||
|
srli a0, a0, 31
|
||||||
|
ret
|
||||||
|
|
||||||
|
SECTION_FUNC(exception.other, __soc_handle_irq)
|
||||||
|
ret
|
32
soc/wch/ch32v/qingke_v4b/vector.S
Normal file
32
soc/wch/ch32v/qingke_v4b/vector.S
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 Michael Hope
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <zephyr/toolchain.h>
|
||||||
|
|
||||||
|
#ifndef CONFIG_VECTOR_TABLE_SIZE
|
||||||
|
#error "VECTOR_TABLE_SIZE must be defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Exports */
|
||||||
|
GTEXT(__start)
|
||||||
|
|
||||||
|
/* Imports */
|
||||||
|
GTEXT(__initialize)
|
||||||
|
|
||||||
|
SECTION_FUNC(vectors, ivt)
|
||||||
|
.option norvc
|
||||||
|
/* Jump to 0x08000008, into the main flash zone where j __start is */
|
||||||
|
lui x5, 0x8000
|
||||||
|
jr 0x8(x5)
|
||||||
|
j __start
|
||||||
|
.rept CONFIG_VECTOR_TABLE_SIZE
|
||||||
|
.word _isr_wrapper
|
||||||
|
.endr
|
||||||
|
|
||||||
|
SECTION_FUNC(vectors, __start)
|
||||||
|
li a0, 0xf
|
||||||
|
csrw mtvec, a0
|
||||||
|
j __initialize
|
|
@ -13,3 +13,6 @@ family:
|
||||||
- name: qingke-v4c
|
- name: qingke-v4c
|
||||||
socs:
|
socs:
|
||||||
- name: ch32v208
|
- name: ch32v208
|
||||||
|
- name: qingke-v4b
|
||||||
|
socs:
|
||||||
|
- name: ch32v203
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue