aboutsummaryrefslogtreecommitdiff
path: root/include/sbi_utils/cache
diff options
context:
space:
mode:
authorBen Zong-You Xie <ben717@andestech.com>2025-12-29 15:19:12 +0800
committerAnup Patel <anup@brainfault.org>2026-02-11 12:11:06 +0530
commit6d26b43c477a7616d1f030261430127fa6c61d27 (patch)
tree14172ff1a148fbfc4f987b62ff3125b97c0cf806 /include/sbi_utils/cache
parent85bff9cc163e05130899264eb6e963fc582de117 (diff)
downloadopensbi-6d26b43c477a7616d1f030261430127fa6c61d27.tar.gz
opensbi-6d26b43c477a7616d1f030261430127fa6c61d27.tar.bz2
opensbi-6d26b43c477a7616d1f030261430127fa6c61d27.zip
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>
Diffstat (limited to 'include/sbi_utils/cache')
-rw-r--r--include/sbi_utils/cache/cache.h11
-rw-r--r--include/sbi_utils/cache/fdt_cmo_helper.h13
2 files changed, 24 insertions, 0 deletions
diff --git a/include/sbi_utils/cache/cache.h b/include/sbi_utils/cache/cache.h
index 70d9286f..de6cf50d 100644
--- a/include/sbi_utils/cache/cache.h
+++ b/include/sbi_utils/cache/cache.h
@@ -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
diff --git a/include/sbi_utils/cache/fdt_cmo_helper.h b/include/sbi_utils/cache/fdt_cmo_helper.h
index a6a28db9..8b3ec89b 100644
--- a/include/sbi_utils/cache/fdt_cmo_helper.h
+++ b/include/sbi_utils/cache/fdt_cmo_helper.h
@@ -23,6 +23,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
*
* @param fdt devicetree blob