sh: add support for linking a builtin device tree blob in the kernel
authorRich Felker <dalias@libc.org>
Sat, 26 Mar 2016 01:24:30 +0000 (01:24 +0000)
committerRich Felker <dalias@libc.org>
Sun, 31 Jul 2016 03:33:32 +0000 (03:33 +0000)
Signed-off-by: Rich Felker <dalias@libc.org>
arch/sh/Kconfig
arch/sh/Makefile
arch/sh/boards/of-generic.c
arch/sh/boot/dts/Makefile [new file with mode: 0644]
arch/sh/kernel/setup.c

index 0d5f3a9..ceeda5c 100644 (file)
@@ -739,6 +739,26 @@ endmenu
 
 menu "Boot options"
 
+config USE_BUILTIN_DTB
+       bool "Use builtin DTB"
+       default n
+       depends on SH_DEVICE_TREE
+       help
+         Link a device tree blob for particular hardware into the kernel,
+         suppressing use of the DTB pointer provided by the bootloader.
+         This option should only be used with legacy bootloaders that are
+         not capable of providing a DTB to the kernel, or for experimental
+         hardware without stable device tree bindings.
+
+config BUILTIN_DTB_SOURCE
+       string "Source file for builtin DTB"
+       default ""
+       depends on USE_BUILTIN_DTB
+       help
+         Base name (without suffix, relative to arch/sh/boot/dts) for the
+         a DTS file that will be used to produce the DTB linked into the
+         kernel.
+
 config ZERO_PAGE_OFFSET
        hex
        default "0x00010000" if PAGE_SIZE_64KB || SH_RTS7751R2D || \
index bf5b3f5..3b2c8b4 100644 (file)
@@ -130,6 +130,8 @@ head-y      := arch/sh/kernel/head_$(BITS).o
 core-y                         += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/
 core-$(CONFIG_SH_FPU_EMU)      += arch/sh/math-emu/
 
+core-$(CONFIG_USE_BUILTIN_DTB) += arch/sh/boot/dts/
+
 # Mach groups
 machdir-$(CONFIG_SOLUTION_ENGINE)              += mach-se
 machdir-$(CONFIG_SH_HP6XX)                     += mach-hp6xx
index 911ffb9..1fb6d57 100644 (file)
@@ -124,13 +124,22 @@ static void __init sh_of_time_init(void)
 
 static void __init sh_of_setup(char **cmdline_p)
 {
+       struct device_node *root;
+
+#ifdef CONFIG_USE_BUILTIN_DTB
+       unflatten_and_copy_device_tree();
+#else
        unflatten_device_tree();
+#endif
 
        board_time_init = sh_of_time_init;
 
-       sh_mv.mv_name = of_flat_dt_get_machine_name();
-       if (!sh_mv.mv_name)
-               sh_mv.mv_name = "Unknown SH model";
+       sh_mv.mv_name = "Unknown SH model";
+       root = of_find_node_by_path("/");
+       if (root) {
+               of_property_read_string(root, "model", &sh_mv.mv_name);
+               of_node_put(root);
+       }
 
        sh_of_smp_probe();
 }
diff --git a/arch/sh/boot/dts/Makefile b/arch/sh/boot/dts/Makefile
new file mode 100644 (file)
index 0000000..e5ce3a0
--- /dev/null
@@ -0,0 +1,3 @@
+obj-$(CONFIG_USE_BUILTIN_DTB) += $(patsubst "%",%,$(CONFIG_BUILTIN_DTB_SOURCE)).dtb.o
+
+clean-files := *.dtb.S
index 5d34605..5b9eb70 100644 (file)
@@ -251,7 +251,11 @@ void __ref sh_fdt_init(phys_addr_t dt_phys)
        /* Avoid calling an __init function on secondary cpus. */
        if (done) return;
 
+#ifdef CONFIG_USE_BUILTIN_DTB
+       dt_virt = __dtb_start;
+#else
        dt_virt = phys_to_virt(dt_phys);
+#endif
 
        if (!dt_virt || !early_init_dt_scan(dt_virt)) {
                pr_crit("Error: invalid device tree blob"