drivers: clock_control: stm32wba: Fix chain loaded applications case

In case of chain loaded application with PLL set as the sysclk source,
directly exit the init function.
This also applies to exit from stop mode and was tested successfully.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
This commit is contained in:
Erwan Gouriou 2024-03-12 16:40:34 +01:00 committed by Fabio Baltieri
parent 3c42daee9c
commit 930e03fdfd

View File

@ -355,19 +355,6 @@ static int set_up_plls(void)
int r;
uint32_t vco_input_range;
/*
* Case of chain-loaded applications:
* Switch to HSI and disable the PLL before configuration.
* (Switching to HSI makes sure we have a SYSCLK source in
* case we're currently running from the PLL we're about to
* turn off and reconfigure.)
*
*/
if (LL_RCC_GetSysClkSource() == LL_RCC_SYS_CLKSOURCE_STATUS_PLL1R) {
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
stm32_clock_switch_to_hsi();
}
LL_RCC_PLL1_Disable();
/* Configure PLL source */
@ -511,11 +498,20 @@ int stm32_clock_control_init(const struct device *dev)
ARG_UNUSED(dev);
if (IS_ENABLED(STM32_SYSCLK_SRC_PLL) &&
(LL_RCC_GetSysClkSource() == LL_RCC_SYS_CLKSOURCE_STATUS_PLL1R)) {
/* In case of chainloaded application, it may happen that PLL
* was already configured as sysclk src by bootloader.
* Don't test other cases as there are multiple options but
* they will be handled smoothly by the function.
*/
SystemCoreClock = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
return 0;
}
old_flash_freq = RCC_CALC_FLASH_FREQ(HAL_RCC_GetSysClockFreq(),
GET_CURRENT_FLASH_PRESCALER());
/* Set up individual enabled clocks */
set_up_fixed_clock_sources();