aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm/bootinfo.h
diff options
context:
space:
mode:
authorThomas Bogendoerfer <tsbogend@alpha.franken.de>2021-01-27 14:24:30 +0100
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>2021-02-04 13:34:51 +0100
commitb83ba0b9df56f8404ccc6ebcc7050fb8294f0f20 (patch)
tree8ddc0b7e76974718408e826aa83e7b7084193bb9 /arch/mips/include/asm/bootinfo.h
parentarch: mips: kernel: Fix two spelling in smp.c (diff)
downloadlinux-dev-b83ba0b9df56f8404ccc6ebcc7050fb8294f0f20.tar.xz
linux-dev-b83ba0b9df56f8404ccc6ebcc7050fb8294f0f20.zip
MIPS: of: Introduce helper function to get DTB
Selection of the DTB to be used was burried in more or less readable code in head.S. Move this code into a inline helper function and use it. Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Diffstat (limited to 'arch/mips/include/asm/bootinfo.h')
-rw-r--r--arch/mips/include/asm/bootinfo.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
index aa03b1237155..5be10ece3ef0 100644
--- a/arch/mips/include/asm/bootinfo.h
+++ b/arch/mips/include/asm/bootinfo.h
@@ -112,7 +112,27 @@ extern char arcs_cmdline[COMMAND_LINE_SIZE];
extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
#ifdef CONFIG_USE_OF
-extern unsigned long fw_passed_dtb;
+#include <linux/libfdt.h>
+#include <linux/of_fdt.h>
+
+extern char __appended_dtb[];
+
+static inline void *get_fdt(void)
+{
+ if (IS_ENABLED(CONFIG_MIPS_RAW_APPENDED_DTB) ||
+ IS_ENABLED(CONFIG_MIPS_ELF_APPENDED_DTB))
+ if (fdt_magic(&__appended_dtb) == FDT_MAGIC)
+ return &__appended_dtb;
+
+ if (fw_arg0 == -2) /* UHI interface */
+ return (void *)fw_arg1;
+
+ if (IS_ENABLED(CONFIG_BUILTIN_DTB))
+ if (&__dtb_start != &__dtb_end)
+ return &__dtb_start;
+
+ return NULL;
+}
#endif
/*