xref: /arm-trusted-firmware/lib/cpus/aarch64/cortex_a510.S (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu/*
2*91f16700Schasinglulu * Copyright (c) 2023, Arm Limited. All rights reserved.
3*91f16700Schasinglulu *
4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause
5*91f16700Schasinglulu */
6*91f16700Schasinglulu
7*91f16700Schasinglulu#include <arch.h>
8*91f16700Schasinglulu#include <asm_macros.S>
9*91f16700Schasinglulu#include <common/bl_common.h>
10*91f16700Schasinglulu#include <cortex_a510.h>
11*91f16700Schasinglulu#include <cpu_macros.S>
12*91f16700Schasinglulu#include <plat_macros.S>
13*91f16700Schasinglulu
14*91f16700Schasinglulu/* Hardware handled coherency */
15*91f16700Schasinglulu#if HW_ASSISTED_COHERENCY == 0
16*91f16700Schasinglulu#error "Cortex-A510 must be compiled with HW_ASSISTED_COHERENCY enabled"
17*91f16700Schasinglulu#endif
18*91f16700Schasinglulu
19*91f16700Schasinglulu/* 64-bit only core */
20*91f16700Schasinglulu#if CTX_INCLUDE_AARCH32_REGS == 1
21*91f16700Schasinglulu#error "Cortex-A510 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
22*91f16700Schasinglulu#endif
23*91f16700Schasinglulu
24*91f16700Schasingluluworkaround_reset_start cortex_a510, ERRATUM(1922240), ERRATA_A510_1922240
25*91f16700Schasinglulu	/* Apply the workaround by setting IMP_CMPXACTLR_EL1[11:10] = 0b11. */
26*91f16700Schasinglulu	sysreg_bitfield_insert CORTEX_A510_CMPXACTLR_EL1, CORTEX_A510_CMPXACTLR_EL1_SNPPREFERUNIQUE_DISABLE, \
27*91f16700Schasinglulu	CORTEX_A510_CMPXACTLR_EL1_SNPPREFERUNIQUE_SHIFT, CORTEX_A510_CMPXACTLR_EL1_SNPPREFERUNIQUE_WIDTH
28*91f16700Schasingluluworkaround_reset_end cortex_a510, ERRATUM(1922240)
29*91f16700Schasinglulu
30*91f16700Schasinglulucheck_erratum_ls cortex_a510, ERRATUM(1922240), CPU_REV(0, 0)
31*91f16700Schasinglulu
32*91f16700Schasingluluworkaround_reset_start cortex_a510, ERRATUM(2041909), ERRATA_A510_2041909
33*91f16700Schasinglulu	/* Apply workaround */
34*91f16700Schasinglulu	mov	x0, xzr
35*91f16700Schasinglulu	msr	S3_6_C15_C4_0, x0
36*91f16700Schasinglulu	isb
37*91f16700Schasinglulu
38*91f16700Schasinglulu	mov	x0, #0x8500000
39*91f16700Schasinglulu	msr	S3_6_C15_C4_2, x0
40*91f16700Schasinglulu
41*91f16700Schasinglulu	mov	x0, #0x1F700000
42*91f16700Schasinglulu	movk	x0, #0x8, lsl #32
43*91f16700Schasinglulu	msr	S3_6_C15_C4_3, x0
44*91f16700Schasinglulu
45*91f16700Schasinglulu	mov	x0, #0x3F1
46*91f16700Schasinglulu	movk	x0, #0x110, lsl #16
47*91f16700Schasinglulu	msr	S3_6_C15_C4_1, x0
48*91f16700Schasingluluworkaround_reset_end cortex_a510, ERRATUM(2041909)
49*91f16700Schasinglulu
50*91f16700Schasinglulucheck_erratum_range cortex_a510, ERRATUM(2041909), CPU_REV(0, 2), CPU_REV(0, 2)
51*91f16700Schasinglulu
52*91f16700Schasingluluworkaround_reset_start cortex_a510, ERRATUM(2042739), ERRATA_A510_2042739
53*91f16700Schasinglulu	/* Apply the workaround by disabling ReadPreferUnique. */
54*91f16700Schasinglulu	sysreg_bitfield_insert CORTEX_A510_CPUECTLR_EL1, CORTEX_A510_CPUECTLR_EL1_READPREFERUNIQUE_DISABLE, \
55*91f16700Schasinglulu		CORTEX_A510_CPUECTLR_EL1_READPREFERUNIQUE_SHIFT, CORTEX_A510_CPUECTLR_EL1_READPREFERUNIQUE_WIDTH
56*91f16700Schasingluluworkaround_reset_end cortex_a510, ERRATUM(2042739)
57*91f16700Schasinglulu
58*91f16700Schasinglulucheck_erratum_ls cortex_a510, ERRATUM(2042739), CPU_REV(0, 2)
59*91f16700Schasinglulu
60*91f16700Schasingluluworkaround_reset_start cortex_a510, ERRATUM(2080326), ERRATA_A510_2080326
61*91f16700Schasinglulu	/* Apply workaround */
62*91f16700Schasinglulu	mov x0, #1
63*91f16700Schasinglulu	msr S3_6_C15_C4_0, x0
64*91f16700Schasinglulu	isb
65*91f16700Schasinglulu
66*91f16700Schasinglulu	mov x0, #0x0100
67*91f16700Schasinglulu	movk x0, #0x0E08, lsl #16
68*91f16700Schasinglulu	msr S3_6_C15_C4_2, x0
69*91f16700Schasinglulu
70*91f16700Schasinglulu	mov x0, #0x0300
71*91f16700Schasinglulu	movk x0, #0x0F1F, lsl #16
72*91f16700Schasinglulu	movk x0, #0x0008, lsl #32
73*91f16700Schasinglulu	msr S3_6_C15_C4_3, x0
74*91f16700Schasinglulu
75*91f16700Schasinglulu	mov x0, #0x03F1
76*91f16700Schasinglulu	movk x0, #0x00C0, lsl #16
77*91f16700Schasinglulu	msr S3_6_C15_C4_1, x0
78*91f16700Schasinglulu
79*91f16700Schasinglulu	isb
80*91f16700Schasingluluworkaround_reset_end cortex_a510, ERRATUM(2080326)
81*91f16700Schasinglulu
82*91f16700Schasinglulucheck_erratum_range cortex_a510, ERRATUM(2080326), CPU_REV(0, 2), CPU_REV(0, 2)
83*91f16700Schasinglulu
84*91f16700Schasingluluworkaround_reset_start cortex_a510, ERRATUM(2172148), ERRATA_A510_2172148
85*91f16700Schasinglulu	/*
86*91f16700Schasinglulu	 * Force L2 allocation of transient lines by setting
87*91f16700Schasinglulu	 * CPUECTLR_EL1.RSCTL=0b01 and CPUECTLR_EL1.NTCTL=0b01.
88*91f16700Schasinglulu	 */
89*91f16700Schasinglulu	mrs	x0, CORTEX_A510_CPUECTLR_EL1
90*91f16700Schasinglulu	mov	x1, #1
91*91f16700Schasinglulu	bfi	x0, x1, #CORTEX_A510_CPUECTLR_EL1_RSCTL_SHIFT, #2
92*91f16700Schasinglulu	bfi	x0, x1, #CORTEX_A510_CPUECTLR_EL1_NTCTL_SHIFT, #2
93*91f16700Schasinglulu	msr	CORTEX_A510_CPUECTLR_EL1, x0
94*91f16700Schasingluluworkaround_reset_end cortex_a510, ERRATUM(2172148)
95*91f16700Schasinglulu
96*91f16700Schasinglulucheck_erratum_ls cortex_a510, ERRATUM(2172148), CPU_REV(1, 0)
97*91f16700Schasinglulu
98*91f16700Schasingluluworkaround_reset_start cortex_a510, ERRATUM(2218950), ERRATA_A510_2218950
99*91f16700Schasinglulu	/* Set bit 18 in CPUACTLR_EL1 */
100*91f16700Schasinglulu	sysreg_bitfield_insert CORTEX_A510_CPUACTLR_EL1, CORTEX_A510_CPUACTLR_EL1_ALIAS_LOADSTORE_DISABLE, \
101*91f16700Schasinglulu	CORTEX_A510_CPUACTLR_EL1_ALIAS_LOADSTORE_SHIFT, CORTEX_A510_CPUACTLR_EL1_ALIAS_LOADSTORE_WIDTH
102*91f16700Schasinglulu
103*91f16700Schasinglulu	/* Set bit 25 in CMPXACTLR_EL1 */
104*91f16700Schasinglulu	sysreg_bitfield_insert CORTEX_A510_CMPXACTLR_EL1, CORTEX_A510_CMPXACTLR_EL1_ALIAS_LOADSTORE_DISABLE, \
105*91f16700Schasinglulu	CORTEX_A510_CMPXACTLR_EL1_ALIAS_LOADSTORE_SHIFT, CORTEX_A510_CMPXACTLR_EL1_ALIAS_LOADSTORE_WIDTH
106*91f16700Schasinglulu
107*91f16700Schasingluluworkaround_reset_end cortex_a510, ERRATUM(2218950)
108*91f16700Schasinglulu
109*91f16700Schasinglulucheck_erratum_ls cortex_a510, ERRATUM(2218950), CPU_REV(1, 0)
110*91f16700Schasinglulu
111*91f16700Schasinglulu	/* --------------------------------------------------
112*91f16700Schasinglulu	 * This workaround is not a typical errata fix. MPMM
113*91f16700Schasinglulu	 * is disabled here, but this conflicts with the BL31
114*91f16700Schasinglulu	 * MPMM support. So in addition to simply disabling
115*91f16700Schasinglulu	 * the feature, a flag is set in the MPMM library
116*91f16700Schasinglulu	 * indicating that it should not be enabled even if
117*91f16700Schasinglulu	 * ENABLE_MPMM=1.
118*91f16700Schasinglulu	 * --------------------------------------------------
119*91f16700Schasinglulu	 */
120*91f16700Schasingluluworkaround_reset_start cortex_a510, ERRATUM(2250311), ERRATA_A510_2250311
121*91f16700Schasinglulu	/* Disable MPMM */
122*91f16700Schasinglulu	mrs	x0, CPUMPMMCR_EL3
123*91f16700Schasinglulu	bfm	x0, xzr, #0, #0 /* bfc instruction does not work in GCC */
124*91f16700Schasinglulu	msr	CPUMPMMCR_EL3, x0
125*91f16700Schasinglulu
126*91f16700Schasinglulu#if ENABLE_MPMM && IMAGE_BL31
127*91f16700Schasinglulu	/* If ENABLE_MPMM is set, tell the runtime lib to skip enabling it. */
128*91f16700Schasinglulu	bl mpmm_errata_disable
129*91f16700Schasinglulu#endif
130*91f16700Schasingluluworkaround_reset_end cortex_a510, ERRATUM(2250311)
131*91f16700Schasinglulu
132*91f16700Schasinglulucheck_erratum_ls cortex_a510, ERRATUM(2250311), CPU_REV(1, 0)
133*91f16700Schasinglulu
134*91f16700Schasingluluworkaround_reset_start cortex_a510, ERRATUM(2288014), ERRATA_A510_2288014
135*91f16700Schasinglulu	/* Apply the workaround by setting IMP_CPUACTLR_EL1[18] = 0b1. */
136*91f16700Schasinglulu	sysreg_bitfield_insert CORTEX_A510_CPUACTLR_EL1, CORTEX_A510_CPUACTLR_EL1_DATA_CORRUPT_DISABLE, \
137*91f16700Schasinglulu	CORTEX_A510_CPUACTLR_EL1_DATA_CORRUPT_SHIFT, CORTEX_A510_CPUACTLR_EL1_DATA_CORRUPT_WIDTH
138*91f16700Schasingluluworkaround_reset_end cortex_a510, ERRATUM(2288014)
139*91f16700Schasinglulu
140*91f16700Schasinglulucheck_erratum_ls cortex_a510, ERRATUM(2288014), CPU_REV(1, 0)
141*91f16700Schasinglulu
142*91f16700Schasingluluworkaround_reset_start cortex_a510, ERRATUM(2347730), ERRATA_A510_2347730
143*91f16700Schasinglulu	/*
144*91f16700Schasinglulu	 * Set CPUACTLR_EL1[17] to 1'b1, which disables
145*91f16700Schasinglulu	 * specific microarchitectural clock gating
146*91f16700Schasinglulu	 * behaviour.
147*91f16700Schasinglulu	 */
148*91f16700Schasinglulu	sysreg_bit_set CORTEX_A510_CPUACTLR_EL1, CORTEX_A510_CPUACTLR_EL1_BIT_17
149*91f16700Schasingluluworkaround_reset_end cortex_a510, ERRATUM(2347730)
150*91f16700Schasinglulu
151*91f16700Schasinglulucheck_erratum_ls cortex_a510, ERRATUM(2347730), CPU_REV(1, 1)
152*91f16700Schasinglulu
153*91f16700Schasingluluworkaround_reset_start cortex_a510, ERRATUM(2371937), ERRATA_A510_2371937
154*91f16700Schasinglulu	/*
155*91f16700Schasinglulu	 * Cacheable atomic operations can be forced
156*91f16700Schasinglulu	 * to be executed near by setting
157*91f16700Schasinglulu	 * IMP_CPUECTLR_EL1.ATOM=0b010. ATOM is found
158*91f16700Schasinglulu	 * in [40:38] of CPUECTLR_EL1.
159*91f16700Schasinglulu	 */
160*91f16700Schasinglulu	sysreg_bitfield_insert CORTEX_A510_CPUECTLR_EL1, CORTEX_A510_CPUECTLR_EL1_ATOM_EXECALLINSTRNEAR, \
161*91f16700Schasinglulu		CORTEX_A510_CPUECTLR_EL1_ATOM_SHIFT, CORTEX_A510_CPUECTLR_EL1_ATOM_WIDTH
162*91f16700Schasingluluworkaround_reset_end cortex_a510, ERRATUM(2371937)
163*91f16700Schasinglulu
164*91f16700Schasinglulucheck_erratum_ls cortex_a510, ERRATUM(2371937), CPU_REV(1, 1)
165*91f16700Schasinglulu
166*91f16700Schasingluluworkaround_reset_start cortex_a510, ERRATUM(2666669), ERRATA_A510_2666669
167*91f16700Schasinglulu	sysreg_bit_set CORTEX_A510_CPUACTLR_EL1, CORTEX_A510_CPUACTLR_EL1_BIT_38
168*91f16700Schasingluluworkaround_reset_end cortex_a510, ERRATUM(2666669)
169*91f16700Schasinglulu
170*91f16700Schasinglulucheck_erratum_ls cortex_a510, ERRATUM(2666669), CPU_REV(1, 1)
171*91f16700Schasinglulu
172*91f16700Schasinglulu.global erratum_cortex_a510_2684597_wa
173*91f16700Schasingluluworkaround_runtime_start cortex_a510, ERRATUM(2684597), ERRATA_A510_2684597, CORTEX_A510_MIDR
174*91f16700Schasinglulu	/*
175*91f16700Schasinglulu	 * Many assemblers do not yet understand the "tsb csync" mnemonic,
176*91f16700Schasinglulu	 * so use the equivalent hint instruction.
177*91f16700Schasinglulu	 */
178*91f16700Schasinglulu	hint	#18			/* tsb csync */
179*91f16700Schasingluluworkaround_runtime_end cortex_a510, ERRATUM(2684597)
180*91f16700Schasinglulu
181*91f16700Schasinglulucheck_erratum_ls cortex_a510, ERRATUM(2684597), CPU_REV(1, 2)
182*91f16700Schasinglulu
183*91f16700Schasinglulu/*
184*91f16700Schasinglulu * ERRATA_DSU_2313941 :
185*91f16700Schasinglulu * The errata is defined in dsu_helpers.S but applies to cortex_a510
186*91f16700Schasinglulu * as well. Henceforth creating symbolic names to the already existing errata
187*91f16700Schasinglulu * workaround functions to get them registered under the Errata Framework.
188*91f16700Schasinglulu */
189*91f16700Schasinglulu.equ check_erratum_cortex_a510_2313941, check_errata_dsu_2313941
190*91f16700Schasinglulu.equ erratum_cortex_a510_2313941_wa, errata_dsu_2313941_wa
191*91f16700Schasingluluadd_erratum_entry cortex_a510, ERRATUM(2313941), ERRATA_DSU_2313941, APPLY_AT_RESET
192*91f16700Schasinglulu
193*91f16700Schasinglulu	/* ----------------------------------------------------
194*91f16700Schasinglulu	 * HW will do the cache maintenance while powering down
195*91f16700Schasinglulu	 * ----------------------------------------------------
196*91f16700Schasinglulu	 */
197*91f16700Schasinglulufunc cortex_a510_core_pwr_dwn
198*91f16700Schasinglulu	/* ---------------------------------------------------
199*91f16700Schasinglulu	 * Enable CPU power down bit in power control register
200*91f16700Schasinglulu	 * ---------------------------------------------------
201*91f16700Schasinglulu	 */
202*91f16700Schasinglulu	sysreg_bit_set CORTEX_A510_CPUPWRCTLR_EL1, CORTEX_A510_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
203*91f16700Schasinglulu	isb
204*91f16700Schasinglulu	ret
205*91f16700Schasingluluendfunc cortex_a510_core_pwr_dwn
206*91f16700Schasinglulu
207*91f16700Schasingluluerrata_report_shim cortex_a510
208*91f16700Schasinglulu
209*91f16700Schasinglulucpu_reset_func_start cortex_a510
210*91f16700Schasinglulu	/* Disable speculative loads */
211*91f16700Schasinglulu	msr	SSBS, xzr
212*91f16700Schasinglulucpu_reset_func_end cortex_a510
213*91f16700Schasinglulu
214*91f16700Schasinglulu	/* ---------------------------------------------
215*91f16700Schasinglulu	 * This function provides Cortex-A510 specific
216*91f16700Schasinglulu	 * register information for crash reporting.
217*91f16700Schasinglulu	 * It needs to return with x6 pointing to
218*91f16700Schasinglulu	 * a list of register names in ascii and
219*91f16700Schasinglulu	 * x8 - x15 having values of registers to be
220*91f16700Schasinglulu	 * reported.
221*91f16700Schasinglulu	 * ---------------------------------------------
222*91f16700Schasinglulu	 */
223*91f16700Schasinglulu.section .rodata.cortex_a510_regs, "aS"
224*91f16700Schasinglulucortex_a510_regs:  /* The ascii list of register names to be reported */
225*91f16700Schasinglulu	.asciz	"cpuectlr_el1", ""
226*91f16700Schasinglulu
227*91f16700Schasinglulufunc cortex_a510_cpu_reg_dump
228*91f16700Schasinglulu	adr	x6, cortex_a510_regs
229*91f16700Schasinglulu	mrs	x8, CORTEX_A510_CPUECTLR_EL1
230*91f16700Schasinglulu	ret
231*91f16700Schasingluluendfunc cortex_a510_cpu_reg_dump
232*91f16700Schasinglulu
233*91f16700Schasingluludeclare_cpu_ops cortex_a510, CORTEX_A510_MIDR, \
234*91f16700Schasinglulu	cortex_a510_reset_func, \
235*91f16700Schasinglulu	cortex_a510_core_pwr_dwn
236