York Sun | a84cd72 | 2014-06-23 15:15:54 -0700 | [diff] [blame] | 1 | /* |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 2 | * (C) Copyright 2014-2015 Freescale Semiconductor |
York Sun | a84cd72 | 2014-06-23 15:15:54 -0700 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | * |
| 6 | * Extracted from armv8/start.S |
| 7 | */ |
| 8 | |
| 9 | #include <config.h> |
| 10 | #include <linux/linkage.h> |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 11 | #include <asm/gic.h> |
York Sun | a84cd72 | 2014-06-23 15:15:54 -0700 | [diff] [blame] | 12 | #include <asm/macro.h> |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 13 | #ifdef CONFIG_MP |
| 14 | #include <asm/arch/mp.h> |
| 15 | #endif |
Priyanka Jain | 96b001f | 2016-11-17 12:29:51 +0530 | [diff] [blame] | 16 | #ifdef CONFIG_FSL_LSCH3 |
| 17 | #include <asm/arch-fsl-layerscape/immap_lsch3.h> |
Priyanka Jain | 583943b | 2016-11-17 12:29:54 +0530 | [diff] [blame] | 18 | #include <asm/arch-fsl-layerscape/soc.h> |
Priyanka Jain | 96b001f | 2016-11-17 12:29:51 +0530 | [diff] [blame] | 19 | #endif |
Alison Wang | 73818d5 | 2016-11-10 10:49:03 +0800 | [diff] [blame] | 20 | #include <asm/u-boot.h> |
York Sun | a84cd72 | 2014-06-23 15:15:54 -0700 | [diff] [blame] | 21 | |
| 22 | ENTRY(lowlevel_init) |
| 23 | mov x29, lr /* Save LR */ |
| 24 | |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 25 | #ifdef CONFIG_FSL_LSCH3 |
Prabhakar Kushwaha | edbbd25 | 2016-01-25 12:08:45 +0530 | [diff] [blame] | 26 | |
| 27 | /* Set Wuo bit for RN-I 20 */ |
York Sun | cbe8e1c | 2016-04-04 11:41:26 -0700 | [diff] [blame] | 28 | #ifdef CONFIG_LS2080A |
Prabhakar Kushwaha | edbbd25 | 2016-01-25 12:08:45 +0530 | [diff] [blame] | 29 | ldr x0, =CCI_AUX_CONTROL_BASE(20) |
| 30 | ldr x1, =0x00000010 |
| 31 | bl ccn504_set_aux |
| 32 | #endif |
| 33 | |
Scott Wood | a814e66 | 2015-03-20 19:28:10 -0700 | [diff] [blame] | 34 | /* Add fully-coherent masters to DVM domain */ |
Bhupesh Sharma | 8238f34 | 2015-07-01 09:58:03 +0530 | [diff] [blame] | 35 | ldr x0, =CCI_MN_BASE |
| 36 | ldr x1, =CCI_MN_RNF_NODEID_LIST |
| 37 | ldr x2, =CCI_MN_DVM_DOMAIN_CTL_SET |
| 38 | bl ccn504_add_masters_to_dvm |
| 39 | |
| 40 | /* Set all RN-I ports to QoS of 15 */ |
| 41 | ldr x0, =CCI_S0_QOS_CONTROL_BASE(0) |
| 42 | ldr x1, =0x00FF000C |
| 43 | bl ccn504_set_qos |
| 44 | ldr x0, =CCI_S1_QOS_CONTROL_BASE(0) |
| 45 | ldr x1, =0x00FF000C |
| 46 | bl ccn504_set_qos |
| 47 | ldr x0, =CCI_S2_QOS_CONTROL_BASE(0) |
| 48 | ldr x1, =0x00FF000C |
| 49 | bl ccn504_set_qos |
| 50 | |
| 51 | ldr x0, =CCI_S0_QOS_CONTROL_BASE(2) |
| 52 | ldr x1, =0x00FF000C |
| 53 | bl ccn504_set_qos |
| 54 | ldr x0, =CCI_S1_QOS_CONTROL_BASE(2) |
| 55 | ldr x1, =0x00FF000C |
| 56 | bl ccn504_set_qos |
| 57 | ldr x0, =CCI_S2_QOS_CONTROL_BASE(2) |
| 58 | ldr x1, =0x00FF000C |
| 59 | bl ccn504_set_qos |
| 60 | |
| 61 | ldr x0, =CCI_S0_QOS_CONTROL_BASE(6) |
| 62 | ldr x1, =0x00FF000C |
| 63 | bl ccn504_set_qos |
| 64 | ldr x0, =CCI_S1_QOS_CONTROL_BASE(6) |
| 65 | ldr x1, =0x00FF000C |
| 66 | bl ccn504_set_qos |
| 67 | ldr x0, =CCI_S2_QOS_CONTROL_BASE(6) |
| 68 | ldr x1, =0x00FF000C |
| 69 | bl ccn504_set_qos |
| 70 | |
| 71 | ldr x0, =CCI_S0_QOS_CONTROL_BASE(12) |
| 72 | ldr x1, =0x00FF000C |
| 73 | bl ccn504_set_qos |
| 74 | ldr x0, =CCI_S1_QOS_CONTROL_BASE(12) |
| 75 | ldr x1, =0x00FF000C |
| 76 | bl ccn504_set_qos |
| 77 | ldr x0, =CCI_S2_QOS_CONTROL_BASE(12) |
| 78 | ldr x1, =0x00FF000C |
| 79 | bl ccn504_set_qos |
| 80 | |
| 81 | ldr x0, =CCI_S0_QOS_CONTROL_BASE(16) |
| 82 | ldr x1, =0x00FF000C |
| 83 | bl ccn504_set_qos |
| 84 | ldr x0, =CCI_S1_QOS_CONTROL_BASE(16) |
| 85 | ldr x1, =0x00FF000C |
| 86 | bl ccn504_set_qos |
| 87 | ldr x0, =CCI_S2_QOS_CONTROL_BASE(16) |
| 88 | ldr x1, =0x00FF000C |
| 89 | bl ccn504_set_qos |
| 90 | |
| 91 | ldr x0, =CCI_S0_QOS_CONTROL_BASE(20) |
| 92 | ldr x1, =0x00FF000C |
| 93 | bl ccn504_set_qos |
| 94 | ldr x0, =CCI_S1_QOS_CONTROL_BASE(20) |
| 95 | ldr x1, =0x00FF000C |
| 96 | bl ccn504_set_qos |
| 97 | ldr x0, =CCI_S2_QOS_CONTROL_BASE(20) |
| 98 | ldr x1, =0x00FF000C |
| 99 | bl ccn504_set_qos |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 100 | #endif |
Scott Wood | a814e66 | 2015-03-20 19:28:10 -0700 | [diff] [blame] | 101 | |
Prabhakar Kushwaha | ae17df2 | 2016-06-03 18:41:26 +0530 | [diff] [blame] | 102 | #ifdef SMMU_BASE |
York Sun | a84cd72 | 2014-06-23 15:15:54 -0700 | [diff] [blame] | 103 | /* Set the SMMU page size in the sACR register */ |
| 104 | ldr x1, =SMMU_BASE |
| 105 | ldr w0, [x1, #0x10] |
| 106 | orr w0, w0, #1 << 16 /* set sACR.pagesize to indicate 64K page */ |
| 107 | str w0, [x1, #0x10] |
Prabhakar Kushwaha | ae17df2 | 2016-06-03 18:41:26 +0530 | [diff] [blame] | 108 | #endif |
York Sun | a84cd72 | 2014-06-23 15:15:54 -0700 | [diff] [blame] | 109 | |
| 110 | /* Initialize GIC Secure Bank Status */ |
| 111 | #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3) |
| 112 | branch_if_slave x0, 1f |
| 113 | ldr x0, =GICD_BASE |
| 114 | bl gic_init_secure |
| 115 | 1: |
| 116 | #ifdef CONFIG_GICV3 |
| 117 | ldr x0, =GICR_BASE |
| 118 | bl gic_init_secure_percpu |
| 119 | #elif defined(CONFIG_GICV2) |
| 120 | ldr x0, =GICD_BASE |
| 121 | ldr x1, =GICC_BASE |
| 122 | bl gic_init_secure_percpu |
| 123 | #endif |
| 124 | #endif |
| 125 | |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 126 | branch_if_master x0, x1, 2f |
York Sun | a84cd72 | 2014-06-23 15:15:54 -0700 | [diff] [blame] | 127 | |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 128 | #if defined(CONFIG_MP) && defined(CONFIG_ARMV8_MULTIENTRY) |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 129 | ldr x0, =secondary_boot_func |
| 130 | blr x0 |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 131 | #endif |
Bhupesh Sharma | a0c00ff | 2015-01-06 13:11:21 -0800 | [diff] [blame] | 132 | |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 133 | 2: |
Bhupesh Sharma | a0c00ff | 2015-01-06 13:11:21 -0800 | [diff] [blame] | 134 | #ifdef CONFIG_FSL_TZPC_BP147 |
| 135 | /* Set Non Secure access for all devices protected via TZPC */ |
| 136 | ldr x1, =TZPCDECPROT_0_SET_BASE /* Decode Protection-0 Set Reg */ |
| 137 | orr w0, w0, #1 << 3 /* DCFG_RESET is accessible from NS world */ |
| 138 | str w0, [x1] |
| 139 | |
| 140 | isb |
| 141 | dsb sy |
| 142 | #endif |
| 143 | |
| 144 | #ifdef CONFIG_FSL_TZASC_400 |
Priyanka Jain | 583943b | 2016-11-17 12:29:54 +0530 | [diff] [blame] | 145 | /* |
| 146 | * LS2080 and its personalities does not support TZASC |
| 147 | * So skip TZASC related operations |
| 148 | */ |
| 149 | bl get_svr |
| 150 | lsr w0, w0, #16 |
| 151 | ldr w1, =SVR_DEV_LS2080A |
| 152 | cmp w0, w1 |
| 153 | b.eq 1f |
| 154 | |
Bhupesh Sharma | a0c00ff | 2015-01-06 13:11:21 -0800 | [diff] [blame] | 155 | /* Set TZASC so that: |
| 156 | * a. We use only Region0 whose global secure write/read is EN |
| 157 | * b. We use only Region0 whose NSAID write/read is EN |
| 158 | * |
| 159 | * NOTE: As per the CCSR map doc, TZASC 3 and TZASC 4 are just |
| 160 | * placeholders. |
| 161 | */ |
| 162 | ldr x1, =TZASC_GATE_KEEPER(0) |
Priyanka Jain | 784269d | 2016-11-17 12:29:53 +0530 | [diff] [blame] | 163 | ldr w0, [x1] /* Filter 0 Gate Keeper Register */ |
| 164 | orr w0, w0, #1 << 0 /* Set open_request for Filter 0 */ |
| 165 | str w0, [x1] |
Bhupesh Sharma | a0c00ff | 2015-01-06 13:11:21 -0800 | [diff] [blame] | 166 | |
| 167 | ldr x1, =TZASC_GATE_KEEPER(1) |
Priyanka Jain | 784269d | 2016-11-17 12:29:53 +0530 | [diff] [blame] | 168 | ldr w0, [x1] /* Filter 0 Gate Keeper Register */ |
| 169 | orr w0, w0, #1 << 0 /* Set open_request for Filter 0 */ |
| 170 | str w0, [x1] |
Bhupesh Sharma | a0c00ff | 2015-01-06 13:11:21 -0800 | [diff] [blame] | 171 | |
| 172 | ldr x1, =TZASC_REGION_ATTRIBUTES_0(0) |
Priyanka Jain | 784269d | 2016-11-17 12:29:53 +0530 | [diff] [blame] | 173 | ldr w0, [x1] /* Region-0 Attributes Register */ |
| 174 | orr w0, w0, #1 << 31 /* Set Sec global write en, Bit[31] */ |
| 175 | orr w0, w0, #1 << 30 /* Set Sec global read en, Bit[30] */ |
| 176 | str w0, [x1] |
Bhupesh Sharma | a0c00ff | 2015-01-06 13:11:21 -0800 | [diff] [blame] | 177 | |
| 178 | ldr x1, =TZASC_REGION_ATTRIBUTES_0(1) |
Priyanka Jain | 784269d | 2016-11-17 12:29:53 +0530 | [diff] [blame] | 179 | ldr w0, [x1] /* Region-1 Attributes Register */ |
| 180 | orr w0, w0, #1 << 31 /* Set Sec global write en, Bit[31] */ |
| 181 | orr w0, w0, #1 << 30 /* Set Sec global read en, Bit[30] */ |
| 182 | str w0, [x1] |
Bhupesh Sharma | a0c00ff | 2015-01-06 13:11:21 -0800 | [diff] [blame] | 183 | |
| 184 | ldr x1, =TZASC_REGION_ID_ACCESS_0(0) |
| 185 | ldr w0, [x1] /* Region-0 Access Register */ |
| 186 | mov w0, #0xFFFFFFFF /* Set nsaid_wr_en and nsaid_rd_en */ |
| 187 | str w0, [x1] |
| 188 | |
| 189 | ldr x1, =TZASC_REGION_ID_ACCESS_0(1) |
| 190 | ldr w0, [x1] /* Region-1 Attributes Register */ |
| 191 | mov w0, #0xFFFFFFFF /* Set nsaid_wr_en and nsaid_rd_en */ |
| 192 | str w0, [x1] |
| 193 | |
| 194 | isb |
| 195 | dsb sy |
| 196 | #endif |
Priyanka Jain | 583943b | 2016-11-17 12:29:54 +0530 | [diff] [blame] | 197 | 1: |
York Sun | bad4984 | 2016-09-26 08:09:24 -0700 | [diff] [blame] | 198 | #ifdef CONFIG_ARCH_LS1046A |
Mingkai Hu | 48ddbe8 | 2016-09-07 17:56:08 +0800 | [diff] [blame] | 199 | /* Initialize the L2 RAM latency */ |
| 200 | mrs x1, S3_1_c11_c0_2 |
| 201 | mov x0, #0x1C7 |
| 202 | /* Clear L2 Tag RAM latency and L2 Data RAM latency */ |
| 203 | bic x1, x1, x0 |
| 204 | /* Set L2 data ram latency bits [2:0] */ |
| 205 | orr x1, x1, #0x2 |
| 206 | /* set L2 tag ram latency bits [8:6] */ |
| 207 | orr x1, x1, #0x80 |
| 208 | msr S3_1_c11_c0_2, x1 |
| 209 | isb |
| 210 | #endif |
| 211 | |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 212 | mov lr, x29 /* Restore LR */ |
| 213 | ret |
| 214 | ENDPROC(lowlevel_init) |
| 215 | |
Prabhakar Kushwaha | d169ebe | 2016-06-03 18:41:31 +0530 | [diff] [blame] | 216 | #ifdef CONFIG_FSL_LSCH3 |
Priyanka Jain | 96b001f | 2016-11-17 12:29:51 +0530 | [diff] [blame] | 217 | .globl get_svr |
| 218 | get_svr: |
| 219 | ldr x1, =FSL_LSCH3_SVR |
| 220 | ldr w0, [x1] |
| 221 | ret |
| 222 | |
York Sun | 1ce575f | 2015-01-06 13:18:42 -0800 | [diff] [blame] | 223 | hnf_pstate_poll: |
| 224 | /* x0 has the desired status, return 0 for success, 1 for timeout |
| 225 | * clobber x1, x2, x3, x4, x6, x7 |
| 226 | */ |
| 227 | mov x1, x0 |
| 228 | mov x7, #0 /* flag for timeout */ |
| 229 | mrs x3, cntpct_el0 /* read timer */ |
| 230 | add x3, x3, #1200 /* timeout after 100 microseconds */ |
| 231 | mov x0, #0x18 |
| 232 | movk x0, #0x420, lsl #16 /* HNF0_PSTATE_STATUS */ |
| 233 | mov w6, #8 /* HN-F node count */ |
| 234 | 1: |
| 235 | ldr x2, [x0] |
| 236 | cmp x2, x1 /* check status */ |
| 237 | b.eq 2f |
| 238 | mrs x4, cntpct_el0 |
| 239 | cmp x4, x3 |
| 240 | b.ls 1b |
| 241 | mov x7, #1 /* timeout */ |
| 242 | b 3f |
| 243 | 2: |
| 244 | add x0, x0, #0x10000 /* move to next node */ |
| 245 | subs w6, w6, #1 |
| 246 | cbnz w6, 1b |
| 247 | 3: |
| 248 | mov x0, x7 |
| 249 | ret |
| 250 | |
| 251 | hnf_set_pstate: |
| 252 | /* x0 has the desired state, clobber x1, x2, x6 */ |
| 253 | mov x1, x0 |
| 254 | /* power state to SFONLY */ |
| 255 | mov w6, #8 /* HN-F node count */ |
| 256 | mov x0, #0x10 |
| 257 | movk x0, #0x420, lsl #16 /* HNF0_PSTATE_REQ */ |
| 258 | 1: /* set pstate to sfonly */ |
| 259 | ldr x2, [x0] |
| 260 | and x2, x2, #0xfffffffffffffffc /* & HNFPSTAT_MASK */ |
| 261 | orr x2, x2, x1 |
| 262 | str x2, [x0] |
| 263 | add x0, x0, #0x10000 /* move to next node */ |
| 264 | subs w6, w6, #1 |
| 265 | cbnz w6, 1b |
| 266 | |
| 267 | ret |
| 268 | |
Stephen Warren | ddb0f63 | 2016-10-19 15:18:46 -0600 | [diff] [blame] | 269 | ENTRY(__asm_flush_l3_dcache) |
York Sun | 1ce575f | 2015-01-06 13:18:42 -0800 | [diff] [blame] | 270 | /* |
| 271 | * Return status in x0 |
| 272 | * success 0 |
| 273 | * tmeout 1 for setting SFONLY, 2 for FAM, 3 for both |
| 274 | */ |
| 275 | mov x29, lr |
| 276 | mov x8, #0 |
| 277 | |
| 278 | dsb sy |
| 279 | mov x0, #0x1 /* HNFPSTAT_SFONLY */ |
| 280 | bl hnf_set_pstate |
| 281 | |
| 282 | mov x0, #0x4 /* SFONLY status */ |
| 283 | bl hnf_pstate_poll |
| 284 | cbz x0, 1f |
| 285 | mov x8, #1 /* timeout */ |
| 286 | 1: |
| 287 | dsb sy |
| 288 | mov x0, #0x3 /* HNFPSTAT_FAM */ |
| 289 | bl hnf_set_pstate |
| 290 | |
| 291 | mov x0, #0xc /* FAM status */ |
| 292 | bl hnf_pstate_poll |
| 293 | cbz x0, 1f |
| 294 | add x8, x8, #0x2 |
| 295 | 1: |
| 296 | mov x0, x8 |
| 297 | mov lr, x29 |
| 298 | ret |
Stephen Warren | ddb0f63 | 2016-10-19 15:18:46 -0600 | [diff] [blame] | 299 | ENDPROC(__asm_flush_l3_dcache) |
Prabhakar Kushwaha | d169ebe | 2016-06-03 18:41:31 +0530 | [diff] [blame] | 300 | #endif |
York Sun | 1ce575f | 2015-01-06 13:18:42 -0800 | [diff] [blame] | 301 | |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 302 | #ifdef CONFIG_MP |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 303 | /* Keep literals not used by the secondary boot code outside it */ |
| 304 | .ltorg |
| 305 | |
| 306 | /* Using 64 bit alignment since the spin table is accessed as data */ |
| 307 | .align 4 |
| 308 | .global secondary_boot_code |
| 309 | /* Secondary Boot Code starts here */ |
| 310 | secondary_boot_code: |
| 311 | .global __spin_table |
| 312 | __spin_table: |
| 313 | .space CONFIG_MAX_CPUS*SPIN_TABLE_ELEM_SIZE |
| 314 | |
| 315 | .align 2 |
| 316 | ENTRY(secondary_boot_func) |
York Sun | a84cd72 | 2014-06-23 15:15:54 -0700 | [diff] [blame] | 317 | /* |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 318 | * MPIDR_EL1 Fields: |
| 319 | * MPIDR[1:0] = AFF0_CPUID <- Core ID (0,1) |
| 320 | * MPIDR[7:2] = AFF0_RES |
| 321 | * MPIDR[15:8] = AFF1_CLUSTERID <- Cluster ID (0,1,2,3) |
| 322 | * MPIDR[23:16] = AFF2_CLUSTERID |
| 323 | * MPIDR[24] = MT |
| 324 | * MPIDR[29:25] = RES0 |
| 325 | * MPIDR[30] = U |
| 326 | * MPIDR[31] = ME |
| 327 | * MPIDR[39:32] = AFF3 |
| 328 | * |
| 329 | * Linear Processor ID (LPID) calculation from MPIDR_EL1: |
| 330 | * (We only use AFF0_CPUID and AFF1_CLUSTERID for now |
| 331 | * until AFF2_CLUSTERID and AFF3 have non-zero values) |
| 332 | * |
| 333 | * LPID = MPIDR[15:8] | MPIDR[1:0] |
York Sun | a84cd72 | 2014-06-23 15:15:54 -0700 | [diff] [blame] | 334 | */ |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 335 | mrs x0, mpidr_el1 |
| 336 | ubfm x1, x0, #8, #15 |
| 337 | ubfm x2, x0, #0, #1 |
| 338 | orr x10, x2, x1, lsl #2 /* x10 has LPID */ |
| 339 | ubfm x9, x0, #0, #15 /* x9 contains MPIDR[15:0] */ |
York Sun | a84cd72 | 2014-06-23 15:15:54 -0700 | [diff] [blame] | 340 | /* |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 341 | * offset of the spin table element for this core from start of spin |
| 342 | * table (each elem is padded to 64 bytes) |
York Sun | a84cd72 | 2014-06-23 15:15:54 -0700 | [diff] [blame] | 343 | */ |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 344 | lsl x1, x10, #6 |
| 345 | ldr x0, =__spin_table |
| 346 | /* physical address of this cpus spin table element */ |
| 347 | add x11, x1, x0 |
| 348 | |
York Sun | 77a1097 | 2015-03-20 19:28:08 -0700 | [diff] [blame] | 349 | ldr x0, =__real_cntfrq |
| 350 | ldr x0, [x0] |
| 351 | msr cntfrq_el0, x0 /* set with real frequency */ |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 352 | str x9, [x11, #16] /* LPID */ |
| 353 | mov x4, #1 |
| 354 | str x4, [x11, #8] /* STATUS */ |
| 355 | dsb sy |
| 356 | #if defined(CONFIG_GICV3) |
| 357 | gic_wait_for_interrupt_m x0 |
| 358 | #elif defined(CONFIG_GICV2) |
| 359 | ldr x0, =GICC_BASE |
| 360 | gic_wait_for_interrupt_m x0, w1 |
| 361 | #endif |
| 362 | |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 363 | slave_cpu: |
| 364 | wfe |
| 365 | ldr x0, [x11] |
| 366 | cbz x0, slave_cpu |
| 367 | #ifndef CONFIG_ARMV8_SWITCH_TO_EL1 |
| 368 | mrs x1, sctlr_el2 |
| 369 | #else |
| 370 | mrs x1, sctlr_el1 |
| 371 | #endif |
| 372 | tbz x1, #25, cpu_is_le |
| 373 | rev x0, x0 /* BE to LE conversion */ |
| 374 | cpu_is_le: |
Alison Wang | 73818d5 | 2016-11-10 10:49:03 +0800 | [diff] [blame] | 375 | ldr x5, [x11, #24] |
| 376 | ldr x6, =IH_ARCH_DEFAULT |
| 377 | cmp x6, x5 |
| 378 | b.eq 1f |
| 379 | |
| 380 | #ifdef CONFIG_ARMV8_SWITCH_TO_EL1 |
| 381 | adr x3, secondary_switch_to_el1 |
| 382 | ldr x4, =ES_TO_AARCH64 |
| 383 | #else |
| 384 | ldr x3, [x11] |
| 385 | ldr x4, =ES_TO_AARCH32 |
| 386 | #endif |
| 387 | bl secondary_switch_to_el2 |
| 388 | |
| 389 | 1: |
| 390 | #ifdef CONFIG_ARMV8_SWITCH_TO_EL1 |
| 391 | adr x3, secondary_switch_to_el1 |
| 392 | #else |
| 393 | ldr x3, [x11] |
| 394 | #endif |
| 395 | ldr x4, =ES_TO_AARCH64 |
| 396 | bl secondary_switch_to_el2 |
| 397 | |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 398 | ENDPROC(secondary_boot_func) |
| 399 | |
| 400 | ENTRY(secondary_switch_to_el2) |
Alison Wang | 73818d5 | 2016-11-10 10:49:03 +0800 | [diff] [blame] | 401 | switch_el x5, 1f, 0f, 0f |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 402 | 0: ret |
Alison Wang | 73818d5 | 2016-11-10 10:49:03 +0800 | [diff] [blame] | 403 | 1: armv8_switch_to_el2_m x3, x4, x5 |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 404 | ENDPROC(secondary_switch_to_el2) |
| 405 | |
| 406 | ENTRY(secondary_switch_to_el1) |
Alison Wang | 73818d5 | 2016-11-10 10:49:03 +0800 | [diff] [blame] | 407 | mrs x0, mpidr_el1 |
| 408 | ubfm x1, x0, #8, #15 |
| 409 | ubfm x2, x0, #0, #1 |
| 410 | orr x10, x2, x1, lsl #2 /* x10 has LPID */ |
| 411 | |
| 412 | lsl x1, x10, #6 |
| 413 | ldr x0, =__spin_table |
| 414 | /* physical address of this cpus spin table element */ |
| 415 | add x11, x1, x0 |
| 416 | |
| 417 | ldr x3, [x11] |
| 418 | |
| 419 | ldr x5, [x11, #24] |
| 420 | ldr x6, =IH_ARCH_DEFAULT |
| 421 | cmp x6, x5 |
| 422 | b.eq 2f |
| 423 | |
| 424 | ldr x4, =ES_TO_AARCH32 |
| 425 | bl switch_to_el1 |
| 426 | |
| 427 | 2: ldr x4, =ES_TO_AARCH64 |
| 428 | |
| 429 | switch_to_el1: |
| 430 | switch_el x5, 0f, 1f, 0f |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 431 | 0: ret |
Alison Wang | 73818d5 | 2016-11-10 10:49:03 +0800 | [diff] [blame] | 432 | 1: armv8_switch_to_el1_m x3, x4, x5 |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 433 | ENDPROC(secondary_switch_to_el1) |
| 434 | |
| 435 | /* Ensure that the literals used by the secondary boot code are |
| 436 | * assembled within it (this is required so that we can protect |
| 437 | * this area with a single memreserve region |
| 438 | */ |
| 439 | .ltorg |
| 440 | |
| 441 | /* 64 bit alignment for elements accessed as data */ |
| 442 | .align 4 |
York Sun | 77a1097 | 2015-03-20 19:28:08 -0700 | [diff] [blame] | 443 | .global __real_cntfrq |
| 444 | __real_cntfrq: |
| 445 | .quad COUNTER_FREQUENCY |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 446 | .globl __secondary_boot_code_size |
| 447 | .type __secondary_boot_code_size, %object |
| 448 | /* Secondary Boot Code ends here */ |
| 449 | __secondary_boot_code_size: |
| 450 | .quad .-secondary_boot_code |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 451 | #endif |