blob: 50fce207a534947dc368147a5c31db647df106b8 [file] [log] [blame]
huang lin1115b642015-11-17 14:20:27 +08001/*
Xu Ziyuan5401eb82016-07-12 19:09:49 +08002 * (C) Copyright 2016 Rockchip Electronics Co., Ltd
Philipp Tomsich29031a82017-06-23 00:05:38 +02003 * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
huang lin1115b642015-11-17 14:20:27 +08004 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <linux/linkage.h>
9
Philipp Tomsich29031a82017-06-23 00:05:38 +020010#if defined(CONFIG_ARM64)
huang lin1115b642015-11-17 14:20:27 +080011.globl SAVE_SP_ADDR
12SAVE_SP_ADDR:
Philipp Tomsich29031a82017-06-23 00:05:38 +020013 .quad 0
14
15ENTRY(save_boot_params)
16 sub sp, sp, #0x60
17 stp x29, x30, [sp, #0x50]
18 stp x27, x28, [sp, #0x40]
19 stp x25, x26, [sp, #0x30]
20 stp x23, x24, [sp, #0x20]
21 stp x21, x22, [sp, #0x10]
22 stp x19, x20, [sp, #0]
23 ldr x8, =SAVE_SP_ADDR
24 mov x9, sp
25 str x9, [x8]
26 b save_boot_params_ret /* back to my caller */
27ENDPROC(save_boot_params)
28
29.globl _back_to_bootrom_s
30ENTRY(_back_to_bootrom_s)
31 ldr x0, =SAVE_SP_ADDR
32 ldr x0, [x0]
33 mov sp, x0
34 ldp x29, x30, [sp, #0x50]
35 ldp x27, x28, [sp, #0x40]
36 ldp x25, x26, [sp, #0x30]
37 ldp x23, x24, [sp, #0x20]
38 ldp x21, x22, [sp, #0x10]
39 ldp x19, x20, [sp]
40 add sp, sp, #0x60
41 mov x0, xzr
42 ret
43ENDPROC(_back_to_bootrom_s)
44#else
45.globl SAVE_SP_ADDR
46SAVE_SP_ADDR:
huang lin1115b642015-11-17 14:20:27 +080047 .word 0
48
49/*
50 * void save_boot_params
51 *
52 * Save sp, lr, r1~r12
53 */
54ENTRY(save_boot_params)
55 push {r1-r12, lr}
56 ldr r0, =SAVE_SP_ADDR
57 str sp, [r0]
58 b save_boot_params_ret @ back to my caller
59ENDPROC(save_boot_params)
60
61
Simon Glassef0ab852017-04-15 13:11:31 -060062.globl _back_to_bootrom_s
63ENTRY(_back_to_bootrom_s)
huang lin1115b642015-11-17 14:20:27 +080064 ldr r0, =SAVE_SP_ADDR
65 ldr sp, [r0]
66 mov r0, #0
67 pop {r1-r12, pc}
Simon Glassef0ab852017-04-15 13:11:31 -060068ENDPROC(_back_to_bootrom_s)
Philipp Tomsich29031a82017-06-23 00:05:38 +020069#endif