2 * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
8 #include <asm_macros.S>
9 #include <neoverse_n1.h>
11 #include <cpu_macros.S>
13 /* Hardware handled coherency */
14 #if HW_ASSISTED_COHERENCY == 0
15 #error "Neoverse N1 must be compiled with HW_ASSISTED_COHERENCY enabled"
18 /* 64-bit only core */
19 #if CTX_INCLUDE_AARCH32_REGS == 1
20 #error "Neoverse-N1 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
23 /* --------------------------------------------------
24 * Errata Workaround for Neoverse N1 Erratum 1043202.
25 * This applies to revision r0p0 and r1p0 of Neoverse N1.
27 * x0: variant[4:7] and revision[0:3] of current cpu.
28 * Shall clobber: x0-x17
29 * --------------------------------------------------
31 func errata_n1_1043202_wa
32 /* Compare x0 against revision r1p0 */
34 bl check_errata_1043202
37 /* Apply instruction patching sequence */
49 endfunc errata_n1_1043202_wa
51 func check_errata_1043202
52 /* Applies to r0p0 and r1p0 */
55 endfunc check_errata_1043202
57 /* --------------------------------------------------
58 * Disable speculative loads if Neoverse N1 supports
62 * --------------------------------------------------
64 func neoverse_n1_disable_speculative_loads
65 /* Check if the PE implements SSBS */
66 mrs x0, id_aa64pfr1_el1
67 tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT)
70 /* Disable speculative loads */
75 endfunc neoverse_n1_disable_speculative_loads
77 /* --------------------------------------------------
78 * Errata Workaround for Neoverse N1 Errata #1073348
79 * This applies to revision r0p0 and r1p0 of Neoverse N1.
81 * x0: variant[4:7] and revision[0:3] of current cpu.
82 * Shall clobber: x0-x17
83 * --------------------------------------------------
85 func errata_n1_1073348_wa
86 /* Compare x0 against revision r1p0 */
88 bl check_errata_1073348
90 mrs x1, NEOVERSE_N1_CPUACTLR_EL1
91 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_6
92 msr NEOVERSE_N1_CPUACTLR_EL1, x1
95 endfunc errata_n1_1073348_wa
97 func check_errata_1073348
98 /* Applies to r0p0 and r1p0 */
101 endfunc check_errata_1073348
103 /* --------------------------------------------------
104 * Errata Workaround for Neoverse N1 Errata #1130799
105 * This applies to revision <=r2p0 of Neoverse N1.
107 * x0: variant[4:7] and revision[0:3] of current cpu.
108 * Shall clobber: x0-x17
109 * --------------------------------------------------
111 func errata_n1_1130799_wa
112 /* Compare x0 against revision r2p0 */
114 bl check_errata_1130799
116 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1
117 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_59
118 msr NEOVERSE_N1_CPUACTLR2_EL1, x1
121 endfunc errata_n1_1130799_wa
123 func check_errata_1130799
124 /* Applies to <=r2p0 */
127 endfunc check_errata_1130799
129 /* --------------------------------------------------
130 * Errata Workaround for Neoverse N1 Errata #1165347
131 * This applies to revision <=r2p0 of Neoverse N1.
133 * x0: variant[4:7] and revision[0:3] of current cpu.
134 * Shall clobber: x0-x17
135 * --------------------------------------------------
137 func errata_n1_1165347_wa
138 /* Compare x0 against revision r2p0 */
140 bl check_errata_1165347
142 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1
143 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_0
144 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_15
145 msr NEOVERSE_N1_CPUACTLR2_EL1, x1
148 endfunc errata_n1_1165347_wa
150 func check_errata_1165347
151 /* Applies to <=r2p0 */
154 endfunc check_errata_1165347
156 /* --------------------------------------------------
157 * Errata Workaround for Neoverse N1 Errata #1207823
158 * This applies to revision <=r2p0 of Neoverse N1.
160 * x0: variant[4:7] and revision[0:3] of current cpu.
161 * Shall clobber: x0-x17
162 * --------------------------------------------------
164 func errata_n1_1207823_wa
165 /* Compare x0 against revision r2p0 */
167 bl check_errata_1207823
169 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1
170 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_11
171 msr NEOVERSE_N1_CPUACTLR2_EL1, x1
174 endfunc errata_n1_1207823_wa
176 func check_errata_1207823
177 /* Applies to <=r2p0 */
180 endfunc check_errata_1207823
182 /* --------------------------------------------------
183 * Errata Workaround for Neoverse N1 Errata #1220197
184 * This applies to revision <=r2p0 of Neoverse N1.
186 * x0: variant[4:7] and revision[0:3] of current cpu.
187 * Shall clobber: x0-x17
188 * --------------------------------------------------
190 func errata_n1_1220197_wa
191 /* Compare x0 against revision r2p0 */
193 bl check_errata_1220197
195 mrs x1, NEOVERSE_N1_CPUECTLR_EL1
196 orr x1, x1, NEOVERSE_N1_WS_THR_L2_MASK
197 msr NEOVERSE_N1_CPUECTLR_EL1, x1
200 endfunc errata_n1_1220197_wa
202 func check_errata_1220197
203 /* Applies to <=r2p0 */
206 endfunc check_errata_1220197
208 /* --------------------------------------------------
209 * Errata Workaround for Neoverse N1 Errata #1257314
210 * This applies to revision <=r3p0 of Neoverse N1.
212 * x0: variant[4:7] and revision[0:3] of current cpu.
213 * Shall clobber: x0-x17
214 * --------------------------------------------------
216 func errata_n1_1257314_wa
217 /* Compare x0 against revision r3p0 */
219 bl check_errata_1257314
221 mrs x1, NEOVERSE_N1_CPUACTLR3_EL1
222 orr x1, x1, NEOVERSE_N1_CPUACTLR3_EL1_BIT_10
223 msr NEOVERSE_N1_CPUACTLR3_EL1, x1
226 endfunc errata_n1_1257314_wa
228 func check_errata_1257314
229 /* Applies to <=r3p0 */
232 endfunc check_errata_1257314
234 /* --------------------------------------------------
235 * Errata Workaround for Neoverse N1 Errata #1262606
236 * This applies to revision <=r3p0 of Neoverse N1.
238 * x0: variant[4:7] and revision[0:3] of current cpu.
239 * Shall clobber: x0-x17
240 * --------------------------------------------------
242 func errata_n1_1262606_wa
243 /* Compare x0 against revision r3p0 */
245 bl check_errata_1262606
247 mrs x1, NEOVERSE_N1_CPUACTLR_EL1
248 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13
249 msr NEOVERSE_N1_CPUACTLR_EL1, x1
252 endfunc errata_n1_1262606_wa
254 func check_errata_1262606
255 /* Applies to <=r3p0 */
258 endfunc check_errata_1262606
260 /* --------------------------------------------------
261 * Errata Workaround for Neoverse N1 Errata #1262888
262 * This applies to revision <=r3p0 of Neoverse N1.
264 * x0: variant[4:7] and revision[0:3] of current cpu.
265 * Shall clobber: x0-x17
266 * --------------------------------------------------
268 func errata_n1_1262888_wa
269 /* Compare x0 against revision r3p0 */
271 bl check_errata_1262888
273 mrs x1, NEOVERSE_N1_CPUECTLR_EL1
274 orr x1, x1, NEOVERSE_N1_CPUECTLR_EL1_MM_TLBPF_DIS_BIT
275 msr NEOVERSE_N1_CPUECTLR_EL1, x1
278 endfunc errata_n1_1262888_wa
280 func check_errata_1262888
281 /* Applies to <=r3p0 */
284 endfunc check_errata_1262888
286 /* --------------------------------------------------
287 * Errata Workaround for Neoverse N1 Errata #1275112
288 * This applies to revision <=r3p0 of Neoverse N1.
290 * x0: variant[4:7] and revision[0:3] of current cpu.
291 * Shall clobber: x0-x17
292 * --------------------------------------------------
294 func errata_n1_1275112_wa
295 /* Compare x0 against revision r3p0 */
297 bl check_errata_1275112
299 mrs x1, NEOVERSE_N1_CPUACTLR_EL1
300 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13
301 msr NEOVERSE_N1_CPUACTLR_EL1, x1
304 endfunc errata_n1_1275112_wa
306 func check_errata_1275112
307 /* Applies to <=r3p0 */
310 endfunc check_errata_1275112
312 /* --------------------------------------------------
313 * Errata Workaround for Neoverse N1 Erratum 1315703.
314 * This applies to revision <= r3p0 of Neoverse N1.
316 * x0: variant[4:7] and revision[0:3] of current cpu.
317 * Shall clobber: x0-x17
318 * --------------------------------------------------
320 func errata_n1_1315703_wa
321 /* Compare x0 against revision r3p1 */
323 bl check_errata_1315703
326 mrs x0, NEOVERSE_N1_CPUACTLR2_EL1
327 orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_16
328 msr NEOVERSE_N1_CPUACTLR2_EL1, x0
332 endfunc errata_n1_1315703_wa
334 func check_errata_1315703
335 /* Applies to everything <= r3p0. */
338 endfunc check_errata_1315703
340 func neoverse_n1_reset_func
343 bl neoverse_n1_disable_speculative_loads
345 /* Forces all cacheable atomic instructions to be near */
346 mrs x0, NEOVERSE_N1_CPUACTLR2_EL1
347 orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_2
348 msr NEOVERSE_N1_CPUACTLR2_EL1, x0
354 #if ERRATA_N1_1043202
356 bl errata_n1_1043202_wa
359 #if ERRATA_N1_1073348
361 bl errata_n1_1073348_wa
364 #if ERRATA_N1_1130799
366 bl errata_n1_1130799_wa
369 #if ERRATA_N1_1165347
371 bl errata_n1_1165347_wa
374 #if ERRATA_N1_1207823
376 bl errata_n1_1207823_wa
379 #if ERRATA_N1_1220197
381 bl errata_n1_1220197_wa
384 #if ERRATA_N1_1257314
386 bl errata_n1_1257314_wa
389 #if ERRATA_N1_1262606
391 bl errata_n1_1262606_wa
394 #if ERRATA_N1_1262888
396 bl errata_n1_1262888_wa
399 #if ERRATA_N1_1275112
401 bl errata_n1_1275112_wa
404 #if ERRATA_N1_1315703
406 bl errata_n1_1315703_wa
410 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
412 orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT
415 /* Make sure accesses from EL0/EL1 are not trapped to EL2 */
417 orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT
420 /* Enable group0 counters */
421 mov x0, #NEOVERSE_N1_AMU_GROUP0_MASK
422 msr CPUAMCNTENSET_EL0, x0
425 #if ERRATA_DSU_936184
426 bl errata_dsu_936184_wa
431 endfunc neoverse_n1_reset_func
433 /* ---------------------------------------------
434 * HW will do the cache maintenance while powering down
435 * ---------------------------------------------
437 func neoverse_n1_core_pwr_dwn
438 /* ---------------------------------------------
439 * Enable CPU power down bit in power control register
440 * ---------------------------------------------
442 mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1
443 orr x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK
444 msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0
447 endfunc neoverse_n1_core_pwr_dwn
451 * Errata printing function for Neoverse N1. Must follow AAPCS.
453 func neoverse_n1_errata_report
454 stp x8, x30, [sp, #-16]!
460 * Report all errata. The revision-variant information is passed to
461 * checking functions of each errata.
463 report_errata ERRATA_N1_1043202, neoverse_n1, 1043202
464 report_errata ERRATA_N1_1073348, neoverse_n1, 1073348
465 report_errata ERRATA_N1_1130799, neoverse_n1, 1130799
466 report_errata ERRATA_N1_1165347, neoverse_n1, 1165347
467 report_errata ERRATA_N1_1207823, neoverse_n1, 1207823
468 report_errata ERRATA_N1_1220197, neoverse_n1, 1220197
469 report_errata ERRATA_N1_1257314, neoverse_n1, 1257314
470 report_errata ERRATA_N1_1262606, neoverse_n1, 1262606
471 report_errata ERRATA_N1_1262888, neoverse_n1, 1262888
472 report_errata ERRATA_N1_1275112, neoverse_n1, 1275112
473 report_errata ERRATA_N1_1315703, neoverse_n1, 1315703
474 report_errata ERRATA_DSU_936184, neoverse_n1, dsu_936184
476 ldp x8, x30, [sp], #16
478 endfunc neoverse_n1_errata_report
481 /* ---------------------------------------------
482 * This function provides neoverse_n1 specific
483 * register information for crash reporting.
484 * It needs to return with x6 pointing to
485 * a list of register names in ascii and
486 * x8 - x15 having values of registers to be
488 * ---------------------------------------------
490 .section .rodata.neoverse_n1_regs, "aS"
491 neoverse_n1_regs: /* The ascii list of register names to be reported */
492 .asciz "cpuectlr_el1", ""
494 func neoverse_n1_cpu_reg_dump
495 adr x6, neoverse_n1_regs
496 mrs x8, NEOVERSE_N1_CPUECTLR_EL1
498 endfunc neoverse_n1_cpu_reg_dump
500 declare_cpu_ops neoverse_n1, NEOVERSE_N1_MIDR, \
501 neoverse_n1_reset_func, \
502 neoverse_n1_core_pwr_dwn