5 * SPDX-License-Identifier: GPL-2.0+
8 #include <asm-offsets.h>
11 #include <linux/linkage.h>
12 #include <asm/macro.h>
13 #include <asm/armv8/mmu.h>
15 /*************************************************************************
17 * Startup Code (reset vector)
19 *************************************************************************/
29 .quad CONFIG_SYS_TEXT_BASE
32 * These are defined in the linker script.
40 .quad __bss_start - _start
44 .quad __bss_end - _start
48 * Could be EL3/EL2/EL1, Initial State:
49 * Little Endian, MMU Disabled, i/dCache Disabled
52 switch_el x1, 3f, 2f, 1f
55 orr x0, x0, #0xf /* SCR_EL3.NS|IRQ|FIQ|EA */
57 msr cptr_el3, xzr /* Enable FP/SIMD */
58 ldr x0, =COUNTER_FREQUENCY
59 msr cntfrq_el0, x0 /* Initialize CNTFRQ */
63 msr cptr_el2, x0 /* Enable FP/SIMD */
67 msr cpacr_el1, x0 /* Enable FP/SIMD */
71 * Cache/BPB/TLB Invalidate
72 * i-cache is invalidated before enabled in icache_enable()
73 * tlb is invalidated before mmu is enabled in dcache_enable()
74 * d-cache is invalidated before enabled in dcache_enable()
77 /* Processor specific initialization */
80 branch_if_master x0, x1, master_cpu
87 ldr x1, =CPU_RELEASE_ADDR
90 br x0 /* branch to the given address */
98 /*-----------------------------------------------------------------------*/
101 mov x29, lr /* Save LR */
103 #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3)
104 branch_if_slave x0, 1f
108 #if defined(CONFIG_GICV3)
110 bl gic_init_secure_percpu
111 #elif defined(CONFIG_GICV2)
114 bl gic_init_secure_percpu
118 branch_if_master x0, x1, 2f
121 * Slave should wait for master clearing spin table.
122 * This sync prevent salves observing incorrect
123 * value of spin table and jumping to wrong place.
125 #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3)
129 bl gic_wait_for_interrupt
133 * All slaves will enter EL2 and optionally EL1.
135 bl armv8_switch_to_el2
136 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
137 bl armv8_switch_to_el1
141 mov lr, x29 /* Restore LR */
143 ENDPROC(lowlevel_init)
145 WEAK(smp_kick_all_cpus)
146 /* Kick secondary cpus up by SGI 0 interrupt */
147 mov x29, lr /* Save LR */
148 #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3)
150 bl gic_kick_secondary_cpus
152 mov lr, x29 /* Restore LR */
154 ENDPROC(smp_kick_all_cpus)
156 /*-----------------------------------------------------------------------*/
158 ENTRY(c_runtime_cpu_setup)
161 switch_el x1, 3f, 2f, 1f
170 ENDPROC(c_runtime_cpu_setup)