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