blob: e5f83aa6a81626069bd95f434ee8dbc1d5384d50 [file] [log] [blame]
johpow01a3810e82021-05-18 15:23:31 -05001/*
johpow01de7b5242022-01-04 16:15:18 -06002 * Copyright (c) 2022, ARM Limited. All rights reserved.
johpow01a3810e82021-05-18 15:23:31 -05003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <common/bl_common.h>
10#include <cortex_a510.h>
11#include <cpu_macros.S>
12#include <plat_macros.S>
13
14/* Hardware handled coherency */
15#if HW_ASSISTED_COHERENCY == 0
johpow01de7b5242022-01-04 16:15:18 -060016#error "Cortex-A510 must be compiled with HW_ASSISTED_COHERENCY enabled"
johpow01a3810e82021-05-18 15:23:31 -050017#endif
18
19/* 64-bit only core */
20#if CTX_INCLUDE_AARCH32_REGS == 1
johpow01de7b5242022-01-04 16:15:18 -060021#error "Cortex-A510 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
johpow01a3810e82021-05-18 15:23:31 -050022#endif
23
johpow01de7b5242022-01-04 16:15:18 -060024 /* --------------------------------------------------
25 * Errata Workaround for Cortex-A510 Errata #1922240.
26 * This applies only to revision r0p0 (fixed in r0p1)
27 * x0: variant[4:7] and revision[0:3] of current cpu.
28 * Shall clobber: x0, x1, x17
29 * --------------------------------------------------
30 */
31func errata_cortex_a510_1922240_wa
32 /* Check workaround compatibility. */
33 mov x17, x30
34 bl check_errata_1922240
35 cbz x0, 1f
36
37 /* Apply the workaround by setting IMP_CMPXACTLR_EL1[11:10] = 0b11. */
38 mrs x0, CORTEX_A510_CMPXACTLR_EL1
39 mov x1, #3
40 bfi x0, x1, #10, #2
41 msr CORTEX_A510_CMPXACTLR_EL1, x0
42
431:
44 ret x17
45endfunc errata_cortex_a510_1922240_wa
46
47func check_errata_1922240
48 /* Applies to r0p0 only */
49 mov x1, #0x00
50 b cpu_rev_var_ls
51endfunc check_errata_1922240
52
johpow0149f60dd2022-01-06 14:54:49 -060053 /* --------------------------------------------------
54 * Errata Workaround for Cortex-A510 Errata #2288014.
55 * This applies only to revisions r0p0, r0p1, r0p2,
56 * r0p3 and r1p0. (fixed in r1p1)
57 * x0: variant[4:7] and revision[0:3] of current cpu.
58 * Shall clobber: x0, x1, x17
59 * --------------------------------------------------
60 */
61func errata_cortex_a510_2288014_wa
62 /* Check workaround compatibility. */
63 mov x17, x30
64 bl check_errata_2288014
65 cbz x0, 1f
66
67 /* Apply the workaround by setting IMP_CPUACTLR_EL1[18] = 0b1. */
68 mrs x0, CORTEX_A510_CPUACTLR_EL1
69 mov x1, #1
70 bfi x0, x1, #18, #1
71 msr CORTEX_A510_CPUACTLR_EL1, x0
72
731:
74 ret x17
75endfunc errata_cortex_a510_2288014_wa
76
77func check_errata_2288014
78 /* Applies to r1p0 and below */
79 mov x1, #0x10
80 b cpu_rev_var_ls
81endfunc check_errata_2288014
82
johpow018276f252022-01-07 17:12:31 -060083 /* --------------------------------------------------
84 * Errata Workaround for Cortex-A510 Errata #2042739.
85 * This applies only to revisions r0p0, r0p1 and r0p2.
86 * (fixed in r0p3)
87 * x0: variant[4:7] and revision[0:3] of current cpu.
88 * Shall clobber: x0, x1, x17
89 * --------------------------------------------------
90 */
91func errata_cortex_a510_2042739_wa
92 /* Check workaround compatibility. */
93 mov x17, x30
94 bl check_errata_2042739
95 cbz x0, 1f
96
97 /* Apply the workaround by disabling ReadPreferUnique. */
98 mrs x0, CORTEX_A510_CPUECTLR_EL1
99 mov x1, #CORTEX_A510_CPUECTLR_EL1_READPREFERUNIQUE_DISABLE
100 bfi x0, x1, #CORTEX_A510_CPUECTLR_EL1_READPREFERUNIQUE_SHIFT, #1
101 msr CORTEX_A510_CPUECTLR_EL1, x0
102
1031:
104 ret x17
105endfunc errata_cortex_a510_2042739_wa
106
107func check_errata_2042739
108 /* Applies to revisions r0p0 - r0p2 */
109 mov x1, #0x02
110 b cpu_rev_var_ls
111endfunc check_errata_2042739
112
johpow015a993002022-01-11 17:54:41 -0600113 /* --------------------------------------------------
114 * Errata Workaround for Cortex-A510 Errata #2041909.
115 * This applies only to revision r0p2 and it is fixed in
116 * r0p3. The issue is also present in r0p0 and r0p1 but
117 * there is no workaround in those revisions.
118 * x0: variant[4:7] and revision[0:3] of current cpu.
119 * Shall clobber: x0, x1, x2, x17
120 * --------------------------------------------------
121 */
122func errata_cortex_a510_2041909_wa
123 /* Check workaround compatibility. */
124 mov x17, x30
125 bl check_errata_2041909
126 cbz x0, 1f
127
128 /* Apply workaround */
129 mov x0, xzr
130 msr S3_6_C15_C4_0, x0
131 isb
132
133 mov x0, #0x8500000
134 msr S3_6_C15_C4_2, x0
135
136 mov x0, #0x1F700000
137 movk x0, #0x8, lsl #32
138 msr S3_6_C15_C4_3, x0
139
140 mov x0, #0x3F1
141 movk x0, #0x110, lsl #16
142 msr S3_6_C15_C4_1, x0
143 isb
144
1451:
146 ret x17
147endfunc errata_cortex_a510_2041909_wa
148
149func check_errata_2041909
150 /* Applies only to revision r0p2 */
151 mov x1, #0x02
152 mov x2, #0x02
153 b cpu_rev_var_range
154endfunc check_errata_2041909
155
johpow013ba9cb22022-02-13 21:00:10 -0600156 /* --------------------------------------------------
157 * Errata Workaround for Cortex-A510 Errata #2250311.
158 * This applies only to revisions r0p0, r0p1, r0p2,
159 * r0p3 and r1p0, and is fixed in r1p1.
160 * This workaround is not a typical errata fix. MPMM
161 * is disabled here, but this conflicts with the BL31
162 * MPMM support. So in addition to simply disabling
163 * the feature, a flag is set in the MPMM library
164 * indicating that it should not be enabled even if
165 * ENABLE_MPMM=1.
166 * x0: variant[4:7] and revision[0:3] of current cpu.
167 * Shall clobber: x0, x1, x17
168 * --------------------------------------------------
169 */
170func errata_cortex_a510_2250311_wa
171 /* Check workaround compatibility. */
172 mov x17, x30
173 bl check_errata_2250311
174 cbz x0, 1f
175
176 /* Disable MPMM */
177 mrs x0, CPUMPMMCR_EL3
178 bfm x0, xzr, #0, #0 /* bfc instruction does not work in GCC */
179 msr CPUMPMMCR_EL3, x0
180
181#if ENABLE_MPMM && IMAGE_BL31
182 /* If ENABLE_MPMM is set, tell the runtime lib to skip enabling it. */
183 bl mpmm_errata_disable
184#endif
185
1861:
187 ret x17
188endfunc errata_cortex_a510_2250311_wa
189
190func check_errata_2250311
191 /* Applies to r1p0 and lower */
192 mov x1, #0x10
193 b cpu_rev_var_ls
194endfunc check_errata_2250311
195
johpow013ead2952022-02-14 20:19:08 -0600196 /* --------------------------------------------------
197 * Errata Workaround for Cortex-A510 Errata #2218950.
198 * This applies only to revisions r0p0, r0p1, r0p2,
199 * r0p3 and r1p0, and is fixed in r1p1.
200 * x0: variant[4:7] and revision[0:3] of current cpu.
201 * Shall clobber: x0, x1, x17
202 * --------------------------------------------------
203 */
204func errata_cortex_a510_2218950_wa
205 /* Check workaround compatibility. */
206 mov x17, x30
207 bl check_errata_2218950
208 cbz x0, 1f
209
210 /* Source register for BFI */
211 mov x1, #1
212
213 /* Set bit 18 in CPUACTLR_EL1 */
214 mrs x0, CORTEX_A510_CPUACTLR_EL1
215 bfi x0, x1, #18, #1
216 msr CORTEX_A510_CPUACTLR_EL1, x0
217
218 /* Set bit 25 in CMPXACTLR_EL1 */
219 mrs x0, CORTEX_A510_CMPXACTLR_EL1
220 bfi x0, x1, #25, #1
221 msr CORTEX_A510_CMPXACTLR_EL1, x0
222
2231:
224 ret x17
225endfunc errata_cortex_a510_2218950_wa
226
227func check_errata_2218950
228 /* Applies to r1p0 and lower */
229 mov x1, #0x10
230 b cpu_rev_var_ls
231endfunc check_errata_2218950
232
johpow01a3810e82021-05-18 15:23:31 -0500233 /* ----------------------------------------------------
234 * HW will do the cache maintenance while powering down
235 * ----------------------------------------------------
236 */
237func cortex_a510_core_pwr_dwn
238 /* ---------------------------------------------------
239 * Enable CPU power down bit in power control register
240 * ---------------------------------------------------
241 */
242 mrs x0, CORTEX_A510_CPUPWRCTLR_EL1
243 orr x0, x0, #CORTEX_A510_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
244 msr CORTEX_A510_CPUPWRCTLR_EL1, x0
245 isb
246 ret
247endfunc cortex_a510_core_pwr_dwn
248
249 /*
johpow01de7b5242022-01-04 16:15:18 -0600250 * Errata printing function for Cortex-A510. Must follow AAPCS.
johpow01a3810e82021-05-18 15:23:31 -0500251 */
252#if REPORT_ERRATA
253func cortex_a510_errata_report
johpow01de7b5242022-01-04 16:15:18 -0600254 stp x8, x30, [sp, #-16]!
255
256 bl cpu_get_rev_var
257 mov x8, x0
258
259 /*
260 * Report all errata. The revision-variant information is passed to
261 * checking functions of each errata.
262 */
263 report_errata ERRATA_A510_1922240, cortex_a510, 1922240
johpow0149f60dd2022-01-06 14:54:49 -0600264 report_errata ERRATA_A510_2288014, cortex_a510, 2288014
johpow018276f252022-01-07 17:12:31 -0600265 report_errata ERRATA_A510_2042739, cortex_a510, 2042739
johpow015a993002022-01-11 17:54:41 -0600266 report_errata ERRATA_A510_2041909, cortex_a510, 2041909
johpow013ba9cb22022-02-13 21:00:10 -0600267 report_errata ERRATA_A510_2250311, cortex_a510, 2250311
johpow013ead2952022-02-14 20:19:08 -0600268 report_errata ERRATA_A510_2218950, cortex_a510, 2218950
johpow01de7b5242022-01-04 16:15:18 -0600269
270 ldp x8, x30, [sp], #16
johpow01a3810e82021-05-18 15:23:31 -0500271 ret
272endfunc cortex_a510_errata_report
273#endif
274
275func cortex_a510_reset_func
johpow01de7b5242022-01-04 16:15:18 -0600276 mov x19, x30
277
johpow01a3810e82021-05-18 15:23:31 -0500278 /* Disable speculative loads */
279 msr SSBS, xzr
280 isb
johpow01de7b5242022-01-04 16:15:18 -0600281
282 /* Get the CPU revision and stash it in x18. */
283 bl cpu_get_rev_var
284 mov x18, x0
285
286#if ERRATA_A510_1922240
287 mov x0, x18
288 bl errata_cortex_a510_1922240_wa
289#endif
290
johpow0149f60dd2022-01-06 14:54:49 -0600291#if ERRATA_A510_2288014
292 mov x0, x18
293 bl errata_cortex_a510_2288014_wa
294#endif
295
johpow018276f252022-01-07 17:12:31 -0600296#if ERRATA_A510_2042739
297 mov x0, x18
298 bl errata_cortex_a510_2042739_wa
299#endif
300
johpow015a993002022-01-11 17:54:41 -0600301#if ERRATA_A510_2041909
302 mov x0, x18
303 bl errata_cortex_a510_2041909_wa
304#endif
305
johpow013ba9cb22022-02-13 21:00:10 -0600306#if ERRATA_A510_2250311
307 mov x0, x18
308 bl errata_cortex_a510_2250311_wa
309#endif
310
johpow013ead2952022-02-14 20:19:08 -0600311#if ERRATA_A510_2218950
312 mov x0, x18
313 bl errata_cortex_a510_2218950_wa
314#endif
315
johpow01de7b5242022-01-04 16:15:18 -0600316 ret x19
johpow01a3810e82021-05-18 15:23:31 -0500317endfunc cortex_a510_reset_func
318
319 /* ---------------------------------------------
320 * This function provides Cortex-A510 specific
321 * register information for crash reporting.
322 * It needs to return with x6 pointing to
323 * a list of register names in ascii and
324 * x8 - x15 having values of registers to be
325 * reported.
326 * ---------------------------------------------
327 */
328.section .rodata.cortex_a510_regs, "aS"
329cortex_a510_regs: /* The ascii list of register names to be reported */
330 .asciz "cpuectlr_el1", ""
331
332func cortex_a510_cpu_reg_dump
333 adr x6, cortex_a510_regs
334 mrs x8, CORTEX_A510_CPUECTLR_EL1
335 ret
336endfunc cortex_a510_cpu_reg_dump
337
338declare_cpu_ops cortex_a510, CORTEX_A510_MIDR, \
339 cortex_a510_reset_func, \
340 cortex_a510_core_pwr_dwn