diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 7c4f7bcc89d7..a4949b69e1dc 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -39,6 +39,8 @@ config M68K select OLD_SIGSUSPEND3 select UACCESS_MEMCPY if !MMU select ZONE_DMA + select OF if COLDFIRE + select OF_EARLY_FLATTREE if COLDFIRE config CPU_BIG_ENDIAN def_bool y diff --git a/arch/m68k/Kconfig.devices b/arch/m68k/Kconfig.devices index e6e3efac1840..ea0bce4db639 100644 --- a/arch/m68k/Kconfig.devices +++ b/arch/m68k/Kconfig.devices @@ -144,3 +144,14 @@ config SERIAL_CONSOLE endmenu endif + +config EMBEDDED_DTB + bool "Embedded devicetree ELF section" + help + If there is no capability for the boot loader to specify a + devicetree (DTB) then this option allows for it to be embedded + within the linux binary itself. Typically you can do this with + something like this: + + objcopy --update-section .embedded_dtb=.dtb vmlinux + diff --git a/arch/m68k/coldfire/head.S b/arch/m68k/coldfire/head.S index c6d7fd28c602..88fd8b5b3bda 100644 --- a/arch/m68k/coldfire/head.S +++ b/arch/m68k/coldfire/head.S @@ -133,6 +133,15 @@ _init_sp: .long 0 #endif +#ifdef CONFIG_EMBEDDED_DTB +/* + * If embedding a DTB in the kernel ELF binary then create a place holder + * for that section. It will be inserted after the final kernel build/link. + */ +.section ".embedded_dtb","aw" +.long 0 +#endif + /*****************************************************************************/ __HEAD diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c index c926da9d5ec2..d1d79c41c6f0 100644 --- a/arch/m68k/kernel/setup_no.c +++ b/arch/m68k/kernel/setup_no.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include @@ -70,6 +72,31 @@ void (*mach_halt)(void); #define CPU_NAME "UNKNOWN" #endif +#ifdef CONFIG_EMBEDDED_DTB +static void __init m68k_setup_fdt(void) +{ + extern void *embedded_dtb; + phys_addr_t fdt = (phys_addr_t) &embedded_dtb; + + pr_info("m68k generic DT machine support, FDT blob at 0x%08x\n", fdt); + if (!early_init_dt_verify(__va(fdt), fdt)) { + pr_err("FDT blob is bad?!\n"); + return; + } + early_init_dt_scan_nodes(); +} + +static void __init m68k_dtb_model(void) +{ + const char *model; + model = of_flat_dt_get_machine_name(); + if (model) + pr_info("DTB reports model = %s\n", model); + else + pr_warn("DTB has no model type?\n"); +} +#endif /* CONFIG_EMBEDDED_DTB */ + /* * Different cores have different instruction execution timings. * The old/traditional 68000 cores are basically all the same, at 16. @@ -166,6 +193,11 @@ void __init setup_arch(char **cmdline_p) * Get kmalloc into gear. */ paging_init(); + +#ifdef CONFIG_EMBEDDED_DTB + m68k_setup_fdt(); + m68k_dtb_model(); +#endif } /* diff --git a/arch/m68k/kernel/vmlinux-nommu.lds b/arch/m68k/kernel/vmlinux-nommu.lds index 2624fc18c131..1be3bfe31ba4 100644 --- a/arch/m68k/kernel/vmlinux-nommu.lds +++ b/arch/m68k/kernel/vmlinux-nommu.lds @@ -70,6 +70,15 @@ SECTIONS { INIT_TEXT_SECTION(PAGE_SIZE) INIT_DATA_SECTION(16) PERCPU_SECTION(16) + +#ifdef CONFIG_EMBEDDED_DTB + STRUCT_ALIGN(); + .embedded_dtb : { + embedded_dtb = .; + *(.embedded_dtb) + KEEP(*(.embedded_dtb)) + } +#endif .m68k_fixup : { __start_fixup = .; *(.m68k_fixup)