Skip to content

Commit 9ae310b

Browse files
mmahadevan108kartben
authored andcommitted
soc: nxp_mxrt7xx: Fix cache implementation for CPU0
This SoC has an external XCACHE controller for CPU0 instruction and data bus. Add code to enable the data cache. Instruction cache is already enabled by SystemInit. Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
1 parent b783bc8 commit 9ae310b

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

boards/nxp/mimxrt700_evk/board.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ void board_early_init_hook(void)
7979
.coarseTrimEn = true,
8080
};
8181

82-
#ifndef CONFIG_IMXRT7XX_CODE_CACHE
83-
CACHE64_DisableCache(CACHE64_CTRL0);
84-
#endif
85-
8682
POWER_DisablePD(kPDRUNCFG_PD_LPOSC);
8783

8884
/* Power up OSC */

soc/nxp/imxrt/imxrt7xx/Kconfig

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ config SOC_MIMXRT798S_CM33_CPU0
1414
select CPU_CORTEX_M_HAS_SYSTICK
1515
select HAS_MCUX
1616
select HAS_MCUX_SYSCON
17-
select HAS_MCUX_CACHE
17+
select HAS_MCUX_XCACHE
18+
select CACHE_MANAGEMENT
19+
select CPU_HAS_ICACHE
20+
select CPU_HAS_DCACHE
21+
select INIT_ARCH_HW_AT_BOOT
1822
select SOC_RESET_HOOK
23+
select SOC_EARLY_INIT_HOOK
1924
select HAS_MCUX_FLEXCOMM
2025

2126
config SOC_MIMXRT798S_CM33_CPU1
@@ -46,13 +51,6 @@ config GLIKEY_MCUX_GLIKEY
4651
default y
4752
bool "Use glikey MCUX Driver"
4853

49-
config IMXRT7XX_CODE_CACHE
50-
bool "Code cache"
51-
default y if HAS_MCUX_CACHE
52-
help
53-
Enable code cache for XSPI region at boot. If this Kconfig is
54-
cleared, the CACHE64 controller will be disabled during SOC init
55-
5654
config MCUX_CORE_SUFFIX
5755
default "_cm33_core0" if SOC_MIMXRT798S_CM33_CPU0
5856
default "_cm33_core1" if SOC_MIMXRT798S_CM33_CPU1

soc/nxp/imxrt/imxrt7xx/Kconfig.defconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ config NUM_IRQS
1212
config SYS_CLOCK_HW_CYCLES_PER_SEC
1313
default 237500000 if CORTEX_M_SYSTICK
1414

15+
choice CACHE_TYPE
16+
default EXTERNAL_CACHE
17+
endchoice
18+
1519
endif # SOC_MIMXRT798S_CM33_CPU0
1620

1721
if SOC_MIMXRT798S_CM33_CPU1

soc/nxp/imxrt/imxrt7xx/cm33/soc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@
1515
#include <zephyr/init.h>
1616
#include <zephyr/devicetree.h>
1717
#include <zephyr/linker/sections.h>
18+
#include <zephyr/cache.h>
1819
#include <soc.h>
1920

21+
void soc_early_init_hook(void)
22+
{
23+
/* Enable data cache */
24+
sys_cache_data_enable();
25+
26+
__ISB();
27+
__DSB();
28+
}
29+
2030
#ifdef CONFIG_SOC_RESET_HOOK
2131

2232
void soc_reset_hook(void)

soc/nxp/imxrt/imxrt7xx/cm33/soc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
#include <zephyr/sys/util.h>
2121
#include <fsl_common.h>
2222

23+
/* CPU 0 has an instruction and data cache, provide the defines for XCACHE */
24+
#ifdef CONFIG_SOC_MIMXRT798S_CM33_CPU0
25+
#define NXP_XCACHE_INSTR XCACHE1
26+
#define NXP_XCACHE_DATA XCACHE0
27+
#endif
28+
2329
#ifdef __cplusplus
2430
extern "C" {
2531
#endif

0 commit comments

Comments
 (0)