summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2026-01-22 21:01:32 +0800
committersakumisu <[email protected]>2026-01-22 21:01:32 +0800
commit309aa2ffd8dbcecd8b1ae793402a5e836c0dd955 (patch)
treeeaab9199587961660c728f395577026f31fe69b6
parent013f51312a72f1618454f12371d53a4fe3863844 (diff)
feat(port/dwc2): add infineon glue
Signed-off-by: sakumisu <[email protected]>
-rw-r--r--Kconfig19
-rw-r--r--Kconfig.rtt29
-rw-r--r--Kconfig.rttpkg40
-rw-r--r--SConscript9
-rw-r--r--port/dwc2/README.md6
-rw-r--r--port/dwc2/usb_glue_infineon.c140
6 files changed, 213 insertions, 30 deletions
diff --git a/Kconfig b/Kconfig
index 109f7969..6d4b0f76 100644
--- a/Kconfig
+++ b/Kconfig
@@ -10,7 +10,7 @@ if CHERRYUSB
default n
if CHERRYUSB_DEVICE
- choice
+ choice CHERRYUSB_DEVICE_SPEED
prompt "Select usb device speed"
default CHERRYUSB_DEVICE_SPEED_FS
config CHERRYUSB_DEVICE_SPEED_FS
@@ -21,7 +21,7 @@ if CHERRYUSB
bool "AUTO"
endchoice
- choice
+ choice CHERRYUSB_DEVICE_IP
prompt "Select usb device ip, and some ip need config in usb_config.h, please check"
default CHERRYUSB_DEVICE_CUSTOM
config CHERRYUSB_DEVICE_CUSTOM
@@ -36,6 +36,8 @@ if CHERRYUSB
bool "dwc2_esp"
config CHERRYUSB_DEVICE_DWC2_KENDRYTE
bool "dwc2_kendryte"
+ config CHERRYUSB_DEVICE_DWC2_INFINEON
+ bool "dwc2_infineon"
config CHERRYUSB_DEVICE_DWC2_AT
bool "dwc2_at"
config CHERRYUSB_DEVICE_DWC2_HC
@@ -159,7 +161,7 @@ if CHERRYUSB
prompt "Enable usb cdc ecm device with lwip for lan"
default n
- choice
+ choice CHERRYUSB_DEVICE_TEMPLATE
prompt "Select usb device template, please select class driver first"
default CHERRYUSB_DEVICE_TEMPLATE_NONE
config CHERRYUSB_DEVICE_TEMPLATE_NONE
@@ -239,7 +241,7 @@ if CHERRYUSB
default n
if CHERRYUSB_HOST
- choice
+ choice CHERRYUSB_HOST_IP
prompt "Select usb host ip, and some ip need config in usb_config.h, please check"
default CHERRYUSB_HOST_CUSTOM
config CHERRYUSB_HOST_CUSTOM
@@ -264,6 +266,10 @@ if CHERRYUSB
bool "dwc2_esp"
config CHERRYUSB_HOST_DWC2_KENDRYTE
bool "dwc2_kendryte"
+ config CHERRYUSB_HOST_DWC2_INFINEON
+ bool "dwc2_infineon"
+ config CHERRYUSB_HOST_DWC2_AT
+ bool "dwc2_at, f405 only"
config CHERRYUSB_HOST_DWC2_HC
bool "dwc2_hc"
config CHERRYUSB_HOST_DWC2_NATION
@@ -452,6 +458,11 @@ if CHERRYUSB
prompt "demo for test msc"
default n
depends on CHERRYUSB_HOST_MSC
+ config TEST_USBH_NET
+ bool
+ prompt "demo for test net, no demo for this, you can use lwip api to test"
+ default n
+ depends on CHERRYUSB_HOST_CDC_ECM || CHERRYUSB_HOST_CDC_RNDIS || CHERRYUSB_HOST_CDC_NCM || CHERRYUSB_HOST_ASIX || CHERRYUSB_HOST_RTL8152
endmenu
endif
endif
diff --git a/Kconfig.rtt b/Kconfig.rtt
index bc45822b..35a8e15f 100644
--- a/Kconfig.rtt
+++ b/Kconfig.rtt
@@ -10,7 +10,7 @@ if RT_USING_CHERRYUSB
default n
if RT_CHERRYUSB_DEVICE
- choice
+ choice CHERRYUSB_DEVICE_SPEED
prompt "Select usb device speed"
default RT_CHERRYUSB_DEVICE_SPEED_FS
config RT_CHERRYUSB_DEVICE_SPEED_FS
@@ -21,7 +21,7 @@ if RT_USING_CHERRYUSB
bool "AUTO"
endchoice
- choice
+ choice CHERRYUSB_DEVICE_IP
prompt "Select usb device ip, and some ip need config in usb_config.h, please check"
default RT_CHERRYUSB_DEVICE_CUSTOM
config RT_CHERRYUSB_DEVICE_CUSTOM
@@ -36,6 +36,8 @@ if RT_USING_CHERRYUSB
bool "dwc2_esp"
config RT_CHERRYUSB_DEVICE_DWC2_KENDRYTE
bool "dwc2_kendryte"
+ config RT_CHERRYUSB_DEVICE_DWC2_INFINEON
+ bool "dwc2_infineon"
config RT_CHERRYUSB_DEVICE_DWC2_AT
bool "dwc2_at"
config RT_CHERRYUSB_DEVICE_DWC2_HC
@@ -165,7 +167,7 @@ if RT_USING_CHERRYUSB
prompt "Enable usb cdc ecm device with lwip for lan"
default n
- choice
+ choice CHERRYUSB_DEVICE_TEMPLATE
prompt "Select usb device template, please select class driver first"
default RT_CHERRYUSB_DEVICE_TEMPLATE_NONE
config RT_CHERRYUSB_DEVICE_TEMPLATE_NONE
@@ -263,7 +265,7 @@ if RT_USING_CHERRYUSB
default n
if RT_CHERRYUSB_HOST
- choice
+ choice CHERRYUSB_HOST_IP
prompt "Select usb host ip, and some ip need config in usb_config.h, please check"
default RT_CHERRYUSB_HOST_CUSTOM
config RT_CHERRYUSB_HOST_CUSTOM
@@ -288,6 +290,10 @@ if RT_USING_CHERRYUSB
bool "dwc2_esp"
config RT_CHERRYUSB_HOST_DWC2_KENDRYTE
bool "dwc2_kendryte"
+ config RT_CHERRYUSB_HOST_DWC2_INFINEON
+ bool "dwc2_infineon"
+ config RT_CHERRYUSB_HOST_DWC2_AT
+ bool "dwc2_at, f405 only"
config RT_CHERRYUSB_HOST_DWC2_HC
bool "dwc2_hc"
config RT_CHERRYUSB_HOST_DWC2_NATION
@@ -466,19 +472,24 @@ if RT_USING_CHERRYUSB
menu "Select USB host template, please select class driver first"
config CONFIG_TEST_USBH_SERIAL
bool
- prompt "demo for test serial, cannot enable this demo, we have used rt-device framework instead"
+ prompt "demo for test seial, cannot enable this demo, you can use rt-thread device api to test"
default n
- depends on RT_CHERRYUSB_HOST_CDC_ACM || RT_CHERRYUSB_HOST_FTDI || RT_CHERRYUSB_HOST_CH34X || RT_CHERRYUSB_HOST_CP210X || RT_CHERRYUSB_HOST_PL2303
+ depends on CONFIG_USBHOST_SERIAL
config CONFIG_TEST_USBH_HID
- bool
+ int
prompt "demo for test hid"
- default n
+ default 0
depends on RT_CHERRYUSB_HOST_HID
config CONFIG_TEST_USBH_MSC
bool
- prompt "demo for test msc, cannot enable this demo, we have used dfs instead"
+ prompt "demo for test msc, cannot enable this demo, you can use rt-thread dfs api to test"
default n
depends on RT_CHERRYUSB_HOST_MSC
+ config CONFIG_TEST_USBH_NET
+ bool
+ prompt "demo for test net, cannot enable this demo, you can use lwip api to test"
+ default n
+ depends on RT_CHERRYUSB_HOST_CDC_ECM || RT_CHERRYUSB_HOST_CDC_RNDIS || RT_CHERRYUSB_HOST_CDC_NCM || RT_CHERRYUSB_HOST_ASIX || RT_CHERRYUSB_HOST_RTL8152
endmenu
endif
endif
diff --git a/Kconfig.rttpkg b/Kconfig.rttpkg
index 24f636b0..5d9a077f 100644
--- a/Kconfig.rttpkg
+++ b/Kconfig.rttpkg
@@ -11,7 +11,7 @@ if PKG_USING_CHERRYUSB
default n
if PKG_CHERRYUSB_DEVICE
- choice
+ choice CHERRYUSB_DEVICE_SPEED
prompt "Select usb device speed"
default PKG_CHERRYUSB_DEVICE_SPEED_FS
config PKG_CHERRYUSB_DEVICE_SPEED_FS
@@ -22,7 +22,7 @@ if PKG_USING_CHERRYUSB
bool "AUTO"
endchoice
- choice
+ choice CHERRYUSB_DEVICE_IP
prompt "Select usb device ip, and some ip need config in usb_config.h, please check"
default PKG_CHERRYUSB_DEVICE_CUSTOM
config PKG_CHERRYUSB_DEVICE_CUSTOM
@@ -37,6 +37,8 @@ if PKG_USING_CHERRYUSB
bool "dwc2_esp"
config PKG_CHERRYUSB_DEVICE_DWC2_KENDRYTE
bool "dwc2_kendryte"
+ config PKG_CHERRYUSB_DEVICE_DWC2_INFINEON
+ bool "dwc2_infineon"
config PKG_CHERRYUSB_DEVICE_DWC2_AT
bool "dwc2_at"
config PKG_CHERRYUSB_DEVICE_DWC2_HC
@@ -164,7 +166,7 @@ if PKG_USING_CHERRYUSB
prompt "Enable usb cdc ecm device with lwip for lan"
default n
- choice
+ choice CHERRYUSB_DEVICE_TEMPLATE
prompt "Select usb device template, please select class driver first"
default PKG_CHERRYUSB_DEVICE_TEMPLATE_NONE
config PKG_CHERRYUSB_DEVICE_TEMPLATE_NONE
@@ -262,7 +264,7 @@ if PKG_USING_CHERRYUSB
default n
if PKG_CHERRYUSB_HOST
- choice
+ choice CHERRYUSB_HOST_IP
prompt "Select usb host ip, and some ip need config in usb_config.h, please check"
default PKG_CHERRYUSB_HOST_CUSTOM
config PKG_CHERRYUSB_HOST_CUSTOM
@@ -287,6 +289,10 @@ if PKG_USING_CHERRYUSB
bool "dwc2_esp"
config PKG_CHERRYUSB_HOST_DWC2_KENDRYTE
bool "dwc2_kendryte"
+ config PKG_CHERRYUSB_HOST_DWC2_INFINEON
+ bool "dwc2_infineon"
+ config PKG_CHERRYUSB_HOST_DWC2_AT
+ bool "dwc2_at, f405 only"
config PKG_CHERRYUSB_HOST_DWC2_HC
bool "dwc2_hc"
config PKG_CHERRYUSB_HOST_DWC2_NATION
@@ -465,19 +471,24 @@ if PKG_USING_CHERRYUSB
menu "Select USB host template, please select class driver first"
config CONFIG_TEST_USBH_SERIAL
bool
- prompt "demo for test serial, cannot enable this demo, we have used rt-device framework instead"
+ prompt "demo for test seial, cannot enable this demo, you can use rt-thread device api to test"
default n
- depends on PKG_CHERRYUSB_HOST_CDC_ACM || PKG_CHERRYUSB_HOST_FTDI || PKG_CHERRYUSB_HOST_CH34X || PKG_CHERRYUSB_HOST_CP210X || PKG_CHERRYUSB_HOST_PL2303
+ depends on CONFIG_USBHOST_SERIAL
config CONFIG_TEST_USBH_HID
- bool
+ int
prompt "demo for test hid"
- default n
+ default 0
depends on PKG_CHERRYUSB_HOST_HID
config CONFIG_TEST_USBH_MSC
bool
- prompt "demo for test msc, cannot enable this demo, we have used dfs instead"
+ prompt "demo for test msc, cannot enable this demo, you can use rt-thread dfs api to test"
default n
depends on PKG_CHERRYUSB_HOST_MSC
+ config CONFIG_TEST_USBH_NET
+ bool
+ prompt "demo for test net, cannot enable this demo, you can use lwip api to test"
+ default n
+ depends on PKG_CHERRYUSB_HOST_CDC_ECM || PKG_CHERRYUSB_HOST_CDC_RNDIS || PKG_CHERRYUSB_HOST_CDC_NCM || PKG_CHERRYUSB_HOST_ASIX || PKG_CHERRYUSB_HOST_RTL8152
endmenu
endif
@@ -487,18 +498,16 @@ if PKG_USING_CHERRYUSB
choice
prompt "Version"
- default PKG_USING_CHERRYUSB_V010503
+ default PKG_USING_CHERRYUSB_V010504
help
Select the package version
config PKG_USING_CHERRYUSB_LATEST_VERSION
bool "latest"
- config PKG_USING_CHERRYUSB_V010503
- bool "v1.5.3"
+ config PKG_USING_CHERRYUSB_V010504
+ bool "v1.5.4"
config PKG_USING_CHERRYUSB_V010502
bool "v1.5.2"
- config PKG_USING_CHERRYUSB_V010501
- bool "v1.5.1"
config PKG_USING_CHERRYUSB_V010500
bool "v1.5.0"
config PKG_USING_CHERRYUSB_V010403
@@ -514,9 +523,8 @@ if PKG_USING_CHERRYUSB
config PKG_CHERRYUSB_VER
string
default "latest" if PKG_USING_CHERRYUSB_LATEST_VERSION
- default "v1.5.3" if PKG_USING_CHERRYUSB_V010503
+ default "v1.5.4" if PKG_USING_CHERRYUSB_V010504
default "v1.5.2" if PKG_USING_CHERRYUSB_V010502
- default "v1.5.1" if PKG_USING_CHERRYUSB_V010501
default "v1.5.0" if PKG_USING_CHERRYUSB_V010500
default "v1.4.3" if PKG_USING_CHERRYUSB_V010403
default "v1.3.1" if PKG_USING_CHERRYUSB_V010301
diff --git a/SConscript b/SConscript
index 5dcdef51..5a4f95d8 100644
--- a/SConscript
+++ b/SConscript
@@ -46,6 +46,9 @@ if GetDepend(['PKG_CHERRYUSB_DEVICE']):
if GetDepend(['PKG_CHERRYUSB_DEVICE_DWC2_KENDRYTE']):
src += Glob('port/dwc2/usb_dc_dwc2.c')
src += Glob('port/dwc2/usb_glue_kendryte.c')
+ if GetDepend(['PKG_CHERRYUSB_DEVICE_DWC2_INFINEON']):
+ src += Glob('port/dwc2/usb_dc_dwc2.c')
+ src += Glob('port/dwc2/usb_glue_infineon.c')
if GetDepend(['PKG_CHERRYUSB_DEVICE_DWC2_AT']):
src += Glob('port/dwc2/usb_dc_dwc2.c')
src += Glob('port/dwc2/usb_glue_at.c')
@@ -220,6 +223,12 @@ if GetDepend(['PKG_CHERRYUSB_HOST']):
if GetDepend(['PKG_CHERRYUSB_HOST_DWC2_KENDRYTE']):
src += Glob('port/dwc2/usb_hc_dwc2.c')
src += Glob('port/dwc2/usb_glue_kendryte.c')
+ if GetDepend(['PKG_CHERRYUSB_HOST_DWC2_INFINEON']):
+ src += Glob('port/dwc2/usb_hc_dwc2.c')
+ src += Glob('port/dwc2/usb_glue_infineon.c')
+ if GetDepend(['PKG_CHERRYUSB_HOST_DWC2_AT']):
+ src += Glob('port/dwc2/usb_hc_dwc2.c')
+ src += Glob('port/dwc2/usb_glue_at.c')
if GetDepend(['PKG_CHERRYUSB_HOST_DWC2_HC']):
src += Glob('port/dwc2/usb_hc_dwc2.c')
src += Glob('port/dwc2/usb_glue_hc.c')
diff --git a/port/dwc2/README.md b/port/dwc2/README.md
index 2861cde7..db82c6cf 100644
--- a/port/dwc2/README.md
+++ b/port/dwc2/README.md
@@ -48,4 +48,8 @@ Please note that host must support dma mode.
### Nationstech
-- N32H4X \ No newline at end of file
+- N32H4X
+
+### Infineon
+
+- PSOC Edge E8X \ No newline at end of file
diff --git a/port/dwc2/usb_glue_infineon.c b/port/dwc2/usb_glue_infineon.c
new file mode 100644
index 00000000..c08ebc08
--- /dev/null
+++ b/port/dwc2/usb_glue_infineon.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2026, sakumisu
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+#include "usbd_core.h"
+#include "usbh_core.h"
+#include "usb_dwc2_param.h"
+#include "rtthread.h"
+#include "cybsp.h"
+
+const struct dwc2_user_params param_common = {
+ .phy_type = DWC2_PHY_TYPE_PARAM_UTMI,
+ .device_dma_enable = true,
+ .device_dma_desc_enable = false,
+ .device_rx_fifo_size = 0x21F,
+ .device_tx_fifo_size = {
+ [0] = 16, // 64 byte
+ [1] = 0x300, // 1024 byte, tripple buffer
+ [2] = 0x300, // 1024 byte, tripple buffer
+ [3] = 0x300, // 1024 byte, tripple buffer
+ [4] = 0x300, // 1024 byte, tripple buffer
+ [5] = 0x300, // 1024 byte, tripple buffer
+ [6] = 0x300, // 1024 byte, tripple buffer
+ [7] = 0x300, // 1024 byte, tripple buffer
+ [8] = 0x300, // 1024 byte, tripple buffer
+ [9] = 0,
+ [10] = 0,
+ [11] = 0,
+ [12] = 0,
+ [13] = 0,
+ [14] = 0,
+ [15] = 0 },
+
+ .host_dma_desc_enable = false,
+ .host_rx_fifo_size = 0x21F,
+ .host_nperio_tx_fifo_size = 0x100, // 512 byte, double buffer
+ .host_perio_tx_fifo_size = 0x400, // 1024 byte, four buffer
+
+ .device_gccfg = 0,
+ .host_gccfg = 0
+};
+
+#ifndef CONFIG_USB_DWC2_CUSTOM_PARAM
+void dwc2_get_user_params(uint32_t reg_base, struct dwc2_user_params *params)
+{
+ memcpy(params, &param_common, sizeof(struct dwc2_user_params));
+#ifdef CONFIG_USB_DWC2_CUSTOM_FIFO
+ struct usb_dwc2_user_fifo_config s_dwc2_fifo_config;
+
+ dwc2_get_user_fifo_config(reg_base, &s_dwc2_fifo_config);
+
+ params->device_rx_fifo_size = s_dwc2_fifo_config.device_rx_fifo_size;
+ for (uint8_t i = 0; i < MAX_EPS_CHANNELS; i++) {
+ params->device_tx_fifo_size[i] = s_dwc2_fifo_config.device_tx_fifo_size[i];
+ }
+#endif
+}
+#endif
+
+void USBHS_DEVICE_IRQHandler(void)
+{
+ USBD_IRQHandler(0);
+}
+
+void usb_dc_low_level_init(uint8_t busid)
+{
+ USBHS_SS->SUBSYSTEM_CTL = (1 << USBHS_SS_SUBSYSTEM_CTL_AHB_MASTER_SYNC_Pos) | USBHS_SS_SUBSYSTEM_CTL_SS_ENABLE_Msk;
+ USBHS_SS->PHY_FUNC_CTL_1 |= (7 << USBHS_SS_PHY_FUNC_CTL_1_PLL_FSEL_Pos);
+ USBHS_SS->PHY_FUNC_CTL_2 |= (USBHS_SS_PHY_FUNC_CTL_2_RES_TUNING_SEL_Msk | USBHS_SS_PHY_FUNC_CTL_2_EFUSE_SEL_Msk);
+
+ cy_stc_sysint_t usb_int_cfg = {
+ .intrSrc = usbhs_interrupt_usbhsctrl_IRQn,
+ .intrPriority = 3
+ };
+
+ /* Install the interrupt service routine */
+ Cy_SysInt_Init(&usb_int_cfg, USBHS_DEVICE_IRQHandler);
+
+ NVIC_EnableIRQ(usbhs_interrupt_usbhsctrl_IRQn);
+}
+
+void usb_dc_low_level_deinit(uint8_t busid)
+{
+ NVIC_DisableIRQ(usbhs_interrupt_usbhsctrl_IRQn);
+}
+
+void usbd_dwc2_delay_ms(uint8_t ms)
+{
+ rt_thread_mdelay(ms);
+}
+
+uint32_t usbd_dwc2_get_system_clock(void)
+{
+ return SystemCoreClock;
+}
+
+void USBHS_HOST_IRQHandler(void)
+{
+ USBH_IRQHandler(0);
+}
+
+void usb_hc_low_level_init(struct usbh_bus *bus)
+{
+ USBHS_SS->SUBSYSTEM_CTL = (1 << USBHS_SS_SUBSYSTEM_CTL_AHB_MASTER_SYNC_Pos) | USBHS_SS_SUBSYSTEM_CTL_USB_MODE_Msk | USBHS_SS_SUBSYSTEM_CTL_SS_ENABLE_Msk;
+ USBHS_SS->PHY_FUNC_CTL_1 |= (7 << USBHS_SS_PHY_FUNC_CTL_1_PLL_FSEL_Pos);
+ USBHS_SS->PHY_FUNC_CTL_2 |= (USBHS_SS_PHY_FUNC_CTL_2_RES_TUNING_SEL_Msk | USBHS_SS_PHY_FUNC_CTL_2_EFUSE_SEL_Msk);
+
+ cy_stc_sysint_t usb_int_cfg = {
+ .intrSrc = usbhs_interrupt_usbhsctrl_IRQn,
+ .intrPriority = 3
+ };
+
+ /* Install the interrupt service routine */
+ Cy_SysInt_Init(&usb_int_cfg, USBHS_HOST_IRQHandler);
+
+ NVIC_EnableIRQ(usbhs_interrupt_usbhsctrl_IRQn);
+}
+
+void usb_hc_low_level_deinit(struct usbh_bus *bus)
+{
+ NVIC_DisableIRQ(usbhs_interrupt_usbhsctrl_IRQn);
+}
+
+#ifdef CONFIG_USB_DCACHE_ENABLE
+void usb_dcache_clean(uintptr_t addr, size_t size)
+{
+ SCB_CleanDCache_by_Addr((void *)addr, size);
+}
+
+void usb_dcache_invalidate(uintptr_t addr, size_t size)
+{
+ SCB_InvalidateDCache_by_Addr((void *)addr, size);
+}
+
+void usb_dcache_flush(uintptr_t addr, size_t size)
+{
+ SCB_CleanInvalidateDCache_by_Addr((void *)addr, size);
+}
+#endif