xref: /openbmc/u-boot/arch/arm/cpu/armv7/sunxi/fel_utils.S (revision 23ff8633)
1/*
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]
18	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]
26	b	save_boot_params_ret
27ENDPROC(save_boot_params)
28
29ENTRY(return_to_fel)
30	mov	sp, r0
31	mov	lr, r1
32	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
41	bx	lr
42ENDPROC(return_to_fel)
43