blob: 9c97cf60aba6e52b2c1e982adc8a1496fe5fd582 [file] [log] [blame]
Isla Mitchellea84d6b2017-08-03 16:04:46 +01001/*
johpow01f1a84f52020-10-07 14:33:15 -05002 * Copyright (c) 2017-2021, Arm Limited and Contributors. All rights reserved.
Isla Mitchellea84d6b2017-08-03 16:04:46 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
Dimitris Papastamos89736dd2018-02-13 11:28:02 +00009#include <cpuamu.h>
Isla Mitchellea84d6b2017-08-03 16:04:46 +010010#include <cpu_macros.S>
laurenw-arm94accd32019-08-20 15:51:24 -050011#include <context.h>
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +010012#include <neoverse_n1.h>
Dimitris Papastamos89736dd2018-02-13 11:28:02 +000013
John Tsichritzisfe6df392019-03-19 17:20:52 +000014/* Hardware handled coherency */
15#if HW_ASSISTED_COHERENCY == 0
16#error "Neoverse N1 must be compiled with HW_ASSISTED_COHERENCY enabled"
17#endif
18
John Tsichritzis7557c662019-06-03 13:54:30 +010019/* 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"
22#endif
23
laurenw-arm94accd32019-08-20 15:51:24 -050024 .global neoverse_n1_errata_ic_trap_handler
laurenw-arm94accd32019-08-20 15:51:24 -050025
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010026/* --------------------------------------------------
Andre Przywarab9347402019-05-20 14:57:06 +010027 * Errata Workaround for Neoverse N1 Erratum 1043202.
John Tsichritzis56369c12019-02-19 13:49:06 +000028 * This applies to revision r0p0 and r1p0 of Neoverse N1.
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010029 * Inputs:
30 * x0: variant[4:7] and revision[0:3] of current cpu.
31 * Shall clobber: x0-x17
32 * --------------------------------------------------
33 */
John Tsichritzis56369c12019-02-19 13:49:06 +000034func errata_n1_1043202_wa
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010035 /* Compare x0 against revision r1p0 */
36 mov x17, x30
37 bl check_errata_1043202
38 cbz x0, 1f
39
40 /* Apply instruction patching sequence */
41 ldr x0, =0x0
42 msr CPUPSELR_EL3, x0
43 ldr x0, =0xF3BF8F2F
44 msr CPUPOR_EL3, x0
45 ldr x0, =0xFFFFFFFF
46 msr CPUPMR_EL3, x0
47 ldr x0, =0x800200071
48 msr CPUPCR_EL3, x0
laurenw-arm33e58f32019-08-19 11:06:18 -050049 isb
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100501:
51 ret x17
John Tsichritzis56369c12019-02-19 13:49:06 +000052endfunc errata_n1_1043202_wa
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010053
54func check_errata_1043202
55 /* Applies to r0p0 and r1p0 */
56 mov x1, #0x10
57 b cpu_rev_var_ls
58endfunc check_errata_1043202
59
Sami Mujawara8722e92019-05-10 14:28:37 +010060/* --------------------------------------------------
61 * Disable speculative loads if Neoverse N1 supports
62 * SSBS.
63 *
64 * Shall clobber: x0.
65 * --------------------------------------------------
66 */
67func neoverse_n1_disable_speculative_loads
68 /* Check if the PE implements SSBS */
69 mrs x0, id_aa64pfr1_el1
70 tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT)
71 b.eq 1f
72
73 /* Disable speculative loads */
74 msr SSBS, xzr
Sami Mujawara8722e92019-05-10 14:28:37 +010075
761:
77 ret
78endfunc neoverse_n1_disable_speculative_loads
79
Andre Przywarab9347402019-05-20 14:57:06 +010080/* --------------------------------------------------
lauwal01bd555f42019-06-24 11:23:50 -050081 * Errata Workaround for Neoverse N1 Errata #1073348
82 * This applies to revision r0p0 and r1p0 of Neoverse N1.
83 * Inputs:
84 * x0: variant[4:7] and revision[0:3] of current cpu.
85 * Shall clobber: x0-x17
86 * --------------------------------------------------
87 */
88func errata_n1_1073348_wa
89 /* Compare x0 against revision r1p0 */
90 mov x17, x30
91 bl check_errata_1073348
92 cbz x0, 1f
93 mrs x1, NEOVERSE_N1_CPUACTLR_EL1
94 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_6
95 msr NEOVERSE_N1_CPUACTLR_EL1, x1
lauwal01bd555f42019-06-24 11:23:50 -0500961:
97 ret x17
98endfunc errata_n1_1073348_wa
99
100func check_errata_1073348
101 /* Applies to r0p0 and r1p0 */
102 mov x1, #0x10
103 b cpu_rev_var_ls
104endfunc check_errata_1073348
105
106/* --------------------------------------------------
lauwal01363ee3c2019-06-24 11:28:34 -0500107 * Errata Workaround for Neoverse N1 Errata #1130799
108 * This applies to revision <=r2p0 of Neoverse N1.
109 * Inputs:
110 * x0: variant[4:7] and revision[0:3] of current cpu.
111 * Shall clobber: x0-x17
112 * --------------------------------------------------
113 */
114func errata_n1_1130799_wa
115 /* Compare x0 against revision r2p0 */
116 mov x17, x30
117 bl check_errata_1130799
118 cbz x0, 1f
119 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1
120 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_59
121 msr NEOVERSE_N1_CPUACTLR2_EL1, x1
lauwal01363ee3c2019-06-24 11:28:34 -05001221:
123 ret x17
124endfunc errata_n1_1130799_wa
125
126func check_errata_1130799
127 /* Applies to <=r2p0 */
128 mov x1, #0x20
129 b cpu_rev_var_ls
130endfunc check_errata_1130799
131
132/* --------------------------------------------------
lauwal01f2adb132019-06-24 11:32:40 -0500133 * Errata Workaround for Neoverse N1 Errata #1165347
134 * This applies to revision <=r2p0 of Neoverse N1.
135 * Inputs:
136 * x0: variant[4:7] and revision[0:3] of current cpu.
137 * Shall clobber: x0-x17
138 * --------------------------------------------------
139 */
140func errata_n1_1165347_wa
141 /* Compare x0 against revision r2p0 */
142 mov x17, x30
143 bl check_errata_1165347
144 cbz x0, 1f
145 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1
146 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_0
147 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_15
148 msr NEOVERSE_N1_CPUACTLR2_EL1, x1
lauwal01f2adb132019-06-24 11:32:40 -05001491:
150 ret x17
151endfunc errata_n1_1165347_wa
152
153func check_errata_1165347
154 /* Applies to <=r2p0 */
155 mov x1, #0x20
156 b cpu_rev_var_ls
157endfunc check_errata_1165347
158
159/* --------------------------------------------------
lauwal01e1590442019-06-24 11:35:37 -0500160 * Errata Workaround for Neoverse N1 Errata #1207823
161 * This applies to revision <=r2p0 of Neoverse N1.
162 * Inputs:
163 * x0: variant[4:7] and revision[0:3] of current cpu.
164 * Shall clobber: x0-x17
165 * --------------------------------------------------
166 */
167func errata_n1_1207823_wa
168 /* Compare x0 against revision r2p0 */
169 mov x17, x30
170 bl check_errata_1207823
171 cbz x0, 1f
172 mrs x1, NEOVERSE_N1_CPUACTLR2_EL1
173 orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_11
174 msr NEOVERSE_N1_CPUACTLR2_EL1, x1
lauwal01e1590442019-06-24 11:35:37 -05001751:
176 ret x17
177endfunc errata_n1_1207823_wa
178
179func check_errata_1207823
180 /* Applies to <=r2p0 */
181 mov x1, #0x20
182 b cpu_rev_var_ls
183endfunc check_errata_1207823
184
185/* --------------------------------------------------
lauwal01197f14c2019-06-24 11:38:53 -0500186 * Errata Workaround for Neoverse N1 Errata #1220197
187 * This applies to revision <=r2p0 of Neoverse N1.
188 * Inputs:
189 * x0: variant[4:7] and revision[0:3] of current cpu.
190 * Shall clobber: x0-x17
191 * --------------------------------------------------
192 */
193func errata_n1_1220197_wa
194 /* Compare x0 against revision r2p0 */
195 mov x17, x30
196 bl check_errata_1220197
197 cbz x0, 1f
198 mrs x1, NEOVERSE_N1_CPUECTLR_EL1
199 orr x1, x1, NEOVERSE_N1_WS_THR_L2_MASK
200 msr NEOVERSE_N1_CPUECTLR_EL1, x1
lauwal01197f14c2019-06-24 11:38:53 -05002011:
202 ret x17
203endfunc errata_n1_1220197_wa
204
205func check_errata_1220197
206 /* Applies to <=r2p0 */
207 mov x1, #0x20
208 b cpu_rev_var_ls
209endfunc check_errata_1220197
210
211/* --------------------------------------------------
lauwal0107c2a232019-06-24 11:42:02 -0500212 * Errata Workaround for Neoverse N1 Errata #1257314
213 * This applies to revision <=r3p0 of Neoverse N1.
214 * Inputs:
215 * x0: variant[4:7] and revision[0:3] of current cpu.
216 * Shall clobber: x0-x17
217 * --------------------------------------------------
218 */
219func errata_n1_1257314_wa
220 /* Compare x0 against revision r3p0 */
221 mov x17, x30
222 bl check_errata_1257314
223 cbz x0, 1f
224 mrs x1, NEOVERSE_N1_CPUACTLR3_EL1
225 orr x1, x1, NEOVERSE_N1_CPUACTLR3_EL1_BIT_10
226 msr NEOVERSE_N1_CPUACTLR3_EL1, x1
lauwal0107c2a232019-06-24 11:42:02 -05002271:
228 ret x17
229endfunc errata_n1_1257314_wa
230
231func check_errata_1257314
232 /* Applies to <=r3p0 */
233 mov x1, #0x30
234 b cpu_rev_var_ls
235endfunc check_errata_1257314
236
237/* --------------------------------------------------
lauwal0142771af2019-06-24 11:44:58 -0500238 * Errata Workaround for Neoverse N1 Errata #1262606
239 * This applies to revision <=r3p0 of Neoverse N1.
240 * Inputs:
241 * x0: variant[4:7] and revision[0:3] of current cpu.
242 * Shall clobber: x0-x17
243 * --------------------------------------------------
244 */
245func errata_n1_1262606_wa
246 /* Compare x0 against revision r3p0 */
247 mov x17, x30
248 bl check_errata_1262606
249 cbz x0, 1f
250 mrs x1, NEOVERSE_N1_CPUACTLR_EL1
251 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13
252 msr NEOVERSE_N1_CPUACTLR_EL1, x1
lauwal0142771af2019-06-24 11:44:58 -05002531:
254 ret x17
255endfunc errata_n1_1262606_wa
256
257func check_errata_1262606
258 /* Applies to <=r3p0 */
259 mov x1, #0x30
260 b cpu_rev_var_ls
261endfunc check_errata_1262606
262
263/* --------------------------------------------------
lauwal0100396bf2019-06-24 11:47:30 -0500264 * Errata Workaround for Neoverse N1 Errata #1262888
265 * This applies to revision <=r3p0 of Neoverse N1.
266 * Inputs:
267 * x0: variant[4:7] and revision[0:3] of current cpu.
268 * Shall clobber: x0-x17
269 * --------------------------------------------------
270 */
271func errata_n1_1262888_wa
272 /* Compare x0 against revision r3p0 */
273 mov x17, x30
274 bl check_errata_1262888
275 cbz x0, 1f
276 mrs x1, NEOVERSE_N1_CPUECTLR_EL1
277 orr x1, x1, NEOVERSE_N1_CPUECTLR_EL1_MM_TLBPF_DIS_BIT
278 msr NEOVERSE_N1_CPUECTLR_EL1, x1
lauwal0100396bf2019-06-24 11:47:30 -05002791:
280 ret x17
281endfunc errata_n1_1262888_wa
282
283func check_errata_1262888
284 /* Applies to <=r3p0 */
285 mov x1, #0x30
286 b cpu_rev_var_ls
287endfunc check_errata_1262888
288
289/* --------------------------------------------------
lauwal01644b6ed2019-06-24 11:49:01 -0500290 * Errata Workaround for Neoverse N1 Errata #1275112
291 * This applies to revision <=r3p0 of Neoverse N1.
292 * Inputs:
293 * x0: variant[4:7] and revision[0:3] of current cpu.
294 * Shall clobber: x0-x17
295 * --------------------------------------------------
296 */
297func errata_n1_1275112_wa
298 /* Compare x0 against revision r3p0 */
299 mov x17, x30
300 bl check_errata_1275112
301 cbz x0, 1f
302 mrs x1, NEOVERSE_N1_CPUACTLR_EL1
303 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13
304 msr NEOVERSE_N1_CPUACTLR_EL1, x1
lauwal01644b6ed2019-06-24 11:49:01 -05003051:
306 ret x17
307endfunc errata_n1_1275112_wa
308
309func check_errata_1275112
310 /* Applies to <=r3p0 */
311 mov x1, #0x30
312 b cpu_rev_var_ls
313endfunc check_errata_1275112
314
315/* --------------------------------------------------
Andre Przywarab9347402019-05-20 14:57:06 +0100316 * Errata Workaround for Neoverse N1 Erratum 1315703.
317 * This applies to revision <= r3p0 of Neoverse N1.
318 * Inputs:
319 * x0: variant[4:7] and revision[0:3] of current cpu.
320 * Shall clobber: x0-x17
321 * --------------------------------------------------
322 */
323func errata_n1_1315703_wa
324 /* Compare x0 against revision r3p1 */
325 mov x17, x30
326 bl check_errata_1315703
327 cbz x0, 1f
328
329 mrs x0, NEOVERSE_N1_CPUACTLR2_EL1
330 orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_16
331 msr NEOVERSE_N1_CPUACTLR2_EL1, x0
Andre Przywarab9347402019-05-20 14:57:06 +0100332
3331:
334 ret x17
335endfunc errata_n1_1315703_wa
336
337func check_errata_1315703
338 /* Applies to everything <= r3p0. */
339 mov x1, #0x30
340 b cpu_rev_var_ls
341endfunc check_errata_1315703
342
laurenw-arm94accd32019-08-20 15:51:24 -0500343/* --------------------------------------------------
344 * Errata Workaround for Neoverse N1 Erratum 1542419.
345 * This applies to revisions r3p0 - r4p0 of Neoverse N1
346 * Inputs:
347 * x0: variant[4:7] and revision[0:3] of current cpu.
348 * Shall clobber: x0-x17
349 * --------------------------------------------------
350 */
351func errata_n1_1542419_wa
352 /* Compare x0 against revision r3p0 and r4p0 */
353 mov x17, x30
354 bl check_errata_1542419
355 cbz x0, 1f
356
laurenw-armcd9a9432019-10-11 15:45:24 -0500357 /* Apply instruction patching sequence */
laurenw-arm94accd32019-08-20 15:51:24 -0500358 ldr x0, =0x0
359 msr CPUPSELR_EL3, x0
360 ldr x0, =0xEE670D35
361 msr CPUPOR_EL3, x0
362 ldr x0, =0xFFFF0FFF
363 msr CPUPMR_EL3, x0
364 ldr x0, =0x08000020007D
365 msr CPUPCR_EL3, x0
366 isb
3671:
368 ret x17
369endfunc errata_n1_1542419_wa
370
371func check_errata_1542419
372 /* Applies to everything r3p0 - r4p0. */
373 mov x1, #0x30
374 mov x2, #0x40
375 b cpu_rev_var_range
376endfunc check_errata_1542419
377
johpow01e2428fd2020-08-05 12:27:12 -0500378 /* --------------------------------------------------
379 * Errata Workaround for Neoverse N1 Errata #1868343.
380 * This applies to revision <= r4p0 of Neoverse N1.
381 * This workaround is the same as the workaround for
382 * errata 1262606 and 1275112 but applies to a wider
383 * revision range.
384 * Inputs:
385 * x0: variant[4:7] and revision[0:3] of current cpu.
386 * Shall clobber: x0-x17
387 * --------------------------------------------------
388 */
389func errata_n1_1868343_wa
390 /*
391 * Compare x0 against revision r4p0
392 */
393 mov x17, x30
394 bl check_errata_1868343
395 cbz x0, 1f
396 mrs x1, NEOVERSE_N1_CPUACTLR_EL1
397 orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13
398 msr NEOVERSE_N1_CPUACTLR_EL1, x1
399 isb
4001:
401 ret x17
402endfunc errata_n1_1868343_wa
403
404func check_errata_1868343
405 /* Applies to everything <= r4p0 */
406 mov x1, #0x40
407 b cpu_rev_var_ls
408endfunc check_errata_1868343
409
johpow01f1a84f52020-10-07 14:33:15 -0500410 /* --------------------------------------------------
411 * Errata Workaround for Neoverse N1 Errata #1946160.
412 * This applies to revisions r3p0, r3p1, r4p0, and
413 * r4p1 of Neoverse N1. It also exists in r0p0, r1p0,
414 * and r2p0 but there is no fix in these revisions.
415 * Inputs:
416 * x0: variant[4:7] and revision[0:3] of current cpu.
417 * Shall clobber: x0-x17
418 * --------------------------------------------------
419 */
420func errata_n1_1946160_wa
421 /*
422 * Compare x0 against r3p0 - r4p1
423 */
424 mov x17, x30
425 bl check_errata_1946160
426 cbz x0, 1f
427
428 mov x0, #3
429 msr S3_6_C15_C8_0, x0
430 ldr x0, =0x10E3900002
431 msr S3_6_C15_C8_2, x0
432 ldr x0, =0x10FFF00083
433 msr S3_6_C15_C8_3, x0
434 ldr x0, =0x2001003FF
435 msr S3_6_C15_C8_1, x0
436
437 mov x0, #4
438 msr S3_6_C15_C8_0, x0
439 ldr x0, =0x10E3800082
440 msr S3_6_C15_C8_2, x0
441 ldr x0, =0x10FFF00083
442 msr S3_6_C15_C8_3, x0
443 ldr x0, =0x2001003FF
444 msr S3_6_C15_C8_1, x0
445
446 mov x0, #5
447 msr S3_6_C15_C8_0, x0
448 ldr x0, =0x10E3800200
449 msr S3_6_C15_C8_2, x0
450 ldr x0, =0x10FFF003E0
451 msr S3_6_C15_C8_3, x0
452 ldr x0, =0x2001003FF
453 msr S3_6_C15_C8_1, x0
454
455 isb
4561:
457 ret x17
458endfunc errata_n1_1946160_wa
459
460func check_errata_1946160
461 /* Applies to r3p0 - r4p1. */
462 mov x1, #0x30
463 mov x2, #0x41
464 b cpu_rev_var_range
465endfunc check_errata_1946160
466
John Tsichritzis56369c12019-02-19 13:49:06 +0000467func neoverse_n1_reset_func
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100468 mov x19, x30
John Tsichritzis1f9ff492019-03-04 16:41:26 +0000469
Sami Mujawara8722e92019-05-10 14:28:37 +0100470 bl neoverse_n1_disable_speculative_loads
John Tsichritzis1f9ff492019-03-04 16:41:26 +0000471
Louis Mayencourtb58142b2019-04-18 14:34:11 +0100472 /* Forces all cacheable atomic instructions to be near */
473 mrs x0, NEOVERSE_N1_CPUACTLR2_EL1
474 orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_2
475 msr NEOVERSE_N1_CPUACTLR2_EL1, x0
476 isb
477
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100478 bl cpu_get_rev_var
479 mov x18, x0
480
John Tsichritzis56369c12019-02-19 13:49:06 +0000481#if ERRATA_N1_1043202
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100482 mov x0, x18
John Tsichritzis56369c12019-02-19 13:49:06 +0000483 bl errata_n1_1043202_wa
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100484#endif
485
lauwal01bd555f42019-06-24 11:23:50 -0500486#if ERRATA_N1_1073348
487 mov x0, x18
488 bl errata_n1_1073348_wa
489#endif
490
lauwal01363ee3c2019-06-24 11:28:34 -0500491#if ERRATA_N1_1130799
492 mov x0, x18
493 bl errata_n1_1130799_wa
494#endif
495
lauwal01f2adb132019-06-24 11:32:40 -0500496#if ERRATA_N1_1165347
497 mov x0, x18
498 bl errata_n1_1165347_wa
499#endif
500
lauwal01e1590442019-06-24 11:35:37 -0500501#if ERRATA_N1_1207823
502 mov x0, x18
503 bl errata_n1_1207823_wa
504#endif
505
lauwal01197f14c2019-06-24 11:38:53 -0500506#if ERRATA_N1_1220197
507 mov x0, x18
508 bl errata_n1_1220197_wa
509#endif
510
lauwal0107c2a232019-06-24 11:42:02 -0500511#if ERRATA_N1_1257314
512 mov x0, x18
513 bl errata_n1_1257314_wa
514#endif
515
lauwal0142771af2019-06-24 11:44:58 -0500516#if ERRATA_N1_1262606
517 mov x0, x18
518 bl errata_n1_1262606_wa
519#endif
520
lauwal0100396bf2019-06-24 11:47:30 -0500521#if ERRATA_N1_1262888
522 mov x0, x18
523 bl errata_n1_1262888_wa
524#endif
525
lauwal01644b6ed2019-06-24 11:49:01 -0500526#if ERRATA_N1_1275112
527 mov x0, x18
528 bl errata_n1_1275112_wa
529#endif
530
Andre Przywarab9347402019-05-20 14:57:06 +0100531#if ERRATA_N1_1315703
532 mov x0, x18
533 bl errata_n1_1315703_wa
534#endif
535
laurenw-arm94accd32019-08-20 15:51:24 -0500536#if ERRATA_N1_1542419
537 mov x0, x18
538 bl errata_n1_1542419_wa
539#endif
540
johpow01e2428fd2020-08-05 12:27:12 -0500541#if ERRATA_N1_1868343
542 mov x0, x18
543 bl errata_n1_1868343_wa
544#endif
545
johpow01f1a84f52020-10-07 14:33:15 -0500546#if ERRATA_N1_1946160
547 mov x0, x18
548 bl errata_n1_1946160_wa
549#endif
550
Dimitris Papastamos89736dd2018-02-13 11:28:02 +0000551#if ENABLE_AMU
552 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
553 mrs x0, actlr_el3
John Tsichritzis56369c12019-02-19 13:49:06 +0000554 orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT
Dimitris Papastamos89736dd2018-02-13 11:28:02 +0000555 msr actlr_el3, x0
Dimitris Papastamos89736dd2018-02-13 11:28:02 +0000556
557 /* Make sure accesses from EL0/EL1 are not trapped to EL2 */
558 mrs x0, actlr_el2
John Tsichritzis56369c12019-02-19 13:49:06 +0000559 orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT
Dimitris Papastamos89736dd2018-02-13 11:28:02 +0000560 msr actlr_el2, x0
Dimitris Papastamos89736dd2018-02-13 11:28:02 +0000561
562 /* Enable group0 counters */
John Tsichritzis56369c12019-02-19 13:49:06 +0000563 mov x0, #NEOVERSE_N1_AMU_GROUP0_MASK
Dimitris Papastamos89736dd2018-02-13 11:28:02 +0000564 msr CPUAMCNTENSET_EL0, x0
Dimitris Papastamos89736dd2018-02-13 11:28:02 +0000565#endif
Louis Mayencourt8b8b13b2019-06-10 16:43:39 +0100566
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +0100567#if NEOVERSE_Nx_EXTERNAL_LLC
Manish Pandey3880a362020-01-24 11:54:44 +0000568 /* Some system may have External LLC, core needs to be made aware */
569 mrs x0, NEOVERSE_N1_CPUECTLR_EL1
570 orr x0, x0, NEOVERSE_N1_CPUECTLR_EL1_EXTLLC_BIT
571 msr NEOVERSE_N1_CPUECTLR_EL1, x0
572#endif
573
Louis Mayencourt8b8b13b2019-06-10 16:43:39 +0100574#if ERRATA_DSU_936184
575 bl errata_dsu_936184_wa
576#endif
577
lauwal01cf12f262019-06-27 11:03:25 -0500578 isb
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100579 ret x19
John Tsichritzis56369c12019-02-19 13:49:06 +0000580endfunc neoverse_n1_reset_func
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100581
582 /* ---------------------------------------------
583 * HW will do the cache maintenance while powering down
584 * ---------------------------------------------
585 */
John Tsichritzis56369c12019-02-19 13:49:06 +0000586func neoverse_n1_core_pwr_dwn
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100587 /* ---------------------------------------------
588 * Enable CPU power down bit in power control register
589 * ---------------------------------------------
590 */
John Tsichritzis56369c12019-02-19 13:49:06 +0000591 mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1
592 orr x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK
593 msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100594 isb
595 ret
John Tsichritzis56369c12019-02-19 13:49:06 +0000596endfunc neoverse_n1_core_pwr_dwn
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100597
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100598#if REPORT_ERRATA
599/*
John Tsichritzis56369c12019-02-19 13:49:06 +0000600 * Errata printing function for Neoverse N1. Must follow AAPCS.
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100601 */
John Tsichritzis56369c12019-02-19 13:49:06 +0000602func neoverse_n1_errata_report
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100603 stp x8, x30, [sp, #-16]!
604
605 bl cpu_get_rev_var
606 mov x8, x0
607
608 /*
609 * Report all errata. The revision-variant information is passed to
610 * checking functions of each errata.
611 */
John Tsichritzis56369c12019-02-19 13:49:06 +0000612 report_errata ERRATA_N1_1043202, neoverse_n1, 1043202
lauwal01bd555f42019-06-24 11:23:50 -0500613 report_errata ERRATA_N1_1073348, neoverse_n1, 1073348
lauwal01363ee3c2019-06-24 11:28:34 -0500614 report_errata ERRATA_N1_1130799, neoverse_n1, 1130799
lauwal01f2adb132019-06-24 11:32:40 -0500615 report_errata ERRATA_N1_1165347, neoverse_n1, 1165347
lauwal01e1590442019-06-24 11:35:37 -0500616 report_errata ERRATA_N1_1207823, neoverse_n1, 1207823
lauwal01197f14c2019-06-24 11:38:53 -0500617 report_errata ERRATA_N1_1220197, neoverse_n1, 1220197
lauwal0107c2a232019-06-24 11:42:02 -0500618 report_errata ERRATA_N1_1257314, neoverse_n1, 1257314
lauwal0142771af2019-06-24 11:44:58 -0500619 report_errata ERRATA_N1_1262606, neoverse_n1, 1262606
lauwal0100396bf2019-06-24 11:47:30 -0500620 report_errata ERRATA_N1_1262888, neoverse_n1, 1262888
lauwal01644b6ed2019-06-24 11:49:01 -0500621 report_errata ERRATA_N1_1275112, neoverse_n1, 1275112
Andre Przywarab9347402019-05-20 14:57:06 +0100622 report_errata ERRATA_N1_1315703, neoverse_n1, 1315703
laurenw-arm94accd32019-08-20 15:51:24 -0500623 report_errata ERRATA_N1_1542419, neoverse_n1, 1542419
johpow01e2428fd2020-08-05 12:27:12 -0500624 report_errata ERRATA_N1_1868343, neoverse_n1, 1868343
johpow01f1a84f52020-10-07 14:33:15 -0500625 report_errata ERRATA_N1_1946160, neoverse_n1, 1946160
Louis Mayencourt8b8b13b2019-06-10 16:43:39 +0100626 report_errata ERRATA_DSU_936184, neoverse_n1, dsu_936184
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100627
628 ldp x8, x30, [sp], #16
629 ret
John Tsichritzis56369c12019-02-19 13:49:06 +0000630endfunc neoverse_n1_errata_report
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100631#endif
laurenw-arm94accd32019-08-20 15:51:24 -0500632
633/*
634 * Handle trap of EL0 IC IVAU instructions to EL3 by executing a TLB
635 * inner-shareable invalidation to an arbitrary address followed by a DSB.
636 *
637 * x1: Exception Syndrome
638 */
639func neoverse_n1_errata_ic_trap_handler
640 cmp x1, #NEOVERSE_N1_EC_IC_TRAP
641 b.ne 1f
642 tlbi vae3is, xzr
643 dsb sy
644
laurenw-armcd9a9432019-10-11 15:45:24 -0500645 # Skip the IC instruction itself
646 mrs x3, elr_el3
647 add x3, x3, #4
648 msr elr_el3, x3
laurenw-arm94accd32019-08-20 15:51:24 -0500649
650 ldp x0, x1, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0]
651 ldp x2, x3, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2]
652 ldp x4, x5, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X4]
653 ldr x30, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_LR]
654
655#if IMAGE_BL31 && RAS_EXTENSION
656 /*
657 * Issue Error Synchronization Barrier to synchronize SErrors before
658 * exiting EL3. We're running with EAs unmasked, so any synchronized
659 * errors would be taken immediately; therefore no need to inspect
660 * DISR_EL1 register.
661 */
662 esb
663#endif
Anthony Steinhauser0f7e6012020-01-07 15:44:06 -0800664 exception_return
laurenw-arm94accd32019-08-20 15:51:24 -05006651:
666 ret
667endfunc neoverse_n1_errata_ic_trap_handler
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100668
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100669 /* ---------------------------------------------
John Tsichritzis56369c12019-02-19 13:49:06 +0000670 * This function provides neoverse_n1 specific
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100671 * register information for crash reporting.
672 * It needs to return with x6 pointing to
673 * a list of register names in ascii and
674 * x8 - x15 having values of registers to be
675 * reported.
676 * ---------------------------------------------
677 */
John Tsichritzis56369c12019-02-19 13:49:06 +0000678.section .rodata.neoverse_n1_regs, "aS"
679neoverse_n1_regs: /* The ascii list of register names to be reported */
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100680 .asciz "cpuectlr_el1", ""
681
John Tsichritzis56369c12019-02-19 13:49:06 +0000682func neoverse_n1_cpu_reg_dump
683 adr x6, neoverse_n1_regs
684 mrs x8, NEOVERSE_N1_CPUECTLR_EL1
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100685 ret
John Tsichritzis56369c12019-02-19 13:49:06 +0000686endfunc neoverse_n1_cpu_reg_dump
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100687
laurenw-arm94accd32019-08-20 15:51:24 -0500688declare_cpu_ops_eh neoverse_n1, NEOVERSE_N1_MIDR, \
John Tsichritzis56369c12019-02-19 13:49:06 +0000689 neoverse_n1_reset_func, \
laurenw-arm94accd32019-08-20 15:51:24 -0500690 neoverse_n1_errata_ic_trap_handler, \
John Tsichritzis56369c12019-02-19 13:49:06 +0000691 neoverse_n1_core_pwr_dwn