@@ -12,6 +12,7 @@ endchoice
# board-specific options below
# platform-specific options below
+source "arch/loongarch/cpu/generic/Kconfig"
# architecture-specific options below
choice
new file mode 100644
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2024 Jiaxun yang <jiaxun.yang@flygoat.com>
+#
+
+config GENERIC_LOONGARCH
+ bool
+ select SYS_CACHE_SHIFT_6
+ imply CPU
+ imply CPU_LOONGARCH
+ imply LOONGARCH_TIMER
+ imply CMD_CPU
+
new file mode 100644
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2024 Jiaxun yang <jiaxun.yang@flygoat.com>
+#
+
+obj-y += dram.o
+obj-y += cpu.o
new file mode 100644
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@flygoat.com>
+ */
+
+#include <irq_func.h>
+#include <asm/cache.h>
+
+/*
+ * cleanup_before_linux() is called just before we call linux
+ * it prepares the processor for linux
+ *
+ * we disable interrupt and caches.
+ */
+int cleanup_before_linux(void)
+{
+ disable_interrupts();
+
+ cache_flush();
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@flygoat.com>
+ */
+
+#include <fdtdec.h>
+#include <init.h>
+#include <asm/global_data.h>
+#include <linux/sizes.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int dram_init(void)
+{
+ return fdtdec_setup_mem_size_base_lowest();
+}
+
+int dram_init_banksize(void)
+{
+ return fdtdec_setup_memory_banksize();
+}
Provide a generic CPU type with some common routines that expected to be implemented at CPU level. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> --- arch/loongarch/Kconfig | 1 + arch/loongarch/cpu/generic/Kconfig | 13 +++++++++++++ arch/loongarch/cpu/generic/Makefile | 7 +++++++ arch/loongarch/cpu/generic/cpu.c | 22 ++++++++++++++++++++++ arch/loongarch/cpu/generic/dram.c | 21 +++++++++++++++++++++ 5 files changed, 64 insertions(+)