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>
This commit is contained in:
Mahesh Mahadevan 2025-02-10 16:46:51 -06:00 committed by Benjamin Cabé
commit 9ae310b923
5 changed files with 26 additions and 12 deletions

View file

@ -79,10 +79,6 @@ void board_early_init_hook(void)
.coarseTrimEn = true, .coarseTrimEn = true,
}; };
#ifndef CONFIG_IMXRT7XX_CODE_CACHE
CACHE64_DisableCache(CACHE64_CTRL0);
#endif
POWER_DisablePD(kPDRUNCFG_PD_LPOSC); POWER_DisablePD(kPDRUNCFG_PD_LPOSC);
/* Power up OSC */ /* Power up OSC */

View file

@ -14,8 +14,13 @@ config SOC_MIMXRT798S_CM33_CPU0
select CPU_CORTEX_M_HAS_SYSTICK select CPU_CORTEX_M_HAS_SYSTICK
select HAS_MCUX select HAS_MCUX
select HAS_MCUX_SYSCON select HAS_MCUX_SYSCON
select HAS_MCUX_CACHE select HAS_MCUX_XCACHE
select CACHE_MANAGEMENT
select CPU_HAS_ICACHE
select CPU_HAS_DCACHE
select INIT_ARCH_HW_AT_BOOT
select SOC_RESET_HOOK select SOC_RESET_HOOK
select SOC_EARLY_INIT_HOOK
select HAS_MCUX_FLEXCOMM select HAS_MCUX_FLEXCOMM
config SOC_MIMXRT798S_CM33_CPU1 config SOC_MIMXRT798S_CM33_CPU1
@ -46,13 +51,6 @@ config GLIKEY_MCUX_GLIKEY
default y default y
bool "Use glikey MCUX Driver" bool "Use glikey MCUX Driver"
config IMXRT7XX_CODE_CACHE
bool "Code cache"
default y if HAS_MCUX_CACHE
help
Enable code cache for XSPI region at boot. If this Kconfig is
cleared, the CACHE64 controller will be disabled during SOC init
config MCUX_CORE_SUFFIX config MCUX_CORE_SUFFIX
default "_cm33_core0" if SOC_MIMXRT798S_CM33_CPU0 default "_cm33_core0" if SOC_MIMXRT798S_CM33_CPU0
default "_cm33_core1" if SOC_MIMXRT798S_CM33_CPU1 default "_cm33_core1" if SOC_MIMXRT798S_CM33_CPU1

View file

@ -12,6 +12,10 @@ config NUM_IRQS
config SYS_CLOCK_HW_CYCLES_PER_SEC config SYS_CLOCK_HW_CYCLES_PER_SEC
default 237500000 if CORTEX_M_SYSTICK default 237500000 if CORTEX_M_SYSTICK
choice CACHE_TYPE
default EXTERNAL_CACHE
endchoice
endif # SOC_MIMXRT798S_CM33_CPU0 endif # SOC_MIMXRT798S_CM33_CPU0
if SOC_MIMXRT798S_CM33_CPU1 if SOC_MIMXRT798S_CM33_CPU1

View file

@ -15,8 +15,18 @@
#include <zephyr/init.h> #include <zephyr/init.h>
#include <zephyr/devicetree.h> #include <zephyr/devicetree.h>
#include <zephyr/linker/sections.h> #include <zephyr/linker/sections.h>
#include <zephyr/cache.h>
#include <soc.h> #include <soc.h>
void soc_early_init_hook(void)
{
/* Enable data cache */
sys_cache_data_enable();
__ISB();
__DSB();
}
#ifdef CONFIG_SOC_RESET_HOOK #ifdef CONFIG_SOC_RESET_HOOK
void soc_reset_hook(void) void soc_reset_hook(void)

View file

@ -20,6 +20,12 @@
#include <zephyr/sys/util.h> #include <zephyr/sys/util.h>
#include <fsl_common.h> #include <fsl_common.h>
/* CPU 0 has an instruction and data cache, provide the defines for XCACHE */
#ifdef CONFIG_SOC_MIMXRT798S_CM33_CPU0
#define NXP_XCACHE_INSTR XCACHE1
#define NXP_XCACHE_DATA XCACHE0
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif