Varun Wadekar | 93bed2a | 2016-03-18 13:07:33 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Varun Wadekar | 93bed2a | 2016-03-18 13:07:33 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
Varun Wadekar | 93bed2a | 2016-03-18 13:07:33 -0700 | [diff] [blame] | 9 | #include <memctrl_v2.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <plat/common/common_def.h> |
Varun Wadekar | 93bed2a | 2016-03-18 13:07:33 -0700 | [diff] [blame] | 11 | #include <tegra_def.h> |
| 12 | |
| 13 | #define TEGRA186_SMMU_CTX_SIZE 0x420 |
| 14 | |
Varun Wadekar | 93bed2a | 2016-03-18 13:07:33 -0700 | [diff] [blame] | 15 | .globl tegra186_cpu_reset_handler |
| 16 | |
| 17 | /* CPU reset handler routine */ |
Julius Werner | b4c75e9 | 2017-08-01 15:16:36 -0700 | [diff] [blame] | 18 | func tegra186_cpu_reset_handler _align=4 |
Varun Wadekar | 93bed2a | 2016-03-18 13:07:33 -0700 | [diff] [blame] | 19 | /* |
Varun Wadekar | 0a6eba3 | 2016-08-08 11:53:14 -0700 | [diff] [blame] | 20 | * The TZRAM loses state during System Suspend. We use this |
| 21 | * information to decide if the reset handler is running after a |
| 22 | * System Suspend. Resume from system suspend requires restoring |
| 23 | * the entire state from TZDRAM to TZRAM. |
Varun Wadekar | 93bed2a | 2016-03-18 13:07:33 -0700 | [diff] [blame] | 24 | */ |
Varun Wadekar | 0a6eba3 | 2016-08-08 11:53:14 -0700 | [diff] [blame] | 25 | mov x0, #BL31_BASE |
| 26 | ldr x0, [x0] |
| 27 | cbnz x0, boot_cpu |
Varun Wadekar | 93bed2a | 2016-03-18 13:07:33 -0700 | [diff] [blame] | 28 | |
| 29 | /* resume from system suspend */ |
| 30 | mov x0, #BL31_BASE |
| 31 | adr x1, __tegra186_cpu_reset_handler_end |
| 32 | adr x2, __tegra186_cpu_reset_handler_data |
| 33 | ldr x2, [x2, #8] |
| 34 | |
| 35 | /* memcpy16 */ |
| 36 | m_loop16: |
| 37 | cmp x2, #16 |
| 38 | b.lt m_loop1 |
| 39 | ldp x3, x4, [x1], #16 |
| 40 | stp x3, x4, [x0], #16 |
| 41 | sub x2, x2, #16 |
| 42 | b m_loop16 |
| 43 | /* copy byte per byte */ |
| 44 | m_loop1: |
| 45 | cbz x2, boot_cpu |
| 46 | ldrb w3, [x1], #1 |
| 47 | strb w3, [x0], #1 |
| 48 | subs x2, x2, #1 |
| 49 | b.ne m_loop1 |
| 50 | |
| 51 | boot_cpu: |
| 52 | adr x0, __tegra186_cpu_reset_handler_data |
| 53 | ldr x0, [x0] |
| 54 | br x0 |
| 55 | endfunc tegra186_cpu_reset_handler |
| 56 | |
| 57 | /* |
| 58 | * Tegra186 reset data (offset 0x0 - 0x430) |
| 59 | * |
| 60 | * 0x000: secure world's entrypoint |
| 61 | * 0x008: BL31 size (RO + RW) |
| 62 | * 0x00C: SMMU context start |
| 63 | * 0x42C: SMMU context end |
| 64 | */ |
| 65 | |
| 66 | .align 4 |
| 67 | .type __tegra186_cpu_reset_handler_data, %object |
| 68 | .globl __tegra186_cpu_reset_handler_data |
| 69 | __tegra186_cpu_reset_handler_data: |
| 70 | .quad tegra_secure_entrypoint |
| 71 | .quad __BL31_END__ - BL31_BASE |
Varun Wadekar | 27155fc | 2017-04-20 18:56:09 -0700 | [diff] [blame] | 72 | .globl __tegra186_smmu_context |
| 73 | __tegra186_smmu_context: |
Varun Wadekar | 93bed2a | 2016-03-18 13:07:33 -0700 | [diff] [blame] | 74 | .rept TEGRA186_SMMU_CTX_SIZE |
| 75 | .quad 0 |
| 76 | .endr |
| 77 | .size __tegra186_cpu_reset_handler_data, \ |
| 78 | . - __tegra186_cpu_reset_handler_data |
| 79 | |
| 80 | .align 4 |
| 81 | .globl __tegra186_cpu_reset_handler_end |
| 82 | __tegra186_cpu_reset_handler_end: |