Skip to content

Conversation

@gautierg-st
Copy link
Contributor

This PR replaces all PLL bindings for STM32F2/F4/F7 by a single one, and adds support for missing PLL outputs for some PLLs of some SoCs.

Here is the table I used as reference, extracted from the information from the different RefMans. A * indicates the presence of an additional divisor for this PLL output.

PLL PLLI2S PLLSAI
M N P Q R M N P Q R M N P Q R
F2xx 2-63 192-432 2/4/6/8 2-15 192-432 2-7
F401 2-63 192-432 2/4/6/8 2-15 192-432 2-7
F405/07/15/17 2-63 50-432 2/4/6/8 2-15 50-432 2-7
F410 2-63 50-432 2/4/6/8 2-15 2-7
F411 2-63 50-432 2/4/6/8 2-15 2-63 50-432 2-7
F412 2-63 50-432 2/4/6/8 2-15 2-7 2-63 50-432 2-15 2-7
F413/23 2-63 50-432 2/4/6/8 2-15 2-7* 2-63 50-432 2-15 2-7*
F427/29/37/39 2-63 50-432 2/4/6/8 2-15 50-432 2-15* 2-7 50-432 2-15* 2-7*
F446 2-63 50-432 2/4/6/8 2-15 2-7 2-63 50-432 2/4/6/8 2-15* 2-7 2-63 50-432 2/4/6/8 2-15*
F469/79 2-63 50-432 2/4/6/8 2-15 2-7 50-432 2-15* 2-7 50-432 2/4/6/8 2-15* 2-7*
F72x/73x 2-63 50-432 2/4/6/8 2-15 50-432 2-15* 2-7 50-432 2/4/6/8 2-15*
F74x/75x 2-63 50-432 2/4/6/8 2-15 50-432 2/4/6/8 2-15* 2-7 50-432 2/4/6/8 2-15* 2-7*
F76x/77x 2-63 50-432 2/4/6/8 2-15 2-7 50-432 2/4/6/8 2-15* 2-7 50-432 2/4/6/8 2-15* 2-7*

With this PR, all these PLL outputs are now supported, including with the additional divisors. Checks are in place to verify all enabled share the same source, that the div-M is the same between active PLLs (for those SoCs that don't have individual div-M), and that additional divisors are correctly defined if they are available and the output is used.

It also completes the support of the 48M clock for some SoCs.

… PLLs

STM32F2, F4 and F7 have up to 3 PLLs: PLL, PLLI2S and PLLSAI. These PLLs
are very similar, the principal differences are which outputs are available
for which PLL of each SoC.

Instead of having a large number of files to describe all the possible
very similar variants, use one single binding to rule them all.

Signed-off-by: Guillaume Gautier <[email protected]>
plli2s: plli2s {
#clock-cells = <0>;
compatible = "st,stm32f411-plli2s-clock";
compatible = "st,stm32fx-plli2s-clock";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
compatible = "st,stm32fx-plli2s-clock";
compatible = "st,stm32fx-pll-clock";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, I missed that one. Fixed.

Comment on lines 23 to 24
#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32fx_pll_clock, okay) && \
DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(plli2s), st_stm32fx_pll_clock, okay)
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify to

#if defined(DT_PLL_CLOCKS_CTRL) && defined(DT_PLLI2S_CLOCKS_CTRL)

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, much less verbose. Done

"For the PLLSAI, both div-r and div-divr must be present if one of them is present");
#endif /* STM32_PLLSAI_ENABLED && RCC_PLLSAICFGR_PLLSAIR */

#if STM32_PLL_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#if STM32_PLL_ENABLED
#ifdef STM32_PLL_ENABLED

STM32_PLL_ENABLED is either not defined or defined to 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If not defined, I think the preprocessor consider it as 0. But I reverted back to ifdef all the same.

}

#if defined(STM32_CK48_ENABLED)
#if STM32_CK48_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

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

Restore the previous way: STM32_CK48_ENABLED is either not defined or defined to 1.

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

#endif /* defined(STM32_PLL_ENABLED) */
#endif /* STM32_PLL_ENABLED */

#if STM32_PLLI2S_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#if STM32_PLLI2S_ENABLED
#ifdef STM32_PLLI2S_ENABLED

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

#endif /* STM32_PLLI2S_ENABLED */

#if defined(STM32_PLLSAI_ENABLED)
#if STM32_PLLSAI_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#if STM32_PLLSAI_ENABLED
#ifdef STM32_PLLSAI_ENABLED

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

For all STM32F2, F4 and F7, use the new binding instead of the various ones
previously defined.

For F411 and F446, this removes the need to define the PLLI2S since it is
already included in F401.

For F7, this commit also adds the PLLI2S that was missing.

Signed-off-by: Guillaume Gautier <[email protected]>
Add some missing clock sources and reorganize them to class the PLL outputs
together.

Signed-off-by: Guillaume Gautier <[email protected]>
This commit updates the STM32Fx clock driver to add complete support for
all PLLs for all SoCs.

Supports  all outputs and additional divisors:
- PLL-DIV-R
- PLLI2S-P
- PLLI2S-DIV-Q
- PLLI2S-DIV-R

Adds global checks to make sure that all:
- All PLLs share the same source clocks
- All PLLs share the same M-Divisor (on applicable SoCs)
- Both div-X and div-divX are defined (on applicable SoCs)

Functions get_plli2s_source and get_plli2ssrc_frequency are added to make
sure that PLLI2S can be used even if PLL is not defined.

Signed-off-by: Guillaume Gautier <[email protected]>
With the new PLL bindings, fixes a few board dts and overlays
that are missing some properties.

Signed-off-by: Guillaume Gautier <[email protected]>
Rename CLK48M_SEL to CK48M_SEL for consistency with stm32f410_clock.h.

Signed-off-by: Guillaume Gautier <[email protected]>
Move get_ck48_frequency function outside of the #if STM32_PLL_ENABLED
because it should be usable even if the main PLL is not used. The mux
can indeed be used with PLLI2S.

Signed-off-by: Guillaume Gautier <[email protected]>
On STM32F446, F469, F479 and on STM32F7x, the CK48M mux can have either
PLL Q or PLLSAI P as input. Adds the support for the PLLSAI P input in
the driver.

Signed-off-by: Guillaume Gautier <[email protected]>
For STM32F446, F469, F479 and F7x, add the clk48 node in the dtsi.
This allows configuring the clock source of the CLK48 clock.
It is necessary to add it for the SDIO peripheral that can have either
SYSCLK or CLK48 as clock source.

Signed-off-by: Guillaume Gautier <[email protected]>
@zephyrbot zephyrbot added the area: Tests Issues related to a particular existing or missing test label Dec 10, 2025
@zephyrbot zephyrbot requested a review from nashif December 10, 2025 08:33
@sonarqubecloud
Copy link

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

Labels

area: Boards/SoCs area: Clock Control area: Devicetree Bindings area: Tests Issues related to a particular existing or missing test platform: STM32 ST Micro STM32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants