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>
14 /* Hardware handled coherency */
15 #if HW_ASSISTED_COHERENCY == 0
16 #error "Neoverse N1 must be compiled with HW_ASSISTED_COHERENCY enabled"
19 /* 64-bit only core */
20 #if CTX_INCLUDE_AARCH32_REGS == 1
21 #error "Neoverse-N1 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
25 .global neoverse_n1_errata_ic_trap_handler
28 /* --------------------------------------------------
29 * Errata Workaround for Neoverse N1 Erratum 1043202.
30 * This applies to revision r0p0 and r1p0 of Neoverse N1.
32 * x0: variant[4:7] and revision[0:3] of current cpu.
33 * Shall clobber: x0-x17
34 * --------------------------------------------------
36 func errata_n1_1043202_wa
37 /* Compare x0 against revision r1p0 */
39 bl check_errata_1043202
42 /* Apply instruction patching sequence */
54 endfunc errata_n1_1043202_wa
56 func check_errata_1043202
57 /* Applies to r0p0 and r1p0 */
60 endfunc check_errata_1043202
62 /* --------------------------------------------------
63 * Disable speculative loads if Neoverse N1 supports
67 * --------------------------------------------------
69 func neoverse_n1_disable_speculative_loads
70 /* Check if the PE implements SSBS */
71 mrs x0, id_aa64pfr1_el1
72 tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT)
75 /* Disable speculative loads */
80 endfunc neoverse_n1_disable_speculative_loads
82 /* --------------------------------------------------
83 * Errata Workaround for Neoverse N1 Errata #1073348
84 * This applies to revision r0p0 and r1p0 of Neoverse N1.
86 * x0: variant[4:7] and revision[0:3] of current cpu.
87 * Shall clobber: x0-x17
88 * --------------------------------------------------
90 func errata_n1_1073348_wa
91 /* Compare x0 against revision r1p0 */
93 bl check_errata_1073348
95 mrs x1, NEOVERSE_N1_CPUACTLR_EL1
96 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_6
97 msr NEOVERSE_N1_CPUACTLR_EL1, x1
100 endfunc errata_n1_1073348_wa
102 func check_errata_1073348
103 /* Applies to r0p0 and r1p0 */
106 endfunc check_errata_1073348
108 /* --------------------------------------------------
109 * Errata Workaround for Neoverse N1 Errata #1130799
110 * This applies to revision <=r2p0 of Neoverse N1.
112 * x0: variant[4:7] and revision[0:3] of current cpu.
113 * Shall clobber: x0-x17
114 * --------------------------------------------------
116 func errata_n1_1130799_wa
117 /* Compare x0 against revision r2p0 */
119 bl check_errata_1130799
121 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1
122 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_59
123 msr NEOVERSE_N1_CPUACTLR2_EL1, x1
126 endfunc errata_n1_1130799_wa
128 func check_errata_1130799
129 /* Applies to <=r2p0 */
132 endfunc check_errata_1130799
134 /* --------------------------------------------------
135 * Errata Workaround for Neoverse N1 Errata #1165347
136 * This applies to revision <=r2p0 of Neoverse N1.
138 * x0: variant[4:7] and revision[0:3] of current cpu.
139 * Shall clobber: x0-x17
140 * --------------------------------------------------
142 func errata_n1_1165347_wa
143 /* Compare x0 against revision r2p0 */
145 bl check_errata_1165347
147 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1
148 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_0
149 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_15
150 msr NEOVERSE_N1_CPUACTLR2_EL1, x1
153 endfunc errata_n1_1165347_wa
155 func check_errata_1165347
156 /* Applies to <=r2p0 */
159 endfunc check_errata_1165347
161 /* --------------------------------------------------
162 * Errata Workaround for Neoverse N1 Errata #1207823
163 * This applies to revision <=r2p0 of Neoverse N1.
165 * x0: variant[4:7] and revision[0:3] of current cpu.
166 * Shall clobber: x0-x17
167 * --------------------------------------------------
169 func errata_n1_1207823_wa
170 /* Compare x0 against revision r2p0 */
172 bl check_errata_1207823
174 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1
175 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_11
176 msr NEOVERSE_N1_CPUACTLR2_EL1, x1
179 endfunc errata_n1_1207823_wa
181 func check_errata_1207823
182 /* Applies to <=r2p0 */
185 endfunc check_errata_1207823
187 /* --------------------------------------------------
188 * Errata Workaround for Neoverse N1 Errata #1220197
189 * This applies to revision <=r2p0 of Neoverse N1.
191 * x0: variant[4:7] and revision[0:3] of current cpu.
192 * Shall clobber: x0-x17
193 * --------------------------------------------------
195 func errata_n1_1220197_wa
196 /* Compare x0 against revision r2p0 */
198 bl check_errata_1220197
200 mrs x1, NEOVERSE_N1_CPUECTLR_EL1
201 orr x1, x1, NEOVERSE_N1_WS_THR_L2_MASK
202 msr NEOVERSE_N1_CPUECTLR_EL1, x1
205 endfunc errata_n1_1220197_wa
207 func check_errata_1220197
208 /* Applies to <=r2p0 */
211 endfunc check_errata_1220197
213 /* --------------------------------------------------
214 * Errata Workaround for Neoverse N1 Errata #1257314
215 * This applies to revision <=r3p0 of Neoverse N1.
217 * x0: variant[4:7] and revision[0:3] of current cpu.
218 * Shall clobber: x0-x17
219 * --------------------------------------------------
221 func errata_n1_1257314_wa
222 /* Compare x0 against revision r3p0 */
224 bl check_errata_1257314
226 mrs x1, NEOVERSE_N1_CPUACTLR3_EL1
227 orr x1, x1, NEOVERSE_N1_CPUACTLR3_EL1_BIT_10
228 msr NEOVERSE_N1_CPUACTLR3_EL1, x1
231 endfunc errata_n1_1257314_wa
233 func check_errata_1257314
234 /* Applies to <=r3p0 */
237 endfunc check_errata_1257314
239 /* --------------------------------------------------
240 * Errata Workaround for Neoverse N1 Errata #1262606
241 * This applies to revision <=r3p0 of Neoverse N1.
243 * x0: variant[4:7] and revision[0:3] of current cpu.
244 * Shall clobber: x0-x17
245 * --------------------------------------------------
247 func errata_n1_1262606_wa
248 /* Compare x0 against revision r3p0 */
250 bl check_errata_1262606
252 mrs x1, NEOVERSE_N1_CPUACTLR_EL1
253 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13
254 msr NEOVERSE_N1_CPUACTLR_EL1, x1
257 endfunc errata_n1_1262606_wa
259 func check_errata_1262606
260 /* Applies to <=r3p0 */
263 endfunc check_errata_1262606
265 /* --------------------------------------------------
266 * Errata Workaround for Neoverse N1 Errata #1262888
267 * This applies to revision <=r3p0 of Neoverse N1.
269 * x0: variant[4:7] and revision[0:3] of current cpu.
270 * Shall clobber: x0-x17
271 * --------------------------------------------------
273 func errata_n1_1262888_wa
274 /* Compare x0 against revision r3p0 */
276 bl check_errata_1262888
278 mrs x1, NEOVERSE_N1_CPUECTLR_EL1
279 orr x1, x1, NEOVERSE_N1_CPUECTLR_EL1_MM_TLBPF_DIS_BIT
280 msr NEOVERSE_N1_CPUECTLR_EL1, x1
283 endfunc errata_n1_1262888_wa
285 func check_errata_1262888
286 /* Applies to <=r3p0 */
289 endfunc check_errata_1262888
291 /* --------------------------------------------------
292 * Errata Workaround for Neoverse N1 Errata #1275112
293 * This applies to revision <=r3p0 of Neoverse N1.
295 * x0: variant[4:7] and revision[0:3] of current cpu.
296 * Shall clobber: x0-x17
297 * --------------------------------------------------
299 func errata_n1_1275112_wa
300 /* Compare x0 against revision r3p0 */
302 bl check_errata_1275112
304 mrs x1, NEOVERSE_N1_CPUACTLR_EL1
305 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13
306 msr NEOVERSE_N1_CPUACTLR_EL1, x1
309 endfunc errata_n1_1275112_wa
311 func check_errata_1275112
312 /* Applies to <=r3p0 */
315 endfunc check_errata_1275112
317 /* --------------------------------------------------
318 * Errata Workaround for Neoverse N1 Erratum 1315703.
319 * This applies to revision <= r3p0 of Neoverse N1.
321 * x0: variant[4:7] and revision[0:3] of current cpu.
322 * Shall clobber: x0-x17
323 * --------------------------------------------------
325 func errata_n1_1315703_wa
326 /* Compare x0 against revision r3p1 */
328 bl check_errata_1315703
331 mrs x0, NEOVERSE_N1_CPUACTLR2_EL1
332 orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_16
333 msr NEOVERSE_N1_CPUACTLR2_EL1, x0
337 endfunc errata_n1_1315703_wa
339 func check_errata_1315703
340 /* Applies to everything <= r3p0. */
343 endfunc check_errata_1315703
345 /* --------------------------------------------------
346 * Errata Workaround for Neoverse N1 Erratum 1542419.
347 * This applies to revisions r3p0 - r4p0 of Neoverse N1
349 * x0: variant[4:7] and revision[0:3] of current cpu.
350 * Shall clobber: x0-x17
351 * --------------------------------------------------
353 func errata_n1_1542419_wa
354 /* Compare x0 against revision r3p0 and r4p0 */
356 bl check_errata_1542419
359 /* Apply instruction patching sequence */
366 ldr x0, =0x08000020007D
371 endfunc errata_n1_1542419_wa
373 func check_errata_1542419
374 /* Applies to everything r3p0 - r4p0. */
378 endfunc check_errata_1542419
380 func neoverse_n1_reset_func
383 bl neoverse_n1_disable_speculative_loads
385 /* Forces all cacheable atomic instructions to be near */
386 mrs x0, NEOVERSE_N1_CPUACTLR2_EL1
387 orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_2
388 msr NEOVERSE_N1_CPUACTLR2_EL1, x0
394 #if ERRATA_N1_1043202
396 bl errata_n1_1043202_wa
399 #if ERRATA_N1_1073348
401 bl errata_n1_1073348_wa
404 #if ERRATA_N1_1130799
406 bl errata_n1_1130799_wa
409 #if ERRATA_N1_1165347
411 bl errata_n1_1165347_wa
414 #if ERRATA_N1_1207823
416 bl errata_n1_1207823_wa
419 #if ERRATA_N1_1220197
421 bl errata_n1_1220197_wa
424 #if ERRATA_N1_1257314
426 bl errata_n1_1257314_wa
429 #if ERRATA_N1_1262606
431 bl errata_n1_1262606_wa
434 #if ERRATA_N1_1262888
436 bl errata_n1_1262888_wa
439 #if ERRATA_N1_1275112
441 bl errata_n1_1275112_wa
444 #if ERRATA_N1_1315703
446 bl errata_n1_1315703_wa
449 #if ERRATA_N1_1542419
451 bl errata_n1_1542419_wa
455 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
457 orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT
460 /* Make sure accesses from EL0/EL1 are not trapped to EL2 */
462 orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT
465 /* Enable group0 counters */
466 mov x0, #NEOVERSE_N1_AMU_GROUP0_MASK
467 msr CPUAMCNTENSET_EL0, x0
470 #if ERRATA_DSU_936184
471 bl errata_dsu_936184_wa
476 endfunc neoverse_n1_reset_func
478 /* ---------------------------------------------
479 * HW will do the cache maintenance while powering down
480 * ---------------------------------------------
482 func neoverse_n1_core_pwr_dwn
483 /* ---------------------------------------------
484 * Enable CPU power down bit in power control register
485 * ---------------------------------------------
487 mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1
488 orr x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK
489 msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0
492 endfunc neoverse_n1_core_pwr_dwn
496 * Errata printing function for Neoverse N1. Must follow AAPCS.
498 func neoverse_n1_errata_report
499 stp x8, x30, [sp, #-16]!
505 * Report all errata. The revision-variant information is passed to
506 * checking functions of each errata.
508 report_errata ERRATA_N1_1043202, neoverse_n1, 1043202
509 report_errata ERRATA_N1_1073348, neoverse_n1, 1073348
510 report_errata ERRATA_N1_1130799, neoverse_n1, 1130799
511 report_errata ERRATA_N1_1165347, neoverse_n1, 1165347
512 report_errata ERRATA_N1_1207823, neoverse_n1, 1207823
513 report_errata ERRATA_N1_1220197, neoverse_n1, 1220197
514 report_errata ERRATA_N1_1257314, neoverse_n1, 1257314
515 report_errata ERRATA_N1_1262606, neoverse_n1, 1262606
516 report_errata ERRATA_N1_1262888, neoverse_n1, 1262888
517 report_errata ERRATA_N1_1275112, neoverse_n1, 1275112
518 report_errata ERRATA_N1_1315703, neoverse_n1, 1315703
519 report_errata ERRATA_N1_1542419, neoverse_n1, 1542419
520 report_errata ERRATA_DSU_936184, neoverse_n1, dsu_936184
522 ldp x8, x30, [sp], #16
524 endfunc neoverse_n1_errata_report
528 * Handle trap of EL0 IC IVAU instructions to EL3 by executing a TLB
529 * inner-shareable invalidation to an arbitrary address followed by a DSB.
531 * x1: Exception Syndrome
533 func neoverse_n1_errata_ic_trap_handler
534 cmp x1, #NEOVERSE_N1_EC_IC_TRAP
539 # Skip the IC instruction itself
544 ldp x0, x1, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0]
545 ldp x2, x3, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2]
546 ldp x4, x5, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X4]
547 ldr x30, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_LR]
549 #if IMAGE_BL31 && RAS_EXTENSION
551 * Issue Error Synchronization Barrier to synchronize SErrors before
552 * exiting EL3. We're running with EAs unmasked, so any synchronized
553 * errors would be taken immediately; therefore no need to inspect
561 endfunc neoverse_n1_errata_ic_trap_handler
563 /* ---------------------------------------------
564 * This function provides neoverse_n1 specific
565 * register information for crash reporting.
566 * It needs to return with x6 pointing to
567 * a list of register names in ascii and
568 * x8 - x15 having values of registers to be
570 * ---------------------------------------------
572 .section .rodata.neoverse_n1_regs, "aS"
573 neoverse_n1_regs: /* The ascii list of register names to be reported */
574 .asciz "cpuectlr_el1", ""
576 func neoverse_n1_cpu_reg_dump
577 adr x6, neoverse_n1_regs
578 mrs x8, NEOVERSE_N1_CPUECTLR_EL1
580 endfunc neoverse_n1_cpu_reg_dump
582 declare_cpu_ops_eh neoverse_n1, NEOVERSE_N1_MIDR, \
583 neoverse_n1_reset_func, \
584 neoverse_n1_errata_ic_trap_handler, \
585 neoverse_n1_core_pwr_dwn