Skip to content

Commit b564878

Browse files
etienne-lmsjhedberg
authored andcommitted
soc: st: stm32: use CONFIG_STM32_FLASH_PREFETCH where applicable
Use CONFIG_STM32_FLASH_PREFETCH config option to enable flash prefetch in C0/F0/F1/F2/F3/F4/F7/G4/L0/L1/L4/U0/U3/WB/WBA/WBL for consistency with other SoCs that use this configuration switch, default enabled at SoC default config level. Add SoC hidden config option HAS_STM32_FLASH_PREFETCH enabled for SoCs that support the feature. STM32_FLASH_PREFETCH is default enabled for all SoC that have HAS_STM32_FLASH_PREFETCH unless target specific constraints (as for G0Bx/G0Cx SoCs). Signed-off-by: Etienne Carriere <[email protected]>
1 parent 7c47bc9 commit b564878

File tree

35 files changed

+60
-7
lines changed

35 files changed

+60
-7
lines changed

soc/st/stm32/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,19 @@ config SWJ_ANALOG_PRIORITY
5555
This priority must be greater than GPIO_INIT_PRIORITY and lower than
5656
UART_INIT_PRIORITY.
5757

58+
config HAS_STM32_FLASH_PREFETCH
59+
bool
60+
help
61+
Hidden symbol selected by SoCs which support flash prefetch.
62+
5863
config STM32_FLASH_PREFETCH
5964
bool "Flash prefetch buffer"
65+
default y
66+
depends on HAS_STM32_FLASH_PREFETCH
67+
help
68+
Enable flash prefetch. For power efficiency, it is recommended to
69+
be enabled when flash is accessed through a cache memory. Flash
70+
prefetch also improves performances a bit.
6071

6172
config STM32_WKUP_PINS
6273
bool "STM32 PWR Wake-up Pins"

soc/st/stm32/stm32c0x/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ config SOC_SERIES_STM32C0X
99
select CPU_CORTEX_M_HAS_VTOR
1010
select CPU_HAS_ARM_MPU
1111
select HAS_STM32CUBE
12+
select HAS_STM32_FLASH_PREFETCH
1213
select CPU_CORTEX_M_HAS_SYSTICK
1314
select HAS_PM
1415
select HAS_POWEROFF

soc/st/stm32/stm32c0x/soc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ void soc_early_init_hook(void)
2828
{
2929
/* Enable ART Accelerator I-cache and prefetch */
3030
LL_FLASH_EnableInstCache();
31+
#if defined(CONFIG_STM32_FLASH_PREFETCH)
3132
LL_FLASH_EnablePrefetch();
33+
#endif
3234

3335
/* Update CMSIS SystemCoreClock variable (HCLK) */
3436
/* At reset, system core clock is set to 48 MHz from HSI */

soc/st/stm32/stm32f0x/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ config SOC_SERIES_STM32F0X
99
select CPU_CORTEX_M0_HAS_VECTOR_TABLE_REMAP
1010
select CPU_CORTEX_M_HAS_SYSTICK
1111
select HAS_STM32CUBE
12+
select HAS_STM32_FLASH_PREFETCH
1213
select SOC_EARLY_INIT_HOOK

soc/st/stm32/stm32f0x/soc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ void relocate_vector_table(void)
6464
*/
6565
void soc_early_init_hook(void)
6666
{
67+
#if defined(CONFIG_STM32_FLASH_PREFETCH)
6768
/* Enable ART Accelerator prefetch */
6869
LL_FLASH_EnablePrefetch();
70+
#endif
6971

7072
/* Update CMSIS SystemCoreClock variable (HCLK) */
7173
/* At reset, system core clock is set to 8 MHz from HSI */

soc/st/stm32/stm32f1x/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ config SOC_SERIES_STM32F1X
88
select CPU_CORTEX_M3
99
select CPU_CORTEX_M_HAS_DWT
1010
select HAS_STM32CUBE
11+
select HAS_STM32_FLASH_PREFETCH
1112
select HAS_PM
1213
select HAS_POWEROFF
1314
select HAS_SWO

soc/st/stm32/stm32f1x/soc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
void soc_early_init_hook(void)
2626
{
27-
#ifdef FLASH_ACR_PRFTBE
27+
#if defined(FLASH_ACR_PRFTBE) && defined(CONFIG_STM32_FLASH_PREFETCH)
2828
/* Enable ART Accelerator prefetch */
2929
LL_FLASH_EnablePrefetch();
3030
#endif

soc/st/stm32/stm32f2x/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ config SOC_SERIES_STM32F2X
88
select CPU_CORTEX_M3
99
select CPU_CORTEX_M_HAS_DWT
1010
select HAS_STM32CUBE
11+
select HAS_STM32_FLASH_PREFETCH
1112
select HAS_SWO
1213
select CPU_HAS_ARM_MPU
1314
select SOC_EARLY_INIT_HOOK

soc/st/stm32/stm32f2x/soc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ void soc_early_init_hook(void)
2929
/* Enable ART Flash I/D-cache accelerator and prefetch */
3030
LL_FLASH_EnableInstCache();
3131
LL_FLASH_EnableDataCache();
32+
#if defined(CONFIG_STM32_FLASH_PREFETCH)
3233
LL_FLASH_EnablePrefetch();
34+
#endif
3335

3436
/* Update CMSIS SystemCoreClock variable (HCLK) */
3537
/* At reset, system core clock is set to 16 MHz from HSI */

soc/st/stm32/stm32f3x/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ config SOC_SERIES_STM32F3X
99
select CPU_CORTEX_M_HAS_DWT
1010
select CPU_HAS_FPU
1111
select HAS_STM32CUBE
12+
select HAS_STM32_FLASH_PREFETCH
1213
select HAS_SWO
1314
select SOC_EARLY_INIT_HOOK

0 commit comments

Comments
 (0)