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
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.
9 That way the original bootloader arugments are kept intact while still
10 making the use of an appended dtb invisible for mach code.
12 Mach code can still find out if it is an appended dtb by comparing
13 fw_arg1 with fw_supplied_dtb.
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>
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(-)
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");
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
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;
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
65 extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
68 +extern unsigned long fw_passed_dtb;
72 * Platform memory detection hook called by setup_arch
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
81 #ifdef CONFIG_MIPS_RAW_APPENDED_DTB
82 - PTR_LA t0, __appended_dtb
83 + PTR_LA t2, __appended_dtb
85 #ifdef CONFIG_CPU_BIG_ENDIAN
91 - bne t1, t2, not_found
98 + beq t0, t1, dtb_found
101 + beq a0, t1, dtb_found
107 PTR_LA t0, __bss_start # clear .bss
109 @@ -123,6 +126,10 @@ not_found:
113 +#ifdef CONFIG_USE_OF
114 + LONG_S t2, fw_passed_dtb
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 @@ -814,6 +814,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;
126 +#ifdef CONFIG_USE_OF
127 +unsigned long fw_passed_dtb;
130 #ifdef CONFIG_DEBUG_FS
131 struct dentry *mips_debugfs_dir;
132 static int __init debugfs_mips(void)