-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drivers: cache: Cache driver for NXP XCACHE controller
Some NXP SoC's have External cache that is managed by the XCACHE cache controller. Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
- Loading branch information
1 parent
00ab7a9
commit e7db2fa
Showing
5 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright 2025 NXP | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config CACHE_NXP_XCACHE | ||
bool "NXP external cache driver for xcache controller" | ||
default y | ||
select CACHE_HAS_DRIVER | ||
depends on HAS_MCUX_XCACHE | ||
help | ||
This option enables the XCACHE driver for NXP SOC's. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* | ||
* Copyright 2025 NXP | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/drivers/cache.h> | ||
#include <zephyr/logging/log.h> | ||
#include <soc.h> | ||
#include <fsl_cache.h> | ||
|
||
LOG_MODULE_REGISTER(cache_nxp_xcache, CONFIG_CACHE_LOG_LEVEL); | ||
|
||
#if !defined(NXP_XCACHE_INSTR) | ||
#define NXP_XCACHE_INSTR XCACHE_PC | ||
#endif | ||
|
||
#if !defined(NXP_XCACHE_DATA) | ||
#define NXP_XCACHE_DATA XCACHE_PS | ||
#endif | ||
|
||
void cache_data_enable(void) | ||
{ | ||
XCACHE_EnableCache(NXP_XCACHE_DATA); | ||
} | ||
|
||
void cache_data_disable(void) | ||
{ | ||
XCACHE_DisableCache(NXP_XCACHE_DATA); | ||
} | ||
|
||
int cache_data_flush_all(void) | ||
{ | ||
XCACHE_CleanCache(NXP_XCACHE_DATA); | ||
|
||
return 0; | ||
} | ||
|
||
int cache_data_invd_all(void) | ||
{ | ||
XCACHE_InvalidateCache(NXP_XCACHE_DATA); | ||
|
||
return 0; | ||
} | ||
|
||
int cache_data_flush_and_invd_all(void) | ||
{ | ||
XCACHE_CleanInvalidateCache(NXP_XCACHE_DATA); | ||
|
||
return 0; | ||
} | ||
|
||
int cache_data_flush_range(void *addr, size_t size) | ||
{ | ||
XCACHE_CleanCacheByRange((uint32_t)addr, size); | ||
|
||
return 0; | ||
} | ||
|
||
int cache_data_invd_range(void *addr, size_t size) | ||
{ | ||
XCACHE_InvalidateCacheByRange((uint32_t)addr, size); | ||
|
||
return 0; | ||
} | ||
|
||
int cache_data_flush_and_invd_range(void *addr, size_t size) | ||
{ | ||
XCACHE_CleanInvalidateCacheByRange((uint32_t)addr, size); | ||
|
||
return 0; | ||
} | ||
|
||
void cache_instr_enable(void) | ||
{ | ||
XCACHE_EnableCache(NXP_XCACHE_INSTR); | ||
} | ||
|
||
void cache_instr_disable(void) | ||
{ | ||
XCACHE_DisableCache(NXP_XCACHE_INSTR); | ||
} | ||
|
||
int cache_instr_flush_all(void) | ||
{ | ||
XCACHE_CleanCache(NXP_XCACHE_INSTR); | ||
|
||
return 0; | ||
} | ||
|
||
int cache_instr_invd_all(void) | ||
{ | ||
XCACHE_InvalidateCache(NXP_XCACHE_INSTR); | ||
|
||
return 0; | ||
} | ||
|
||
int cache_instr_flush_and_invd_all(void) | ||
{ | ||
XCACHE_CleanInvalidateCache(NXP_XCACHE_INSTR); | ||
|
||
return 0; | ||
} | ||
|
||
int cache_instr_flush_range(void *addr, size_t size) | ||
{ | ||
XCACHE_CleanCacheByRange((uint32_t)addr, size); | ||
|
||
return 0; | ||
} | ||
|
||
int cache_instr_invd_range(void *addr, size_t size) | ||
{ | ||
XCACHE_InvalidateCacheByRange((uint32_t)addr, size); | ||
|
||
return 0; | ||
} | ||
|
||
int cache_instr_flush_and_invd_range(void *addr, size_t size) | ||
{ | ||
XCACHE_CleanInvalidateCacheByRange((uint32_t)addr, size); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters