blob: bf0033552d23b34b079e3055c3c062981b25b15e [file] [log] [blame]
Simon Glass5debe1f2015-02-07 10:47:30 -07001/*
2 * Utility functions for FEL mode.
3 *
4 * Copyright (c) 2015 Google, Inc
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
9#include <asm-offsets.h>
10#include <config.h>
11#include <asm/system.h>
12#include <linux/linkage.h>
13
14ENTRY(save_boot_params)
15 ldr r0, =fel_stash
16 str sp, [r0, #0]
17 str lr, [r0, #4]
Siarhei Siamashka7ef91f02015-02-16 10:23:59 +020018 mrs lr, cpsr @ Read CPSR
19 str lr, [r0, #8]
20 mrc p15, 0, lr, c1, c0, 0 @ Read CP15 SCTLR Register
21 str lr, [r0, #12]
22 mrc p15, 0, lr, c12, c0, 0 @ Read VBAR
23 str lr, [r0, #16]
24 mrc p15, 0, lr, c1, c0, 0 @ Read CP15 Control Register
25 str lr, [r0, #20]
Simon Glass5debe1f2015-02-07 10:47:30 -070026 b save_boot_params_ret
27ENDPROC(save_boot_params)
28
29ENTRY(return_to_fel)
30 mov sp, r0
31 mov lr, r1
Siarhei Siamashka7ef91f02015-02-16 10:23:59 +020032 ldr r0, =fel_stash
33 ldr r1, [r0, #20]
34 mcr p15, 0, r1, c1, c0, 0 @ Write CP15 Control Register
35 ldr r1, [r0, #16]
36 mcr p15, 0, r1, c12, c0, 0 @ Write VBAR
37 ldr r1, [r0, #12]
38 mcr p15, 0, r1, c1, c0, 0 @ Write CP15 SCTLR Register
39 ldr r1, [r0, #8]
40 msr cpsr, r1 @ Write CPSR
Simon Glass5debe1f2015-02-07 10:47:30 -070041 bx lr
42ENDPROC(return_to_fel)