xref: /openbmc/u-boot/arch/arm/cpu/armv8/transition.S (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini/* SPDX-License-Identifier: GPL-2.0+ */
20ae76531SDavid Feng/*
30ae76531SDavid Feng * (C) Copyright 2013
40ae76531SDavid Feng * David Feng <fenghua@phytium.com.cn>
50ae76531SDavid Feng */
60ae76531SDavid Feng
70ae76531SDavid Feng#include <asm-offsets.h>
80ae76531SDavid Feng#include <config.h>
90ae76531SDavid Feng#include <linux/linkage.h>
100ae76531SDavid Feng#include <asm/macro.h>
110ae76531SDavid Feng
12e6a05862SPhilipp Tomsich.pushsection .text.armv8_switch_to_el2, "ax"
130ae76531SDavid FengENTRY(armv8_switch_to_el2)
147c5e1febSAlison Wang	switch_el x6, 1f, 0f, 0f
15ec6617c3SAlison Wang0:
167c5e1febSAlison Wang	cmp x5, #ES_TO_AARCH64
173db86f4bSAlison Wang	b.eq 2f
183db86f4bSAlison Wang	/*
193db86f4bSAlison Wang	 * When loading 32-bit kernel, it will jump
203db86f4bSAlison Wang	 * to secure firmware again, and never return.
213db86f4bSAlison Wang	 */
223db86f4bSAlison Wang	bl armv8_el2_to_aarch32
233db86f4bSAlison Wang2:
24ec6617c3SAlison Wang	/*
257c5e1febSAlison Wang	 * x4 is kernel entry point or switch_to_el1
26ec6617c3SAlison Wang	 * if CONFIG_ARMV8_SWITCH_TO_EL1 is defined.
27ec6617c3SAlison Wang         * When running in EL2 now, jump to the
287c5e1febSAlison Wang	 * address saved in x4.
29ec6617c3SAlison Wang	 */
307c5e1febSAlison Wang	br x4
317c5e1febSAlison Wang1:	armv8_switch_to_el2_m x4, x5, x6
320ae76531SDavid FengENDPROC(armv8_switch_to_el2)
33e6a05862SPhilipp Tomsich.popsection
340ae76531SDavid Feng
35e6a05862SPhilipp Tomsich.pushsection .text.armv8_switch_to_el1, "ax"
360ae76531SDavid FengENTRY(armv8_switch_to_el1)
377c5e1febSAlison Wang	switch_el x6, 0f, 1f, 0f
38ec6617c3SAlison Wang0:
397c5e1febSAlison Wang	/* x4 is kernel entry point. When running in EL1
407c5e1febSAlison Wang	 * now, jump to the address saved in x4.
41ec6617c3SAlison Wang	 */
427c5e1febSAlison Wang	br x4
437c5e1febSAlison Wang1:	armv8_switch_to_el1_m x4, x5, x6
440ae76531SDavid FengENDPROC(armv8_switch_to_el1)
45e6a05862SPhilipp Tomsich.popsection
463db86f4bSAlison Wang
47e6a05862SPhilipp Tomsich.pushsection .text.armv8_el2_to_aarch32, "ax"
483db86f4bSAlison WangWEAK(armv8_el2_to_aarch32)
493db86f4bSAlison Wang	ret
503db86f4bSAlison WangENDPROC(armv8_el2_to_aarch32)
51e6a05862SPhilipp Tomsich.popsection
52