summaryrefslogtreecommitdiffstats
path: root/arch/riscv
diff options
context:
space:
mode:
authorMarco Felsch <m.felsch@pengutronix.de>2022-10-05 13:12:12 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-10-07 10:29:53 +0200
commit1adde7755b6481f77823b54baaee8dcc9da4b243 (patch)
treefa93b0e57eb4e33080610e76d8c19dfca3a9c7a2 /arch/riscv
parentc986c565b023b245d11d7aefe56d9d28ea412395 (diff)
downloadbarebox-1adde7755b6481f77823b54baaee8dcc9da4b243.tar.gz
barebox-1adde7755b6481f77823b54baaee8dcc9da4b243.tar.xz
RISC-V: implement cache-management errata for T-Head SoCs
Since riscv_vendor_id() can be used from pbl and non-pbl context as well as from relocated and non-relocated code, we are able to query the vendor id and add special vendor handlings. This is required since the T-Head C906 and C910 implement a scheme for handling cache operations different from the generic Zicbom extension. While on it replace the 'asm' statement by '__asm__' so we are not relying on GNU extension. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221005111214.148844-5-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/riscv')
-rw-r--r--arch/riscv/include/asm/cache.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/arch/riscv/include/asm/cache.h b/arch/riscv/include/asm/cache.h
index 6d69ed49bd..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 CONFIG_HAS_CACHE
- asm volatile ("fence.i" ::: "memory");
+ switch(riscv_vendor_id()) {
+ case THEAD_VENDOR_ID:
+ thead_local_flush_icache_all();
+ break;
+ default:
+ __asm__ volatile ("fence.i" ::: "memory");
+ }
#endif
}