Skip to content

Conversation

@mathieuchopstm
Copy link
Contributor

Allow selecting a voltage scale using Device Tree on STM32U5 series. This is notably useful when a high system clock frequency is not required, but the application still wants to use the USB IPs which are only available in certain ranges.

Fixes #98641.

@mathieuchopstm mathieuchopstm added the platform: STM32 ST Micro STM32 label Dec 1, 2025
@mathieuchopstm
Copy link
Contributor Author

@petrosyan-van could you please give some feedback on this? 🙂

@petrosyan-van
Copy link
Contributor

@petrosyan-van could you please give some feedback on this? 🙂

Thanks for this PR! I will try it out in upcoming days and will let you know :)

+---------+----------------+-----------------------------------+
| 3 | 55 MHz | [1] |
+---------+----------------+-----------------------------------+
| 4 | 25 MHz | [1][2]; lowest power consumption |
Copy link
Contributor

@petrosyan-van petrosyan-van Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in udc_stm32.c we have:

	/* Check that power range is 1 or 2 */
	if (LL_PWR_GetRegulVoltageScaling() < LL_PWR_REGU_VOLTAGE_SCALE2) {
		LOG_ERR("Wrong Power range to use USB OTG HS");
		return -EIO;
	}

there is no check if it's OTG_HS or OTG_FS. Seems the requirement is to have at least scale 2 in the code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code in UDC driver is overzealous - the table is correct and based on STM32U5 series Reference Manual:
image

The UDC driver should definitely be fixed, but this is a separate issue outside PR scope.

@mathieuchopstm mathieuchopstm force-pushed the topic/stm32u5_dt_vos_cfg branch from f916d18 to 70587c3 Compare December 2, 2025 13:14
@mathieuchopstm
Copy link
Contributor Author

Added missing compatible: directive in binding

+---------+----------------+-----------------------------------+
| 3 | 55 MHz | [1] |
+---------+----------------+-----------------------------------+
| 4 | 25 MHz | [1][2]; lowest power consumption |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
| 4 | 25 MHz | [1][2]; lowest power consumption |
| 4 | 25 MHz | Lowest power consumption [1][2] |

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done + saved a few characters at the right of table.

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LTGM

Controls two voltage regulators which can output one voltage
among four different ranges depending on use case.
among four different voltage scales, depending on use case.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be fixed in previous commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@petrosyan-van
Copy link
Contributor

I tried with voltage-scale = <2>; and the USB stack now works, thanks! :)
Is there a possibility to change it dynamically? I mean, ideally, I would set the voltage-scale to 2 (or 3 after UDC driver fix), when USB is connected, but would go to 4 when it is disconnected to save some power. Cause my plan is to enable/disable USB stack on plug/unplug

Add a binding for the power controller of STM32U5 series.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Add the "st,stm32u5-pwr" compatible to the Power Controller node in the
DTSI for STM32U5 series.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Add support for the new `voltage-scale` property on the STM32U5-specific
Power Controller binding.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Add new voltage scale selection property for STM32U5 to 4.4 release notes.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
@mathieuchopstm mathieuchopstm force-pushed the topic/stm32u5_dt_vos_cfg branch from 70587c3 to 0757899 Compare December 2, 2025 15:16
@zephyrbot zephyrbot requested a review from erwango December 2, 2025 15:18
@mathieuchopstm
Copy link
Contributor Author

I tried with voltage-scale = <2>; and the USB stack now works, thanks! :) Is there a possibility to change it dynamically? I mean, ideally, I would set the voltage-scale to 2 (or 3 after UDC driver fix), when USB is connected, but would go to 4 when it is disconnected to save some power. Cause my plan is to enable/disable USB stack on plug/unplug

We have no plan at the moment for supporting dynamic voltage scaling on STM32 platforms.

If you want such functionality, you will have to roll your own implementation (note that the LL API can be used by the application through the #include <stm32_ll_PPP.h> headers). You might also be interested in the CPU Frequency Scaling subsystem (which is not supported on STM32 platforms either).

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 2, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clock_stm32_u5: Voltage regulator high ranges cannot be selected when running at low clock frequency

4 participants