Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Hou Zhiqiang | 505d735 | 2016-06-28 20:18:13 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2016 NXP Semiconductor, Inc. |
Hou Zhiqiang | 505d735 | 2016-06-28 20:18:13 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <config.h> |
| 7 | #include <linux/linkage.h> |
| 8 | #include <asm/system.h> |
| 9 | #include <asm/macro.h> |
| 10 | |
| 11 | WEAK(_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 Zhiqiang | 2498c23 | 2017-01-16 17:31:47 +0800 | [diff] [blame] | 25 | #ifdef CONFIG_ARMV8_SEC_FIRMWARE_ERET_ADDR_REVERT |
Hou Zhiqiang | 505d735 | 2016-06-28 20:18:13 +0800 | [diff] [blame] | 26 | rev w3, w3 |
| 27 | #endif |
| 28 | str w3, [x1] |
| 29 | lsr x3, x4, #32 |
Hou Zhiqiang | 2498c23 | 2017-01-16 17:31:47 +0800 | [diff] [blame] | 30 | #ifdef CONFIG_ARMV8_SEC_FIRMWARE_ERET_ADDR_REVERT |
Hou Zhiqiang | 505d735 | 2016-06-28 20:18:13 +0800 | [diff] [blame] | 31 | rev w3, w3 |
| 32 | #endif |
| 33 | str w3, [x2] |
| 34 | |
| 35 | /* Call SEC monitor */ |
| 36 | br x0 |
| 37 | |
| 38 | 1: |
| 39 | mov x0, #0 |
| 40 | ret |
| 41 | ENDPROC(_sec_firmware_entry) |
| 42 | |
Hou Zhiqiang | 6be115d | 2017-01-16 17:31:48 +0800 | [diff] [blame] | 43 | #ifdef CONFIG_SEC_FIRMWARE_ARMV8_PSCI |
Hou Zhiqiang | 505d735 | 2016-06-28 20:18:13 +0800 | [diff] [blame] | 44 | ENTRY(_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 |
| 51 | ENDPROC(_sec_firmware_support_psci_version) |
Alison Wang | f547fca | 2016-11-10 10:49:05 +0800 | [diff] [blame] | 52 | |
| 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 Wang | eb2088d | 2017-01-17 09:39:17 +0800 | [diff] [blame] | 59 | * x3: input argument |
| 60 | * x4: kernel entry point |
Alison Wang | f547fca | 2016-11-10 10:49:05 +0800 | [diff] [blame] | 61 | * @param outputs for secure firmware: |
| 62 | * x0: function id |
| 63 | * x1: kernel entry point |
| 64 | * x2: machine nr |
| 65 | * x3: fdt address |
| 66 | */ |
| 67 | ENTRY(armv8_el2_to_aarch32) |
Alison Wang | f547fca | 2016-11-10 10:49:05 +0800 | [diff] [blame] | 68 | mov x3, x2 |
| 69 | mov x2, x1 |
Alison Wang | eb2088d | 2017-01-17 09:39:17 +0800 | [diff] [blame] | 70 | mov x1, x4 |
Alison Wang | f547fca | 2016-11-10 10:49:05 +0800 | [diff] [blame] | 71 | ldr x0, =0xc000ff04 |
| 72 | smc #0 |
| 73 | ret |
| 74 | ENDPROC(armv8_el2_to_aarch32) |
Hou Zhiqiang | 505d735 | 2016-06-28 20:18:13 +0800 | [diff] [blame] | 75 | #endif |