blob: 1c0f963e18af72409453d139db6ac2398e26bf32 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Hou Zhiqiang505d7352016-06-28 20:18:13 +08002/*
3 * Copyright 2016 NXP Semiconductor, Inc.
Hou Zhiqiang505d7352016-06-28 20:18:13 +08004 */
5
6#include <config.h>
7#include <linux/linkage.h>
8#include <asm/system.h>
9#include <asm/macro.h>
10
11WEAK(_sec_firmware_entry)
12 /*
13 * x0: Secure Firmware entry point
14 * x1: Exception return address Low
15 * x2: Exception return address High
16 */
17
18 /* Save stack pointer for EL2 */
19 mov x3, sp
20 msr sp_el2, x3
21
22 /* Set exception return address hold pointer */
23 adr x4, 1f
24 mov x3, x4
Hou Zhiqiang2498c232017-01-16 17:31:47 +080025#ifdef CONFIG_ARMV8_SEC_FIRMWARE_ERET_ADDR_REVERT
Hou Zhiqiang505d7352016-06-28 20:18:13 +080026 rev w3, w3
27#endif
28 str w3, [x1]
29 lsr x3, x4, #32
Hou Zhiqiang2498c232017-01-16 17:31:47 +080030#ifdef CONFIG_ARMV8_SEC_FIRMWARE_ERET_ADDR_REVERT
Hou Zhiqiang505d7352016-06-28 20:18:13 +080031 rev w3, w3
32#endif
33 str w3, [x2]
34
35 /* Call SEC monitor */
36 br x0
37
381:
39 mov x0, #0
40 ret
41ENDPROC(_sec_firmware_entry)
42
Hou Zhiqiang6be115d2017-01-16 17:31:48 +080043#ifdef CONFIG_SEC_FIRMWARE_ARMV8_PSCI
Hou Zhiqiang505d7352016-06-28 20:18:13 +080044ENTRY(_sec_firmware_support_psci_version)
45 mov x0, 0x84000000
46 mov x1, 0x0
47 mov x2, 0x0
48 mov x3, 0x0
49 smc #0
50 ret
51ENDPROC(_sec_firmware_support_psci_version)
Alison Wangf547fca2016-11-10 10:49:05 +080052
53/*
54 * Switch from AArch64 EL2 to AArch32 EL2
55 * @param inputs:
56 * x0: argument, zero
57 * x1: machine nr
58 * x2: fdt address
Alison Wangeb2088d2017-01-17 09:39:17 +080059 * x3: input argument
60 * x4: kernel entry point
Alison Wangf547fca2016-11-10 10:49:05 +080061 * @param outputs for secure firmware:
62 * x0: function id
63 * x1: kernel entry point
64 * x2: machine nr
65 * x3: fdt address
66*/
67ENTRY(armv8_el2_to_aarch32)
Alison Wangf547fca2016-11-10 10:49:05 +080068 mov x3, x2
69 mov x2, x1
Alison Wangeb2088d2017-01-17 09:39:17 +080070 mov x1, x4
Alison Wangf547fca2016-11-10 10:49:05 +080071 ldr x0, =0xc000ff04
72 smc #0
73 ret
74ENDPROC(armv8_el2_to_aarch32)
Hou Zhiqiang505d7352016-06-28 20:18:13 +080075#endif