093-MIPS-store-the-appended-dtb-address-in-a-variable.patch 3.8 KB

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