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 switch_el x1, 1f, 100f, 100f /* skip if not in EL3 */
80 #if defined (CONFIG_SYS_FSL_HAS_CCN504)
82 /* Set Wuo bit for RN-I 20 */
83 #ifdef CONFIG_ARCH_LS2080A
84 ldr x0, =CCI_AUX_CONTROL_BASE(20)
89 * Set forced-order mode in RNI-6, RNI-20
90 * This is required for performance optimization on LS2088A
91 * LS2080A family does not support setting forced-order mode,
92 * so skip this operation for LS2080A family
96 ldr w1, =SVR_DEV(SVR_LS2080A)
100 ldr x0, =CCI_AUX_CONTROL_BASE(6)
103 ldr x0, =CCI_AUX_CONTROL_BASE(20)
109 /* Add fully-coherent masters to DVM domain */
111 ldr x1, =CCI_MN_RNF_NODEID_LIST
112 ldr x2, =CCI_MN_DVM_DOMAIN_CTL_SET
113 bl ccn504_add_masters_to_dvm
115 /* Set all RN-I ports to QoS of 15 */
116 ldr x0, =CCI_S0_QOS_CONTROL_BASE(0)
119 ldr x0, =CCI_S1_QOS_CONTROL_BASE(0)
122 ldr x0, =CCI_S2_QOS_CONTROL_BASE(0)
126 ldr x0, =CCI_S0_QOS_CONTROL_BASE(2)
129 ldr x0, =CCI_S1_QOS_CONTROL_BASE(2)
132 ldr x0, =CCI_S2_QOS_CONTROL_BASE(2)
136 ldr x0, =CCI_S0_QOS_CONTROL_BASE(6)
139 ldr x0, =CCI_S1_QOS_CONTROL_BASE(6)
142 ldr x0, =CCI_S2_QOS_CONTROL_BASE(6)
146 ldr x0, =CCI_S0_QOS_CONTROL_BASE(12)
149 ldr x0, =CCI_S1_QOS_CONTROL_BASE(12)
152 ldr x0, =CCI_S2_QOS_CONTROL_BASE(12)
156 ldr x0, =CCI_S0_QOS_CONTROL_BASE(16)
159 ldr x0, =CCI_S1_QOS_CONTROL_BASE(16)
162 ldr x0, =CCI_S2_QOS_CONTROL_BASE(16)
166 ldr x0, =CCI_S0_QOS_CONTROL_BASE(20)
169 ldr x0, =CCI_S1_QOS_CONTROL_BASE(20)
172 ldr x0, =CCI_S2_QOS_CONTROL_BASE(20)
175 #endif /* CONFIG_SYS_FSL_HAS_CCN504 */
178 /* Set the SMMU page size in the sACR register */
181 orr w0, w0, #1 << 16 /* set sACR.pagesize to indicate 64K page */
185 /* Initialize GIC Secure Bank Status */
186 #if !defined(CONFIG_SPL_BUILD)
187 #if defined(CONFIG_GICV2) || defined(CONFIG_GICV3)
188 branch_if_slave x0, 1f
194 bl gic_init_secure_percpu
195 #elif defined(CONFIG_GICV2)
197 bl gic_init_secure_percpu
203 branch_if_master x0, 2f
205 #if defined(CONFIG_MP) && defined(CONFIG_ARMV8_MULTIENTRY)
207 * Formerly, here was a jump to secondary_boot_func, but we just
208 * return early here and let the generic code in start.S handle
209 * the jump to secondary_boot_func.
211 mov lr, x29 /* Restore LR */
216 switch_el x1, 1f, 100f, 100f /* skip if not in EL3 */
218 #ifdef CONFIG_FSL_TZPC_BP147
219 /* Set Non Secure access for all devices protected via TZPC */
220 ldr x1, =TZPCDECPROT_0_SET_BASE /* Decode Protection-0 Set Reg */
221 orr w0, w0, #1 << 3 /* DCFG_RESET is accessible from NS world */
228 #ifdef CONFIG_FSL_TZASC_400
230 * LS2080 and its personalities does not support TZASC
231 * So skip TZASC related operations
235 ldr w1, =SVR_DEV(SVR_LS2080A)
239 /* Set TZASC so that:
240 * a. We use only Region0 whose global secure write/read is EN
241 * b. We use only Region0 whose NSAID write/read is EN
243 * NOTE: As per the CCSR map doc, TZASC 3 and TZASC 4 are just
247 .macro tzasc_prog, xreg
256 ldr w0, [x1] /* Filter 0 Gate Keeper Register */
257 orr w0, w0, #1 << 0 /* Set open_request for Filter 0 */
263 ldr w0, [x1] /* Region-0 Attributes Register */
264 orr w0, w0, #1 << 31 /* Set Sec global write en, Bit[31] */
265 orr w0, w0, #1 << 30 /* Set Sec global read en, Bit[30] */
271 ldr w0, [x1] /* Region-0 Access Register */
272 mov w0, #0xFFFFFFFF /* Set nsaid_wr_en and nsaid_rd_en */
276 #ifdef CONFIG_FSL_TZASC_1
281 #ifdef CONFIG_FSL_TZASC_2
291 #ifdef CONFIG_ARCH_LS1046A
292 switch_el x1, 1f, 100f, 100f /* skip if not in EL3 */
294 /* Initialize the L2 RAM latency */
295 mrs x1, S3_1_c11_c0_2
297 /* Clear L2 Tag RAM latency and L2 Data RAM latency */
299 /* Set L2 data ram latency bits [2:0] */
301 /* set L2 tag ram latency bits [8:6] */
303 msr S3_1_c11_c0_2, x1
308 #if !defined(CONFIG_TFABOOT) && \
309 (defined(CONFIG_FSL_LSCH2) && !defined(CONFIG_SPL_BUILD))
313 mov lr, x29 /* Restore LR */
315 ENDPROC(lowlevel_init)
317 #if defined(CONFIG_FSL_LSCH2) && !defined(CONFIG_SPL_BUILD)
318 ENTRY(fsl_ocram_init)
319 mov x28, lr /* Save LR */
321 bl fsl_ocram_clear_ecc_err
322 mov lr, x28 /* Restore LR */
324 ENDPROC(fsl_ocram_init)
326 ENTRY(fsl_clear_ocram)
328 ldr x0, =CONFIG_SYS_FSL_OCRAM_BASE
329 ldr x1, =(CONFIG_SYS_FSL_OCRAM_BASE + CONFIG_SYS_FSL_OCRAM_SIZE)
337 ENDPROC(fsl_clear_ocram)
339 ENTRY(fsl_ocram_clear_ecc_err)
340 /* OCRAM1/2 ECC status bit */
342 ldr x0, =DCSR_DCFG_SBEESR2
344 ldr x0, =DCSR_DCFG_MBEESR2
347 ENDPROC(fsl_ocram_init)
350 #ifdef CONFIG_FSL_LSCH3
353 ldr x1, =FSL_LSCH3_SVR
358 #if defined(CONFIG_SYS_FSL_HAS_CCN504) || defined(CONFIG_SYS_FSL_HAS_CCN508)
360 /* x0 has the desired status, return only if operation succeed
364 mov w6, #8 /* HN-F node count */
366 movk x0, #0x420, lsl #16 /* HNF0_PSTATE_STATUS */
369 cmp x2, x1 /* check status */
373 add x0, x0, #0x10000 /* move to next node */
379 /* x0 has the desired state, clobber x1, x2, x6 */
381 /* power state to SFONLY */
382 mov w6, #8 /* HN-F node count */
384 movk x0, #0x420, lsl #16 /* HNF0_PSTATE_REQ */
385 1: /* set pstate to sfonly */
387 and x2, x2, #0xfffffffffffffffc /* & HNFPSTAT_MASK */
390 add x0, x0, #0x10000 /* move to next node */
396 ENTRY(__asm_flush_l3_dcache)
398 * Return status in x0
404 mov x0, #0x1 /* HNFPSTAT_SFONLY */
407 mov x0, #0x4 /* SFONLY status */
411 mov x0, #0x3 /* HNFPSTAT_FAM */
414 mov x0, #0xc /* FAM status */
420 ENDPROC(__asm_flush_l3_dcache)
421 #endif /* CONFIG_SYS_FSL_HAS_CCN504 */