huang lin | 1115b64 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 1 | /* |
Xu Ziyuan | 5401eb8 | 2016-07-12 19:09:49 +0800 | [diff] [blame] | 2 | * (C) Copyright 2016 Rockchip Electronics Co., Ltd |
Philipp Tomsich | 29031a8 | 2017-06-23 00:05:38 +0200 | [diff] [blame] | 3 | * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH |
huang lin | 1115b64 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <linux/linkage.h> |
| 9 | |
Philipp Tomsich | 29031a8 | 2017-06-23 00:05:38 +0200 | [diff] [blame] | 10 | #if defined(CONFIG_ARM64) |
huang lin | 1115b64 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 11 | .globl SAVE_SP_ADDR |
| 12 | SAVE_SP_ADDR: |
Philipp Tomsich | 29031a8 | 2017-06-23 00:05:38 +0200 | [diff] [blame] | 13 | .quad 0 |
| 14 | |
| 15 | ENTRY(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 */ |
| 27 | ENDPROC(save_boot_params) |
| 28 | |
| 29 | .globl _back_to_bootrom_s |
| 30 | ENTRY(_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 |
| 43 | ENDPROC(_back_to_bootrom_s) |
| 44 | #else |
| 45 | .globl SAVE_SP_ADDR |
| 46 | SAVE_SP_ADDR: |
huang lin | 1115b64 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 47 | .word 0 |
| 48 | |
| 49 | /* |
| 50 | * void save_boot_params |
| 51 | * |
| 52 | * Save sp, lr, r1~r12 |
| 53 | */ |
| 54 | ENTRY(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 |
| 59 | ENDPROC(save_boot_params) |
| 60 | |
| 61 | |
Simon Glass | ef0ab85 | 2017-04-15 13:11:31 -0600 | [diff] [blame] | 62 | .globl _back_to_bootrom_s |
| 63 | ENTRY(_back_to_bootrom_s) |
huang lin | 1115b64 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 64 | ldr r0, =SAVE_SP_ADDR |
| 65 | ldr sp, [r0] |
| 66 | mov r0, #0 |
| 67 | pop {r1-r12, pc} |
Simon Glass | ef0ab85 | 2017-04-15 13:11:31 -0600 | [diff] [blame] | 68 | ENDPROC(_back_to_bootrom_s) |
Philipp Tomsich | 29031a8 | 2017-06-23 00:05:38 +0200 | [diff] [blame] | 69 | #endif |