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
19 /* Using 64 bit alignment since the spin table is accessed as data */
21 .global secondary_boot_code
22 /* Secondary Boot Code starts here */
26 .space CONFIG_MAX_CPUS*SPIN_TABLE_ELEM_SIZE
29 ENTRY(secondary_boot_func)
32 * MPIDR[1:0] = AFF0_CPUID <- Core ID (0,1)
33 * MPIDR[7:2] = AFF0_RES
34 * MPIDR[15:8] = AFF1_CLUSTERID <- Cluster ID (0,1,2,3)
35 * MPIDR[23:16] = AFF2_CLUSTERID
42 * Linear Processor ID (LPID) calculation from MPIDR_EL1:
43 * (We only use AFF0_CPUID and AFF1_CLUSTERID for now
44 * until AFF2_CLUSTERID and AFF3 have non-zero values)
46 * LPID = MPIDR[15:8] | MPIDR[1:0]
51 orr x10, x2, x1, lsl #2 /* x10 has LPID */
52 ubfm x9, x0, #0, #15 /* x9 contains MPIDR[15:0] */
54 * offset of the spin table element for this core from start of spin
55 * table (each elem is padded to 64 bytes)
59 /* physical address of this cpus spin table element */
64 msr cntfrq_el0, x0 /* set with real frequency */
65 str x9, [x11, #16] /* LPID */
67 str x4, [x11, #8] /* STATUS */
74 #ifndef CONFIG_ARMV8_SWITCH_TO_EL1
79 tbz x1, #25, cpu_is_le
80 rev x0, x0 /* BE to LE conversion */
85 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
86 adr x4, secondary_switch_to_el1
87 ldr x5, =ES_TO_AARCH64
90 ldr x5, =ES_TO_AARCH32
92 bl secondary_switch_to_el2
95 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
96 adr x4, secondary_switch_to_el1
100 ldr x5, =ES_TO_AARCH64
101 bl secondary_switch_to_el2
103 ENDPROC(secondary_boot_func)
105 ENTRY(secondary_switch_to_el2)
106 switch_el x6, 1f, 0f, 0f
108 1: armv8_switch_to_el2_m x4, x5, x6
109 ENDPROC(secondary_switch_to_el2)
111 ENTRY(secondary_switch_to_el1)
115 orr x10, x2, x1, lsl #2 /* x10 has LPID */
119 /* physical address of this cpus spin table element */
127 ldr x5, =ES_TO_AARCH32
130 2: ldr x5, =ES_TO_AARCH64
133 switch_el x6, 0f, 1f, 0f
135 1: armv8_switch_to_el1_m x4, x5, x6
136 ENDPROC(secondary_switch_to_el1)
138 /* Ensure that the literals used by the secondary boot code are
139 * assembled within it (this is required so that we can protect
140 * this area with a single memreserve region
144 /* 64 bit alignment for elements accessed as data */
146 .global __real_cntfrq
148 .quad COUNTER_FREQUENCY
149 .globl __secondary_boot_code_size
150 .type __secondary_boot_code_size, %object
151 /* Secondary Boot Code ends here */
152 __secondary_boot_code_size:
153 .quad .-secondary_boot_code