From ae111ba6133c33d9c7089e939007fbbe2026bd67 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Mon, 17 Oct 2022 20:01:54 +0200 Subject: [PATCH 1/5] drivers/usbdev_synopsys_dwc2: fix dependency on ztimer_msec The `usbdev_synopsys_dwc2 driver` requires the `ztimer_msec` module and is therefore responsible for pulling it in. --- drivers/Makefile.dep | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/Makefile.dep b/drivers/Makefile.dep index aa73dee94d..a190ffeb82 100644 --- a/drivers/Makefile.dep +++ b/drivers/Makefile.dep @@ -209,6 +209,7 @@ endif ifneq (,$(filter usbdev_synopsys_dwc2,$(USEMODULE))) FEATURES_REQUIRED += periph_usbdev + USEMODULE += ztimer_msec endif ifneq (,$(filter vcnl40%0,$(USEMODULE))) From a7bf2d74ba63dde751820d6367c71057f1ab0cc5 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Mon, 17 Oct 2022 20:03:04 +0200 Subject: [PATCH 2/5] cpu/esp32: fix usbdev_synopsys_dwc2 on ztimer_msec The `usbdev_synopsys_dwc2 driver` requires the `ztimer_msec` module and is therefore responsible for pulling it in. Therefore, the dependency on `ztimer_msec` can be removed here. --- cpu/esp32/Makefile.dep | 1 - 1 file changed, 1 deletion(-) diff --git a/cpu/esp32/Makefile.dep b/cpu/esp32/Makefile.dep index f46f939e5d..600b94af0a 100644 --- a/cpu/esp32/Makefile.dep +++ b/cpu/esp32/Makefile.dep @@ -160,7 +160,6 @@ endif ifneq (,$(filter periph_usbdev,$(USEMODULE))) USEMODULE += esp_idf_usb USEMODULE += usbdev_synopsys_dwc2 - USEMODULE += ztimer_msec endif ifneq (,$(filter shell,$(USEMODULE))) From 59a84285aed52c422f67267fb5ded6a6b37459ec Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sun, 16 Oct 2022 18:37:40 +0200 Subject: [PATCH 3/5] cpu/esp32s{2,3}: fix MODULE_USBDEV_SYNOPSYS_DWC2 dependency in Kconfig `MODULE_USBDEV_SYNOPSYS_DWC2` depends already on `HAS_PERIPH_USBDEV`. --- cpu/esp32/Kconfig.esp32s2 | 2 +- cpu/esp32/Kconfig.esp32s3 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/esp32/Kconfig.esp32s2 b/cpu/esp32/Kconfig.esp32s2 index 22db166788..045b717459 100644 --- a/cpu/esp32/Kconfig.esp32s2 +++ b/cpu/esp32/Kconfig.esp32s2 @@ -26,7 +26,7 @@ config CPU_FAM_ESP32S2 select MODULE_PS if MODULE_SHELL select MODULE_PTHREAD if MODULE_CPP select MODULE_RTT_RTC if HAS_PERIPH_RTT && MODULE_PERIPH_RTC - select MODULE_USBDEV_SYNOPSYS_DWC2 if HAS_PERIPH_USBDEV && MODULE_PERIPH_USBDEV + select MODULE_USBDEV_SYNOPSYS_DWC2 if MODULE_PERIPH_USBDEV imply MODULE_NEWLIB_NANO config CPU_FAM diff --git a/cpu/esp32/Kconfig.esp32s3 b/cpu/esp32/Kconfig.esp32s3 index c05358024c..6e4ec98344 100644 --- a/cpu/esp32/Kconfig.esp32s3 +++ b/cpu/esp32/Kconfig.esp32s3 @@ -33,7 +33,7 @@ config CPU_FAM_ESP32S3 select MODULE_PS if MODULE_SHELL select MODULE_PTHREAD if MODULE_CPP select MODULE_RTT_RTC if HAS_PERIPH_RTT && MODULE_PERIPH_RTC - select MODULE_USBDEV_SYNOPSYS_DWC2 if HAS_PERIPH_USBDEV && MODULE_PERIPH_USBDEV + select MODULE_USBDEV_SYNOPSYS_DWC2 if MODULE_PERIPH_USBDEV imply MODULE_NEWLIB_NANO config CPU_FAM From d9dbaa3c2c30e3c1db54f54d731d9bd1bc6f94cc Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sun, 16 Oct 2022 18:39:29 +0200 Subject: [PATCH 4/5] cpu/esp32s{2,3}: DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE must not overridable Since the total USB OTG FIFO size is a hardware propertie, it must not be overridable. --- cpu/esp32/include/periph_cpu_esp32s2.h | 2 -- cpu/esp32/include/periph_cpu_esp32s3.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/cpu/esp32/include/periph_cpu_esp32s2.h b/cpu/esp32/include/periph_cpu_esp32s2.h index 5f9f6b572e..faf9cce0c4 100644 --- a/cpu/esp32/include/periph_cpu_esp32s2.h +++ b/cpu/esp32/include/periph_cpu_esp32s2.h @@ -264,9 +264,7 @@ extern "C" { /** * @brief Total size of the FIFO */ -#ifndef DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE #define DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE (1024U) -#endif /** * @brief Buffers have to be word aligned for DMA diff --git a/cpu/esp32/include/periph_cpu_esp32s3.h b/cpu/esp32/include/periph_cpu_esp32s3.h index 90e5c5b5c0..39d3cc58b0 100644 --- a/cpu/esp32/include/periph_cpu_esp32s3.h +++ b/cpu/esp32/include/periph_cpu_esp32s3.h @@ -265,9 +265,7 @@ extern "C" { /** * @brief Total size of the FIFO */ -#ifndef DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE #define DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE (1024U) -#endif /** * @brief Buffers have to be word aligned for DMA From 1dfe79fe7c8bc5220944d2e77e2c12fd7bc69e1b Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sun, 16 Oct 2022 18:44:41 +0200 Subject: [PATCH 5/5] drivers/usbdev_synopsys_dwc2: use DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE Use `DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE` instead of `USB_OTG_FS_TOTAL_FIFO_SIZE` since the latter is only defined in the vendor headers for STM32 MCUs. The STM32-specific problem that `USB_OTG_FS_TOTAL_FIFO_SIZE` is not defined in the vendor headers for all STM32 families has therefore been moved from the driver to the STM32-specific USB device header. --- cpu/stm32/include/usbdev_stm32.h | 34 ++++++++++++++++++- .../usbdev_synopsys_dwc2.c | 18 ++-------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/cpu/stm32/include/usbdev_stm32.h b/cpu/stm32/include/usbdev_stm32.h index 0a860cf880..02d234e7a2 100644 --- a/cpu/stm32/include/usbdev_stm32.h +++ b/cpu/stm32/include/usbdev_stm32.h @@ -81,7 +81,7 @@ extern "C" { /** * @brief USB OTG FS FIFO reception buffer space in 32-bit words * - * Used as shared FIFO for reception of all OUT transfers + * Used as shared FIFO for reception of all OUT transfers from the host * * @note The application might have to increase this when dealing with large * isochronous transfers @@ -99,6 +99,38 @@ extern "C" { #define DWC2_USB_OTG_HS_RX_FIFO_SIZE (512U) #endif +/** + * @brief USB OTG FS FIFO total size + * + * Some device families (F7 and L4) forgot to define the FS device FIFO size + * in their vendor headers. This define sets it to the value from the + * reference manual. + */ +#ifndef USB_OTG_FS_TOTAL_FIFO_SIZE +#define USB_OTG_FS_TOTAL_FIFO_SIZE (1280U) +#endif + +/** + * @brief USB OTG FS FIFO total size + * + * Some device families (F7 and L4) forgot to define the HS device FIFO size + * in their vendor headers. This define sets it to the value from the + * reference manual. + */ +#ifndef USB_OTG_HS_TOTAL_FIFO_SIZE +#define USB_OTG_HS_TOTAL_FIFO_SIZE (4096U) +#endif + +/** + * @brief USB OTG FS FIFO total size + */ +#define DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE USB_OTG_FS_TOTAL_FIFO_SIZE + +/** + * @brief USB OTG HS FIFO total size + */ +#define DWC2_USB_OTG_HS_TOTAL_FIFO_SIZE USB_OTG_HS_TOTAL_FIFO_SIZE + /** * @brief Use the built-in DMA controller of the HS peripheral when possible */ diff --git a/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c b/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c index ee2e939f9e..92a8220708 100644 --- a/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c +++ b/drivers/usbdev_synopsys_dwc2/usbdev_synopsys_dwc2.c @@ -93,20 +93,6 @@ #define DWC2_PKTSTS_SETUP_COMP 0x04 /**< Rx fifo setup complete */ #define DWC2_PKTSTS_SETUP_UPDT 0x06 /**< Rx fifo setup update */ -/* Some device families (F7 and L4) forgot to define the FS device FIFO size * - * in their vendor headers. This define sets it to the value from the * - * reference manual */ -#ifndef USB_OTG_FS_TOTAL_FIFO_SIZE -#define USB_OTG_FS_TOTAL_FIFO_SIZE (1280U) -#endif - -/* Some device families (F7 and L4) forgot to define the HS device FIFO size * - * in their vendor headers. This define sets it to the value from the * - * reference manual */ -#ifndef USB_OTG_HS_TOTAL_FIFO_SIZE -#define USB_OTG_HS_TOTAL_FIFO_SIZE (4096U) -#endif - /* minimum depth of an individual transmit FIFO */ #define DWC2_USB_OTG_FIFO_MIN_WORD_SIZE (16U) /* Offset for OUT endpoints in a shared IN/OUT endpoint bit flag register */ @@ -472,14 +458,14 @@ static size_t _total_fifo_size(const dwc2_usb_otg_fshs_config_t *conf) { if (conf->type == DWC2_USB_OTG_FS) { #ifdef DWC2_USB_OTG_FS_ENABLED - return USB_OTG_FS_TOTAL_FIFO_SIZE; + return DWC2_USB_OTG_FS_TOTAL_FIFO_SIZE; #else return 0; #endif /* DWC2_USB_OTG_FS_ENABLED */ } else { #ifdef DWC2_USB_OTG_HS_ENABLED - return USB_OTG_HS_TOTAL_FIFO_SIZE; + return DWC2_USB_OTG_HS_TOTAL_FIFO_SIZE; #else return 0; #endif /* DWC2_USB_OTG_HS_ENABLED */