summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun Liang Tan <junliang.tan@linux.starfivetech.com>2022-08-01 11:03:00 +0300
committerJun Liang Tan <junliang.tan@linux.starfivetech.com>2022-10-27 11:42:31 +0300
commitbee8253d8f04c56017860386d1b2132cf4f4b7c5 (patch)
tree812ff760c32c9818f7d18a9c9d6e8178668b82e8
parent361530eceac3fe7209adc47341afb68130b224f2 (diff)
downloadopensbi-starfive-v1.1-dubhe.tar.xz
platform: generic: starfive: Add platform specific Cache Maintenance OperationsREL_DUBHE_JAN2023starfive-v1.1-dubhe
Add SBI call for L2 cache flush and L2 cache invalidate for Dubhe Signed-off-by: Jun Liang Tan <junliang.tan@linux.starfivetech.com>
-rw-r--r--platform/generic/starfive/cache.h18
-rwxr-xr-xplatform/generic/starfive/dubhe_cache.S84
-rw-r--r--platform/generic/starfive/jh8100.c48
-rw-r--r--platform/generic/starfive/jh8100.h18
-rw-r--r--platform/generic/starfive/objects.mk11
5 files changed, 179 insertions, 0 deletions
diff --git a/platform/generic/starfive/cache.h b/platform/generic/starfive/cache.h
new file mode 100644
index 0000000..a60f900
--- /dev/null
+++ b/platform/generic/starfive/cache.h
@@ -0,0 +1,18 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 StarFive Technology Co., Ltd.
+ *
+ * Author: Jun Liang Tan <junliang.tan@linux.starfivetech.com>
+ *
+ */
+
+#ifndef _DUBHE_CACHE_H_
+#define _DUBHE_CACHE_H_
+
+#include <sbi/sbi_types.h>
+
+void __sbi_dubhe_L2_flush_range(uint64_t start, uint64_t len);
+void __sbi_dubhe_L2_inv_range(uint64_t start, uint64_t len);
+
+#endif /* _DUBHE_CACHE_H_ */
diff --git a/platform/generic/starfive/dubhe_cache.S b/platform/generic/starfive/dubhe_cache.S
new file mode 100755
index 0000000..d0b3f94
--- /dev/null
+++ b/platform/generic/starfive/dubhe_cache.S
@@ -0,0 +1,84 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 StarFive Technology Co., Ltd.
+ *
+ * Author: Chee Hong Ang <cheehong.ang@linux.starfivetech.com>
+ *
+ */
+
+#define DUBHE_L2_CACHELINE_SIZE 0x40
+
+ /*
+ * __sbi_dubhe_L2_inv_range(start,len)
+ *
+ * Invalidate the L2 cache within the specified region
+ *
+ * start - physical start address of region
+ * len - size of memory region
+ */
+
+ .align 3
+ .global __sbi_dubhe_L2_inv_range
+__sbi_dubhe_L2_inv_range:
+ beqz a1, 4f
+ li t0, DUBHE_L2_CACHELINE_SIZE
+ addi t1, t0, -1
+ add a1, a1, a0 /* Compute end address */
+ and t2, a0, t1
+ not t3, t1
+ and a0, a0, t3
+ beqz t2, 1f
+ /* CFLUSH.L2 rs1 = a0 */
+ fence rw, rw
+ .insn i 0x73, 0, x0, a0, -0x3C
+ fence rw, rw
+ add a0, a0, t0
+1:
+ and t2, a1, t1
+ not t3, t1
+ and a1, a1, t3
+ beqz t2, 2f
+ /* CFLUSH.L2 rs1 = a1 */
+ fence rw, rw
+ .insn i 0x73, 0, x0, a1, -0x3C
+ fence rw, rw
+2:
+ bge a0, a1, 4f
+3:
+ /* CDISCARD.L2 rs1 = a0 */
+ fence rw, rw
+ .insn i 0x73, 0, x0, a0, -0x3A
+ fence rw, rw
+ add a0, a0, t0
+ blt a0, a1, 3b
+4:
+ ret
+
+ /*
+ * __sbi_dubhe_L2_flush_range(start,len)
+ *
+ * Flush and invalidate the L2 cache within the specified region
+ *
+ * start - physical start address of region
+ * len - size of memory region
+ */
+
+ .align 3
+ .global __sbi_dubhe_L2_flush_range
+__sbi_dubhe_L2_flush_range:
+ beqz a1, 2f
+ li t0, DUBHE_L2_CACHELINE_SIZE
+ addi t1, t0, -1
+ add a1, a1, a0 /* Compute end address */
+ not t2, t1
+ and a0, a0, t2
+1:
+ /* CFLUSH.L2 rs1 = a0 */
+ fence rw, rw
+ .insn i 0x73, 0, x0, a0, -0x3C
+ fence rw, rw
+ add a0, a0, t0
+ blt a0, a1, 1b
+2:
+ ret
diff --git a/platform/generic/starfive/jh8100.c b/platform/generic/starfive/jh8100.c
new file mode 100644
index 0000000..b11ffcf
--- /dev/null
+++ b/platform/generic/starfive/jh8100.c
@@ -0,0 +1,48 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 StarFive Technology Co., Ltd.
+ *
+ * Author: Jun Liang Tan <junliang.tan@linux.starfivetech.com>
+ *
+ */
+
+#include <cache.h>
+#include <jh8100.h>
+#include <platform_override.h>
+#include <sbi/sbi_console.h>
+#include <sbi_utils/fdt/fdt_helper.h>
+
+static int starfive_vendor_ext_provider(long extid, long funcid,
+ const struct sbi_trap_regs *regs,
+ unsigned long *out_value,
+ struct sbi_trap_info *out_trap,
+ const struct fdt_match *match)
+{
+ int ret = 0;
+
+ switch (funcid) {
+ case SBI_EXT_STARFIVE_DUBHE_L2_FLUSH:
+ __sbi_dubhe_L2_flush_range(regs->a0, regs->a1);
+ break;
+ case SBI_EXT_STARFIVE_DUBHE_L2_INVALIDATE:
+ __sbi_dubhe_L2_inv_range(regs->a0, regs->a1);
+ break;
+ default:
+ sbi_printf("Unsupported vendor sbi call : %ld\n", funcid);
+ asm volatile("ebreak");
+ }
+
+ return ret;
+}
+
+static const struct fdt_match starfive_jh8xxx_match[] = {
+ { .compatible = "starfive,dubhe" },
+ { .compatible = "starfive,jh8100" },
+ { },
+};
+
+const struct platform_override starfive_jh8xxx = {
+ .match_table = starfive_jh8xxx_match,
+ .vendor_ext_provider = starfive_vendor_ext_provider,
+};
diff --git a/platform/generic/starfive/jh8100.h b/platform/generic/starfive/jh8100.h
new file mode 100644
index 0000000..c905f84
--- /dev/null
+++ b/platform/generic/starfive/jh8100.h
@@ -0,0 +1,18 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 StarFive Technology Co., Ltd.
+ *
+ * Author: Jun Liang Tan <junliang.tan@linux.starfivetech.com>
+ *
+ */
+
+#ifndef _STARFIVE_JH8100_H_
+#define _STARFIVE_JH8100_H_
+
+enum sbi_ext_dubhe_cmo_fid {
+ SBI_EXT_STARFIVE_DUBHE_L2_FLUSH = 0,
+ SBI_EXT_STARFIVE_DUBHE_L2_INVALIDATE,
+};
+
+#endif /* _STARFIVE_JH8100_H_ */
diff --git a/platform/generic/starfive/objects.mk b/platform/generic/starfive/objects.mk
new file mode 100644
index 0000000..0baa9f7
--- /dev/null
+++ b/platform/generic/starfive/objects.mk
@@ -0,0 +1,11 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2022 StarFive Technology Co., Ltd.
+#
+# Author: Jun Liang Tan <junliang.tan@linux.starfivetech.com>
+#
+
+carray-platform_override_modules-y += starfive_jh8xxx
+platform-objs-y += starfive/dubhe_cache.o
+platform-objs-y += starfive/jh8100.o