1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2014-2015 Freescale Semiconductor
6 * Extracted from armv8/start.S
10 #include <linux/linkage.h>
12 #include <asm/macro.h>
13 #include <asm/arch-fsl-layerscape/soc.h>
14 #ifdef CONFIG_FSL_LSCH3
15 #include <asm/arch-fsl-layerscape/immap_lsch3.h>
17 #include <asm/u-boot.h>
20 .weak secondary_boot_addr
25 * For LS1043a rev1.0, GIC base address align with 4k.
26 * For LS1043a rev1.1, if DCFG_GIC400_ALIGN[GIC_ADDR_BIT]
27 * is set, GIC base address align with 4K, or else align
30 * x0: the base address of GICD
31 * x1: the base address of GICC
38 #ifdef CONFIG_HAS_FEATURE_GIC64K_ALIGN
39 ldr x2, =DCFG_CCSR_SVR
43 ldr w4, =SVR_DEV(SVR_LS1043A)
49 ldr x2, =SCFG_GIC400_ALIGN
52 tbnz w2, #GIC_ADDR_BIT, 1f
53 ldr x0, =GICD_BASE_64K
55 ldr x1, =GICC_BASE_64K
60 ENDPROC(get_gic_offset)
62 ENTRY(smp_kick_all_cpus)
63 /* Kick secondary cpus up by SGI 0 interrupt */
64 #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3)
65 mov x29, lr /* Save LR */
67 bl gic_kick_secondary_cpus
68 mov lr, x29 /* Restore LR */
71 ENDPROC(smp_kick_all_cpus)
75 mov x29, lr /* Save LR */
77 /* unmask SError and abort */
80 /* Set HCR_EL2[AMO] so SError @EL2 is taken */
82 orr x0, x0, #0x20 /* AMO */
86 switch_el x1, 1f, 100f, 100f /* skip if not in EL3 */
89 #if defined (CONFIG_SYS_FSL_HAS_CCN504)
91 /* Set Wuo bit for RN-I 20 */
92 #ifdef CONFIG_ARCH_LS2080A
93 ldr x0, =CCI_AUX_CONTROL_BASE(20)
98 * Set forced-order mode in RNI-6, RNI-20
99 * This is required for performance optimization on LS2088A
100 * LS2080A family does not support setting forced-order mode,
101 * so skip this operation for LS2080A family
105 ldr w1, =SVR_DEV(SVR_LS2080A)
109 ldr x0, =CCI_AUX_CONTROL_BASE(6)
112 ldr x0, =CCI_AUX_CONTROL_BASE(20)
118 /* Add fully-coherent masters to DVM domain */
120 ldr x1, =CCI_MN_RNF_NODEID_LIST
121 ldr x2, =CCI_MN_DVM_DOMAIN_CTL_SET
122 bl ccn504_add_masters_to_dvm
124 /* Set all RN-I ports to QoS of 15 */
125 ldr x0, =CCI_S0_QOS_CONTROL_BASE(0)
128 ldr x0, =CCI_S1_QOS_CONTROL_BASE(0)
131 ldr x0, =CCI_S2_QOS_CONTROL_BASE(0)
135 ldr x0, =CCI_S0_QOS_CONTROL_BASE(2)
138 ldr x0, =CCI_S1_QOS_CONTROL_BASE(2)
141 ldr x0, =CCI_S2_QOS_CONTROL_BASE(2)
145 ldr x0, =CCI_S0_QOS_CONTROL_BASE(6)
148 ldr x0, =CCI_S1_QOS_CONTROL_BASE(6)
151 ldr x0, =CCI_S2_QOS_CONTROL_BASE(6)
155 ldr x0, =CCI_S0_QOS_CONTROL_BASE(12)
158 ldr x0, =CCI_S1_QOS_CONTROL_BASE(12)
161 ldr x0, =CCI_S2_QOS_CONTROL_BASE(12)
165 ldr x0, =CCI_S0_QOS_CONTROL_BASE(16)
168 ldr x0, =CCI_S1_QOS_CONTROL_BASE(16)
171 ldr x0, =CCI_S2_QOS_CONTROL_BASE(16)
175 ldr x0, =CCI_S0_QOS_CONTROL_BASE(20)
178 ldr x0, =CCI_S1_QOS_CONTROL_BASE(20)
181 ldr x0, =CCI_S2_QOS_CONTROL_BASE(20)
184 #endif /* CONFIG_SYS_FSL_HAS_CCN504 */
187 /* Set the SMMU page size in the sACR register */
190 orr w0, w0, #1 << 16 /* set sACR.pagesize to indicate 64K page */
194 /* Initialize GIC Secure Bank Status */
195 #if !defined(CONFIG_SPL_BUILD)
196 #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3)
197 branch_if_slave x0, 1f
203 bl gic_init_secure_percpu
204 #elif defined(CONFIG_GICV2)
206 bl gic_init_secure_percpu
212 branch_if_master x0, x1, 2f
214 #if defined(CONFIG_MP) && defined(CONFIG_ARMV8_MULTIENTRY)
216 * Formerly, here was a jump to secondary_boot_func, but we just
217 * return early here and let the generic code in start.S handle
218 * the jump to secondary_boot_func.
220 mov lr, x29 /* Restore LR */
225 switch_el x1, 1f, 100f, 100f /* skip if not in EL3 */
227 #ifdef CONFIG_FSL_TZPC_BP147
228 /* Set Non Secure access for all devices protected via TZPC */
229 ldr x1, =TZPCDECPROT_0_SET_BASE /* Decode Protection-0 Set Reg */
230 orr w0, w0, #1 << 3 /* DCFG_RESET is accessible from NS world */
237 #ifdef CONFIG_FSL_TZASC_400
239 * LS2080 and its personalities does not support TZASC
240 * So skip TZASC related operations
244 ldr w1, =SVR_DEV(SVR_LS2080A)
248 /* Set TZASC so that:
249 * a. We use only Region0 whose global secure write/read is EN
250 * b. We use only Region0 whose NSAID write/read is EN
252 * NOTE: As per the CCSR map doc, TZASC 3 and TZASC 4 are just
256 .macro tzasc_prog, xreg
265 ldr w0, [x1] /* Filter 0 Gate Keeper Register */
266 orr w0, w0, #1 << 0 /* Set open_request for Filter 0 */
272 ldr w0, [x1] /* Region-0 Attributes Register */
273 orr w0, w0, #1 << 31 /* Set Sec global write en, Bit[31] */
274 orr w0, w0, #1 << 30 /* Set Sec global read en, Bit[30] */
280 ldr w0, [x1] /* Region-0 Access Register */
281 mov w0, #0xFFFFFFFF /* Set nsaid_wr_en and nsaid_rd_en */
285 #ifdef CONFIG_FSL_TZASC_1
290 #ifdef CONFIG_FSL_TZASC_2
300 #ifdef CONFIG_ARCH_LS1046A
301 switch_el x1, 1f, 100f, 100f /* skip if not in EL3 */
303 /* Initialize the L2 RAM latency */
304 mrs x1, S3_1_c11_c0_2
306 /* Clear L2 Tag RAM latency and L2 Data RAM latency */
308 /* Set L2 data ram latency bits [2:0] */
310 /* set L2 tag ram latency bits [8:6] */
312 msr S3_1_c11_c0_2, x1
317 #if !defined(CONFIG_TFABOOT) && \
318 (defined(CONFIG_FSL_LSCH2) && !defined(CONFIG_SPL_BUILD))
322 mov lr, x29 /* Restore LR */
324 ENDPROC(lowlevel_init)
326 #if defined(CONFIG_FSL_LSCH2) && !defined(CONFIG_SPL_BUILD)
327 ENTRY(fsl_ocram_init)
328 mov x28, lr /* Save LR */
330 bl fsl_ocram_clear_ecc_err
331 mov lr, x28 /* Restore LR */
333 ENDPROC(fsl_ocram_init)
335 ENTRY(fsl_clear_ocram)
337 ldr x0, =CONFIG_SYS_FSL_OCRAM_BASE
338 ldr x1, =(CONFIG_SYS_FSL_OCRAM_BASE + CONFIG_SYS_FSL_OCRAM_SIZE)
346 ENDPROC(fsl_clear_ocram)
348 ENTRY(fsl_ocram_clear_ecc_err)
349 /* OCRAM1/2 ECC status bit */
351 ldr x0, =DCSR_DCFG_SBEESR2
353 ldr x0, =DCSR_DCFG_MBEESR2
356 ENDPROC(fsl_ocram_init)
359 #ifdef CONFIG_FSL_LSCH3
362 ldr x1, =FSL_LSCH3_SVR
367 #if defined(CONFIG_SYS_FSL_HAS_CCN504) || defined(CONFIG_SYS_FSL_HAS_CCN508)
369 /* x0 has the desired status, return only if operation succeed
373 mov w6, #8 /* HN-F node count */
375 movk x0, #0x420, lsl #16 /* HNF0_PSTATE_STATUS */
378 cmp x2, x1 /* check status */
382 add x0, x0, #0x10000 /* move to next node */
388 /* x0 has the desired state, clobber x1, x2, x6 */
390 /* power state to SFONLY */
391 mov w6, #8 /* HN-F node count */
393 movk x0, #0x420, lsl #16 /* HNF0_PSTATE_REQ */
394 1: /* set pstate to sfonly */
396 and x2, x2, #0xfffffffffffffffc /* & HNFPSTAT_MASK */
399 add x0, x0, #0x10000 /* move to next node */
405 ENTRY(__asm_flush_l3_dcache)
407 * Return status in x0
413 mov x0, #0x1 /* HNFPSTAT_SFONLY */
416 mov x0, #0x4 /* SFONLY status */
420 mov x0, #0x3 /* HNFPSTAT_FAM */
423 mov x0, #0xc /* FAM status */
429 ENDPROC(__asm_flush_l3_dcache)
430 #endif /* CONFIG_SYS_FSL_HAS_CCN504 */