]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
riscv: cpu: th1520: Support cache enabling/disabling in M mode only
authorYao Zi <ziyao@disroot.org>
Fri, 30 May 2025 09:48:48 +0000 (09:48 +0000)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Mon, 9 Jun 2025 02:44:06 +0000 (10:44 +0800)
These operations rely on a customized M-mode CSR, MHCR, which isn't
available when running in S mode.

Let's fallback to the generic weak stub when running in S mode to avoid
illegal accesses.

Signed-off-by: Yao Zi <ziyao@disroot.org>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
arch/riscv/cpu/th1520/cache.c

index 08aa1f789fd6d356a6d1a9c945807ee4638080f3..b2fec229363b9d2f5024fa30af71fabb9de6f4e6 100644 (file)
@@ -11,6 +11,7 @@
 #define  CSR_MHCR_IE           BIT(0)
 #define  CSR_MHCR_DE           BIT(1)
 
+#if CONFIG_IS_ENABLED(RISCV_MMODE)
 void icache_enable(void)
 {
        csr_write(CSR_MHCR, csr_read(CSR_MHCR) | CSR_MHCR_IE);
@@ -30,3 +31,4 @@ int dcache_status(void)
 {
        return (csr_read(CSR_MHCR) & CSR_MHCR_DE) != 0;
 }
+#endif /* CONFIG_IS_ENABLED(RISCV_MMODE) */