MIPS: Add helper function to allow platforms to point at a DTB.
authorRalf Baechle <ralf@linux-mips.org>
Wed, 25 Jan 2012 14:03:19 +0000 (15:03 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 15 May 2012 15:49:19 +0000 (17:49 +0200)
Add __dt_setup_arch() that can be called to load a builtin DT.
Additionally we add a macro to allow loading a specific symbol
from the __dtb_* section.

Signed-off-by: John Crispin <blogic@openwrt.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/3715/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/prom.h
arch/mips/kernel/prom.c

index 40ed25952e6bfb1aca679425410ce74d522e7302..7206d445bab876e926cec6bd242309b893870007 100644 (file)
@@ -36,6 +36,17 @@ static inline unsigned long pci_address_to_pio(phys_addr_t address)
 }
 #define pci_address_to_pio pci_address_to_pio
 
+struct boot_param_header;
+
+extern void __dt_setup_arch(struct boot_param_header *bph);
+
+#define dt_setup_arch(sym)                                             \
+({                                                                     \
+       extern struct boot_param_header __dtb_##sym##_begin;            \
+                                                                       \
+       __dt_setup_arch(&__dtb_##sym##_begin);                          \
+})
+
 #else /* CONFIG_OF */
 static inline void device_tree_init(void) { }
 #endif /* CONFIG_OF */
index 558b5395795df810d01c97ed36efa96fc9141eea..4c788d2595390fb054b69f07bd21e662f075b228 100644 (file)
@@ -95,3 +95,14 @@ void __init device_tree_init(void)
        /* free the space reserved for the dt blob */
        free_mem_mach(base, size);
 }
+
+void __init __dt_setup_arch(struct boot_param_header *bph)
+{
+       if (be32_to_cpu(bph->magic) != OF_DT_HEADER) {
+               pr_err("DTB has bad magic, ignoring builtin OF DTB\n");
+
+               return;
+       }
+
+       initial_boot_params = bph;
+}