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 <erwan.gouriou@linaro.org>
This commit is contained in:
parent
8af5e41f91
commit
18b3fcd86d
1 changed files with 8 additions and 3 deletions
|
@ -358,9 +358,6 @@ static void set_up_fixed_clock_sources(void)
|
||||||
*/
|
*/
|
||||||
int stm32_clock_control_init(const struct device *dev)
|
int stm32_clock_control_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
uint32_t new_hclk_freq;
|
|
||||||
uint32_t old_flash_freq;
|
|
||||||
uint32_t new_flash_freq;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
ARG_UNUSED(dev);
|
ARG_UNUSED(dev);
|
||||||
|
@ -369,6 +366,11 @@ int stm32_clock_control_init(const struct device *dev)
|
||||||
/* Some clocks would be activated by default */
|
/* Some clocks would be activated by default */
|
||||||
config_enable_default_clocks();
|
config_enable_default_clocks();
|
||||||
|
|
||||||
|
#if defined(FLASH_ACR_LATENCY)
|
||||||
|
uint32_t new_hclk_freq;
|
||||||
|
uint32_t old_flash_freq;
|
||||||
|
uint32_t new_flash_freq;
|
||||||
|
|
||||||
old_flash_freq = RCC_CALC_FLASH_FREQ(HAL_RCC_GetSysClockFreq(),
|
old_flash_freq = RCC_CALC_FLASH_FREQ(HAL_RCC_GetSysClockFreq(),
|
||||||
GET_CURRENT_FLASH_PRESCALER());
|
GET_CURRENT_FLASH_PRESCALER());
|
||||||
|
|
||||||
|
@ -382,6 +384,7 @@ int stm32_clock_control_init(const struct device *dev)
|
||||||
if (new_flash_freq > old_flash_freq) {
|
if (new_flash_freq > old_flash_freq) {
|
||||||
LL_SetFlashLatency(new_flash_freq);
|
LL_SetFlashLatency(new_flash_freq);
|
||||||
}
|
}
|
||||||
|
#endif /* FLASH_ACR_LATENCY */
|
||||||
|
|
||||||
/* Set up indiviual enabled clocks */
|
/* Set up indiviual enabled clocks */
|
||||||
set_up_fixed_clock_sources();
|
set_up_fixed_clock_sources();
|
||||||
|
@ -425,10 +428,12 @@ int stm32_clock_control_init(const struct device *dev)
|
||||||
LL_RCC_SetAHBPrescaler(ahb_prescaler(STM32_CORE_PRESCALER));
|
LL_RCC_SetAHBPrescaler(ahb_prescaler(STM32_CORE_PRESCALER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(FLASH_ACR_LATENCY)
|
||||||
/* If freq not increased, set flash latency after all clock setting */
|
/* If freq not increased, set flash latency after all clock setting */
|
||||||
if (old_flash_freq >= CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) {
|
if (old_flash_freq >= CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) {
|
||||||
LL_SetFlashLatency(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC);
|
LL_SetFlashLatency(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC);
|
||||||
}
|
}
|
||||||
|
#endif /* FLASH_ACR_LATENCY */
|
||||||
|
|
||||||
SystemCoreClock = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
|
SystemCoreClock = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue