From: Miodrag Dinic Date: Tue, 25 Nov 2014 17:31:30 +0000 (+0100) Subject: [MIPS] Ranchu platform Appended DTB support X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=231425de6f3169ce99cd3a61a2c42a39f4d07dd3;p=platform%2Fkernel%2Flinux-arm64.git [MIPS] Ranchu platform Appended DTB support With CONFIG_MIPS_APPENDED_DTB=y option enabled, the boot code will look for a device tree binary (dtb) appended to raw vmlinux.bin (without decompressor). (e.g. cat vmlinux.bin .dtb > vmlinux_w_dtb). Beware that there is very little in terms of protection against this option being confused by leftover garbage in memory that might look like a DTB header after a reboot if no actual DTB is appended to vmlinux.bin. Change-Id: Ia1d7e0e4fe3848385b84cb06b04ea480897946f9 Reviewed-on: https://mipsia.review.mips.com/2860 Reviewed-by: Raghu Gandham Tested-by: Raghu Gandham --- diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 79ca0e2a699..897591216a8 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2499,6 +2499,20 @@ config USE_OF select OF_EARLY_FLATTREE select IRQ_DOMAIN +config MIPS_APPENDED_DTB + bool "Use appended device tree blob to vmlinux.bin (EXPERIMENTAL)" + depends on OF && MIPS_RANCHU + help + With this option, the boot code will look for a device tree binary + DTB) appended to raw vmlinux.bin (without decompressor). + (e.g. cat vmlinux.bin .dtb > vmlinux_w_dtb). + + Beware that there is very little in terms of protection against + this option being confused by leftover garbage in memory that might + look like a DTB header after a reboot if no actual DTB is appended + to vmlinux.bin. Do not leave this option active in a production kernel + if you don't intend to always append a DTB. + endmenu config LOCKDEP_SUPPORT diff --git a/arch/mips/goldfish/Makefile b/arch/mips/goldfish/Makefile index e48f32ccad4..4d8535f50c2 100644 --- a/arch/mips/goldfish/Makefile +++ b/arch/mips/goldfish/Makefile @@ -10,7 +10,9 @@ obj-$(CONFIG_GOLDFISH) += goldfish-time.o obj-$(CONFIG_GOLDFISH) += switch.o obj-$(CONFIG_GOLDFISH) += pm.o -obj-$(CONFIG_MIPS_RANCHU) += ranchu.dtb.o +ifneq ($(CONFIG_MIPS_APPENDED_DTB), y) +obj-$(CONFIG_MIPS_RANCHU) += ranchu.dtb.o $(obj)/%.dtb: $(obj)/%.dts $(call if_changed,dtc) +endif diff --git a/arch/mips/goldfish/goldfish-platform.c b/arch/mips/goldfish/goldfish-platform.c index 63139f204cc..286b0e305a5 100644 --- a/arch/mips/goldfish/goldfish-platform.c +++ b/arch/mips/goldfish/goldfish-platform.c @@ -58,10 +58,17 @@ const char *get_system_type(void) void __init plat_mem_setup(void) { /* - * Load the builtin devicetree. This causes the chosen node to be + * Load the builtin or appended devicetree. + * This causes the chosen node to be * parsed resulting in our memory appearing */ +#ifdef CONFIG_MIPS_APPENDED_DTB + pr_info("Try setup using Appended DTB\n"); + __dt_setup_arch(&__appended_dtb); +#else + pr_info("Try setup using Built-in DTB\n"); __dt_setup_arch(&__dtb_start); +#endif } void __init device_tree_init(void) diff --git a/arch/mips/include/asm/mips-boards/generic.h b/arch/mips/include/asm/mips-boards/generic.h index 48616816bcb..dc7cfbcc564 100644 --- a/arch/mips/include/asm/mips-boards/generic.h +++ b/arch/mips/include/asm/mips-boards/generic.h @@ -69,6 +69,9 @@ extern int mips_revision_sconid; #ifdef CONFIG_OF extern struct boot_param_header __dtb_start; +#ifdef CONFIG_MIPS_APPENDED_DTB +extern struct boot_param_header __appended_dtb; +#endif #endif #ifdef CONFIG_PCI diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S index 4a4c4f17414..aa98896fbb2 100644 --- a/arch/mips/kernel/head.S +++ b/arch/mips/kernel/head.S @@ -179,6 +179,23 @@ NESTED(kernel_entry, 16, sp) # kernel entry point mtc0 t0, CP0_STATUS #endif /* CONFIG_MIPS_MT_SMTC */ +#ifdef CONFIG_MIPS_APPENDED_DTB + PTR_LA t0, __appended_dtb + PTR_LI t3, 0 + +#ifdef CONFIG_CPU_BIG_ENDIAN + PTR_LI t1, 0xd00dfeed +#else + PTR_LI t1, 0xedfe0dd0 +#endif + LONG_L t2, (t0) + bne t1, t2, not_found + + PTR_LA t3, __appended_dtb + +not_found: +#endif + PTR_LA t0, __bss_start # clear .bss LONG_S zero, (t0) PTR_LA t1, __bss_stop - LONGSIZE @@ -192,6 +209,10 @@ NESTED(kernel_entry, 16, sp) # kernel entry point LONG_S a2, fw_arg2 LONG_S a3, fw_arg3 +#ifdef CONFIG_MIPS_APPENDED_DTB + LONG_S t3, initial_boot_params +#endif + MTC0 zero, CP0_CONTEXT # clear context register PTR_LA $28, init_thread_union /* Set the SP after an empty pt_regs. */ diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c index 32b87882ac8..3b0bf5d4f98 100644 --- a/arch/mips/kernel/prom.c +++ b/arch/mips/kernel/prom.c @@ -101,7 +101,11 @@ void __init early_init_devtree(void *params) void __init __dt_setup_arch(struct boot_param_header *bph) { if (be32_to_cpu(bph->magic) != OF_DT_HEADER) { +#ifdef CONFIG_MIPS_APPENDED_DTB + pr_err("DTB has bad magic, ignoring appended OF DTB\n"); +#else pr_err("DTB has bad magic, ignoring builtin OF DTB\n"); +#endif return; } diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 05826d20a79..7ed2fe5dd37 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -145,6 +145,12 @@ SECTIONS _end = . ; +#ifdef CONFIG_MIPS_APPENDED_DTB + __appended_dtb = .; + /* leave space for appended DTB */ + . = . + 0x100000; +#endif + /* These mark the ABI of the kernel for debuggers. */ .mdebug.abi32 : { KEEP(*(.mdebug.abi32))