Skip to content

STM32L0: fix PLL input frequency division by HSI clock divider #92546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kbidani
Copy link
Contributor

@kbidani kbidani commented Jul 2, 2025

In the STM32L0 clock driver the HSI clock divider is not considered when calculating the PLL source frequency (register value RCC_CR/HSIDIV).
Add new clocks bindings for stm32l0 series "st,stm32l0-hsi-clock" to use hsi-div property.
Updated the clk_hsi node to use the "st,stm32l0-hsi-clock" compatible to enable support for the HSI clock divider (hsi-div property).

@@ -662,7 +662,13 @@ static void set_up_fixed_clock_sources(void)
}
}
#if STM32_HSI_DIV_ENABLED
#if defined(CONFIG_SOC_SERIES_STM32L0X)
if (LL_RCC_IsActiveFlag_HSIDIV()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why this check is there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replaced with STM32_HSI_DIVISOR check.

@kbidani kbidani force-pushed the fix_pll_frequency_l0 branch from e7e3710 to 7cd19aa Compare July 11, 2025 12:59
@kbidani kbidani requested a review from mathieuchopstm July 11, 2025 13:03
@kbidani kbidani force-pushed the fix_pll_frequency_l0 branch from 7cd19aa to a7d69e8 Compare July 15, 2025 07:47
@kbidani kbidani requested a review from etienne-lms July 15, 2025 07:47
kbidani added 2 commits July 15, 2025 10:04
Add hsi clock for stm32l0.

Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
Enable support for HSI_DIV and its use as a clock source on STM32L0 SoCs.

Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
@kbidani kbidani force-pushed the fix_pll_frequency_l0 branch from a7d69e8 to 94bf03b Compare July 15, 2025 08:06
kbidani added 2 commits July 15, 2025 12:04
Updated the clk_hsi node to use the "st,stm32l0-hsi-clock"
compatible to use hsi divider.

Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
Updated the PLL input frequency calculation to include
division by the HSI clock divider.
Enable HSI divider using LL_RCC_HSI_EnableDivider().

Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
@kbidani kbidani force-pushed the fix_pll_frequency_l0 branch from 94bf03b to 7285b1a Compare July 15, 2025 10:04
Copy link

@kbidani
Copy link
Contributor Author

kbidani commented Jul 15, 2025

@nordic-krch PTAL

Comment on lines +670 to +672
if (STM32_HSI_DIVISOR == 4) {
LL_RCC_HSI_EnableDivider();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The disable function should also be called in an else. I think it is necessary if for example an MCUBoot enables the divider, but the application wants it disabled

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.

5 participants