Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 1 | /* |
Ambroise Vincent | 09a22e7 | 2019-05-29 14:04:16 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. |
Varun Wadekar | c9bd0aa | 2018-06-07 11:21:02 -0700 | [diff] [blame] | 3 | * Copyright (c) 2020, NVIDIA Corporation. All rights reserved. |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 4 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 5 | * SPDX-License-Identifier: BSD-3-Clause |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 6 | */ |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
| 9 | #include <assert_macros.S> |
| 10 | #include <cpu_macros.S> |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 11 | #include <cortex_a53.h> |
Isla Mitchell | e363146 | 2017-07-14 10:46:32 +0100 | [diff] [blame] | 12 | #include <cortex_a57.h> |
Varun Wadekar | 25e658e | 2016-04-26 11:38:38 -0700 | [diff] [blame] | 13 | #include <platform_def.h> |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 14 | #include <tegra_def.h> |
Harvey Hsieh | 6dc0d76 | 2017-04-24 19:35:51 +0800 | [diff] [blame] | 15 | #include <tegra_platform.h> |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 16 | |
Varun Wadekar | b24dea9 | 2015-09-22 13:33:56 +0530 | [diff] [blame] | 17 | #define MIDR_PN_CORTEX_A57 0xD07 |
| 18 | |
| 19 | /******************************************************************************* |
| 20 | * Implementation defined ACTLR_EL3 bit definitions |
| 21 | ******************************************************************************/ |
Varun Wadekar | c9bd0aa | 2018-06-07 11:21:02 -0700 | [diff] [blame] | 22 | #define ACTLR_ELx_L2ACTLR_BIT (U(1) << 6) |
| 23 | #define ACTLR_ELx_L2ECTLR_BIT (U(1) << 5) |
| 24 | #define ACTLR_ELx_L2CTLR_BIT (U(1) << 4) |
| 25 | #define ACTLR_ELx_CPUECTLR_BIT (U(1) << 1) |
| 26 | #define ACTLR_ELx_CPUACTLR_BIT (U(1) << 0) |
| 27 | #define ACTLR_ELx_ENABLE_ALL_ACCESS (ACTLR_ELx_L2ACTLR_BIT | \ |
| 28 | ACTLR_ELx_L2ECTLR_BIT | \ |
| 29 | ACTLR_ELx_L2CTLR_BIT | \ |
| 30 | ACTLR_ELx_CPUECTLR_BIT | \ |
| 31 | ACTLR_ELx_CPUACTLR_BIT) |
Varun Wadekar | b24dea9 | 2015-09-22 13:33:56 +0530 | [diff] [blame] | 32 | |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 33 | /* Global functions */ |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 34 | .globl plat_is_my_cpu_primary |
| 35 | .globl plat_my_core_pos |
| 36 | .globl plat_get_my_entrypoint |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 37 | .globl plat_secondary_cold_boot_setup |
| 38 | .globl platform_mem_init |
| 39 | .globl plat_crash_console_init |
| 40 | .globl plat_crash_console_putc |
Antonio Nino Diaz | 1eb64a1 | 2018-10-17 15:29:34 +0100 | [diff] [blame] | 41 | .globl plat_crash_console_flush |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 42 | .globl tegra_secure_entrypoint |
| 43 | .globl plat_reset_handler |
| 44 | |
| 45 | /* Global variables */ |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 46 | .globl tegra_sec_entry_point |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 47 | .globl ns_image_entrypoint |
| 48 | .globl tegra_bl31_phys_base |
Varun Wadekar | d2014c6 | 2015-10-29 10:37:28 +0530 | [diff] [blame] | 49 | .globl tegra_console_base |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 50 | |
| 51 | /* --------------------- |
| 52 | * Common CPU init code |
| 53 | * --------------------- |
| 54 | */ |
| 55 | .macro cpu_init_common |
| 56 | |
Varun Wadekar | b24dea9 | 2015-09-22 13:33:56 +0530 | [diff] [blame] | 57 | /* ------------------------------------------------ |
Varun Wadekar | 69ce101 | 2016-05-12 13:43:33 -0700 | [diff] [blame] | 58 | * We enable procesor retention, L2/CPUECTLR NS |
| 59 | * access and ECC/Parity protection for A57 CPUs |
Varun Wadekar | b24dea9 | 2015-09-22 13:33:56 +0530 | [diff] [blame] | 60 | * ------------------------------------------------ |
| 61 | */ |
| 62 | mrs x0, midr_el1 |
| 63 | mov x1, #(MIDR_PN_MASK << MIDR_PN_SHIFT) |
| 64 | and x0, x0, x1 |
| 65 | lsr x0, x0, #MIDR_PN_SHIFT |
| 66 | cmp x0, #MIDR_PN_CORTEX_A57 |
| 67 | b.ne 1f |
| 68 | |
Varun Wadekar | 4e9c231 | 2015-08-21 15:56:02 +0530 | [diff] [blame] | 69 | /* --------------------------- |
| 70 | * Enable processor retention |
| 71 | * --------------------------- |
Varun Wadekar | 69ce101 | 2016-05-12 13:43:33 -0700 | [diff] [blame] | 72 | */ |
Varun Wadekar | 1384a16 | 2017-06-05 14:54:46 -0700 | [diff] [blame] | 73 | mrs x0, CORTEX_A57_L2ECTLR_EL1 |
| 74 | mov x1, #RETENTION_ENTRY_TICKS_512 |
| 75 | bic x0, x0, #CORTEX_A57_L2ECTLR_RET_CTRL_MASK |
Varun Wadekar | 4e9c231 | 2015-08-21 15:56:02 +0530 | [diff] [blame] | 76 | orr x0, x0, x1 |
Varun Wadekar | 1384a16 | 2017-06-05 14:54:46 -0700 | [diff] [blame] | 77 | msr CORTEX_A57_L2ECTLR_EL1, x0 |
Varun Wadekar | 4e9c231 | 2015-08-21 15:56:02 +0530 | [diff] [blame] | 78 | isb |
Varun Wadekar | 4e9c231 | 2015-08-21 15:56:02 +0530 | [diff] [blame] | 79 | |
Varun Wadekar | 1384a16 | 2017-06-05 14:54:46 -0700 | [diff] [blame] | 80 | mrs x0, CORTEX_A57_ECTLR_EL1 |
| 81 | mov x1, #RETENTION_ENTRY_TICKS_512 |
| 82 | bic x0, x0, #CORTEX_A57_ECTLR_CPU_RET_CTRL_MASK |
Varun Wadekar | 4e9c231 | 2015-08-21 15:56:02 +0530 | [diff] [blame] | 83 | orr x0, x0, x1 |
Varun Wadekar | 1384a16 | 2017-06-05 14:54:46 -0700 | [diff] [blame] | 84 | msr CORTEX_A57_ECTLR_EL1, x0 |
Varun Wadekar | 4e9c231 | 2015-08-21 15:56:02 +0530 | [diff] [blame] | 85 | isb |
Varun Wadekar | 4e9c231 | 2015-08-21 15:56:02 +0530 | [diff] [blame] | 86 | |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 87 | /* ------------------------------------------------------- |
| 88 | * Enable L2 and CPU ECTLR RW access from non-secure world |
| 89 | * ------------------------------------------------------- |
Varun Wadekar | 69ce101 | 2016-05-12 13:43:33 -0700 | [diff] [blame] | 90 | */ |
Steven Kao | d417cea | 2017-06-14 14:02:23 +0800 | [diff] [blame] | 91 | mrs x0, actlr_el3 |
Varun Wadekar | c9bd0aa | 2018-06-07 11:21:02 -0700 | [diff] [blame] | 92 | mov x1, #ACTLR_ELx_ENABLE_ALL_ACCESS |
Steven Kao | d417cea | 2017-06-14 14:02:23 +0800 | [diff] [blame] | 93 | orr x0, x0, x1 |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 94 | msr actlr_el3, x0 |
Steven Kao | d417cea | 2017-06-14 14:02:23 +0800 | [diff] [blame] | 95 | mrs x0, actlr_el2 |
Varun Wadekar | c9bd0aa | 2018-06-07 11:21:02 -0700 | [diff] [blame] | 96 | mov x1, #ACTLR_ELx_ENABLE_ALL_ACCESS |
Steven Kao | d417cea | 2017-06-14 14:02:23 +0800 | [diff] [blame] | 97 | orr x0, x0, x1 |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 98 | msr actlr_el2, x0 |
| 99 | isb |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 100 | |
| 101 | /* -------------------------------- |
| 102 | * Enable the cycle count register |
| 103 | * -------------------------------- |
| 104 | */ |
Varun Wadekar | b24dea9 | 2015-09-22 13:33:56 +0530 | [diff] [blame] | 105 | 1: mrs x0, pmcr_el0 |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 106 | ubfx x0, x0, #11, #5 // read PMCR.N field |
| 107 | mov x1, #1 |
| 108 | lsl x0, x1, x0 |
| 109 | sub x0, x0, #1 // mask of event counters |
| 110 | orr x0, x0, #0x80000000 // disable overflow intrs |
| 111 | msr pmintenclr_el1, x0 |
| 112 | msr pmuserenr_el0, x1 // enable user mode access |
| 113 | |
| 114 | /* ---------------------------------------------------------------- |
| 115 | * Allow non-privileged access to CNTVCT: Set CNTKCTL (Kernel Count |
| 116 | * register), bit 1 (EL0VCTEN) to enable access to CNTVCT/CNTFRQ |
| 117 | * registers from EL0. |
| 118 | * ---------------------------------------------------------------- |
| 119 | */ |
| 120 | mrs x0, cntkctl_el1 |
| 121 | orr x0, x0, #EL0VCTEN_BIT |
| 122 | msr cntkctl_el1, x0 |
| 123 | .endm |
| 124 | |
| 125 | /* ----------------------------------------------------- |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 126 | * unsigned int plat_is_my_cpu_primary(void); |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 127 | * |
| 128 | * This function checks if this is the Primary CPU |
| 129 | * ----------------------------------------------------- |
| 130 | */ |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 131 | func plat_is_my_cpu_primary |
| 132 | mrs x0, mpidr_el1 |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 133 | and x0, x0, #(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK) |
| 134 | cmp x0, #TEGRA_PRIMARY_CPU |
| 135 | cset x0, eq |
| 136 | ret |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 137 | endfunc plat_is_my_cpu_primary |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 138 | |
Varun Wadekar | fa99b22 | 2017-08-23 16:02:06 -0700 | [diff] [blame] | 139 | /* ---------------------------------------------------------- |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 140 | * unsigned int plat_my_core_pos(void); |
| 141 | * |
Varun Wadekar | fa99b22 | 2017-08-23 16:02:06 -0700 | [diff] [blame] | 142 | * result: CorePos = CoreId + (ClusterId * cpus per cluster) |
| 143 | * ---------------------------------------------------------- |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 144 | */ |
| 145 | func plat_my_core_pos |
| 146 | mrs x0, mpidr_el1 |
| 147 | and x1, x0, #MPIDR_CPU_MASK |
| 148 | and x0, x0, #MPIDR_CLUSTER_MASK |
Varun Wadekar | fa99b22 | 2017-08-23 16:02:06 -0700 | [diff] [blame] | 149 | lsr x0, x0, #MPIDR_AFFINITY_BITS |
| 150 | mov x2, #PLATFORM_MAX_CPUS_PER_CLUSTER |
| 151 | mul x0, x0, x2 |
| 152 | add x0, x1, x0 |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 153 | ret |
| 154 | endfunc plat_my_core_pos |
| 155 | |
| 156 | /* ----------------------------------------------------- |
| 157 | * unsigned long plat_get_my_entrypoint (void); |
| 158 | * |
| 159 | * Main job of this routine is to distinguish between |
| 160 | * a cold and warm boot. If the tegra_sec_entry_point for |
| 161 | * this CPU is present, then it's a warm boot. |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 162 | * |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 163 | * ----------------------------------------------------- |
| 164 | */ |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 165 | func plat_get_my_entrypoint |
| 166 | adr x1, tegra_sec_entry_point |
| 167 | ldr x0, [x1] |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 168 | ret |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 169 | endfunc plat_get_my_entrypoint |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 170 | |
| 171 | /* ----------------------------------------------------- |
Varun Wadekar | 39f87d1 | 2015-09-22 13:45:07 +0530 | [diff] [blame] | 172 | * int platform_get_core_pos(int mpidr); |
| 173 | * |
Varun Wadekar | fa99b22 | 2017-08-23 16:02:06 -0700 | [diff] [blame] | 174 | * result: CorePos = (ClusterId * cpus per cluster) + |
| 175 | * CoreId |
Varun Wadekar | 39f87d1 | 2015-09-22 13:45:07 +0530 | [diff] [blame] | 176 | * ----------------------------------------------------- |
| 177 | */ |
| 178 | func platform_get_core_pos |
| 179 | and x1, x0, #MPIDR_CPU_MASK |
| 180 | and x0, x0, #MPIDR_CLUSTER_MASK |
Varun Wadekar | fa99b22 | 2017-08-23 16:02:06 -0700 | [diff] [blame] | 181 | lsr x0, x0, #MPIDR_AFFINITY_BITS |
| 182 | mov x2, #PLATFORM_MAX_CPUS_PER_CLUSTER |
| 183 | mul x0, x0, x2 |
| 184 | add x0, x1, x0 |
Varun Wadekar | 39f87d1 | 2015-09-22 13:45:07 +0530 | [diff] [blame] | 185 | ret |
| 186 | endfunc platform_get_core_pos |
| 187 | |
| 188 | /* ----------------------------------------------------- |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 189 | * void plat_secondary_cold_boot_setup (void); |
| 190 | * |
| 191 | * This function performs any platform specific actions |
| 192 | * needed for a secondary cpu after a cold reset. Right |
| 193 | * now this is a stub function. |
| 194 | * ----------------------------------------------------- |
| 195 | */ |
| 196 | func plat_secondary_cold_boot_setup |
| 197 | mov x0, #0 |
| 198 | ret |
| 199 | endfunc plat_secondary_cold_boot_setup |
| 200 | |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 201 | /* -------------------------------------------------------- |
| 202 | * void platform_mem_init (void); |
| 203 | * |
| 204 | * Any memory init, relocation to be done before the |
| 205 | * platform boots. Called very early in the boot process. |
| 206 | * -------------------------------------------------------- |
| 207 | */ |
| 208 | func platform_mem_init |
| 209 | mov x0, #0 |
| 210 | ret |
| 211 | endfunc platform_mem_init |
| 212 | |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 213 | /* --------------------------------------------------- |
| 214 | * Function to handle a platform reset and store |
| 215 | * input parameters passed by BL2. |
| 216 | * --------------------------------------------------- |
| 217 | */ |
| 218 | func plat_reset_handler |
| 219 | |
Varun Wadekar | 1ec441e | 2016-03-24 15:34:24 -0700 | [diff] [blame] | 220 | /* ---------------------------------------------------- |
| 221 | * Verify if we are running from BL31_BASE address |
| 222 | * ---------------------------------------------------- |
| 223 | */ |
| 224 | adr x18, bl31_entrypoint |
| 225 | mov x17, #BL31_BASE |
| 226 | cmp x18, x17 |
| 227 | b.eq 1f |
| 228 | |
| 229 | /* ---------------------------------------------------- |
| 230 | * Copy the entire BL31 code to BL31_BASE if we are not |
| 231 | * running from it already |
| 232 | * ---------------------------------------------------- |
| 233 | */ |
| 234 | mov x0, x17 |
| 235 | mov x1, x18 |
| 236 | mov x2, #BL31_SIZE |
| 237 | _loop16: |
| 238 | cmp x2, #16 |
Douglas Raillard | 2bb9f47 | 2017-03-20 10:38:29 +0000 | [diff] [blame] | 239 | b.lo _loop1 |
Varun Wadekar | 1ec441e | 2016-03-24 15:34:24 -0700 | [diff] [blame] | 240 | ldp x3, x4, [x1], #16 |
| 241 | stp x3, x4, [x0], #16 |
| 242 | sub x2, x2, #16 |
| 243 | b _loop16 |
| 244 | /* copy byte per byte */ |
| 245 | _loop1: |
| 246 | cbz x2, _end |
| 247 | ldrb w3, [x1], #1 |
| 248 | strb w3, [x0], #1 |
| 249 | subs x2, x2, #1 |
| 250 | b.ne _loop1 |
| 251 | |
| 252 | /* ---------------------------------------------------- |
| 253 | * Jump to BL31_BASE and start execution again |
| 254 | * ---------------------------------------------------- |
| 255 | */ |
| 256 | _end: mov x0, x20 |
| 257 | mov x1, x21 |
| 258 | br x17 |
| 259 | 1: |
| 260 | |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 261 | /* ----------------------------------- |
| 262 | * derive and save the phys_base addr |
| 263 | * ----------------------------------- |
| 264 | */ |
| 265 | adr x17, tegra_bl31_phys_base |
| 266 | ldr x18, [x17] |
| 267 | cbnz x18, 1f |
| 268 | adr x18, bl31_entrypoint |
| 269 | str x18, [x17] |
| 270 | |
| 271 | 1: cpu_init_common |
| 272 | |
| 273 | ret |
| 274 | endfunc plat_reset_handler |
| 275 | |
| 276 | /* ---------------------------------------- |
| 277 | * Secure entrypoint function for CPU boot |
| 278 | * ---------------------------------------- |
| 279 | */ |
Julius Werner | b4c75e9 | 2017-08-01 15:16:36 -0700 | [diff] [blame] | 280 | func tegra_secure_entrypoint _align=6 |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 281 | |
| 282 | #if ERRATA_TEGRA_INVALIDATE_BTB_AT_BOOT |
| 283 | |
Harvey Hsieh | 6dc0d76 | 2017-04-24 19:35:51 +0800 | [diff] [blame] | 284 | /* -------------------------------------------------------- |
| 285 | * Skip the invalidate BTB workaround for Tegra210B01 SKUs. |
| 286 | * -------------------------------------------------------- |
| 287 | */ |
| 288 | mov x0, #TEGRA_MISC_BASE |
| 289 | add x0, x0, #HARDWARE_REVISION_OFFSET |
| 290 | ldr w1, [x0] |
| 291 | lsr w1, w1, #CHIP_ID_SHIFT |
| 292 | and w1, w1, #CHIP_ID_MASK |
| 293 | cmp w1, #TEGRA_CHIPID_TEGRA21 /* T210? */ |
| 294 | b.ne 2f |
| 295 | ldr w1, [x0] |
| 296 | lsr w1, w1, #MAJOR_VERSION_SHIFT |
| 297 | and w1, w1, #MAJOR_VERSION_MASK |
| 298 | cmp w1, #0x02 /* T210 B01? */ |
| 299 | b.eq 2f |
| 300 | |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 301 | /* ------------------------------------------------------- |
| 302 | * Invalidate BTB along with I$ to remove any stale |
| 303 | * entries from the branch predictor array. |
| 304 | * ------------------------------------------------------- |
| 305 | */ |
Eleanor Bonnici | 91b11c3 | 2017-08-10 14:46:26 +0100 | [diff] [blame] | 306 | mrs x0, CORTEX_A57_CPUACTLR_EL1 |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 307 | orr x0, x0, #1 |
Eleanor Bonnici | 91b11c3 | 2017-08-10 14:46:26 +0100 | [diff] [blame] | 308 | msr CORTEX_A57_CPUACTLR_EL1, x0 /* invalidate BTB and I$ together */ |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 309 | dsb sy |
| 310 | isb |
| 311 | ic iallu /* actual invalidate */ |
| 312 | dsb sy |
| 313 | isb |
| 314 | |
Eleanor Bonnici | 91b11c3 | 2017-08-10 14:46:26 +0100 | [diff] [blame] | 315 | mrs x0, CORTEX_A57_CPUACTLR_EL1 |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 316 | bic x0, x0, #1 |
Eleanor Bonnici | 91b11c3 | 2017-08-10 14:46:26 +0100 | [diff] [blame] | 317 | msr CORTEX_A57_CPUACTLR_EL1, X0 /* restore original CPUACTLR_EL1 */ |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 318 | dsb sy |
| 319 | isb |
| 320 | |
| 321 | .rept 7 |
| 322 | nop /* wait */ |
| 323 | .endr |
| 324 | |
| 325 | /* ----------------------------------------------- |
| 326 | * Extract OSLK bit and check if it is '1'. This |
| 327 | * bit remains '0' for A53 on warm-resets. If '1', |
| 328 | * turn off regional clock gating and request warm |
| 329 | * reset. |
| 330 | * ----------------------------------------------- |
| 331 | */ |
| 332 | mrs x0, oslsr_el1 |
| 333 | and x0, x0, #2 |
| 334 | mrs x1, mpidr_el1 |
| 335 | bics xzr, x0, x1, lsr #7 /* 0 = slow cluster or warm reset */ |
| 336 | b.eq restore_oslock |
| 337 | mov x0, xzr |
| 338 | msr oslar_el1, x0 /* os lock stays 0 across warm reset */ |
| 339 | mov x3, #3 |
| 340 | movz x4, #0x8000, lsl #48 |
Eleanor Bonnici | 91b11c3 | 2017-08-10 14:46:26 +0100 | [diff] [blame] | 341 | msr CORTEX_A57_CPUACTLR_EL1, x4 /* turn off RCG */ |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 342 | isb |
| 343 | msr rmr_el3, x3 /* request warm reset */ |
| 344 | isb |
| 345 | dsb sy |
| 346 | 1: wfi |
| 347 | b 1b |
| 348 | |
| 349 | /* -------------------------------------------------- |
| 350 | * These nops are here so that speculative execution |
| 351 | * won't harm us before we are done with warm reset. |
| 352 | * -------------------------------------------------- |
| 353 | */ |
| 354 | .rept 65 |
| 355 | nop |
| 356 | .endr |
Harvey Hsieh | 6dc0d76 | 2017-04-24 19:35:51 +0800 | [diff] [blame] | 357 | 2: |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 358 | /* -------------------------------------------------- |
| 359 | * Do not insert instructions here |
| 360 | * -------------------------------------------------- |
| 361 | */ |
| 362 | #endif |
| 363 | |
| 364 | /* -------------------------------------------------- |
| 365 | * Restore OS Lock bit |
| 366 | * -------------------------------------------------- |
| 367 | */ |
| 368 | restore_oslock: |
| 369 | mov x0, #1 |
| 370 | msr oslar_el1, x0 |
| 371 | |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 372 | /* -------------------------------------------------- |
| 373 | * Get secure world's entry point and jump to it |
| 374 | * -------------------------------------------------- |
| 375 | */ |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 376 | bl plat_get_my_entrypoint |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 377 | br x0 |
| 378 | endfunc tegra_secure_entrypoint |
| 379 | |
| 380 | .data |
| 381 | .align 3 |
| 382 | |
| 383 | /* -------------------------------------------------- |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 384 | * CPU Secure entry point - resume from suspend |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 385 | * -------------------------------------------------- |
| 386 | */ |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 387 | tegra_sec_entry_point: |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 388 | .quad 0 |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 389 | |
| 390 | /* -------------------------------------------------- |
| 391 | * NS world's cold boot entry point |
| 392 | * -------------------------------------------------- |
| 393 | */ |
| 394 | ns_image_entrypoint: |
| 395 | .quad 0 |
| 396 | |
| 397 | /* -------------------------------------------------- |
| 398 | * BL31's physical base address |
| 399 | * -------------------------------------------------- |
| 400 | */ |
| 401 | tegra_bl31_phys_base: |
| 402 | .quad 0 |
Varun Wadekar | d2014c6 | 2015-10-29 10:37:28 +0530 | [diff] [blame] | 403 | |
| 404 | /* -------------------------------------------------- |
| 405 | * UART controller base for console init |
| 406 | * -------------------------------------------------- |
| 407 | */ |
| 408 | tegra_console_base: |
| 409 | .quad 0 |