soc: wch: reorganize series directories by core

Place ch32v003 under the qingke_v2a series.
Place qingke series under the ch32v family.

Signed-off-by: Jianxiong Gu <jianxiong.gu@outlook.com>
This commit is contained in:
Jianxiong Gu 2024-12-12 03:57:22 +08:00 committed by Benjamin Cabé
commit 384144dc65
15 changed files with 78 additions and 26 deletions

View file

@ -0,0 +1,6 @@
# Copyright (c) 2024 Michael Hope
# SPDX-License-Identifier: Apache-2.0
add_subdirectory(${SOC_SERIES})
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/riscv/common/linker.ld CACHE INTERNAL "")

15
soc/wch/ch32v/Kconfig Normal file
View file

@ -0,0 +1,15 @@
# Copyright (c) 2024 Michael Hope
# SPDX-License-Identifier: Apache-2.0
config SOC_FAMILY_CH32V
select RISCV
select BUILD_OUTPUT_HEX
select CH32V00X_SYSTICK
select ATOMIC_OPERATIONS_C
imply XIP
if SOC_FAMILY_CH32V
rsource "*/Kconfig"
endif # SOC_FAMILY_CH32V

View file

@ -0,0 +1,9 @@
# Copyright (c) 2024 Michael Hope
# Copyright (c) 2024 Jianxiong Gu
# SPDX-License-Identifier: Apache-2.0
if SOC_FAMILY_CH32V
rsource "*/Kconfig.defconfig"
endif # SOC_FAMILY_CH32V

11
soc/wch/ch32v/Kconfig.soc Normal file
View file

@ -0,0 +1,11 @@
# Copyright (c) 2024 Michael Hope
# Copyright (c) 2024 Jianxiong Gu
# SPDX-License-Identifier: Apache-2.0
config SOC_FAMILY_CH32V
bool
config SOC_FAMILY
default "ch32v" if SOC_FAMILY_CH32V
rsource "*/Kconfig.soc"

View 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(.)

View file

@ -0,0 +1,8 @@
# Copyright (c) 2024 Michael Hope
# SPDX-License-Identifier: Apache-2.0
config SOC_SERIES_QINGKE_V2A
select RISCV_ISA_RV32E
select RISCV_ISA_EXT_ZICSR
select RISCV_ISA_EXT_ZIFENCEI
select RISCV_ISA_EXT_C

View file

@ -0,0 +1,23 @@
# Copyright (c) 2024 Michael Hope
# SPDX-License-Identifier: Apache-2.0
if SOC_SERIES_QINGKE_V2A
config SYS_CLOCK_HW_CYCLES_PER_SEC
default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)
config MAIN_STACK_SIZE
default 512
config IDLE_STACK_SIZE
default 256
config ISR_STACK_SIZE
default 256
config CLOCK_CONTROL
default y
rsource "Kconfig.defconfig.*"
endif # SOC_SERIES_QINGKE_V2A

View file

@ -0,0 +1,9 @@
# Copyright (c) 2024 Michael Hope
# SPDX-License-Identifier: Apache-2.0
if SOC_CH32V003
config NUM_IRQS
default 48
endif # SOC_CH32V003

View file

@ -0,0 +1,11 @@
# Copyright (c) 2024 Jianxiong Gu
# SPDX-License-Identifier: Apache-2.0
config SOC_SERIES_QINGKE_V2A
bool
select SOC_FAMILY_CH32V
config SOC_SERIES
default "qingke_v2a" if SOC_SERIES_QINGKE_V2A
rsource "Kconfig.soc.*"

View file

@ -0,0 +1,9 @@
# Copyright (c) 2024 Michael Hope
# SPDX-License-Identifier: Apache-2.0
config SOC_CH32V003
bool
select SOC_SERIES_QINGKE_V2A
config SOC
default "ch32v003" if SOC_CH32V003

View 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 ch32v003_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 ch32v003_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

View 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

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2024 Michael Hope
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/toolchain.h>
/* Exports */
GTEXT(__start)
/* Imports */
GTEXT(__initialize)
SECTION_FUNC(vectors, ivt)
.option norvc
j __start
.rept 38
.word _isr_wrapper
.endr
SECTION_FUNC(vectors, __start)
li a0, 3
csrw mtvec, a0
j __initialize

9
soc/wch/ch32v/soc.yml Normal file
View file

@ -0,0 +1,9 @@
# Copyright (c) 2024 Michael Hope
# SPDX-License-Identifier: Apache-2.0
family:
- name: ch32v
series:
- name: qingke-v2
socs:
- name: ch32v003