Skip to content

Commit 2b2b41d

Browse files
Dat-NguyenDuynashif
authored andcommitted
arch: arm: cortex_a_r: add Kconfig options for cache segregation
On Arm Cortex R52, cache segregation policy controls the number of L1 I/D cache ways that are allocated to Flash and AXIM interface. Adding Kconfig options for configuring it. Writing to IMP_CSCTRL is only permitted before the caches have been enabled, following a system reset. Signed-off-by: Dat Nguyen Duy <[email protected]>
1 parent 303bc5a commit 2b2b41d

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

arch/arm/core/cortex_a_r/Kconfig

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,32 @@ config CPU_CORTEX_R52
111111
help
112112
This option signifies the use of a Cortex-R52 CPU
113113

114+
config CPU_CORTEX_R52_CACHE_SEGREGATION
115+
bool "Control segregation of L1 I/D-Cache ways between Flash and AXIM"
116+
depends on CPU_CORTEX_R52
117+
help
118+
Control segregation of L1 I/D-Cache ways between Flash and AXIM.
119+
Updates to the cache segregation controls are only permitted before the caches
120+
have ever been enabled, following a system reset, otherwise the update is ignored.
121+
122+
config CPU_CORTEX_R52_ICACHE_FLASH_WAY
123+
int "L1 I-Cache Flash way"
124+
depends on CPU_CORTEX_R52_CACHE_SEGREGATION
125+
range 0 4
126+
default 0
127+
help
128+
Configure L1 I-Cache ways for Flash interface. Default is reset value, all
129+
I-Cache ways are allocated for AXIM interface.
130+
131+
config CPU_CORTEX_R52_DCACHE_FLASH_WAY
132+
int "L1 D-Cache Flash way"
133+
depends on CPU_CORTEX_R52_CACHE_SEGREGATION
134+
range 0 4
135+
default 0
136+
help
137+
Configure L1 D-Cache ways for Flash interface. Default is reset value,
138+
all D-Cache ways are allocated for AXIM interface.
139+
114140
if CPU_AARCH32_CORTEX_R
115141

116142
config ARMV7_R

arch/arm/core/cortex_a_r/reset.S

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ SECTION_SUBSEC_FUNC(TEXT, _reset_section, __start)
5656
cmp r0, #MODE_HYP
5757
bne EL1_Reset_Handler
5858

59-
/* Init HSCTLR see Armv8-R AArch32 architecture profile */
60-
ldr r0, =(HSCTLR_RES1 | SCTLR_I_BIT | SCTLR_C_BIT)
61-
mcr p15, 4, r0, c1, c0, 0
59+
/*
60+
* The HSCTLR register provides top-level control of system operation in Hyp mode.
61+
* Since the OS is not running in Hyp mode, and considering the Armv8-R AArch32
62+
* architecture profile, there's no need to modify HSCTLR configuration unless
63+
* Fast Interrupts need to be enabled.
64+
*/
6265

6366
/* Init HACTLR: Enable EL1 access to all IMP DEF registers */
6467
ldr r0, =HACTLR_INIT
@@ -200,6 +203,12 @@ EL1_Reset_Handler:
200203

201204
#endif /* CONFIG_DCLS */
202205

206+
#if defined(CONFIG_CPU_CORTEX_R52_CACHE_SEGREGATION)
207+
ldr r0, =IMP_CSCTLR(CONFIG_CPU_CORTEX_R52_ICACHE_FLASH_WAY,
208+
CONFIG_CPU_CORTEX_R52_DCACHE_FLASH_WAY)
209+
mcr p15, 1, r0, c9, c1, 0
210+
#endif
211+
203212
ldr r0, =arm_cpu_boot_params
204213

205214
#if CONFIG_MP_MAX_NUM_CPUS > 1

include/zephyr/arch/arm/cortex_a_r/cpu.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
#define SCTLR_C_BIT BIT(2)
5757
#define SCTLR_I_BIT BIT(12)
5858

59+
/* Armv8-R Cortex-R52 Cache Segregation Control Register */
60+
#define IMP_CSCTLR_DFLW_SHIFT (0)
61+
#define IMP_CSCTLR_IFLW_SHIFT (8)
62+
#define IMP_CSCTLR(iway, dway) ((iway << IMP_CSCTLR_IFLW_SHIFT) | \
63+
((dway << IMP_CSCTLR_DFLW_SHIFT)))
64+
5965
/* Hyp System Control Register */
6066
#define HSCTLR_RES1 (BIT(29) | BIT(28) | BIT(23) | \
6167
BIT(22) | BIT(18) | BIT(16) | \

0 commit comments

Comments
 (0)