Skip to content

Commit e179f48

Browse files
Holt-Sunkartben
authored andcommitted
drivers: cache: add NXP LMEM cache driver
Add LMEM cache driver implementing instruction cache ops. Wire driver into cache Kconfig menu and CMake build. Enables I-cache control on SoCs with NXP LMEM controller. Signed-off-by: Holt Sun <[email protected]>
1 parent e881029 commit e179f48

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

drivers/cache/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ zephyr_library_sources_ifdef(CONFIG_CACHE_ANDES cache_andes.c)
1212
zephyr_library_sources_ifdef(CONFIG_CACHE_ASPEED cache_aspeed.c)
1313
zephyr_library_sources_ifdef(CONFIG_CACHE_BFLB_L1C cache_bflb_l1c.c)
1414
zephyr_library_sources_ifdef(CONFIG_CACHE_NRF_CACHE cache_nrf.c)
15+
zephyr_library_sources_ifdef(CONFIG_CACHE_NXP_LMEM_CACHE cache_nxp_lmem_cache.c)
1516
zephyr_library_sources_ifdef(CONFIG_CACHE_NXP_XCACHE cache_nxp_xcache.c)
1617
zephyr_library_sources_ifdef(CONFIG_CACHE_STM32 cache_stm32.c)
1718
# zephyr-keep-sorted-stop

drivers/cache/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ source "drivers/cache/Kconfig.andes"
2323
source "drivers/cache/Kconfig.aspeed"
2424
source "drivers/cache/Kconfig.bflb"
2525
source "drivers/cache/Kconfig.nrf"
26+
source "drivers/cache/Kconfig.nxp_lmem_cache"
2627
source "drivers/cache/Kconfig.nxp_xcache"
2728
source "drivers/cache/Kconfig.stm32"
2829
# zephyr-keep-sorted-stop
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright 2025 NXP
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config CACHE_NXP_LMEM_CACHE
5+
bool "NXP LMEM cache driver"
6+
default y
7+
select CACHE_HAS_DRIVER
8+
depends on HAS_MCUX_LMEM_CACHE
9+
help
10+
This option enables the LMEM cache driver for NXP SOCs.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/drivers/cache.h>
9+
#include <zephyr/logging/log.h>
10+
#include <fsl_cache.h>
11+
12+
void cache_instr_enable(void)
13+
{
14+
L1CACHE_EnableCodeCache();
15+
}
16+
17+
void cache_instr_disable(void)
18+
{
19+
L1CACHE_DisableCodeCache();
20+
}
21+
22+
int cache_instr_flush_all(void)
23+
{
24+
L1CACHE_CleanCodeCache();
25+
26+
return 0;
27+
}
28+
29+
int cache_instr_invd_all(void)
30+
{
31+
L1CACHE_InvalidateCodeCache();
32+
33+
return 0;
34+
}
35+
36+
int cache_instr_flush_and_invd_all(void)
37+
{
38+
L1CACHE_CleanInvalidateCodeCache();
39+
40+
return 0;
41+
}
42+
43+
int cache_instr_flush_range(void *addr, size_t size)
44+
{
45+
L1CACHE_CleanCodeCacheByRange((uint32_t)addr, (uint32_t)size);
46+
47+
return 0;
48+
}
49+
50+
int cache_instr_invd_range(void *addr, size_t size)
51+
{
52+
L1CACHE_InvalidateCodeCacheByRange((uint32_t)addr, (uint32_t)size);
53+
54+
return 0;
55+
}
56+
57+
int cache_instr_flush_and_invd_range(void *addr, size_t size)
58+
{
59+
L1CACHE_CleanInvalidateCodeCacheByRange((uint32_t)addr, (uint32_t)size);
60+
61+
return 0;
62+
}

0 commit comments

Comments
 (0)