Skip to content

Commit

Permalink
drivers: usb stm32H5 and stm32U5 have an independent power supply
Browse files Browse the repository at this point in the history
The stm32H5 mcu has an independent USB supply to be enabled
at init with LL_PWR_EnableVDDUSB function like the stm32U5 serie.
Both series have PWR_USBSCR_USB33SV bit in their USBSCR POWER reg.
and other series all have PWR_CR2_USV bit in their CR2 POWER reg.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
  • Loading branch information
FRASTM authored and fabiobaltieri committed Dec 19, 2023
1 parent 98336b2 commit 6e678e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 7 additions & 4 deletions drivers/usb/device/usb_dc_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,13 @@ static int usb_dc_stm32_clock_enable(void)
return -ENODEV;
}

#ifdef CONFIG_SOC_SERIES_STM32U5X
/* VDDUSB independent USB supply (PWR clock is on) */
#ifdef PWR_USBSCR_USB33SV
/*
* VDDUSB independent USB supply (PWR clock is on)
* with LL_PWR_EnableVDDUSB function (higher case)
*/
LL_PWR_EnableVDDUSB();
#endif /* CONFIG_SOC_SERIES_STM32U5X */
#endif /* PWR_USBSCR_USB33SV */

if (DT_INST_NUM_CLOCKS(0) > 1) {
if (clock_control_configure(clk, (clock_control_subsys_t)&pclken[1],
Expand Down Expand Up @@ -508,7 +511,7 @@ int usb_dc_attach(void)

/*
* Required for at least STM32L4 devices as they electrically
* isolate USB features from VDDUSB. It must be enabled before
* isolate USB features from VddUSB. It must be enabled before
* USB can function. Refer to section 5.1.3 in DM00083560 or
* DM00310109.
*/
Expand Down
9 changes: 6 additions & 3 deletions drivers/usb/udc/udc_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,10 +914,13 @@ static int priv_clock_enable(void)
return -ENODEV;
}

#ifdef CONFIG_SOC_SERIES_STM32U5X
/* VDDUSB independent USB supply (PWR clock is on) */
#if defined(PWR_USBSCR_USB33SV)
/*
* VDDUSB independent USB supply (PWR clock is on)
* with LL_PWR_EnableVDDUSB function (higher case)
*/
LL_PWR_EnableVDDUSB();
#endif /* CONFIG_SOC_SERIES_STM32U5X */
#endif /* PWR_USBSCR_USB33SV */
#if defined(CONFIG_SOC_SERIES_STM32H7X)
LL_PWR_EnableUSBVoltageDetector();

Expand Down

0 comments on commit 6e678e3

Please sign in to comment.