This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 2c4f0feb6d72513d2bc0a0030eb27c6e2e8e22ab Author: raiden00pl <[email protected]> AuthorDate: Mon Nov 2 21:50:55 2026 +0100 arch/arm/stm32: Move the STM32H7 OTG drivers to common. The STM32H7 OTG device and host drivers become common/stm32 stm32_otgdev_v2.c and stm32_otghost_v2.c behind STM32_HAVE_IP_OTG_V2. The transceiver supply set-up moves to the family stm32_otg_phyif.h. Assisted-by: Claude:claude-fable-5-1 Signed-off-by: raiden00pl <[email protected]> --- Documentation/guides/chip-specific/stm32_ports.rst | 4 +- arch/arm/src/common/stm32/CMakeLists.txt | 12 + arch/arm/src/common/stm32/Kconfig.have | 3 + arch/arm/src/common/stm32/Make.defs | 14 + .../{stm32_usbhost.h => hardware/stm32_otg.h} | 14 +- .../stm32/hardware/stm32_otg_v2.h} | 8 +- .../common/stm32/{stm32_usbhost.h => stm32_otg.h} | 14 +- .../stm32_otg.h => common/stm32/stm32_otg_v2.h} | 10 +- .../stm32/stm32_otgdev_v2.c} | 41 +- .../stm32/stm32_otghost_v2.c} | 483 ++++++++++----------- arch/arm/src/common/stm32/stm32_usbhost.h | 2 + .../stm32/stm32_usbhost_v2.c} | 4 +- .../stm32/stm32_usbhost_v2.h} | 8 +- arch/arm/src/stm32h7/CMakeLists.txt | 15 - arch/arm/src/stm32h7/Kconfig | 1 + arch/arm/src/stm32h7/Make.defs | 15 - arch/arm/src/stm32h7/stm32_otg_phyif.h | 79 ++++ 17 files changed, 398 insertions(+), 329 deletions(-) diff --git a/Documentation/guides/chip-specific/stm32_ports.rst b/Documentation/guides/chip-specific/stm32_ports.rst index 01a75fe6bd0..c4ddaa22fc2 100644 --- a/Documentation/guides/chip-specific/stm32_ports.rst +++ b/Documentation/guides/chip-specific/stm32_ports.rst @@ -666,7 +666,7 @@ SDMMC v2 arch/arm/src/common/stm32/stm32_sdmmc_v2.c SPI/I2S to be done arch/arm/src/stm32h7/stm32_spi.c TIM v2, H7RS v3 arch/arm/src/common/stm32/stm32_tim.c USART/LPUART v4 arch/arm/src/stm32h7/stm32_serial.c -USB OTG FS/HS arch/arm/src/stm32h7/stm32_otgdev.c +USB OTG v2 arch/arm/src/common/stm32/stm32_otgdev_v2.c WWDG v2, H7RS v3 arch/arm/src/common/stm32/stm32_wwdg.c AES/CRYP n/a arch/arm/src/stm32h7/stm32_aes.c BBSRAM n/a arch/arm/src/stm32h7/stm32_bbsram.c @@ -675,7 +675,7 @@ LPTIM v1, H7RS v2 arch/arm/src/common/stm32/stm32_lptim.c PULSECOUNT n/a arch/arm/src/common/stm32/stm32_pulsecount.c PWM n/a arch/arm/src/stm32h7/stm32_pwm.c QENCODER n/a arch/arm/src/common/stm32/stm32_qencoder.c -USB host n/a arch/arm/src/stm32h7/stm32_otghost.c +USB host OTG v2 arch/arm/src/common/stm32/stm32_otghost_v2.c ============ ============ ============================================ STM32L0 diff --git a/arch/arm/src/common/stm32/CMakeLists.txt b/arch/arm/src/common/stm32/CMakeLists.txt index 5e15e027345..232950cfcf7 100644 --- a/arch/arm/src/common/stm32/CMakeLists.txt +++ b/arch/arm/src/common/stm32/CMakeLists.txt @@ -115,6 +115,18 @@ if(CONFIG_STM32_SDMMC AND CONFIG_STM32_HAVE_IP_SDMMC_V2) list(APPEND SRCS stm32_sdmmc_v2.c) endif() +if(CONFIG_STM32_HAVE_IP_OTG_V2) + if(CONFIG_USBDEV) + list(APPEND SRCS stm32_otgdev_v2.c) + endif() + if(CONFIG_USBHOST) + list(APPEND SRCS stm32_otghost_v2.c) + if(CONFIG_USBHOST_TRACE OR CONFIG_DEBUG_USB) + list(APPEND SRCS stm32_usbhost_v2.c) + endif() + endif() +endif() + if(CONFIG_STM32_COMMON_M33) list(APPEND SRCS stm32_allocateheap_m33_v1.c stm32_irq_m33_v1.c stm32_start_m33_v1.c) diff --git a/arch/arm/src/common/stm32/Kconfig.have b/arch/arm/src/common/stm32/Kconfig.have index a71368137e5..a18bed42484 100644 --- a/arch/arm/src/common/stm32/Kconfig.have +++ b/arch/arm/src/common/stm32/Kconfig.have @@ -1267,6 +1267,9 @@ config STM32_HAVE_IP_OTGFS_M3M4_V1 config STM32_HAVE_IP_OTGHS_M3M4_V1 bool +config STM32_HAVE_IP_OTG_V2 + bool + config STM32_HAVE_COMMON_USBHOST_DEBUG bool default y if STM32_COMMON_LEGACY diff --git a/arch/arm/src/common/stm32/Make.defs b/arch/arm/src/common/stm32/Make.defs index 2ffb0bf53fb..996ad94cc98 100644 --- a/arch/arm/src/common/stm32/Make.defs +++ b/arch/arm/src/common/stm32/Make.defs @@ -126,6 +126,20 @@ ifeq ($(CONFIG_STM32_SDMMC)$(CONFIG_STM32_HAVE_IP_SDMMC_V2),yy) CHIP_CSRCS += stm32_sdmmc_v2.c endif +ifeq ($(CONFIG_STM32_HAVE_IP_OTG_V2),y) +ifeq ($(CONFIG_USBDEV),y) +CHIP_CSRCS += stm32_otgdev_v2.c +endif +ifeq ($(CONFIG_USBHOST),y) +CHIP_CSRCS += stm32_otghost_v2.c +ifeq ($(CONFIG_USBHOST_TRACE),y) +CHIP_CSRCS += stm32_usbhost_v2.c +else ifeq ($(CONFIG_DEBUG_USB),y) +CHIP_CSRCS += stm32_usbhost_v2.c +endif +endif +endif + ifeq ($(CONFIG_STM32_COMMON_M33),y) CHIP_CSRCS += stm32_allocateheap_m33_v1.c CHIP_CSRCS += stm32_irq_m33_v1.c diff --git a/arch/arm/src/common/stm32/stm32_usbhost.h b/arch/arm/src/common/stm32/hardware/stm32_otg.h similarity index 78% copy from arch/arm/src/common/stm32/stm32_usbhost.h copy to arch/arm/src/common/stm32/hardware/stm32_otg.h index c659a23a25b..045b2b4e9f0 100644 --- a/arch/arm/src/common/stm32/stm32_usbhost.h +++ b/arch/arm/src/common/stm32/hardware/stm32_otg.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/common/stm32/stm32_usbhost.h + * arch/arm/src/common/stm32/hardware/stm32_otg.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_ARM_SRC_COMMON_COMPAT_STM32USBHOST_H -#define __ARCH_ARM_SRC_COMMON_COMPAT_STM32USBHOST_H +#ifndef __ARCH_ARM_SRC_COMMON_STM32_HARDWARE_STM32_OTG_H +#define __ARCH_ARM_SRC_COMMON_STM32_HARDWARE_STM32_OTG_H /**************************************************************************** * Included Files @@ -29,10 +29,10 @@ #include <nuttx/config.h> -#if defined(CONFIG_STM32_COMMON_LEGACY) -# include "stm32_usbhost_m3m4_v1.h" +#if defined(CONFIG_STM32_HAVE_IP_OTG_V2) +# include "hardware/stm32_otg_v2.h" #else -# error "Unsupported STM32 stm32_usbhost" +# error "Unsupported STM32 OTG" #endif -#endif /* __ARCH_ARM_SRC_COMMON_COMPAT_STM32USBHOST_H */ +#endif /* __ARCH_ARM_SRC_COMMON_STM32_HARDWARE_STM32_OTG_H */ diff --git a/arch/arm/src/stm32h7/hardware/stm32_otg.h b/arch/arm/src/common/stm32/hardware/stm32_otg_v2.h similarity index 99% rename from arch/arm/src/stm32h7/hardware/stm32_otg.h rename to arch/arm/src/common/stm32/hardware/stm32_otg_v2.h index e009b6706ad..0353981f53c 100644 --- a/arch/arm/src/stm32h7/hardware/stm32_otg.h +++ b/arch/arm/src/common/stm32/hardware/stm32_otg_v2.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/stm32h7/hardware/stm32_otg.h + * arch/arm/src/common/stm32/hardware/stm32_otg_v2.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32_OTG_H -#define __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32_OTG_H +#ifndef __ARCH_ARM_SRC_COMMON_STM32_HARDWARE_STM32_OTG_V2_H +#define __ARCH_ARM_SRC_COMMON_STM32_HARDWARE_STM32_OTG_V2_H /**************************************************************************** * Included Files @@ -933,4 +933,4 @@ #define OTG_PCGCCTL_SUSP (1 << 7) /* Bit 7: PHY Suspended */ /* Bits 7-31: Reserved */ -#endif /* __ARCH_ARM_SRC_STM32H7_HARDWARE_STM32_OTG_H */ +#endif /* __ARCH_ARM_SRC_COMMON_STM32_HARDWARE_STM32_OTG_V2_H */ diff --git a/arch/arm/src/common/stm32/stm32_usbhost.h b/arch/arm/src/common/stm32/stm32_otg.h similarity index 78% copy from arch/arm/src/common/stm32/stm32_usbhost.h copy to arch/arm/src/common/stm32/stm32_otg.h index c659a23a25b..1caad5ced3d 100644 --- a/arch/arm/src/common/stm32/stm32_usbhost.h +++ b/arch/arm/src/common/stm32/stm32_otg.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/common/stm32/stm32_usbhost.h + * arch/arm/src/common/stm32/stm32_otg.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_ARM_SRC_COMMON_COMPAT_STM32USBHOST_H -#define __ARCH_ARM_SRC_COMMON_COMPAT_STM32USBHOST_H +#ifndef __ARCH_ARM_SRC_COMMON_STM32_STM32_OTG_H +#define __ARCH_ARM_SRC_COMMON_STM32_STM32_OTG_H /**************************************************************************** * Included Files @@ -29,10 +29,10 @@ #include <nuttx/config.h> -#if defined(CONFIG_STM32_COMMON_LEGACY) -# include "stm32_usbhost_m3m4_v1.h" +#if defined(CONFIG_STM32_HAVE_IP_OTG_V2) +# include "stm32_otg_v2.h" #else -# error "Unsupported STM32 stm32_usbhost" +# error "Unsupported STM32 stm32_otg" #endif -#endif /* __ARCH_ARM_SRC_COMMON_COMPAT_STM32USBHOST_H */ +#endif /* __ARCH_ARM_SRC_COMMON_STM32_STM32_OTG_H */ diff --git a/arch/arm/src/stm32h7/stm32_otg.h b/arch/arm/src/common/stm32/stm32_otg_v2.h similarity index 95% rename from arch/arm/src/stm32h7/stm32_otg.h rename to arch/arm/src/common/stm32/stm32_otg_v2.h index bdbf61f5db6..045d4489e32 100644 --- a/arch/arm/src/stm32h7/stm32_otg.h +++ b/arch/arm/src/common/stm32/stm32_otg_v2.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/stm32h7/stm32_otg.h + * arch/arm/src/common/stm32/stm32_otg_v2.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_ARM_SRC_STM32H7_STM32_OTG_H -#define __ARCH_ARM_SRC_STM32H7_STM32_OTG_H +#ifndef __ARCH_ARM_SRC_COMMON_STM32_STM32_OTG_V2_H +#define __ARCH_ARM_SRC_COMMON_STM32_STM32_OTG_V2_H /**************************************************************************** * Included Files @@ -34,7 +34,7 @@ #include <arch/board/board.h> #include "chip.h" -#include "stm32_rcc.h" +#include "stm32.h" #include "hardware/stm32_otg.h" #if defined(CONFIG_STM32_OTGFS) || defined(CONFIG_STM32_OTGHS) @@ -141,4 +141,4 @@ void stm32_usbulpireset(struct usbdev_s *dev); #endif /* __ASSEMBLY__ */ #endif /* CONFIG_STM32_OTGFS */ -#endif /* __ARCH_ARM_SRC_STM32H7_STM32_OTG_H */ +#endif /* __ARCH_ARM_SRC_COMMON_STM32_STM32_OTG_V2_H */ diff --git a/arch/arm/src/stm32h7/stm32_otgdev.c b/arch/arm/src/common/stm32/stm32_otgdev_v2.c similarity index 99% rename from arch/arm/src/stm32h7/stm32_otgdev.c rename to arch/arm/src/common/stm32/stm32_otgdev_v2.c index f97123a5c29..368a6df39a9 100644 --- a/arch/arm/src/stm32h7/stm32_otgdev.c +++ b/arch/arm/src/common/stm32/stm32_otgdev_v2.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/stm32h7/stm32_otgdev.c + * arch/arm/src/common/stm32/stm32_otgdev_v2.c * * SPDX-License-Identifier: Apache-2.0 * @@ -46,11 +46,10 @@ #include <nuttx/irq.h> #include <arch/board/board.h> -#include "hardware/stm32_pwr.h" #include "chip.h" -#include "stm32_rcc.h" -#include "stm32_gpio.h" +#include "stm32.h" #include "stm32_otg.h" +#include "stm32_otg_phyif.h" #include "arm_internal.h" #if defined(CONFIG_USBDEV) && (defined(CONFIG_STM32_OTGFS) || \ @@ -1215,6 +1214,7 @@ static void stm32_epin_transfer(struct stm32_ep_s *privep, */ uint32_t status = stm32_getreg(STM32_OTG_DSTS); + if ((status & OTG_DSTS_SOFFN0) == OTG_DSTS_SOFFN_EVEN) { regval |= OTG_DIEPCTL_SEVNFRM; @@ -1410,6 +1410,7 @@ static void stm32_epin_request(struct stm32_usbdev_s *priv, */ uint32_t empmsk = stm32_getreg(STM32_OTG_DIEPEMPMSK); + empmsk |= OTG_DIEPEMPMSK(privep->epphy); stm32_putreg(empmsk, STM32_OTG_DIEPEMPMSK); @@ -1545,6 +1546,7 @@ static void stm32_rxfifo_discard(struct stm32_ep_s *privep, int len) for (i = 0; i < len; i += 4) { volatile uint32_t data = stm32_getreg(regaddr); + UNUSED(data); } } @@ -1632,6 +1634,7 @@ static inline void stm32_ep0out_receive(struct stm32_ep_s *privep, /* Read the data into our special buffer for SETUP data */ int readlen = MIN(CONFIG_USBDEV_SETUP_MAXDATASIZE, bcnt); + stm32_rxfifo_read(privep, priv->ep0data, readlen); /* Do we have to discard any excess bytes? */ @@ -1935,6 +1938,7 @@ static void stm32_req_complete(struct stm32_ep_s *privep, int16_t result) */ bool stalled = privep->stalled; + if (privep->epphy == EP0) { privep->stalled = privep->dev->stalled; @@ -2331,6 +2335,7 @@ void stm32_ep0out_stdrequest(struct stm32_usbdev_s *priv, if (priv->addressed != 0 && ctrlreq->len == 0) { uint8_t recipient = ctrlreq->type & USB_REQ_RECIPIENT_MASK; + if (recipient == USB_REQ_RECIPIENT_ENDPOINT && ctrlreq->value == USB_FEATURE_ENDPOINTHALT && (privep = stm32_ep_findbyaddr(priv, @@ -2372,6 +2377,7 @@ void stm32_ep0out_stdrequest(struct stm32_usbdev_s *priv, if (priv->addressed != 0 && ctrlreq->len == 0) { uint8_t recipient = ctrlreq->type & USB_REQ_RECIPIENT_MASK; + if (recipient == USB_REQ_RECIPIENT_ENDPOINT && ctrlreq->value == USB_FEATURE_ENDPOINTHALT && (privep = stm32_ep_findbyaddr(priv, @@ -2528,6 +2534,7 @@ void stm32_ep0out_stdrequest(struct stm32_usbdev_s *priv, if (ret == OK) { uint8_t cfg = (uint8_t)ctrlreq->value; + if (cfg != 0) { priv->devstate = DEVSTATE_CONFIGURED; @@ -2870,6 +2877,7 @@ static inline void stm32_epout_interrupt(struct stm32_usbdev_s *priv) static inline void stm32_epin_runtestmode(struct stm32_usbdev_s *priv) { uint32_t regval = stm32_getreg(STM32_OTG_DCTL); + regval &= OTG_DCTL_TCTL_MASK; regval |= (uint32_t)priv->testmode << OTG_DCTL_TCTL_SHIFT; stm32_putreg(regval , STM32_OTG_DCTL); @@ -4907,6 +4915,7 @@ static struct usbdev_ep_s *stm32_ep_alloc(struct usbdev_s *dev, for (epno = 1; epno < STM32_NENDPOINTS; epno++) { uint8_t bit = 1 << epno; + if ((epavail & bit) != 0) { /* Mark the endpoint no longer available */ @@ -5064,6 +5073,7 @@ static int stm32_pullup(struct usbdev_s *dev, bool enable) usbtrace(TRACE_DEVPULLUP, (uint16_t)enable); irqstate_t flags = enter_critical_section(); + regval = stm32_getreg(STM32_OTG_DCTL); if (enable) { @@ -5632,30 +5642,17 @@ void arm_usbinitialize(void) */ struct stm32_usbdev_s *priv = &g_otghsdev; - uint32_t regval; int ret; usbtrace(TRACE_DEVINIT, 0); - /* Configure USB voltage regulator */ - - regval = stm32_getreg(STM32_PWR_CR3); - - /* Enable USB regulator if configured */ - -#ifdef CONFIG_STM32_OTG_USBREGEN - regval |= STM32_PWR_CR3_USBREGEN; -#else - regval &= ~STM32_PWR_CR3_USBREGEN; -#endif - - /* Enable VDD33USB supply level detector */ - - regval |= STM32_PWR_CR3_USB33DEN; - stm32_putreg(regval, STM32_PWR_CR3); + /* Power up the USB transceiver supply */ - while ((stm32_getreg(STM32_PWR_CR3) & STM32_PWR_CR3_USB33RDY) == 0) + ret = stm32_otg_phyinit(); + if (ret < 0) { + uerr("ERROR: OTG PHY initialization failed: %d\n", ret); + return; } /* Here we assume that: diff --git a/arch/arm/src/stm32h7/stm32_otghost.c b/arch/arm/src/common/stm32/stm32_otghost_v2.c similarity index 95% rename from arch/arm/src/stm32h7/stm32_otghost.c rename to arch/arm/src/common/stm32/stm32_otghost_v2.c index a192ab25ea6..d92fc2e8be8 100644 --- a/arch/arm/src/stm32h7/stm32_otghost.c +++ b/arch/arm/src/common/stm32/stm32_otghost_v2.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/stm32h7/stm32_otghost.c + * arch/arm/src/common/stm32/stm32_otghost_v2.c * * SPDX-License-Identifier: Apache-2.0 * @@ -55,9 +55,9 @@ #include <arch/board/board.h> /* May redefine GPIO settings */ #include "arm_internal.h" -#include "hardware/stm32_pwr.h" -#include "stm32_gpio.h" +#include "stm32.h" #include "stm32_otg.h" +#include "stm32_otg_phyif.h" #include "stm32_usbhost.h" #if defined(CONFIG_USBHOST) && defined(CONFIG_STM32_OTGFS) @@ -762,95 +762,95 @@ static void stm32_chan_configure(struct stm32_usbhost_s *priv, int chidx) switch (chan->eptype) { - case OTG_EPTYPE_CTRL: - case OTG_EPTYPE_BULK: - { + case OTG_EPTYPE_CTRL: + case OTG_EPTYPE_BULK: + { #ifdef HAVE_USBHOST_TRACE_VERBOSE - uint16_t intrace; - uint16_t outtrace; - - /* Determine the definitive trace ID to use below */ - - if (chan->eptype == OTG_EPTYPE_CTRL) - { - intrace = OTG_VTRACE2_CHANCONF_CTRL_IN; - outtrace = OTG_VTRACE2_CHANCONF_CTRL_OUT; - } - else - { - intrace = OTG_VTRACE2_CHANCONF_BULK_IN; - outtrace = OTG_VTRACE2_CHANCONF_BULK_OUT; - } + uint16_t intrace; + uint16_t outtrace; + + /* Determine the definitive trace ID to use below */ + + if (chan->eptype == OTG_EPTYPE_CTRL) + { + intrace = OTG_VTRACE2_CHANCONF_CTRL_IN; + outtrace = OTG_VTRACE2_CHANCONF_CTRL_OUT; + } + else + { + intrace = OTG_VTRACE2_CHANCONF_BULK_IN; + outtrace = OTG_VTRACE2_CHANCONF_BULK_OUT; + } #endif - /* Interrupts required for CTRL and BULK endpoints */ - - regval |= (OTG_HCINT_XFRC | OTG_HCINT_STALL | OTG_HCINT_NAK | - OTG_HCINT_TXERR | OTG_HCINT_DTERR); - - /* Additional setting for IN/OUT endpoints */ - - if (chan->in) - { - usbhost_vtrace2(intrace, chidx, chan->epno); - regval |= OTG_HCINT_BBERR; - } - else - { - usbhost_vtrace2(outtrace, chidx, chan->epno); - regval |= OTG_HCINT_NYET; - } - } - break; - - case OTG_EPTYPE_INTR: - { - /* Interrupts required for INTR endpoints */ - - regval |= (OTG_HCINT_XFRC | OTG_HCINT_STALL | OTG_HCINT_NAK | - OTG_HCINT_TXERR | OTG_HCINT_FRMOR | OTG_HCINT_DTERR); - - /* Additional setting for IN endpoints */ - - if (chan->in) - { - usbhost_vtrace2(OTG_VTRACE2_CHANCONF_INTR_IN, chidx, - chan->epno); - regval |= OTG_HCINT_BBERR; - } + /* Interrupts required for CTRL and BULK endpoints */ + + regval |= (OTG_HCINT_XFRC | OTG_HCINT_STALL | OTG_HCINT_NAK | + OTG_HCINT_TXERR | OTG_HCINT_DTERR); + + /* Additional setting for IN/OUT endpoints */ + + if (chan->in) + { + usbhost_vtrace2(intrace, chidx, chan->epno); + regval |= OTG_HCINT_BBERR; + } + else + { + usbhost_vtrace2(outtrace, chidx, chan->epno); + regval |= OTG_HCINT_NYET; + } + } + break; + + case OTG_EPTYPE_INTR: + { + /* Interrupts required for INTR endpoints */ + + regval |= (OTG_HCINT_XFRC | OTG_HCINT_STALL | OTG_HCINT_NAK | + OTG_HCINT_TXERR | OTG_HCINT_FRMOR | OTG_HCINT_DTERR); + + /* Additional setting for IN endpoints */ + + if (chan->in) + { + usbhost_vtrace2(OTG_VTRACE2_CHANCONF_INTR_IN, chidx, + chan->epno); + regval |= OTG_HCINT_BBERR; + } #ifdef HAVE_USBHOST_TRACE_VERBOSE - else - { - usbhost_vtrace2(OTG_VTRACE2_CHANCONF_INTR_OUT, chidx, - chan->epno); - } + else + { + usbhost_vtrace2(OTG_VTRACE2_CHANCONF_INTR_OUT, chidx, + chan->epno); + } #endif - } - break; + } + break; - case OTG_EPTYPE_ISOC: - { - /* Interrupts required for ISOC endpoints */ + case OTG_EPTYPE_ISOC: + { + /* Interrupts required for ISOC endpoints */ - regval |= (OTG_HCINT_XFRC | OTG_HCINT_ACK | OTG_HCINT_FRMOR); + regval |= (OTG_HCINT_XFRC | OTG_HCINT_ACK | OTG_HCINT_FRMOR); - /* Additional setting for IN endpoints */ + /* Additional setting for IN endpoints */ - if (chan->in) - { - usbhost_vtrace2(OTG_VTRACE2_CHANCONF_ISOC_IN, chidx, - chan->epno); - regval |= (OTG_HCINT_TXERR | OTG_HCINT_BBERR); - } + if (chan->in) + { + usbhost_vtrace2(OTG_VTRACE2_CHANCONF_ISOC_IN, chidx, + chan->epno); + regval |= (OTG_HCINT_TXERR | OTG_HCINT_BBERR); + } #ifdef HAVE_USBHOST_TRACE_VERBOSE - else - { - usbhost_vtrace2(OTG_VTRACE2_CHANCONF_ISOC_OUT, chidx, - chan->epno); - } + else + { + usbhost_vtrace2(OTG_VTRACE2_CHANCONF_ISOC_OUT, chidx, + chan->epno); + } #endif - } - break; + } + break; } stm32_putreg(STM32_OTG_HCINTMSK(chidx), regval); @@ -1504,33 +1504,33 @@ static void stm32_transfer_start(struct stm32_usbhost_s *priv, int chidx) switch (chan->eptype) { - case OTG_EPTYPE_CTRL: /* Non periodic transfer */ - case OTG_EPTYPE_BULK: - { - /* Read the Non-periodic Tx FIFO status register */ - - regval = stm32_getreg(STM32_OTG_HNPTXSTS); - avail = ((regval & OTG_HNPTXSTS_NPTXFSAV_MASK) >> - OTG_HNPTXSTS_NPTXFSAV_SHIFT) << 2; - } - break; + case OTG_EPTYPE_CTRL: /* Non periodic transfer */ + case OTG_EPTYPE_BULK: + { + /* Read the Non-periodic Tx FIFO status register */ - /* Periodic transfer */ + regval = stm32_getreg(STM32_OTG_HNPTXSTS); + avail = ((regval & OTG_HNPTXSTS_NPTXFSAV_MASK) >> + OTG_HNPTXSTS_NPTXFSAV_SHIFT) << 2; + } + break; - case OTG_EPTYPE_INTR: - case OTG_EPTYPE_ISOC: - { - /* Read the Non-periodic Tx FIFO status register */ + /* Periodic transfer */ - regval = stm32_getreg(STM32_OTG_HPTXSTS); - avail = ((regval & OTG_HPTXSTS_PTXFSAVL_MASK) >> - OTG_HPTXSTS_PTXFSAVL_SHIFT) << 2; - } - break; + case OTG_EPTYPE_INTR: + case OTG_EPTYPE_ISOC: + { + /* Read the Non-periodic Tx FIFO status register */ - default: - DEBUGPANIC(); - return; + regval = stm32_getreg(STM32_OTG_HPTXSTS); + avail = ((regval & OTG_HPTXSTS_PTXFSAVL_MASK) >> + OTG_HPTXSTS_PTXFSAVL_SHIFT) << 2; + } + break; + + default: + DEBUGPANIC(); + return; } /* Is there space in the TxFIFO to hold the minimum size packet? */ @@ -1549,6 +1549,7 @@ static void stm32_transfer_start(struct stm32_usbhost_s *priv, int chidx) */ unsigned int wrpackets = avail / chan->maxpacket; + wrsize = wrpackets * chan->maxpacket; } @@ -1566,7 +1567,7 @@ static void stm32_transfer_start(struct stm32_usbhost_s *priv, int chidx) * FIFO becomes empty. */ - stm32_txfe_enable(priv, chidx); + stm32_txfe_enable(priv, chidx); } } } @@ -1775,42 +1776,42 @@ static int stm32_in_setup(struct stm32_usbhost_s *priv, int chidx) chan = &priv->chan[chidx]; switch (chan->eptype) { - default: - case OTG_EPTYPE_CTRL: /* Control */ - { - /* This kind of transfer on control endpoints other than EP0 are not - * currently supported - */ - - return -ENOSYS; - } - - case OTG_EPTYPE_ISOC: /* Isochronous */ - { - /* Set up the IN data PID */ - - usbhost_vtrace2(OTG_VTRACE2_ISOCIN, chidx, chan->buflen); - chan->pid = OTG_PID_DATA0; - } - break; - - case OTG_EPTYPE_BULK: /* Bulk */ - { - /* Setup the IN data PID */ - - usbhost_vtrace2(OTG_VTRACE2_BULKIN, chidx, chan->buflen); - chan->pid = chan->indata1 ? OTG_PID_DATA1 : OTG_PID_DATA0; - } - break; - - case OTG_EPTYPE_INTR: /* Interrupt */ - { - /* Setup the IN data PID */ - - usbhost_vtrace2(OTG_VTRACE2_INTRIN, chidx, chan->buflen); - chan->pid = chan->indata1 ? OTG_PID_DATA1 : OTG_PID_DATA0; - } - break; + default: + case OTG_EPTYPE_CTRL: /* Control */ + { + /* This kind of transfer on control endpoints other than EP0 are + * not currently supported + */ + + return -ENOSYS; + } + + case OTG_EPTYPE_ISOC: /* Isochronous */ + { + /* Set up the IN data PID */ + + usbhost_vtrace2(OTG_VTRACE2_ISOCIN, chidx, chan->buflen); + chan->pid = OTG_PID_DATA0; + } + break; + + case OTG_EPTYPE_BULK: /* Bulk */ + { + /* Setup the IN data PID */ + + usbhost_vtrace2(OTG_VTRACE2_BULKIN, chidx, chan->buflen); + chan->pid = chan->indata1 ? OTG_PID_DATA1 : OTG_PID_DATA0; + } + break; + + case OTG_EPTYPE_INTR: /* Interrupt */ + { + /* Setup the IN data PID */ + + usbhost_vtrace2(OTG_VTRACE2_INTRIN, chidx, chan->buflen); + chan->pid = chan->indata1 ? OTG_PID_DATA1 : OTG_PID_DATA0; + } + break; } /* Start the transfer */ @@ -1904,6 +1905,7 @@ static ssize_t stm32_in_transfer(struct stm32_usbhost_s *priv, int chidx, */ clock_t elapsed = clock_systime_ticks() - start; + if (elapsed >= STM32_DATANAK_DELAY) { /* Timeout out... break out returning the NAK as @@ -2132,46 +2134,46 @@ static int stm32_out_setup(struct stm32_usbhost_s *priv, int chidx) chan = &priv->chan[chidx]; switch (chan->eptype) { - default: - case OTG_EPTYPE_CTRL: /* Control */ - { - /* This kind of transfer on control endpoints other than EP0 are not - * currently supported - */ - - return -ENOSYS; - } - - case OTG_EPTYPE_ISOC: /* Isochronous */ - { - /* Set up the OUT data PID */ - - usbhost_vtrace2(OTG_VTRACE2_ISOCOUT, chidx, chan->buflen); - chan->pid = OTG_PID_DATA0; - } - break; - - case OTG_EPTYPE_BULK: /* Bulk */ - { - /* Setup the OUT data PID */ - - usbhost_vtrace2(OTG_VTRACE2_BULKOUT, chidx, chan->buflen); - chan->pid = chan->outdata1 ? OTG_PID_DATA1 : OTG_PID_DATA0; - } - break; - - case OTG_EPTYPE_INTR: /* Interrupt */ - { - /* Setup the OUT data PID */ - - usbhost_vtrace2(OTG_VTRACE2_INTROUT, chidx, chan->buflen); - chan->pid = chan->outdata1 ? OTG_PID_DATA1 : OTG_PID_DATA0; - - /* Toggle the OUT data PID for the next transfer */ - - chan->outdata1 ^= true; - } - break; + default: + case OTG_EPTYPE_CTRL: /* Control */ + { + /* This kind of transfer on control endpoints other than EP0 are + * not currently supported + */ + + return -ENOSYS; + } + + case OTG_EPTYPE_ISOC: /* Isochronous */ + { + /* Set up the OUT data PID */ + + usbhost_vtrace2(OTG_VTRACE2_ISOCOUT, chidx, chan->buflen); + chan->pid = OTG_PID_DATA0; + } + break; + + case OTG_EPTYPE_BULK: /* Bulk */ + { + /* Setup the OUT data PID */ + + usbhost_vtrace2(OTG_VTRACE2_BULKOUT, chidx, chan->buflen); + chan->pid = chan->outdata1 ? OTG_PID_DATA1 : OTG_PID_DATA0; + } + break; + + case OTG_EPTYPE_INTR: /* Interrupt */ + { + /* Setup the OUT data PID */ + + usbhost_vtrace2(OTG_VTRACE2_INTROUT, chidx, chan->buflen); + chan->pid = chan->outdata1 ? OTG_PID_DATA1 : OTG_PID_DATA0; + + /* Toggle the OUT data PID for the next transfer */ + + chan->outdata1 ^= true; + } + break; } /* Start the transfer */ @@ -2437,6 +2439,7 @@ static void stm32_gint_wrpacket(struct stm32_usbhost_s *priv, for (; buflen32 > 0; buflen32--) { uint32_t data = *src++; + stm32_putreg(fifo, data); } @@ -3070,55 +3073,55 @@ static inline void stm32_gint_rxflvlisr(struct stm32_usbhost_s *priv) switch (grxsts & OTG_GRXSTSH_PKTSTS_MASK) { - case OTG_GRXSTSH_PKTSTS_INRECVD: /* IN data packet received */ - { - /* Read the data into the host buffer. */ + case OTG_GRXSTSH_PKTSTS_INRECVD: /* IN data packet received */ + { + /* Read the data into the host buffer. */ - bcnt = (grxsts & OTG_GRXSTSH_BCNT_MASK) >> OTG_GRXSTSH_BCNT_SHIFT; - if (bcnt > 0 && priv->chan[chidx].buffer != NULL) - { - /* Transfer the packet from the Rx FIFO into the user buffer */ + bcnt = (grxsts & OTG_GRXSTSH_BCNT_MASK) >> OTG_GRXSTSH_BCNT_SHIFT; + if (bcnt > 0 && priv->chan[chidx].buffer != NULL) + { + /* Transfer the packet from the Rx FIFO into the user buffer */ - dest = (uint32_t *)priv->chan[chidx].buffer; - fifo = STM32_OTG_DFIFO_HCH(0); - bcnt32 = (bcnt + 3) >> 2; + dest = (uint32_t *)priv->chan[chidx].buffer; + fifo = STM32_OTG_DFIFO_HCH(0); + bcnt32 = (bcnt + 3) >> 2; - for (i = 0; i < bcnt32; i++) - { - *dest++ = stm32_getreg(fifo); - } + for (i = 0; i < bcnt32; i++) + { + *dest++ = stm32_getreg(fifo); + } - stm32_pktdump("Received", priv->chan[chidx].buffer, bcnt); + stm32_pktdump("Received", priv->chan[chidx].buffer, bcnt); - /* Toggle the IN data pid (Used by Bulk and INTR only) */ + /* Toggle the IN data pid (Used by Bulk and INTR only) */ - priv->chan[chidx].indata1 ^= true; + priv->chan[chidx].indata1 ^= true; - /* Manage multiple packet transfers */ + /* Manage multiple packet transfers */ - priv->chan[chidx].buffer += bcnt; - priv->chan[chidx].xfrd += bcnt; + priv->chan[chidx].buffer += bcnt; + priv->chan[chidx].xfrd += bcnt; - /* Check if more packets are expected */ + /* Check if more packets are expected */ - hctsiz = stm32_getreg(STM32_OTG_HCTSIZ(chidx)); - if ((hctsiz & OTG_HCTSIZ_PKTCNT_MASK) != 0) - { - /* Re-activate the channel when more packets are expected */ + hctsiz = stm32_getreg(STM32_OTG_HCTSIZ(chidx)); + if ((hctsiz & OTG_HCTSIZ_PKTCNT_MASK) != 0) + { + /* Re-activate the channel when more packets are expected */ - hcchar |= OTG_HCCHAR_CHENA; - hcchar &= ~OTG_HCCHAR_CHDIS; - stm32_putreg(STM32_OTG_HCCHAR(chidx), hcchar); - } - } - } - break; + hcchar |= OTG_HCCHAR_CHENA; + hcchar &= ~OTG_HCCHAR_CHDIS; + stm32_putreg(STM32_OTG_HCCHAR(chidx), hcchar); + } + } + } + break; - case OTG_GRXSTSH_PKTSTS_INDONE: /* IN transfer completed */ - case OTG_GRXSTSH_PKTSTS_DTOGERR: /* Data toggle error */ - case OTG_GRXSTSH_PKTSTS_HALTED: /* Channel halted */ - default: - break; + case OTG_GRXSTSH_PKTSTS_INDONE: /* IN transfer completed */ + case OTG_GRXSTSH_PKTSTS_DTOGERR: /* Data toggle error */ + case OTG_GRXSTSH_PKTSTS_HALTED: /* Channel halted */ + default: + break; } /* Re-enable the RxFIFO non-empty interrupt */ @@ -3196,6 +3199,7 @@ static inline void stm32_gint_nptxfeisr(struct stm32_usbhost_s *priv) */ unsigned int wrpackets = avail / chan->maxpacket; + wrsize = wrpackets * chan->maxpacket; } @@ -3286,6 +3290,7 @@ static inline void stm32_gint_ptxfeisr(struct stm32_usbhost_s *priv) */ unsigned int wrpackets = avail / chan->maxpacket; + wrsize = wrpackets * chan->maxpacket; } @@ -3796,16 +3801,16 @@ static void stm32_txfe_enable(struct stm32_usbhost_s *priv, int chidx) regval = stm32_getreg(STM32_OTG_GINTMSK); switch (chan->eptype) { - default: - case OTG_EPTYPE_CTRL: /* Non periodic transfer */ - case OTG_EPTYPE_BULK: - regval |= OTG_GINT_NPTXFE; - break; - - case OTG_EPTYPE_INTR: /* Periodic transfer */ - case OTG_EPTYPE_ISOC: - regval |= OTG_GINT_PTXFE; - break; + default: + case OTG_EPTYPE_CTRL: /* Non periodic transfer */ + case OTG_EPTYPE_BULK: + regval |= OTG_GINT_NPTXFE; + break; + + case OTG_EPTYPE_INTR: /* Periodic transfer */ + case OTG_EPTYPE_ISOC: + regval |= OTG_GINT_PTXFE; + break; } /* Enable interrupts */ @@ -5394,7 +5399,6 @@ struct usbhost_connection_s *stm32_otgfshost_initialize(int controller) */ struct stm32_usbhost_s *priv = &g_usbhost; - uint32_t regval; /* Sanity checks */ @@ -5408,25 +5412,12 @@ struct usbhost_connection_s *stm32_otgfshost_initialize(int controller) stm32_sw_initialize(priv); - /* Configure USB voltage regulator */ - - regval = stm32_getreg(STM32_PWR_CR3); - - /* Enable USB regulator if configured */ + /* Power up the USB transceiver supply */ -#ifdef CONFIG_STM32_OTG_USBREGEN - regval |= STM32_PWR_CR3_USBREGEN; -#else - regval &= ~STM32_PWR_CR3_USBREGEN; -#endif - - /* Enable VDD33USB supply level detector */ - - regval |= STM32_PWR_CR3_USB33DEN; - stm32_putreg(STM32_PWR_CR3, regval); - - while ((stm32_getreg(STM32_PWR_CR3) & STM32_PWR_CR3_USB33RDY) == 0) + if (stm32_otg_phyinit() < 0) { + uerr("ERROR: OTG PHY initialization failed\n"); + return NULL; } /* Alternate function pin configuration. Here we assume that: diff --git a/arch/arm/src/common/stm32/stm32_usbhost.h b/arch/arm/src/common/stm32/stm32_usbhost.h index c659a23a25b..276e5b08f76 100644 --- a/arch/arm/src/common/stm32/stm32_usbhost.h +++ b/arch/arm/src/common/stm32/stm32_usbhost.h @@ -31,6 +31,8 @@ #if defined(CONFIG_STM32_COMMON_LEGACY) # include "stm32_usbhost_m3m4_v1.h" +#elif defined(CONFIG_STM32_HAVE_IP_OTG_V2) +# include "stm32_usbhost_v2.h" #else # error "Unsupported STM32 stm32_usbhost" #endif diff --git a/arch/arm/src/stm32h7/stm32_usbhost.c b/arch/arm/src/common/stm32/stm32_usbhost_v2.c similarity index 99% rename from arch/arm/src/stm32h7/stm32_usbhost.c rename to arch/arm/src/common/stm32/stm32_usbhost_v2.c index 6d6890f8287..03f6ff24cc5 100644 --- a/arch/arm/src/stm32h7/stm32_usbhost.c +++ b/arch/arm/src/common/stm32/stm32_usbhost_v2.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/stm32h7/stm32_usbhost.c + * arch/arm/src/common/stm32/stm32_usbhost_v2.c * * SPDX-License-Identifier: Apache-2.0 * @@ -30,7 +30,7 @@ #include <stdbool.h> #include <sys/types.h> -#include "stm32_usbhost.h" +#include "stm32_usbhost_v2.h" #ifdef HAVE_USBHOST_TRACE diff --git a/arch/arm/src/stm32h7/stm32_usbhost.h b/arch/arm/src/common/stm32/stm32_usbhost_v2.h similarity index 97% rename from arch/arm/src/stm32h7/stm32_usbhost.h rename to arch/arm/src/common/stm32/stm32_usbhost_v2.h index ecb5e373bc2..3b1ad1e0e8d 100644 --- a/arch/arm/src/stm32h7/stm32_usbhost.h +++ b/arch/arm/src/common/stm32/stm32_usbhost_v2.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/stm32h7/stm32_usbhost.h + * arch/arm/src/common/stm32/stm32_usbhost_v2.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __ARCH_ARM_SRC_STM32H7_STM32_USBHOST_H -#define __ARCH_ARM_SRC_STM32H7_STM32_USBHOST_H +#ifndef __ARCH_ARM_SRC_COMMON_STM32_STM32_USBHOST_V2_H +#define __ARCH_ARM_SRC_COMMON_STM32_STM32_USBHOST_V2_H /* STM32 USB OTG Host Driver Support * @@ -186,4 +186,4 @@ void stm32_usbhost_vbusdrive(int iface, bool enable); #endif /* __ASSEMBLY__ */ #endif /* (CONFIG_STM32_OTGFS || CONFIG_STM32_OTGHS) && CONFIG_USBHOST */ -#endif /* __ARCH_ARM_SRC_STM32H7_STM32_USBHOST_H */ +#endif /* __ARCH_ARM_SRC_COMMON_STM32_STM32_USBHOST_V2_H */ diff --git a/arch/arm/src/stm32h7/CMakeLists.txt b/arch/arm/src/stm32h7/CMakeLists.txt index 1d9dfffe670..856958637ff 100644 --- a/arch/arm/src/stm32h7/CMakeLists.txt +++ b/arch/arm/src/stm32h7/CMakeLists.txt @@ -139,21 +139,6 @@ if(CONFIG_STM32_LTDC) list(APPEND SRCS stm32_ltdc.c) endif() -if(CONFIG_USBDEV) - list(APPEND SRCS stm32_otgdev.c) -endif() - -if(CONFIG_USBHOST) - list(APPEND SRCS stm32_otghost.c) - if(CONFIG_USBHOST_TRACE) - list(APPEND SRCS stm32_usbhost.c) - else() - if(CONFIG_DEBUG_USB) - list(APPEND SRCS stm32_usbhost.c) - endif() - endif() -endif() - if(CONFIG_STM32_PWM) list(APPEND SRCS stm32_pwm.c) endif() diff --git a/arch/arm/src/stm32h7/Kconfig b/arch/arm/src/stm32h7/Kconfig index 069de5ac3ca..c6160f7763c 100644 --- a/arch/arm/src/stm32h7/Kconfig +++ b/arch/arm/src/stm32h7/Kconfig @@ -109,6 +109,7 @@ config STM32_H7_PERIPHERALS select STM32_HAVE_HSI48 select STM32_HAVE_OTG_H7 select STM32_HAVE_OTGHS + select STM32_HAVE_IP_OTG_V2 select STM32_HAVE_USART_RXFIFO_THRESHOLD select STM32_HAVE_FDCAN_H7 select STM32_HAVE_ETHERNET diff --git a/arch/arm/src/stm32h7/Make.defs b/arch/arm/src/stm32h7/Make.defs index 119e3e1ad72..093b79ddbff 100644 --- a/arch/arm/src/stm32h7/Make.defs +++ b/arch/arm/src/stm32h7/Make.defs @@ -142,21 +142,6 @@ ifeq ($(CONFIG_STM32_LTDC),y) CHIP_CSRCS += stm32_ltdc.c endif -ifeq ($(CONFIG_USBDEV),y) -CHIP_CSRCS += stm32_otgdev.c -endif - -ifeq ($(CONFIG_USBHOST),y) -CHIP_CSRCS += stm32_otghost.c -ifeq ($(CONFIG_USBHOST_TRACE),y) -CHIP_CSRCS += stm32_usbhost.c -else -ifeq ($(CONFIG_DEBUG_USB),y) -CHIP_CSRCS += stm32_usbhost.c -endif -endif -endif - ifeq ($(CONFIG_STM32_PWM),y) CHIP_CSRCS += stm32_pwm.c endif diff --git a/arch/arm/src/stm32h7/stm32_otg_phyif.h b/arch/arm/src/stm32h7/stm32_otg_phyif.h new file mode 100644 index 00000000000..9093a7fb8d1 --- /dev/null +++ b/arch/arm/src/stm32h7/stm32_otg_phyif.h @@ -0,0 +1,79 @@ +/**************************************************************************** + * arch/arm/src/stm32h7/stm32_otg_phyif.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_STM32H7_STM32_OTG_PHYIF_H +#define __ARCH_ARM_SRC_STM32H7_STM32_OTG_PHYIF_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include "arm_internal.h" +#include "hardware/stm32_pwr.h" + +/**************************************************************************** + * Inline Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_otg_phyinit + * + * Description: + * Power up the supply of the OTG transceivers. The common OTG device + * and host drivers call this before they touch the OTG core. On the + * STM32H7 this configures the USB voltage regulator and waits for the + * VDD33USB supply level detector. + * + * Returned Value: + * OK + * + ****************************************************************************/ + +static inline int stm32_otg_phyinit(void) +{ + uint32_t regval; + + regval = getreg32(STM32_PWR_CR3); + + /* Enable USB regulator if configured */ + +#ifdef CONFIG_STM32_OTG_USBREGEN + regval |= STM32_PWR_CR3_USBREGEN; +#else + regval &= ~STM32_PWR_CR3_USBREGEN; +#endif + + /* Enable VDD33USB supply level detector */ + + regval |= STM32_PWR_CR3_USB33DEN; + putreg32(regval, STM32_PWR_CR3); + + while ((getreg32(STM32_PWR_CR3) & STM32_PWR_CR3_USB33RDY) == 0) + { + } + + return OK; +} + +#endif /* __ARCH_ARM_SRC_STM32H7_STM32_OTG_PHYIF_H */
