4154fd3bb4a8206644cb0bdfbca96bdc75844577
[openwrt/svn-archive/archive.git] / target / linux / brcm63xx / patches-4.1 / 001-4.2-MIPS-Add-support-for-vmlinux.bin-appended-dtb.patch
1 From 1da8f1798e307fb8422753984339beb00025f97d Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Sun, 12 Apr 2015 12:24:58 +0200
4 Subject: [PATCH] MIPS: Add support for vmlinux.bin appended dtb
5
6 Add support for detecting a vmlinux.bin appended dtb and overriding
7 the boot arguments to match the UHI interface.
8
9 Due to the PERCPU section being empty for !SMP, but still modifying
10 the current address by aligning it to the page size, do not define
11 it for !SMP builds to allow __appended_dtb to still point to
12 the actual end of the data.
13
14 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
15 Cc: linux-mips@linux-mips.org
16 Cc: devicetree@vger.kernel.org
17 Cc: John Crispin <blogic@openwrt.org>
18 Cc: Kevin Cernekee <cernekee@gmail.com>
19 Cc: Florian Fainelli <f.fainelli@gmail.com>
20 Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
21 Cc: Markos Chandras <markos.chandras@imgtec.com>
22 Cc: Andrew Bresticker <abrestic@chromium.org>
23 Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
24 Cc: Paul Burton <paul.burton@imgtec.com>
25 Cc: James Hartley <James.Hartley@imgtec.com>
26 Patchwork: https://patchwork.linux-mips.org/patch/9739/
27 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
28 ---
29 arch/mips/Kconfig | 27 +++++++++++++++++++++++++++
30 arch/mips/kernel/head.S | 16 ++++++++++++++++
31 arch/mips/kernel/vmlinux.lds.S | 8 +++++++-
32 3 files changed, 50 insertions(+), 1 deletion(-)
33
34 --- a/arch/mips/Kconfig
35 +++ b/arch/mips/Kconfig
36 @@ -2702,6 +2702,33 @@ config BOOT_RAW
37
38
39
40 +choice
41 + prompt "Kernel appended dtb support" if OF
42 + default MIPS_NO_APPENDED_DTB
43 +
44 + config MIPS_NO_APPENDED_DTB
45 + bool "None"
46 + help
47 + Do not enable appended dtb support.
48 +
49 + config MIPS_RAW_APPENDED_DTB
50 + bool "vmlinux.bin"
51 + help
52 + With this option, the boot code will look for a device tree binary
53 + DTB) appended to raw vmlinux.bin (without decompressor).
54 + (e.g. cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb).
55 +
56 + This is meant as a backward compatibility convenience for those
57 + systems with a bootloader that can't be upgraded to accommodate
58 + the documented boot protocol using a device tree.
59 +
60 + Beware that there is very little in terms of protection against
61 + this option being confused by leftover garbage in memory that might
62 + look like a DTB header after a reboot if no actual DTB is appended
63 + to vmlinux.bin. Do not leave this option active in a production kernel
64 + if you don't intend to always append a DTB.
65 +endchoice
66 +
67 endmenu
68
69 config LOCKDEP_SUPPORT
70 --- a/arch/mips/kernel/head.S
71 +++ b/arch/mips/kernel/head.S
72 @@ -100,6 +100,22 @@ NESTED(kernel_entry, 16, sp) # kernel
73 jr t0
74 0:
75
76 +#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
77 + PTR_LA t0, __appended_dtb
78 +
79 +#ifdef CONFIG_CPU_BIG_ENDIAN
80 + li t1, 0xd00dfeed
81 +#else
82 + li t1, 0xedfe0dd0
83 +#endif
84 + lw t2, (t0)
85 + bne t1, t2, not_found
86 + nop
87 +
88 + move a1, t0
89 + PTR_LI a0, -2
90 +not_found:
91 +#endif
92 PTR_LA t0, __bss_start # clear .bss
93 LONG_S zero, (t0)
94 PTR_LA t1, __bss_stop - LONGSIZE
95 --- a/arch/mips/kernel/vmlinux.lds.S
96 +++ b/arch/mips/kernel/vmlinux.lds.S
97 @@ -125,8 +125,14 @@ SECTIONS
98 .exit.data : {
99 EXIT_DATA
100 }
101 -
102 +#ifdef CONFIG_SMP
103 PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
104 +#endif
105 +#ifdef CONFIG_MIPS_RAW_APPENDED_DTB
106 + __appended_dtb = .;
107 + /* leave space for appended DTB */
108 + . += 0x100000;
109 +#endif
110 /*
111 * Align to 64K in attempt to eliminate holes before the
112 * .bss..swapper_pg_dir section at the start of .bss. This