Skip to content

Commit d2be144

Browse files
committed
drivers: clock: stm32H5 clock control of the PLL in MemoryMapped mode
Do not disable the pll clock if it source the xspi and if the external flash is executing in Place. After mcuboot reset, the code is executed on the external flash, through the xspi. The CONFIG_STM32_APP_IN_EXT_FLASH tis set and will avoid re-config of the pll which is sourcing the xspi peripheral. When excuting in Place on this external NOR It must not disable its own clock source (PLL). Signed-off-by: Francois Ramu <[email protected]>
1 parent b4ab92f commit d2be144

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

drivers/clock_control/clock_stm32_ll_h5.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,19 @@ static int set_up_plls(void)
435435
#endif
436436

437437
#if defined(STM32_PLL_ENABLED)
438+
439+
#if defined(CONFIG_STM32_APP_IN_EXT_FLASH)
440+
/*
441+
* Don't disable PLL1 during application initialization
442+
* that runs on the external octospi flash (in memmap mode)
443+
* when (Q/O)SPI uses PLL1 as its clock source.
444+
*/
445+
if (LL_RCC_GetOCTOSPIClockSource(LL_RCC_OCTOSPI_CLKSOURCE) == LL_RCC_OSPI_CLKSOURCE_PLL1Q) {
446+
goto setup_pll2;
447+
}
448+
#endif /* CONFIG_STM32_APP_IN_EXT_FLASH */
438449
/*
450+
* Case of chain-loaded applications:
439451
* Switch to HSI and disable the PLL before configuration.
440452
* (Switching to HSI makes sure we have a SYSCLK source in
441453
* case we're currently running from the PLL we're about to
@@ -501,12 +513,30 @@ static int set_up_plls(void)
501513
LL_RCC_PLL1_Enable();
502514
while (LL_RCC_PLL1_IsReady() != 1U) {
503515
}
516+
517+
goto setup_pll2;
504518
#else
505519
/* Init PLL source to None */
506520
LL_RCC_PLL1_SetSource(LL_RCC_PLL1SOURCE_NONE);
521+
522+
goto setup_pll2;
507523
#endif /* STM32_PLL_ENABLED */
508524

525+
setup_pll2:
509526
#if defined(STM32_PLL2_ENABLED)
527+
528+
#if defined(CONFIG_STM32_APP_IN_EXT_FLASH)
529+
/*
530+
* Don't disable PLL2 during application initialization
531+
* that runs on the external octospi flash (in memmap mode)
532+
* when (Q/O)SPI uses PLL2 as its clock source.
533+
*/
534+
if (LL_RCC_GetOCTOSPIClockSource(LL_RCC_OCTOSPI_CLKSOURCE) == LL_RCC_OSPI_CLKSOURCE_PLL2R) {
535+
goto setup_pll3;
536+
}
537+
#endif /* CONFIG_STM32_APP_IN_EXT_FLASH */
538+
LL_RCC_PLL2_Disable();
539+
510540
/* Configure PLL2 source */
511541
if (IS_ENABLED(STM32_PLL2_SRC_HSE)) {
512542
LL_RCC_PLL2_SetSource(LL_RCC_PLL2SOURCE_HSE);
@@ -554,11 +584,16 @@ static int set_up_plls(void)
554584
LL_RCC_PLL2_Enable();
555585
while (LL_RCC_PLL2_IsReady() != 1U) {
556586
}
587+
588+
goto setup_pll3;
557589
#else
558590
/* Init PLL2 source to None */
559591
LL_RCC_PLL2_SetSource(LL_RCC_PLL2SOURCE_NONE);
592+
593+
goto setup_pll3;
560594
#endif /* STM32_PLL2_ENABLED */
561595

596+
setup_pll3:
562597
#if defined(RCC_CR_PLL3ON)
563598
#if defined(STM32_PLL3_ENABLED)
564599
/* Configure PLL3 source */

0 commit comments

Comments
 (0)