Skip to content

Commit 18b3fcd

Browse files
erwangocarlescufi
authored andcommitted
drivers/clock_control: stm32 common: Set flash latency code under switch
Some specific F1 variants don't handle flash latency. Put flash latency dealing code under dedicated switch. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent 8af5e41 commit 18b3fcd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/clock_control/clock_stm32_ll_common.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,6 @@ static void set_up_fixed_clock_sources(void)
358358
*/
359359
int stm32_clock_control_init(const struct device *dev)
360360
{
361-
uint32_t new_hclk_freq;
362-
uint32_t old_flash_freq;
363-
uint32_t new_flash_freq;
364361
int r;
365362

366363
ARG_UNUSED(dev);
@@ -369,6 +366,11 @@ int stm32_clock_control_init(const struct device *dev)
369366
/* Some clocks would be activated by default */
370367
config_enable_default_clocks();
371368

369+
#if defined(FLASH_ACR_LATENCY)
370+
uint32_t new_hclk_freq;
371+
uint32_t old_flash_freq;
372+
uint32_t new_flash_freq;
373+
372374
old_flash_freq = RCC_CALC_FLASH_FREQ(HAL_RCC_GetSysClockFreq(),
373375
GET_CURRENT_FLASH_PRESCALER());
374376

@@ -382,6 +384,7 @@ int stm32_clock_control_init(const struct device *dev)
382384
if (new_flash_freq > old_flash_freq) {
383385
LL_SetFlashLatency(new_flash_freq);
384386
}
387+
#endif /* FLASH_ACR_LATENCY */
385388

386389
/* Set up indiviual enabled clocks */
387390
set_up_fixed_clock_sources();
@@ -425,10 +428,12 @@ int stm32_clock_control_init(const struct device *dev)
425428
LL_RCC_SetAHBPrescaler(ahb_prescaler(STM32_CORE_PRESCALER));
426429
}
427430

431+
#if defined(FLASH_ACR_LATENCY)
428432
/* If freq not increased, set flash latency after all clock setting */
429433
if (old_flash_freq >= CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) {
430434
LL_SetFlashLatency(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC);
431435
}
436+
#endif /* FLASH_ACR_LATENCY */
432437

433438
SystemCoreClock = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
434439

0 commit comments

Comments
 (0)