new file mode 100644
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2019 Jiaxun Yang <jiaxun.yang@flygoat.com>
+ *
+ * Built-in Generic dtbs for MACH_LOONGSON64
+ */
+
+#ifndef __ASM_MACH_LOONGSON64_BUILTIN_DTBS_H_
+#define __ASM_MACH_LOONGSON64_BUILTIN_DTBS_H_
+
+extern u32 __dtb_3a1000_780e_begin[];
+extern u32 __dtb_3a2000_780e_begin[];
+extern u32 __dtb_3a3000_780e_begin[];
+extern u32 __dtb_3b1x00_780e_begin[];
+
+#endif
@@ -45,4 +45,6 @@ extern u64 loongson_freqctrl[MAX_PACKAGES];
extern const struct plat_smp_ops loongson3_smp_ops;
extern void __init prom_init_lefi(void);
+extern void *loongson_fdt_blob;
+
#endif
@@ -20,6 +20,7 @@
#include <loongson64.h>
#include <boot_param.h>
+#include <builtin_dtbs.h>
#include <workarounds.h>
u32 cpu_clock_freq;
@@ -126,6 +127,31 @@ void __init prom_init_lefi(void)
loongson_sysconf.cores_per_node - 1) /
loongson_sysconf.cores_per_node;
+ if ((read_c0_prid() & PRID_IMP_MASK) == PRID_IMP_LOONGSON_64) {
+ switch (read_c0_prid() & PRID_REV_MASK) {
+ case PRID_REV_LOONGSON3A_R1:
+ loongson_fdt_blob = __dtb_3a1000_780e_begin;
+ break;
+ case PRID_REV_LOONGSON3A_R2_0:
+ case PRID_REV_LOONGSON3A_R2_1:
+ loongson_fdt_blob = __dtb_3a2000_780e_begin;
+ break;
+ case PRID_REV_LOONGSON3A_R3_0:
+ case PRID_REV_LOONGSON3A_R3_1:
+ loongson_fdt_blob = __dtb_3a3000_780e_begin;
+ break;
+ case PRID_REV_LOONGSON3B_R1:
+ case PRID_REV_LOONGSON3B_R2:
+ loongson_fdt_blob = __dtb_3b1x00_780e_begin;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (!loongson_fdt_blob)
+ pr_err("Failed to determine built-in Loongson64 dtb\n");
+
loongson_sysconf.pci_mem_start_addr = eirq_source->pci_mem_start_addr;
loongson_sysconf.pci_mem_end_addr = eirq_source->pci_mem_end_addr;
loongson_sysconf.pci_io_base = eirq_source->pci_io_start_addr;
@@ -7,9 +7,15 @@
#include <asm/setup.h>
#include <asm/smp-ops.h>
#include <asm/cacheflush.h>
+#include <linux/libfdt.h>
+#include <linux/of_fdt.h>
+
+#include <asm/prom.h>
#include <loongson64.h>
+void *loongson_fdt_blob;
+
static void wbflush_loongson(void)
{
asm(".set\tpush\n\t"
@@ -81,6 +87,8 @@ void __init prom_free_prom_memory(void)
void __init plat_mem_setup(void)
{
+ if (loongson_fdt_blob)
+ __dt_setup_arch(loongson_fdt_blob);
}
void __init plat_time_init(void)
@@ -89,3 +97,11 @@ void __init plat_time_init(void)
setup_hpet_timer();
#endif
}
+
+void __init device_tree_init(void)
+{
+ if (!initial_boot_params)
+ return;
+
+ unflatten_and_copy_device_tree();
+}
Load proper dtb according to firmware passed parameters and CPU PRID. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> --- .../asm/mach-loongson64/builtin_dtbs.h | 16 ++++++++++++ .../include/asm/mach-loongson64/loongson64.h | 2 ++ arch/mips/loongson64/env.c | 26 +++++++++++++++++++ arch/mips/loongson64/setup.c | 16 ++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 arch/mips/include/asm/mach-loongson64/builtin_dtbs.h