Commit e11c6c279d823dc0d2f470c5c2e3c0a9854a640f

Authored by Simon Glass
Committed by Hans de Goede
1 parent c924e2a803

arm: Allow lr to be saved by board code

The link register value can be required on some boards (e.g. FEL mode on
sunxi) so use a branch instruction to jump to save_boot_params() instead
of a branch link.

This requires a branch back to save_boot_params_ret so adjust the users
to deal with this. For exynos just drop the function since it doesn't
do anything.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Showing 6 changed files with 24 additions and 6 deletions Side-by-side Diff

arch/arm/cpu/armv7/exynos/spl_boot.c
... ... @@ -309,5 +309,4 @@
309 309 while (1)
310 310 ;
311 311 }
312   -void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3) {}
arch/arm/cpu/armv7/omap-common/lowlevel_init.S
... ... @@ -19,7 +19,7 @@
19 19 ENTRY(save_boot_params)
20 20 ldr r1, =OMAP_SRAM_SCRATCH_BOOT_PARAMS
21 21 str r0, [r1]
22   - bx lr
  22 + b save_boot_params_ret
23 23 ENDPROC(save_boot_params)
24 24  
25 25 ENTRY(set_pl310_ctrl_reg)
arch/arm/cpu/armv7/omap3/lowlevel_init.S
... ... @@ -23,7 +23,7 @@
23 23 ldr r5, [r0, #0x4]
24 24 and r5, r5, #0xff
25 25 str r5, [r4]
26   - bx lr
  26 + b save_boot_params_ret
27 27 ENDPROC(save_boot_params)
28 28 #endif
29 29  
arch/arm/cpu/armv7/start.S
... ... @@ -31,9 +31,12 @@
31 31 *************************************************************************/
32 32  
33 33 .globl reset
  34 + .globl save_boot_params_ret
34 35  
35 36 reset:
36   - bl save_boot_params
  37 + /* Allow the board to save important registers */
  38 + b save_boot_params
  39 +save_boot_params_ret:
37 40 /*
38 41 * disable interrupts (FIQ and IRQ), also set the cpu to SVC32 mode,
39 42 * except if in HYP mode already
... ... @@ -96,7 +99,7 @@
96 99 *
97 100 *************************************************************************/
98 101 ENTRY(save_boot_params)
99   - bx lr @ back to my caller
  102 + b save_boot_params_ret @ back to my caller
100 103 ENDPROC(save_boot_params)
101 104 .weak save_boot_params
102 105  
arch/arm/include/asm/system.h
... ... @@ -142,6 +142,21 @@
142 142  
143 143 #ifndef __ASSEMBLY__
144 144  
  145 +/**
  146 + * save_boot_params() - Save boot parameters before starting reset sequence
  147 + *
  148 + * If you provide this function it will be called immediately U-Boot starts,
  149 + * both for SPL and U-Boot proper.
  150 + *
  151 + * All registers are unchanged from U-Boot entry. No registers need be
  152 + * preserved.
  153 + *
  154 + * This is not a normal C function. There is no stack. Return by branching to
  155 + * save_boot_params_ret.
  156 + *
  157 + * void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3);
  158 + */
  159 +
145 160 #define isb() __asm__ __volatile__ ("" : : : "memory")
146 161  
147 162 #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
board/nokia/rx51/lowlevel_init.S
... ... @@ -37,7 +37,8 @@
37 37  
38 38 .global save_boot_params
39 39 save_boot_params:
40   -
  40 + /* Get return address */
  41 + ldr lr, =save_boot_params_ret
41 42  
42 43 /* Copy valid attached kernel to address KERNEL_ADDRESS */
43 44