From ce4dc7649e5e1f7053d996f08c7da071b80b654f Mon Sep 17 00:00:00 2001 From: Nick Hu Date: Mon, 20 Oct 2025 14:34:06 +0800 Subject: lib: utils/cache: Add fdt cmo helpers Add the helpers to build up the cache hierarchy via FDT and provide some cmo functions for the user who want to flush the entire cache. Signed-off-by: Nick Hu Reviewed-by: Samuel Holland Reviewed-by: Anup Patel Link: https://lore.kernel.org/r/20251020-cache-upstream-v7-4-69a132447d8a@sifive.com Signed-off-by: Anup Patel --- include/sbi_utils/cache/fdt_cmo_helper.h | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 include/sbi_utils/cache/fdt_cmo_helper.h (limited to 'include') diff --git a/include/sbi_utils/cache/fdt_cmo_helper.h b/include/sbi_utils/cache/fdt_cmo_helper.h new file mode 100644 index 00000000..a6a28db9 --- /dev/null +++ b/include/sbi_utils/cache/fdt_cmo_helper.h @@ -0,0 +1,40 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 SiFive Inc. + */ + +#ifndef __FDT_CMO_HELPER_H__ +#define __FDT_CMO_HELPER_H__ + +#ifdef CONFIG_FDT_CACHE +/** + * Flush 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_flush_all(void); + +/** + * Flush the last level cache of the current hart + * + * @return 0 on success, or a negative error code on failure + */ +int fdt_cmo_llc_flush_all(void); + +/** + * Initialize the cache devices for each hart + * + * @param fdt devicetree blob + * @param cold_boot cold init or warm init + * + * @return 0 on success, or a negative error code on failure + */ +int fdt_cmo_init(bool cold_boot); + +#else + +static inline int fdt_cmo_init(bool cold_boot) { return 0; } + +#endif /* CONFIG_FDT_CACHE */ +#endif /* __FDT_CMO_HELPER_H__ */ -- cgit v1.3.1