From ae8dcee445fd8291a5d33862c4b23ad5ba8ff05e Mon Sep 17 00:00:00 2001 From: HaiLong Yang Date: Wed, 1 Mar 2023 22:17:34 +0800 Subject: [PATCH 1/2] modules: hal_gigadevice: add usb support This add usb support for hal_gigadevice. Signed-off-by: HaiLong Yang --- modules/hal_gigadevice/CMakeLists.txt | 4 ++++ modules/hal_gigadevice/Kconfig | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/modules/hal_gigadevice/CMakeLists.txt b/modules/hal_gigadevice/CMakeLists.txt index 7a4096bc4d2f0..029ae460f820e 100644 --- a/modules/hal_gigadevice/CMakeLists.txt +++ b/modules/hal_gigadevice/CMakeLists.txt @@ -57,6 +57,10 @@ zephyr_include_directories(${gd32_std_dir}/include) zephyr_include_directories(${ZEPHYR_HAL_GIGADEVICE_MODULE_DIR}/include) zephyr_include_directories(${ZEPHYR_HAL_GIGADEVICE_MODULE_DIR}/common_include) +if (${CONFIG_GD32_USB_SUPPORT}) + zephyr_include_directories(${gd32_soc_dir}/usb_drivers/include) +endif() + zephyr_library_sources(${gd32_soc_sys_dir}/source/system_${CONFIG_SOC_SERIES}.c) zephyr_library_sources_ifdef(CONFIG_USE_GD32_ADC ${gd32_std_src_dir}/${CONFIG_SOC_SERIES}_adc.c) diff --git a/modules/hal_gigadevice/Kconfig b/modules/hal_gigadevice/Kconfig index 66132779eb175..7b3ff3bf0dba2 100644 --- a/modules/hal_gigadevice/Kconfig +++ b/modules/hal_gigadevice/Kconfig @@ -79,6 +79,11 @@ config GD32_DBG_SUPPORT This option makes allows using functions that access to DBG_CTL register such as dbg_periph_enable(). +config GD32_USB_SUPPORT + bool "USB driver support" + help + Enable this if usb driver is supported for certain gd32 soc. + config USE_GD32_ADC bool help From 6bd6244df403898fc24bcfc2d60245f596272854 Mon Sep 17 00:00:00 2001 From: HaiLong Yang Date: Wed, 1 Mar 2023 22:19:13 +0800 Subject: [PATCH 2/2] drivers: usb: introduce gd32 usb device driver This add initial support for gd32 usb device driver. Signed-off-by: HaiLong Yang --- drivers/usb/udc/udc_gd32.c | 10 ++++++++++ soc/arm/gigadevice/gd32f4xx/Kconfig.series | 1 + 2 files changed, 11 insertions(+) create mode 100644 drivers/usb/udc/udc_gd32.c diff --git a/drivers/usb/udc/udc_gd32.c b/drivers/usb/udc/udc_gd32.c new file mode 100644 index 0000000000000..77c682946065c --- /dev/null +++ b/drivers/usb/udc/udc_gd32.c @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2023 BrainCo Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +#include diff --git a/soc/arm/gigadevice/gd32f4xx/Kconfig.series b/soc/arm/gigadevice/gd32f4xx/Kconfig.series index 9b1d74dfa978d..b59ee58d2c8af 100644 --- a/soc/arm/gigadevice/gd32f4xx/Kconfig.series +++ b/soc/arm/gigadevice/gd32f4xx/Kconfig.series @@ -10,5 +10,6 @@ config SOC_SERIES_GD32F4XX select SOC_FAMILY_GD32_ARM select GD32_HAS_AF_PINMUX select GD32_HAS_IRC_32K + select GD32_USB_SUPPORT help Enable support for GigaDevice GD32F4XX MCU series