Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2013 |
| 4 | * David Feng <fenghua@phytium.com.cn> |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <asm-offsets.h> |
| 8 | #include <config.h> |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 9 | #include <linux/linkage.h> |
| 10 | #include <asm/macro.h> |
| 11 | #include <asm/armv8/mmu.h> |
| 12 | |
| 13 | /************************************************************************* |
| 14 | * |
| 15 | * Startup Code (reset vector) |
| 16 | * |
| 17 | *************************************************************************/ |
| 18 | |
| 19 | .globl _start |
| 20 | _start: |
Mian Yousaf Kaukab | a0dcfc5 | 2019-06-13 14:46:44 +0200 | [diff] [blame] | 21 | #if defined(CONFIG_LINUX_KERNEL_IMAGE_HEADER) |
Stephen Warren | 80a9365 | 2018-01-03 14:31:51 -0700 | [diff] [blame] | 22 | #include <asm/boot0-linux-kernel-header.h> |
| 23 | #elif defined(CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK) |
Andre Przywara | 48321ba | 2016-05-31 10:45:06 -0700 | [diff] [blame] | 24 | /* |
| 25 | * Various SoCs need something special and SoC-specific up front in |
| 26 | * order to boot, allow them to set that in their boot0.h file and then |
| 27 | * use it here. |
| 28 | */ |
| 29 | #include <asm/arch/boot0.h> |
Andre Przywara | 313a578 | 2017-01-02 11:48:33 +0000 | [diff] [blame] | 30 | #else |
| 31 | b reset |
Andre Przywara | 48321ba | 2016-05-31 10:45:06 -0700 | [diff] [blame] | 32 | #endif |
| 33 | |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 34 | .align 3 |
| 35 | |
| 36 | .globl _TEXT_BASE |
| 37 | _TEXT_BASE: |
| 38 | .quad CONFIG_SYS_TEXT_BASE |
| 39 | |
| 40 | /* |
| 41 | * These are defined in the linker script. |
| 42 | */ |
| 43 | .globl _end_ofs |
| 44 | _end_ofs: |
| 45 | .quad _end - _start |
| 46 | |
| 47 | .globl _bss_start_ofs |
| 48 | _bss_start_ofs: |
| 49 | .quad __bss_start - _start |
| 50 | |
| 51 | .globl _bss_end_ofs |
| 52 | _bss_end_ofs: |
| 53 | .quad __bss_end - _start |
| 54 | |
| 55 | reset: |
Stephen Warren | 100a479 | 2016-07-18 17:01:50 -0600 | [diff] [blame] | 56 | /* Allow the board to save important registers */ |
| 57 | b save_boot_params |
| 58 | .globl save_boot_params_ret |
| 59 | save_boot_params_ret: |
| 60 | |
Stephen Warren | 81c2137 | 2017-11-02 18:11:27 -0600 | [diff] [blame] | 61 | #if CONFIG_POSITION_INDEPENDENT |
Edgar E. Iglesias | 67c9c93 | 2020-09-09 19:07:25 +0200 | [diff] [blame] | 62 | /* Verify that we're 4K aligned. */ |
| 63 | adr x0, _start |
| 64 | ands x0, x0, #0xfff |
| 65 | b.eq 1f |
| 66 | 0: |
| 67 | /* |
| 68 | * FATAL, can't continue. |
| 69 | * U-Boot needs to be loaded at a 4K aligned address. |
| 70 | * |
| 71 | * We use ADRP and ADD to load some symbol addresses during startup. |
| 72 | * The ADD uses an absolute (non pc-relative) lo12 relocation |
| 73 | * thus requiring 4K alignment. |
| 74 | */ |
| 75 | wfi |
| 76 | b 0b |
| 77 | 1: |
| 78 | |
Stephen Warren | 81c2137 | 2017-11-02 18:11:27 -0600 | [diff] [blame] | 79 | /* |
| 80 | * Fix .rela.dyn relocations. This allows U-Boot to be loaded to and |
| 81 | * executed at a different address than it was linked at. |
| 82 | */ |
| 83 | pie_fixup: |
| 84 | adr x0, _start /* x0 <- Runtime value of _start */ |
| 85 | ldr x1, _TEXT_BASE /* x1 <- Linked value of _start */ |
| 86 | sub x9, x0, x1 /* x9 <- Run-vs-link offset */ |
Edgar E. Iglesias | 545474e | 2020-09-09 19:07:26 +0200 | [diff] [blame^] | 87 | adrp x2, __rel_dyn_start /* x2 <- Runtime &__rel_dyn_start */ |
| 88 | add x2, x2, #:lo12:__rel_dyn_start |
| 89 | adrp x3, __rel_dyn_end /* x3 <- Runtime &__rel_dyn_end */ |
| 90 | add x3, x3, #:lo12:__rel_dyn_end |
Stephen Warren | 81c2137 | 2017-11-02 18:11:27 -0600 | [diff] [blame] | 91 | pie_fix_loop: |
| 92 | ldp x0, x1, [x2], #16 /* (x0, x1) <- (Link location, fixup) */ |
| 93 | ldr x4, [x2], #8 /* x4 <- addend */ |
| 94 | cmp w1, #1027 /* relative fixup? */ |
| 95 | bne pie_skip_reloc |
| 96 | /* relative fix: store addend plus offset at dest location */ |
| 97 | add x0, x0, x9 |
| 98 | add x4, x4, x9 |
| 99 | str x4, [x0] |
| 100 | pie_skip_reloc: |
| 101 | cmp x2, x3 |
| 102 | b.lo pie_fix_loop |
| 103 | pie_fixup_done: |
| 104 | #endif |
| 105 | |
Sergey Temerkhanov | 78eaa49 | 2015-10-14 09:55:45 -0700 | [diff] [blame] | 106 | #ifdef CONFIG_SYS_RESET_SCTRL |
| 107 | bl reset_sctrl |
| 108 | #endif |
Andre Przywara | 4eecab7 | 2018-07-25 00:57:01 +0100 | [diff] [blame] | 109 | |
Alexander Graf | b3e9dc6 | 2019-02-20 17:14:49 +0100 | [diff] [blame] | 110 | #if defined(CONFIG_ARMV8_SPL_EXCEPTION_VECTORS) || !defined(CONFIG_SPL_BUILD) |
Andre Przywara | 4eecab7 | 2018-07-25 00:57:01 +0100 | [diff] [blame] | 111 | .macro set_vbar, regname, reg |
| 112 | msr \regname, \reg |
| 113 | .endm |
| 114 | adr x0, vectors |
| 115 | #else |
| 116 | .macro set_vbar, regname, reg |
| 117 | .endm |
| 118 | #endif |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 119 | /* |
| 120 | * Could be EL3/EL2/EL1, Initial State: |
| 121 | * Little Endian, MMU Disabled, i/dCache Disabled |
| 122 | */ |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 123 | switch_el x1, 3f, 2f, 1f |
Andre Przywara | 4eecab7 | 2018-07-25 00:57:01 +0100 | [diff] [blame] | 124 | 3: set_vbar vbar_el3, x0 |
David Feng | 7c5eca7 | 2014-04-19 09:45:21 +0800 | [diff] [blame] | 125 | mrs x0, scr_el3 |
David Feng | 79bbde0 | 2014-03-14 14:26:27 +0800 | [diff] [blame] | 126 | orr x0, x0, #0xf /* SCR_EL3.NS|IRQ|FIQ|EA */ |
| 127 | msr scr_el3, x0 |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 128 | msr cptr_el3, xzr /* Enable FP/SIMD */ |
Thierry Reding | 2565792 | 2015-08-20 11:42:18 +0200 | [diff] [blame] | 129 | #ifdef COUNTER_FREQUENCY |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 130 | ldr x0, =COUNTER_FREQUENCY |
| 131 | msr cntfrq_el0, x0 /* Initialize CNTFRQ */ |
Thierry Reding | 2565792 | 2015-08-20 11:42:18 +0200 | [diff] [blame] | 132 | #endif |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 133 | b 0f |
Andre Przywara | 4eecab7 | 2018-07-25 00:57:01 +0100 | [diff] [blame] | 134 | 2: set_vbar vbar_el2, x0 |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 135 | mov x0, #0x33ff |
| 136 | msr cptr_el2, x0 /* Enable FP/SIMD */ |
| 137 | b 0f |
Andre Przywara | 4eecab7 | 2018-07-25 00:57:01 +0100 | [diff] [blame] | 138 | 1: set_vbar vbar_el1, x0 |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 139 | mov x0, #3 << 20 |
| 140 | msr cpacr_el1, x0 /* Enable FP/SIMD */ |
| 141 | 0: |
Volodymyr Babchuk | b2b5225 | 2020-06-24 01:05:19 +0000 | [diff] [blame] | 142 | isb |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 143 | |
Mingkai Hu | 553d405 | 2017-01-06 17:41:10 +0800 | [diff] [blame] | 144 | /* |
Dinh Nguyen | c3e970a | 2017-04-26 23:36:03 -0500 | [diff] [blame] | 145 | * Enable SMPEN bit for coherency. |
Mingkai Hu | 553d405 | 2017-01-06 17:41:10 +0800 | [diff] [blame] | 146 | * This register is not architectural but at the moment |
| 147 | * this bit should be set for A53/A57/A72. |
| 148 | */ |
| 149 | #ifdef CONFIG_ARMV8_SET_SMPEN |
York Sun | e6b871e | 2017-05-15 08:51:59 -0700 | [diff] [blame] | 150 | switch_el x1, 3f, 1f, 1f |
| 151 | 3: |
Dinh Nguyen | c3e970a | 2017-04-26 23:36:03 -0500 | [diff] [blame] | 152 | mrs x0, S3_1_c15_c2_1 /* cpuectlr_el1 */ |
Mingkai Hu | 553d405 | 2017-01-06 17:41:10 +0800 | [diff] [blame] | 153 | orr x0, x0, #0x40 |
| 154 | msr S3_1_c15_c2_1, x0 |
Volodymyr Babchuk | b2b5225 | 2020-06-24 01:05:19 +0000 | [diff] [blame] | 155 | isb |
York Sun | e6b871e | 2017-05-15 08:51:59 -0700 | [diff] [blame] | 156 | 1: |
Mingkai Hu | 553d405 | 2017-01-06 17:41:10 +0800 | [diff] [blame] | 157 | #endif |
| 158 | |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 159 | /* Apply ARM core specific erratas */ |
| 160 | bl apply_core_errata |
| 161 | |
York Sun | ef04201 | 2014-02-26 13:26:04 -0800 | [diff] [blame] | 162 | /* |
| 163 | * Cache/BPB/TLB Invalidate |
| 164 | * i-cache is invalidated before enabled in icache_enable() |
| 165 | * tlb is invalidated before mmu is enabled in dcache_enable() |
| 166 | * d-cache is invalidated before enabled in dcache_enable() |
| 167 | */ |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 168 | |
| 169 | /* Processor specific initialization */ |
| 170 | bl lowlevel_init |
| 171 | |
Oded Gabbay | 97a8d65 | 2016-12-27 11:19:43 +0200 | [diff] [blame] | 172 | #if defined(CONFIG_ARMV8_SPIN_TABLE) && !defined(CONFIG_SPL_BUILD) |
Masahiro Yamada | 2663cd6 | 2016-06-27 19:31:05 +0900 | [diff] [blame] | 173 | branch_if_master x0, x1, master_cpu |
| 174 | b spin_table_secondary_jump |
| 175 | /* never return */ |
| 176 | #elif defined(CONFIG_ARMV8_MULTIENTRY) |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 177 | branch_if_master x0, x1, master_cpu |
| 178 | |
| 179 | /* |
| 180 | * Slave CPUs |
| 181 | */ |
| 182 | slave_cpu: |
| 183 | wfe |
| 184 | ldr x1, =CPU_RELEASE_ADDR |
| 185 | ldr x0, [x1] |
| 186 | cbz x0, slave_cpu |
| 187 | br x0 /* branch to the given address */ |
Linus Walleij | 7477139 | 2015-03-09 10:53:21 +0100 | [diff] [blame] | 188 | #endif /* CONFIG_ARMV8_MULTIENTRY */ |
Masahiro Yamada | 2663cd6 | 2016-06-27 19:31:05 +0900 | [diff] [blame] | 189 | master_cpu: |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 190 | bl _main |
| 191 | |
Sergey Temerkhanov | 78eaa49 | 2015-10-14 09:55:45 -0700 | [diff] [blame] | 192 | #ifdef CONFIG_SYS_RESET_SCTRL |
| 193 | reset_sctrl: |
| 194 | switch_el x1, 3f, 2f, 1f |
| 195 | 3: |
| 196 | mrs x0, sctlr_el3 |
| 197 | b 0f |
| 198 | 2: |
| 199 | mrs x0, sctlr_el2 |
| 200 | b 0f |
| 201 | 1: |
| 202 | mrs x0, sctlr_el1 |
| 203 | |
| 204 | 0: |
| 205 | ldr x1, =0xfdfffffa |
| 206 | and x0, x0, x1 |
| 207 | |
| 208 | switch_el x1, 6f, 5f, 4f |
| 209 | 6: |
| 210 | msr sctlr_el3, x0 |
| 211 | b 7f |
| 212 | 5: |
| 213 | msr sctlr_el2, x0 |
| 214 | b 7f |
| 215 | 4: |
| 216 | msr sctlr_el1, x0 |
| 217 | |
| 218 | 7: |
| 219 | dsb sy |
| 220 | isb |
| 221 | b __asm_invalidate_tlb_all |
| 222 | ret |
| 223 | #endif |
| 224 | |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 225 | /*-----------------------------------------------------------------------*/ |
| 226 | |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 227 | WEAK(apply_core_errata) |
| 228 | |
| 229 | mov x29, lr /* Save LR */ |
Alison Wang | c129387 | 2017-12-28 13:00:55 +0800 | [diff] [blame] | 230 | /* For now, we support Cortex-A53, Cortex-A57 specific errata */ |
| 231 | |
| 232 | /* Check if we are running on a Cortex-A53 core */ |
| 233 | branch_if_a53_core x0, apply_a53_core_errata |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 234 | |
| 235 | /* Check if we are running on a Cortex-A57 core */ |
| 236 | branch_if_a57_core x0, apply_a57_core_errata |
| 237 | 0: |
| 238 | mov lr, x29 /* Restore LR */ |
| 239 | ret |
| 240 | |
Alison Wang | c129387 | 2017-12-28 13:00:55 +0800 | [diff] [blame] | 241 | apply_a53_core_errata: |
| 242 | |
| 243 | #ifdef CONFIG_ARM_ERRATA_855873 |
| 244 | mrs x0, midr_el1 |
| 245 | tst x0, #(0xf << 20) |
| 246 | b.ne 0b |
| 247 | |
| 248 | mrs x0, midr_el1 |
| 249 | and x0, x0, #0xf |
| 250 | cmp x0, #3 |
| 251 | b.lt 0b |
| 252 | |
| 253 | mrs x0, S3_1_c15_c2_0 /* cpuactlr_el1 */ |
| 254 | /* Enable data cache clean as data cache clean/invalidate */ |
| 255 | orr x0, x0, #1 << 44 |
| 256 | msr S3_1_c15_c2_0, x0 /* cpuactlr_el1 */ |
Volodymyr Babchuk | b2b5225 | 2020-06-24 01:05:19 +0000 | [diff] [blame] | 257 | isb |
Alison Wang | c129387 | 2017-12-28 13:00:55 +0800 | [diff] [blame] | 258 | #endif |
| 259 | b 0b |
| 260 | |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 261 | apply_a57_core_errata: |
| 262 | |
| 263 | #ifdef CONFIG_ARM_ERRATA_828024 |
| 264 | mrs x0, S3_1_c15_c2_0 /* cpuactlr_el1 */ |
| 265 | /* Disable non-allocate hint of w-b-n-a memory type */ |
Bhupesh Sharma | 06a0f1d | 2015-05-28 14:54:13 +0530 | [diff] [blame] | 266 | orr x0, x0, #1 << 49 |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 267 | /* Disable write streaming no L1-allocate threshold */ |
Bhupesh Sharma | 06a0f1d | 2015-05-28 14:54:13 +0530 | [diff] [blame] | 268 | orr x0, x0, #3 << 25 |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 269 | /* Disable write streaming no-allocate threshold */ |
Bhupesh Sharma | 06a0f1d | 2015-05-28 14:54:13 +0530 | [diff] [blame] | 270 | orr x0, x0, #3 << 27 |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 271 | msr S3_1_c15_c2_0, x0 /* cpuactlr_el1 */ |
Volodymyr Babchuk | b2b5225 | 2020-06-24 01:05:19 +0000 | [diff] [blame] | 272 | isb |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 273 | #endif |
| 274 | |
| 275 | #ifdef CONFIG_ARM_ERRATA_826974 |
| 276 | mrs x0, S3_1_c15_c2_0 /* cpuactlr_el1 */ |
| 277 | /* Disable speculative load execution ahead of a DMB */ |
Bhupesh Sharma | 06a0f1d | 2015-05-28 14:54:13 +0530 | [diff] [blame] | 278 | orr x0, x0, #1 << 59 |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 279 | msr S3_1_c15_c2_0, x0 /* cpuactlr_el1 */ |
Volodymyr Babchuk | b2b5225 | 2020-06-24 01:05:19 +0000 | [diff] [blame] | 280 | isb |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 281 | #endif |
| 282 | |
Ashish kumar | 9c6d33c | 2016-01-27 18:09:32 +0530 | [diff] [blame] | 283 | #ifdef CONFIG_ARM_ERRATA_833471 |
| 284 | mrs x0, S3_1_c15_c2_0 /* cpuactlr_el1 */ |
| 285 | /* FPSCR write flush. |
| 286 | * Note that in some cases where a flush is unnecessary this |
| 287 | could impact performance. */ |
| 288 | orr x0, x0, #1 << 38 |
| 289 | msr S3_1_c15_c2_0, x0 /* cpuactlr_el1 */ |
Volodymyr Babchuk | b2b5225 | 2020-06-24 01:05:19 +0000 | [diff] [blame] | 290 | isb |
Ashish kumar | 9c6d33c | 2016-01-27 18:09:32 +0530 | [diff] [blame] | 291 | #endif |
| 292 | |
| 293 | #ifdef CONFIG_ARM_ERRATA_829520 |
| 294 | mrs x0, S3_1_c15_c2_0 /* cpuactlr_el1 */ |
| 295 | /* Disable Indirect Predictor bit will prevent this erratum |
| 296 | from occurring |
| 297 | * Note that in some cases where a flush is unnecessary this |
| 298 | could impact performance. */ |
| 299 | orr x0, x0, #1 << 4 |
| 300 | msr S3_1_c15_c2_0, x0 /* cpuactlr_el1 */ |
Volodymyr Babchuk | b2b5225 | 2020-06-24 01:05:19 +0000 | [diff] [blame] | 301 | isb |
Ashish kumar | 9c6d33c | 2016-01-27 18:09:32 +0530 | [diff] [blame] | 302 | #endif |
| 303 | |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 304 | #ifdef CONFIG_ARM_ERRATA_833069 |
| 305 | mrs x0, S3_1_c15_c2_0 /* cpuactlr_el1 */ |
| 306 | /* Disable Enable Invalidates of BTB bit */ |
| 307 | and x0, x0, #0xE |
| 308 | msr S3_1_c15_c2_0, x0 /* cpuactlr_el1 */ |
Volodymyr Babchuk | b2b5225 | 2020-06-24 01:05:19 +0000 | [diff] [blame] | 309 | isb |
Bhupesh Sharma | 80a7e35 | 2015-01-23 15:50:04 +0530 | [diff] [blame] | 310 | #endif |
| 311 | b 0b |
| 312 | ENDPROC(apply_core_errata) |
| 313 | |
| 314 | /*-----------------------------------------------------------------------*/ |
| 315 | |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 316 | WEAK(lowlevel_init) |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 317 | mov x29, lr /* Save LR */ |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 318 | |
David Feng | 79bbde0 | 2014-03-14 14:26:27 +0800 | [diff] [blame] | 319 | #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3) |
| 320 | branch_if_slave x0, 1f |
| 321 | ldr x0, =GICD_BASE |
| 322 | bl gic_init_secure |
| 323 | 1: |
| 324 | #if defined(CONFIG_GICV3) |
| 325 | ldr x0, =GICR_BASE |
| 326 | bl gic_init_secure_percpu |
| 327 | #elif defined(CONFIG_GICV2) |
| 328 | ldr x0, =GICD_BASE |
| 329 | ldr x1, =GICC_BASE |
| 330 | bl gic_init_secure_percpu |
| 331 | #endif |
Stephen Warren | 73f47af | 2016-04-28 12:45:44 -0600 | [diff] [blame] | 332 | #endif |
David Feng | 79bbde0 | 2014-03-14 14:26:27 +0800 | [diff] [blame] | 333 | |
Masahiro Yamada | e4ce25f | 2016-05-20 12:13:10 +0900 | [diff] [blame] | 334 | #ifdef CONFIG_ARMV8_MULTIENTRY |
David Feng | 79bbde0 | 2014-03-14 14:26:27 +0800 | [diff] [blame] | 335 | branch_if_master x0, x1, 2f |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 336 | |
| 337 | /* |
| 338 | * Slave should wait for master clearing spin table. |
| 339 | * This sync prevent salves observing incorrect |
| 340 | * value of spin table and jumping to wrong place. |
| 341 | */ |
David Feng | 79bbde0 | 2014-03-14 14:26:27 +0800 | [diff] [blame] | 342 | #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3) |
| 343 | #ifdef CONFIG_GICV2 |
| 344 | ldr x0, =GICC_BASE |
| 345 | #endif |
| 346 | bl gic_wait_for_interrupt |
| 347 | #endif |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 348 | |
| 349 | /* |
David Feng | 79bbde0 | 2014-03-14 14:26:27 +0800 | [diff] [blame] | 350 | * All slaves will enter EL2 and optionally EL1. |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 351 | */ |
Alison Wang | eb2088d | 2017-01-17 09:39:17 +0800 | [diff] [blame] | 352 | adr x4, lowlevel_in_el2 |
| 353 | ldr x5, =ES_TO_AARCH64 |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 354 | bl armv8_switch_to_el2 |
Alison Wang | 73818d5 | 2016-11-10 10:49:03 +0800 | [diff] [blame] | 355 | |
| 356 | lowlevel_in_el2: |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 357 | #ifdef CONFIG_ARMV8_SWITCH_TO_EL1 |
Alison Wang | eb2088d | 2017-01-17 09:39:17 +0800 | [diff] [blame] | 358 | adr x4, lowlevel_in_el1 |
| 359 | ldr x5, =ES_TO_AARCH64 |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 360 | bl armv8_switch_to_el1 |
Alison Wang | 73818d5 | 2016-11-10 10:49:03 +0800 | [diff] [blame] | 361 | |
| 362 | lowlevel_in_el1: |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 363 | #endif |
| 364 | |
Linus Walleij | 7477139 | 2015-03-09 10:53:21 +0100 | [diff] [blame] | 365 | #endif /* CONFIG_ARMV8_MULTIENTRY */ |
| 366 | |
David Feng | 79bbde0 | 2014-03-14 14:26:27 +0800 | [diff] [blame] | 367 | 2: |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 368 | mov lr, x29 /* Restore LR */ |
| 369 | ret |
| 370 | ENDPROC(lowlevel_init) |
| 371 | |
David Feng | 79bbde0 | 2014-03-14 14:26:27 +0800 | [diff] [blame] | 372 | WEAK(smp_kick_all_cpus) |
| 373 | /* Kick secondary cpus up by SGI 0 interrupt */ |
David Feng | 79bbde0 | 2014-03-14 14:26:27 +0800 | [diff] [blame] | 374 | #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3) |
| 375 | ldr x0, =GICD_BASE |
Masahiro Yamada | b914009 | 2016-06-17 18:32:47 +0900 | [diff] [blame] | 376 | b gic_kick_secondary_cpus |
David Feng | 79bbde0 | 2014-03-14 14:26:27 +0800 | [diff] [blame] | 377 | #endif |
David Feng | 79bbde0 | 2014-03-14 14:26:27 +0800 | [diff] [blame] | 378 | ret |
| 379 | ENDPROC(smp_kick_all_cpus) |
| 380 | |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 381 | /*-----------------------------------------------------------------------*/ |
| 382 | |
| 383 | ENTRY(c_runtime_cpu_setup) |
Alexander Graf | b3e9dc6 | 2019-02-20 17:14:49 +0100 | [diff] [blame] | 384 | #if defined(CONFIG_ARMV8_SPL_EXCEPTION_VECTORS) || !defined(CONFIG_SPL_BUILD) |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 385 | /* Relocate vBAR */ |
| 386 | adr x0, vectors |
| 387 | switch_el x1, 3f, 2f, 1f |
| 388 | 3: msr vbar_el3, x0 |
| 389 | b 0f |
| 390 | 2: msr vbar_el2, x0 |
| 391 | b 0f |
| 392 | 1: msr vbar_el1, x0 |
| 393 | 0: |
Andre Przywara | 4eecab7 | 2018-07-25 00:57:01 +0100 | [diff] [blame] | 394 | #endif |
David Feng | 85fd5f1 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 395 | |
| 396 | ret |
| 397 | ENDPROC(c_runtime_cpu_setup) |
Stephen Warren | 100a479 | 2016-07-18 17:01:50 -0600 | [diff] [blame] | 398 | |
| 399 | WEAK(save_boot_params) |
| 400 | b save_boot_params_ret /* back to my caller */ |
| 401 | ENDPROC(save_boot_params) |