Skip to content

Commit b71a301

Browse files
FRASTMfabiobaltieri
authored andcommitted
drivers: clock_control: stm32f7 flash latency with overdrive
The Flash latency depends on the sysclock In case of the stm32F7 the regulator overdrive mode is set depending on the sys clock freq. The overdrive must be set before the first LL_SetFlashLatency. Signed-off-by: Francois Ramu <[email protected]>
1 parent d24f3b9 commit b71a301

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

drivers/clock_control/clock_stm32_ll_common.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -484,20 +484,6 @@ static void set_up_plls(void)
484484

485485
#if defined(STM32_PLL_ENABLED)
486486

487-
#ifdef CONFIG_SOC_SERIES_STM32F7X
488-
/* Assuming we stay on Power Scale default value: Power Scale 1 */
489-
if (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC > 180000000) {
490-
LL_PWR_EnableOverDriveMode();
491-
while (LL_PWR_IsActiveFlag_OD() != 1) {
492-
/* Wait for OverDrive mode ready */
493-
}
494-
LL_PWR_EnableOverDriveSwitching();
495-
while (LL_PWR_IsActiveFlag_ODSW() != 1) {
496-
/* Wait for OverDrive switch ready */
497-
}
498-
}
499-
#endif
500-
501487
#if defined(STM32_SRC_PLL_P) & STM32_PLL_P_ENABLED
502488
MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLP, pllp(STM32_PLL_P_DIVISOR));
503489
RCC_PLLP_ENABLE();
@@ -659,6 +645,21 @@ int stm32_clock_control_init(const struct device *dev)
659645
/* Some clocks would be activated by default */
660646
config_enable_default_clocks();
661647

648+
#if defined(STM32_PLL_ENABLED) && defined(CONFIG_SOC_SERIES_STM32F7X)
649+
/* Assuming we stay on Power Scale default value: Power Scale 1 */
650+
if (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC > 180000000) {
651+
/* Set Overdrive if needed before configuring the Flash Latency */
652+
LL_PWR_EnableOverDriveMode();
653+
while (LL_PWR_IsActiveFlag_OD() != 1) {
654+
/* Wait for OverDrive mode ready */
655+
}
656+
LL_PWR_EnableOverDriveSwitching();
657+
while (LL_PWR_IsActiveFlag_ODSW() != 1) {
658+
/* Wait for OverDrive switch ready */
659+
}
660+
}
661+
#endif /* STM32_PLL_ENABLED && CONFIG_SOC_SERIES_STM32F7X */
662+
662663
#if defined(FLASH_ACR_LATENCY)
663664
uint32_t old_flash_freq;
664665
uint32_t new_flash_freq;

0 commit comments

Comments
 (0)