Skip to content

Commit 2b56eb6

Browse files
marwaiehm-stkartben
authored andcommitted
drivers: usb: Add STM32N6 USB support
Enable clock and power for the OTG HS peripheral of the STM32N6x serie Signed-off-by: IBEN EL HADJ MESSAOUD Marwa <marwa.ibenelhadjmessaoud-ext@st.com>
1 parent 752e1fe commit 2b56eb6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drivers/usb/device/usb_dc_stm32.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ LOG_MODULE_REGISTER(usb_dc_stm32);
6767

6868
static const struct stm32_pclken pclken[] = STM32_DT_INST_CLOCKS(0);
6969

70+
#if !DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_otghs)
7071
PINCTRL_DT_INST_DEFINE(0);
7172
static const struct pinctrl_dev_config *usb_pcfg =
7273
PINCTRL_DT_INST_DEV_CONFIG_GET(0);
74+
#endif
7375

7476
#define USB_OTG_HS_EMB_PHYC (DT_HAS_COMPAT_STATUS_OKAY(st_stm32_usbphyc) && \
7577
DT_HAS_COMPAT_STATUS_OKAY(st_stm32_otghs))
@@ -339,6 +341,14 @@ static int usb_dc_stm32_phy_specific_clock_enable(const struct device *const clk
339341
* with LL_PWR_EnableVDDUSB function (higher case)
340342
*/
341343
LL_PWR_EnableVDDUSB();
344+
#elif DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_otghs)
345+
/* Enable Vdd USB voltage monitoring */
346+
LL_PWR_EnableVddUSBMonitoring();
347+
while (__HAL_PWR_GET_FLAG(PWR_FLAG_USB33RDY)) {
348+
/* Wait for VDD33USB ready */
349+
}
350+
/* Enable VDDUSB */
351+
LL_PWR_EnableVddUSB();
342352
#endif
343353

344354
if (DT_INST_NUM_CLOCKS(0) > 1) {
@@ -417,13 +427,15 @@ static int usb_dc_stm32_clock_enable(void)
417427
/* Both OTG HS and USBPHY sleep clock MUST be disabled here at the same time */
418428
LL_AHB2_GRP1_DisableClockStopSleep(LL_AHB2_GRP1_PERIPH_OTG_HS ||
419429
LL_AHB2_GRP1_PERIPH_USBPHY);
420-
#else
430+
#elif !DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_otghs)
421431
LL_AHB1_GRP1_DisableClockLowPower(LL_AHB1_GRP1_PERIPH_OTGHSULPI);
422432
#endif
423433

424434
#if USB_OTG_HS_EMB_PHYC
435+
#if !DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_otghs)
425436
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_OTGPHYC);
426437
#endif
438+
#endif
427439
#endif /* USB_OTG_HS_ULPI_PHY */
428440

429441
return 0;
@@ -511,12 +523,14 @@ static int usb_dc_stm32_init(void)
511523
}
512524
#endif
513525

526+
#if !DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_otghs)
514527
LOG_DBG("Pinctrl signals configuration");
515528
ret = pinctrl_apply_state(usb_pcfg, PINCTRL_STATE_DEFAULT);
516529
if (ret < 0) {
517530
LOG_ERR("USB pinctrl setup failed (%d)", ret);
518531
return ret;
519532
}
533+
#endif
520534

521535
LOG_DBG("HAL_PCD_Init");
522536
status = HAL_PCD_Init(&usb_dc_stm32_state.pcd);

0 commit comments

Comments
 (0)