kernel: Update kernel 4.4 to 4.4.100
[openwrt/openwrt.git] / target / linux / generic / pending-4.4 / 093-MIPS-store-the-appended-dtb-address-in-a-variable.patch
1 From 15f37e1588920e010f20b53f04af94e91b8ee714 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Mon, 20 Jun 2016 11:27:37 +0200
4 Subject: [PATCH] MIPS: store the appended dtb address in a variable
5
6 Instead of rewriting the arguments to match the UHI spec, store the
7 address of a appended or UHI supplied dtb in fw_supplied_dtb.
8
9 That way the original bootloader arugments are kept intact while still
10 making the use of an appended dtb invisible for mach code.
11
12 Mach code can still find out if it is an appended dtb by comparing
13 fw_arg1 with fw_supplied_dtb.
14
15 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
16 Cc: Kevin Cernekee <cernekee@gmail.com>
17 Cc: Florian Fainelli <f.fainelli@gmail.com>
18 Cc: John Crispin <john@phrozen.org>
19 Cc: Paul Burton <paul.burton@imgtec.com>
20 Cc: James Hogan <james.hogan@imgtec.com>
21 Cc: Alban Bedel <albeu@free.fr>
22 Cc: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
23 Cc: Antony Pavlov <antonynpavlov@gmail.com>
24 Cc: linux-mips@linux-mips.org
25 Patchwork: https://patchwork.linux-mips.org/patch/13699/
26 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
27 ---
28 arch/mips/ath79/setup.c | 4 ++--
29 arch/mips/bmips/setup.c | 4 ++--
30 arch/mips/include/asm/bootinfo.h | 4 ++++
31 arch/mips/kernel/head.S | 21 ++++++++++++++-------
32 arch/mips/kernel/setup.c | 4 ++++
33 arch/mips/lantiq/prom.c | 4 ++--
34 arch/mips/pic32/pic32mzda/init.c | 4 ++--
35 7 files changed, 30 insertions(+), 15 deletions(-)
36
37 --- a/arch/mips/ath79/setup.c
38 +++ b/arch/mips/ath79/setup.c
39 @@ -207,6 +207,8 @@ void __init plat_mem_setup(void)
40 fdt_start = fw_getenvl("fdt_start");
41 if (fdt_start)
42 __dt_setup_arch((void *)KSEG0ADDR(fdt_start));
43 + else if (fw_passed_dtb)
44 + __dt_setup_arch((void *)KSEG0ADDR(fw_passed_dtb));
45 #ifdef CONFIG_BUILTIN_DTB
46 else
47 __dt_setup_arch(__dtb_start);
48 --- a/arch/mips/bmips/setup.c
49 +++ b/arch/mips/bmips/setup.c
50 @@ -149,8 +149,8 @@ void __init plat_mem_setup(void)
51 /* intended to somewhat resemble ARM; see Documentation/arm/Booting */
52 if (fw_arg0 == 0 && fw_arg1 == 0xffffffff)
53 dtb = phys_to_virt(fw_arg2);
54 - else if (fw_arg0 == -2) /* UHI interface */
55 - dtb = (void *)fw_arg1;
56 + else if (fw_passed_dtb) /* UHI interface */
57 + dtb = (void *)fw_passed_dtb;
58 else if (__dtb_start != __dtb_end)
59 dtb = (void *)__dtb_start;
60 else
61 --- a/arch/mips/include/asm/bootinfo.h
62 +++ b/arch/mips/include/asm/bootinfo.h
63 @@ -127,6 +127,10 @@ extern char arcs_cmdline[COMMAND_LINE_SI
64 */
65 extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
66
67 +#ifdef CONFIG_USE_OF
68 +extern unsigned long fw_passed_dtb;
69 +#endif
70 +
71 /*
72 * Platform memory detection hook called by setup_arch
73 */
74 --- a/arch/mips/kernel/head.S
75 +++ b/arch/mips/kernel/head.S
76 @@ -94,21 +94,24 @@ NESTED(kernel_entry, 16, sp) # kernel
77 jr t0
78 0:
79
80 +#ifdef CONFIG_USE_OF
81 #ifdef CONFIG_MIPS_RAW_APPENDED_DTB
82 - PTR_LA t0, __appended_dtb
83 + PTR_LA t2, __appended_dtb
84
85 #ifdef CONFIG_CPU_BIG_ENDIAN
86 li t1, 0xd00dfeed
87 #else
88 li t1, 0xedfe0dd0
89 #endif
90 - lw t2, (t0)
91 - bne t1, t2, not_found
92 - nop
93 -
94 - move a1, t0
95 - PTR_LI a0, -2
96 -not_found:
97 + lw t0, (t2)
98 + beq t0, t1, dtb_found
99 +#endif
100 + li t1, -2
101 + beq a0, t1, dtb_found
102 + move t2, a1
103 +
104 + li t2, 0
105 +dtb_found:
106 #endif
107 PTR_LA t0, __bss_start # clear .bss
108 LONG_S zero, (t0)
109 @@ -123,6 +126,10 @@ not_found:
110 LONG_S a2, fw_arg2
111 LONG_S a3, fw_arg3
112
113 +#ifdef CONFIG_USE_OF
114 + LONG_S t2, fw_passed_dtb
115 +#endif
116 +
117 MTC0 zero, CP0_CONTEXT # clear context register
118 PTR_LA $28, init_thread_union
119 /* Set the SP after an empty pt_regs. */
120 --- a/arch/mips/kernel/setup.c
121 +++ b/arch/mips/kernel/setup.c
122 @@ -886,6 +886,10 @@ void __init setup_arch(char **cmdline_p)
123 unsigned long kernelsp[NR_CPUS];
124 unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
125
126 +#ifdef CONFIG_USE_OF
127 +unsigned long fw_passed_dtb;
128 +#endif
129 +
130 #ifdef CONFIG_DEBUG_FS
131 struct dentry *mips_debugfs_dir;
132 static int __init debugfs_mips(void)