1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2014-2015 Freescale Semiconductor
8 #include <linux/linkage.h>
10 #include <asm/system.h>
11 #include <asm/arch/mp.h>
14 .global secondary_boot_addr
16 .quad __secondary_boot_func
18 .global secondary_boot_code_start
19 secondary_boot_code_start:
20 .quad __secondary_boot_code_start
22 .global secondary_boot_code_size
23 secondary_boot_code_size:
24 .quad __secondary_boot_code_end - __secondary_boot_code_start
26 /* Using 64 bit alignment since the spin table is accessed as data */
28 /* Secondary Boot Code starts here */
29 __secondary_boot_code_start:
31 .space CONFIG_MAX_CPUS*SPIN_TABLE_ELEM_SIZE
34 __secondary_boot_func:
37 * MPIDR[1:0] = AFF0_CPUID <- Core ID (0,1)
38 * MPIDR[7:2] = AFF0_RES
39 * MPIDR[15:8] = AFF1_CLUSTERID <- Cluster ID (0,1,2,3)
40 * MPIDR[23:16] = AFF2_CLUSTERID
47 * Linear Processor ID (LPID) calculation from MPIDR_EL1:
48 * (We only use AFF0_CPUID and AFF1_CLUSTERID for now
49 * until AFF2_CLUSTERID and AFF3 have non-zero values)
51 * LPID = MPIDR[15:8] | MPIDR[1:0]
56 orr x10, x2, x1, lsl #2 /* x10 has LPID */
57 ubfm x9, x0, #0, #15 /* x9 contains MPIDR[15:0] */
59 * offset of the spin table element for this core from start of spin
60 * table (each elem is padded to 64 bytes)
64 /* physical address of this cpus spin table element */
69 msr cntfrq_el0, x0 /* set with real frequency */
70 str x9, [x11, #16] /* LPID */
72 str x4, [x11, #8] /* STATUS */
81 rev x4, x4 /* BE to LE conversion */
83 ldr x6, =ES_TO_AARCH64
84 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
86 switch_el x7, 0f, _dead_loop, _dead_loop
87 0: armv8_switch_to_el2_m x5, x6, x7
90 ldr x7, [x11, #24] /* ARCH_COMP */
92 ldr x6, =ES_TO_AARCH32
94 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
95 switch_el x7, _dead_loop, 0f, _dead_loop
96 0: armv8_switch_to_el1_m x4, x6, x7
98 switch_el x7, 0f, _dead_loop, _dead_loop
99 0: armv8_switch_to_el2_m x4, x6, x7
106 /* Ensure that the literals used by the secondary boot code are
107 * assembled within it (this is required so that we can protect
108 * this area with a single memreserve region
112 /* 64 bit alignment for elements accessed as data */
114 .global __real_cntfrq
116 .quad COUNTER_FREQUENCY
117 /* Secondary Boot Code ends here */
118 __secondary_boot_code_end: