lib: utils/cache: add cache enable function

Add functions to enable/disable the cache.

Signed-off-by: Ben Zong-You Xie <ben717@andestech.com>
Link: https://lore.kernel.org/r/20251229071914.1451587-4-ben717@andestech.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Ben Zong-You Xie
2025-12-29 15:19:12 +08:00
committed by Anup Patel
parent 85bff9cc16
commit 6d26b43c47
4 changed files with 58 additions and 0 deletions

View File

@@ -19,6 +19,8 @@ struct cache_ops {
int (*warm_init)(struct cache_device *dev);
/** Flush entire cache **/
int (*cache_flush_all)(struct cache_device *dev);
/** Enable/Disable cache **/
int (*cache_enable)(struct cache_device *dev, bool enable);
};
struct cache_device {
@@ -66,4 +68,13 @@ int cache_add(struct cache_device *dev);
*/
int cache_flush_all(struct cache_device *dev);
/**
* Enable/Disable the cache
*
* @param dev the cache to enable/disable
*
* @return 0 on success, or a negative error code on failure
*/
int cache_enable(struct cache_device *dev, bool enable);
#endif

View File

@@ -22,6 +22,19 @@ int fdt_cmo_private_flc_flush_all(void);
*/
int fdt_cmo_llc_flush_all(void);
/**
* Enable/Disable the private first level cache of the current hart
*
* @return 0 on success, or a negative error code on failure
*/
int fdt_cmo_private_flc_enable(bool enable);
/**
* Enable/Disable the last level cache of the current hart
*
* @return 0 on success, or a negative error code on failure
*/
int fdt_cmo_llc_enable(bool enable);
/**
* Initialize the cache devices for each hart
*