summaryrefslogtreecommitdiffstats
path: root/arch/riscv/include/asm/cache.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/riscv/include/asm/cache.h')
-rw-r--r--arch/riscv/include/asm/cache.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/arch/riscv/include/asm/cache.h b/arch/riscv/include/asm/cache.h
index 9a0b9326b2..c787f89001 100644
--- a/arch/riscv/include/asm/cache.h
+++ b/arch/riscv/include/asm/cache.h
@@ -6,10 +6,29 @@
#ifndef _ASM_RISCV_CACHE_H
#define _ASM_RISCV_CACHE_H
+#include <asm/vendorid_list.h>
+
+static inline void thead_local_flush_icache_all(void)
+{
+ /*
+ * According [1] "13.3 Example of cache settings"
+ * [1]: https://github.com/T-head-Semi/openc906/blob/main/ \
+ * doc/openc906%20datasheet.pd
+ */
+ __asm__ volatile (".long 0x0100000b" ::: "memory"); /* th.icache.iall */
+ __asm__ volatile (".long 0x01b0000b" ::: "memory"); /* th.sync.is */
+}
+
static inline void local_flush_icache_all(void)
{
-#ifdef HAS_CACHE
- asm volatile ("fence.i" ::: "memory");
+#ifdef CONFIG_HAS_CACHE
+ switch(riscv_vendor_id()) {
+ case THEAD_VENDOR_ID:
+ thead_local_flush_icache_all();
+ break;
+ default:
+ __asm__ volatile ("fence.i" ::: "memory");
+ }
#endif
}