Skip to content

Commit 190fe19

Browse files
author
Rich Felker
committed
sh: add support for linking a builtin device tree blob in the kernel
Signed-off-by: Rich Felker <dalias@libc.org>
1 parent ff18143 commit 190fe19

5 files changed

Lines changed: 41 additions & 3 deletions

File tree

‎arch/sh/Kconfig‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,26 @@ endmenu
739739

740740
menu "Boot options"
741741

742+
config USE_BUILTIN_DTB
743+
bool "Use builtin DTB"
744+
default n
745+
depends on SH_DEVICE_TREE
746+
help
747+
Link a device tree blob for particular hardware into the kernel,
748+
suppressing use of the DTB pointer provided by the bootloader.
749+
This option should only be used with legacy bootloaders that are
750+
not capable of providing a DTB to the kernel, or for experimental
751+
hardware without stable device tree bindings.
752+
753+
config BUILTIN_DTB_SOURCE
754+
string "Source file for builtin DTB"
755+
default ""
756+
depends on USE_BUILTIN_DTB
757+
help
758+
Base name (without suffix, relative to arch/sh/boot/dts) for the
759+
a DTS file that will be used to produce the DTB linked into the
760+
kernel.
761+
742762
config ZERO_PAGE_OFFSET
743763
hex
744764
default "0x00010000" if PAGE_SIZE_64KB || SH_RTS7751R2D || \

‎arch/sh/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ head-y := arch/sh/kernel/head_$(BITS).o
130130
core-y += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/
131131
core-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/
132132

133+
core-$(CONFIG_USE_BUILTIN_DTB) += arch/sh/boot/dts/
134+
133135
# Mach groups
134136
machdir-$(CONFIG_SOLUTION_ENGINE) += mach-se
135137
machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx

‎arch/sh/boards/of-generic.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,22 @@ static void __init sh_of_time_init(void)
124124

125125
static void __init sh_of_setup(char **cmdline_p)
126126
{
127+
struct device_node *root;
128+
129+
#ifdef CONFIG_USE_BUILTIN_DTB
130+
unflatten_and_copy_device_tree();
131+
#else
127132
unflatten_device_tree();
133+
#endif
128134

129135
board_time_init = sh_of_time_init;
130136

131-
sh_mv.mv_name = of_flat_dt_get_machine_name();
132-
if (!sh_mv.mv_name)
133-
sh_mv.mv_name = "Unknown SH model";
137+
sh_mv.mv_name = "Unknown SH model";
138+
root = of_find_node_by_path("/");
139+
if (root) {
140+
of_property_read_string(root, "model", &sh_mv.mv_name);
141+
of_node_put(root);
142+
}
134143

135144
sh_of_smp_probe();
136145
}

‎arch/sh/boot/dts/Makefile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
obj-$(CONFIG_USE_BUILTIN_DTB) += $(patsubst "%",%,$(CONFIG_BUILTIN_DTB_SOURCE)).dtb.o
2+
3+
clean-files := *.dtb.S

‎arch/sh/kernel/setup.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,11 @@ void __ref sh_fdt_init(phys_addr_t dt_phys)
251251
/* Avoid calling an __init function on secondary cpus. */
252252
if (done) return;
253253

254+
#ifdef CONFIG_USE_BUILTIN_DTB
255+
dt_virt = __dtb_start;
256+
#else
254257
dt_virt = phys_to_virt(dt_phys);
258+
#endif
255259

256260
if (!dt_virt || !early_init_dt_scan(dt_virt)) {
257261
pr_crit("Error: invalid device tree blob"

0 commit comments

Comments
 (0)