blob: c197590bad23c40c9504b4fa4e2b11ff803a515d [file] [log] [blame]
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +01001/*
Bipin Ravi7f565472021-03-31 10:10:27 -05002 * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <cpu_macros.S>
10#include <neoverse_n2.h>
11
12/* Hardware handled coherency */
13#if HW_ASSISTED_COHERENCY == 0
14#error "Neoverse N2 must be compiled with HW_ASSISTED_COHERENCY enabled"
15#endif
16
17/* 64-bit only core */
18#if CTX_INCLUDE_AARCH32_REGS == 1
19#error "Neoverse-N2 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
20#endif
21
nayanpatel-arm277581e2021-08-06 17:46:10 -070022/* --------------------------------------------------
23 * Errata Workaround for Neoverse N2 Erratum 2002655.
24 * This applies to revision r0p0 of Neoverse N2. it is still open.
25 * Inputs:
26 * x0: variant[4:7] and revision[0:3] of current cpu.
27 * Shall clobber: x0-x17
28 * --------------------------------------------------
29 */
30func errata_n2_2002655_wa
31 /* Check revision. */
32 mov x17, x30
33 bl check_errata_2002655
34 cbz x0, 1f
35
36 /* Apply instruction patching sequence */
37 ldr x0,=0x6
38 msr S3_6_c15_c8_0,x0
39 ldr x0,=0xF3A08002
40 msr S3_6_c15_c8_2,x0
41 ldr x0,=0xFFF0F7FE
42 msr S3_6_c15_c8_3,x0
43 ldr x0,=0x40000001003ff
44 msr S3_6_c15_c8_1,x0
45 ldr x0,=0x7
46 msr S3_6_c15_c8_0,x0
47 ldr x0,=0xBF200000
48 msr S3_6_c15_c8_2,x0
49 ldr x0,=0xFFEF0000
50 msr S3_6_c15_c8_3,x0
51 ldr x0,=0x40000001003f3
52 msr S3_6_c15_c8_1,x0
53 isb
541:
55 ret x17
56endfunc errata_n2_2002655_wa
57
58func check_errata_2002655
59 /* Applies to r0p0 */
60 mov x1, #0x00
61 b cpu_rev_var_ls
62endfunc check_errata_2002655
63
Bipin Ravieb35e852021-03-30 16:08:32 -050064/* ---------------------------------------------------------------
65 * Errata Workaround for Neoverse N2 Erratum 2067956.
66 * This applies to revision r0p0 of Neoverse N2 and is still open.
67 * Inputs:
68 * x0: variant[4:7] and revision[0:3] of current cpu.
69 * Shall clobber: x0-x17
70 * ---------------------------------------------------------------
71 */
72func errata_n2_2067956_wa
73 /* Compare x0 against revision r0p0 */
74 mov x17, x30
75 bl check_errata_2067956
76 cbz x0, 1f
77 mrs x1, NEOVERSE_N2_CPUACTLR_EL1
78 orr x1, x1, NEOVERSE_N2_CPUACTLR_EL1_BIT_46
79 msr NEOVERSE_N2_CPUACTLR_EL1, x1
801:
81 ret x17
82endfunc errata_n2_2067956_wa
83
84func check_errata_2067956
85 /* Applies to r0p0 */
86 mov x1, #0x00
87 b cpu_rev_var_ls
88endfunc check_errata_2067956
89
Bipin Ravi7f565472021-03-31 10:10:27 -050090/* ---------------------------------------------------------------
91 * Errata Workaround for Neoverse N2 Erratum 2025414.
92 * This applies to revision r0p0 of Neoverse N2 and is still open.
93 * Inputs:
94 * x0: variant[4:7] and revision[0:3] of current cpu.
95 * Shall clobber: x0-x17
96 * ---------------------------------------------------------------
97 */
98func errata_n2_2025414_wa
99 /* Compare x0 against revision r0p0 */
100 mov x17, x30
101 bl check_errata_2025414
102 cbz x0, 1f
103 mrs x1, NEOVERSE_N2_CPUECTLR_EL1
104 orr x1, x1, NEOVERSE_N2_CPUECTLR_EL1_PFSTIDIS_BIT
105 msr NEOVERSE_N2_CPUECTLR_EL1, x1
106
1071:
108 ret x17
109endfunc errata_n2_2025414_wa
110
111func check_errata_2025414
112 /* Applies to r0p0 */
113 mov x1, #0x00
114 b cpu_rev_var_ls
115endfunc check_errata_2025414
116
Bipin Ravi7e030692021-08-30 13:02:51 -0500117/* ---------------------------------------------------------------
118 * Errata Workaround for Neoverse N2 Erratum 2189731.
119 * This applies to revision r0p0 of Neoverse N2 and is still open.
120 * Inputs:
121 * x0: variant[4:7] and revision[0:3] of current cpu.
122 * Shall clobber: x0-x17
123 * ---------------------------------------------------------------
124 */
125func errata_n2_2189731_wa
126 /* Compare x0 against revision r0p0 */
127 mov x17, x30
128 bl check_errata_2189731
129 cbz x0, 1f
130 mrs x1, NEOVERSE_N2_CPUACTLR5_EL1
131 orr x1, x1, NEOVERSE_N2_CPUACTLR5_EL1_BIT_44
132 msr NEOVERSE_N2_CPUACTLR5_EL1, x1
133
1341:
135 ret x17
136endfunc errata_n2_2189731_wa
137
138func check_errata_2189731
139 /* Applies to r0p0 */
140 mov x1, #0x00
141 b cpu_rev_var_ls
142endfunc check_errata_2189731
143
Bipin Ravi0ba631c2021-09-01 01:36:43 -0500144/* --------------------------------------------------
145 * Errata Workaround for Neoverse N2 Erratum 2138956.
146 * This applies to revision r0p0 of Neoverse N2. it is still open.
147 * Inputs:
148 * x0: variant[4:7] and revision[0:3] of current cpu.
149 * Shall clobber: x0-x17
150 * --------------------------------------------------
151 */
152func errata_n2_2138956_wa
153 /* Check revision. */
154 mov x17, x30
155 bl check_errata_2138956
156 cbz x0, 1f
157
158 /* Apply instruction patching sequence */
159 ldr x0,=0x3
160 msr S3_6_c15_c8_0,x0
161 ldr x0,=0xF3A08002
162 msr S3_6_c15_c8_2,x0
163 ldr x0,=0xFFF0F7FE
164 msr S3_6_c15_c8_3,x0
165 ldr x0,=0x10002001003FF
166 msr S3_6_c15_c8_1,x0
167 ldr x0,=0x4
168 msr S3_6_c15_c8_0,x0
169 ldr x0,=0xBF200000
170 msr S3_6_c15_c8_2,x0
171 ldr x0,=0xFFEF0000
172 msr S3_6_c15_c8_3,x0
173 ldr x0,=0x10002001003F3
174 msr S3_6_c15_c8_1,x0
175 isb
1761:
177 ret x17
178endfunc errata_n2_2138956_wa
179
180func check_errata_2138956
181 /* Applies to r0p0 */
182 mov x1, #0x00
183 b cpu_rev_var_ls
184endfunc check_errata_2138956
185
nayanpatel-armd4c5f9c2021-09-28 09:46:45 -0700186/* --------------------------------------------------
nayanpatel-arm2f153992021-10-06 15:31:24 -0700187 * Errata Workaround for Neoverse N2 Erratum 2242415.
188 * This applies to revision r0p0 of Neoverse N2. it is still open.
189 * Inputs:
190 * x0: variant[4:7] and revision[0:3] of current cpu.
191 * Shall clobber: x0-x1, x17
192 * --------------------------------------------------
193 */
194func errata_n2_2242415_wa
195 /* Check revision. */
196 mov x17, x30
197 bl check_errata_2242415
198 cbz x0, 1f
199
200 /* Apply instruction patching sequence */
201 mrs x1, NEOVERSE_N2_CPUACTLR_EL1
202 orr x1, x1, NEOVERSE_N2_CPUACTLR_EL1_BIT_22
203 msr NEOVERSE_N2_CPUACTLR_EL1, x1
2041:
205 ret x17
206endfunc errata_n2_2242415_wa
207
208func check_errata_2242415
209 /* Applies to r0p0 */
210 mov x1, #0x00
211 b cpu_rev_var_ls
212endfunc check_errata_2242415
213
214/* --------------------------------------------------
nayanpatel-armd4c5f9c2021-09-28 09:46:45 -0700215 * Errata Workaround for Neoverse N2 Erratum 2138953.
216 * This applies to revision r0p0 of Neoverse N2. it is still open.
217 * Inputs:
218 * x0: variant[4:7] and revision[0:3] of current cpu.
219 * Shall clobber: x0-x1, x17
220 * --------------------------------------------------
221 */
222func errata_n2_2138953_wa
223 /* Check revision. */
224 mov x17, x30
225 bl check_errata_2138953
226 cbz x0, 1f
227
228 /* Apply instruction patching sequence */
229 mrs x1, NEOVERSE_N2_CPUECTLR2_EL1
230 mov x0, #NEOVERSE_N2_CPUECTLR2_EL1_PF_MODE_CNSRV
231 bfi x1, x0, #CPUECTLR2_EL1_PF_MODE_LSB, #CPUECTLR2_EL1_PF_MODE_WIDTH
232 msr NEOVERSE_N2_CPUECTLR2_EL1, x1
2331:
234 ret x17
235endfunc errata_n2_2138953_wa
236
237func check_errata_2138953
238 /* Applies to r0p0 */
239 mov x1, #0x00
240 b cpu_rev_var_ls
241endfunc check_errata_2138953
242
Bipin Ravi7f565472021-03-31 10:10:27 -0500243 /* -------------------------------------------
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +0100244 * The CPU Ops reset function for Neoverse N2.
Bipin Ravi7f565472021-03-31 10:10:27 -0500245 * -------------------------------------------
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +0100246 */
247func neoverse_n2_reset_func
nayanpatel-arm277581e2021-08-06 17:46:10 -0700248 mov x19, x30
249
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +0100250 /* Check if the PE implements SSBS */
251 mrs x0, id_aa64pfr1_el1
252 tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT)
253 b.eq 1f
254
255 /* Disable speculative loads */
256 msr SSBS, xzr
2571:
258 /* Force all cacheable atomic instructions to be near */
259 mrs x0, NEOVERSE_N2_CPUACTLR2_EL1
260 orr x0, x0, #NEOVERSE_N2_CPUACTLR2_EL1_BIT_2
261 msr NEOVERSE_N2_CPUACTLR2_EL1, x0
262
Bipin Ravieb35e852021-03-30 16:08:32 -0500263#if ERRATA_N2_2067956
264 mov x0, x18
265 bl errata_n2_2067956_wa
266#endif
267
Bipin Ravi7f565472021-03-31 10:10:27 -0500268#if ERRATA_N2_2025414
269 mov x0, x18
270 bl errata_n2_2025414_wa
271#endif
272
Bipin Ravi7e030692021-08-30 13:02:51 -0500273#if ERRATA_N2_2189731
274 mov x0, x18
275 bl errata_n2_2189731_wa
276#endif
277
Bipin Ravi0ba631c2021-09-01 01:36:43 -0500278
279#if ERRATA_N2_2138956
280 mov x0, x18
281 bl errata_n2_2138956_wa
282#endif
283
nayanpatel-armd4c5f9c2021-09-28 09:46:45 -0700284#if ERRATA_N2_2138953
285 mov x0, x18
286 bl errata_n2_2138953_wa
287#endif
288
nayanpatel-arm2f153992021-10-06 15:31:24 -0700289#if ERRATA_N2_2242415
290 mov x0, x18
291 bl errata_n2_2242415_wa
292#endif
293
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +0100294#if ENABLE_AMU
295 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
296 mrs x0, cptr_el3
297 orr x0, x0, #TAM_BIT
298 msr cptr_el3, x0
299
300 /* Make sure accesses from EL0/EL1 are not trapped to EL2 */
301 mrs x0, cptr_el2
302 orr x0, x0, #TAM_BIT
303 msr cptr_el2, x0
304
305 /* No need to enable the counters as this would be done at el3 exit */
306#endif
307
308#if NEOVERSE_Nx_EXTERNAL_LLC
309 /* Some systems may have External LLC, core needs to be made aware */
Bipin Ravieb35e852021-03-30 16:08:32 -0500310 mrs x0, NEOVERSE_N2_CPUECTLR_EL1
311 orr x0, x0, NEOVERSE_N2_CPUECTLR_EL1_EXTLLC_BIT
312 msr NEOVERSE_N2_CPUECTLR_EL1, x0
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +0100313#endif
314
nayanpatel-arm277581e2021-08-06 17:46:10 -0700315 bl cpu_get_rev_var
316 mov x18, x0
317
318#if ERRATA_N2_2002655
319 mov x0, x18
320 bl errata_n2_2002655_wa
321#endif
322
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +0100323 isb
Bipin Ravieb35e852021-03-30 16:08:32 -0500324 ret x19
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +0100325endfunc neoverse_n2_reset_func
326
327func neoverse_n2_core_pwr_dwn
Bipin Ravi7f565472021-03-31 10:10:27 -0500328 /* ---------------------------------------------------
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +0100329 * Enable CPU power down bit in power control register
330 * No need to do cache maintenance here.
Bipin Ravi7f565472021-03-31 10:10:27 -0500331 * ---------------------------------------------------
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +0100332 */
333 mrs x0, NEOVERSE_N2_CPUPWRCTLR_EL1
334 orr x0, x0, #NEOVERSE_N2_CORE_PWRDN_EN_BIT
335 msr NEOVERSE_N2_CPUPWRCTLR_EL1, x0
336 isb
337 ret
338endfunc neoverse_n2_core_pwr_dwn
339
340#if REPORT_ERRATA
341/*
342 * Errata printing function for Neoverse N2 cores. Must follow AAPCS.
343 */
344func neoverse_n2_errata_report
nayanpatel-arm277581e2021-08-06 17:46:10 -0700345 stp x8, x30, [sp, #-16]!
346
347 bl cpu_get_rev_var
348 mov x8, x0
349
350 /*
351 * Report all errata. The revision-variant information is passed to
352 * checking functions of each errata.
353 */
354 report_errata ERRATA_N2_2002655, neoverse_n2, 2002655
Bipin Ravieb35e852021-03-30 16:08:32 -0500355 report_errata ERRATA_N2_2067956, neoverse_n2, 2067956
Bipin Ravi7f565472021-03-31 10:10:27 -0500356 report_errata ERRATA_N2_2025414, neoverse_n2, 2025414
nayanpatel-armd4c5f9c2021-09-28 09:46:45 -0700357 report_errata ERRATA_N2_2189731, neoverse_n2, 2189731
Bipin Ravi0ba631c2021-09-01 01:36:43 -0500358 report_errata ERRATA_N2_2138956, neoverse_n2, 2138956
nayanpatel-armd4c5f9c2021-09-28 09:46:45 -0700359 report_errata ERRATA_N2_2138953, neoverse_n2, 2138953
nayanpatel-arm2f153992021-10-06 15:31:24 -0700360 report_errata ERRATA_N2_2242415, neoverse_n2, 2242415
nayanpatel-arm277581e2021-08-06 17:46:10 -0700361
362 ldp x8, x30, [sp], #16
Javier Almansa Sobrino9faad3c2020-10-23 13:22:07 +0100363 ret
364endfunc neoverse_n2_errata_report
365#endif
366
367 /* ---------------------------------------------
368 * This function provides Neoverse N2 specific
369 * register information for crash reporting.
370 * It needs to return with x6 pointing to
371 * a list of register names in ASCII and
372 * x8 - x15 having values of registers to be
373 * reported.
374 * ---------------------------------------------
375 */
376.section .rodata.neoverse_n2_regs, "aS"
377neoverse_n2_regs: /* The ASCII list of register names to be reported */
378 .asciz "cpupwrctlr_el1", ""
379
380func neoverse_n2_cpu_reg_dump
381 adr x6, neoverse_n2_regs
382 mrs x8, NEOVERSE_N2_CPUPWRCTLR_EL1
383 ret
384endfunc neoverse_n2_cpu_reg_dump
385
386declare_cpu_ops neoverse_n2, NEOVERSE_N2_MIDR, \
387 neoverse_n2_reset_func, \
388 neoverse_n2_core_pwr_dwn