Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 1 | /* |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 9 | #include <neoverse_n1.h> |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 10 | #include <cpuamu.h> |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 11 | #include <cpu_macros.S> |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 12 | #include <context.h> |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 13 | |
John Tsichritzis | fe6df39 | 2019-03-19 17:20:52 +0000 | [diff] [blame] | 14 | /* 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 Tsichritzis | 7557c66 | 2019-06-03 13:54:30 +0100 | [diff] [blame] | 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" |
| 22 | #endif |
| 23 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 24 | #if ERRATA_N1_IC_TRAP |
| 25 | .global neoverse_n1_errata_ic_trap_handler |
| 26 | #endif |
| 27 | |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 28 | /* -------------------------------------------------- |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 29 | * Errata Workaround for Neoverse N1 Erratum 1043202. |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 30 | * This applies to revision r0p0 and r1p0 of Neoverse N1. |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 31 | * Inputs: |
| 32 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 33 | * Shall clobber: x0-x17 |
| 34 | * -------------------------------------------------- |
| 35 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 36 | func errata_n1_1043202_wa |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 37 | /* Compare x0 against revision r1p0 */ |
| 38 | mov x17, x30 |
| 39 | bl check_errata_1043202 |
| 40 | cbz x0, 1f |
| 41 | |
| 42 | /* Apply instruction patching sequence */ |
| 43 | ldr x0, =0x0 |
| 44 | msr CPUPSELR_EL3, x0 |
| 45 | ldr x0, =0xF3BF8F2F |
| 46 | msr CPUPOR_EL3, x0 |
| 47 | ldr x0, =0xFFFFFFFF |
| 48 | msr CPUPMR_EL3, x0 |
| 49 | ldr x0, =0x800200071 |
| 50 | msr CPUPCR_EL3, x0 |
laurenw-arm | 33e58f3 | 2019-08-19 11:06:18 -0500 | [diff] [blame] | 51 | isb |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 52 | 1: |
| 53 | ret x17 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 54 | endfunc errata_n1_1043202_wa |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 55 | |
| 56 | func check_errata_1043202 |
| 57 | /* Applies to r0p0 and r1p0 */ |
| 58 | mov x1, #0x10 |
| 59 | b cpu_rev_var_ls |
| 60 | endfunc check_errata_1043202 |
| 61 | |
Sami Mujawar | a8722e9 | 2019-05-10 14:28:37 +0100 | [diff] [blame] | 62 | /* -------------------------------------------------- |
| 63 | * Disable speculative loads if Neoverse N1 supports |
| 64 | * SSBS. |
| 65 | * |
| 66 | * Shall clobber: x0. |
| 67 | * -------------------------------------------------- |
| 68 | */ |
| 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) |
| 73 | b.eq 1f |
| 74 | |
| 75 | /* Disable speculative loads */ |
| 76 | msr SSBS, xzr |
Sami Mujawar | a8722e9 | 2019-05-10 14:28:37 +0100 | [diff] [blame] | 77 | |
| 78 | 1: |
| 79 | ret |
| 80 | endfunc neoverse_n1_disable_speculative_loads |
| 81 | |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 82 | /* -------------------------------------------------- |
lauwal01 | bd555f4 | 2019-06-24 11:23:50 -0500 | [diff] [blame] | 83 | * Errata Workaround for Neoverse N1 Errata #1073348 |
| 84 | * This applies to revision r0p0 and r1p0 of Neoverse N1. |
| 85 | * Inputs: |
| 86 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 87 | * Shall clobber: x0-x17 |
| 88 | * -------------------------------------------------- |
| 89 | */ |
| 90 | func errata_n1_1073348_wa |
| 91 | /* Compare x0 against revision r1p0 */ |
| 92 | mov x17, x30 |
| 93 | bl check_errata_1073348 |
| 94 | cbz x0, 1f |
| 95 | mrs x1, NEOVERSE_N1_CPUACTLR_EL1 |
| 96 | orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_6 |
| 97 | msr NEOVERSE_N1_CPUACTLR_EL1, x1 |
lauwal01 | bd555f4 | 2019-06-24 11:23:50 -0500 | [diff] [blame] | 98 | 1: |
| 99 | ret x17 |
| 100 | endfunc errata_n1_1073348_wa |
| 101 | |
| 102 | func check_errata_1073348 |
| 103 | /* Applies to r0p0 and r1p0 */ |
| 104 | mov x1, #0x10 |
| 105 | b cpu_rev_var_ls |
| 106 | endfunc check_errata_1073348 |
| 107 | |
| 108 | /* -------------------------------------------------- |
lauwal01 | 363ee3c | 2019-06-24 11:28:34 -0500 | [diff] [blame] | 109 | * Errata Workaround for Neoverse N1 Errata #1130799 |
| 110 | * This applies to revision <=r2p0 of Neoverse N1. |
| 111 | * Inputs: |
| 112 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 113 | * Shall clobber: x0-x17 |
| 114 | * -------------------------------------------------- |
| 115 | */ |
| 116 | func errata_n1_1130799_wa |
| 117 | /* Compare x0 against revision r2p0 */ |
| 118 | mov x17, x30 |
| 119 | bl check_errata_1130799 |
| 120 | cbz x0, 1f |
| 121 | mrs x1, NEOVERSE_N1_CPUACTLR2_EL1 |
| 122 | orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_59 |
| 123 | msr NEOVERSE_N1_CPUACTLR2_EL1, x1 |
lauwal01 | 363ee3c | 2019-06-24 11:28:34 -0500 | [diff] [blame] | 124 | 1: |
| 125 | ret x17 |
| 126 | endfunc errata_n1_1130799_wa |
| 127 | |
| 128 | func check_errata_1130799 |
| 129 | /* Applies to <=r2p0 */ |
| 130 | mov x1, #0x20 |
| 131 | b cpu_rev_var_ls |
| 132 | endfunc check_errata_1130799 |
| 133 | |
| 134 | /* -------------------------------------------------- |
lauwal01 | f2adb13 | 2019-06-24 11:32:40 -0500 | [diff] [blame] | 135 | * Errata Workaround for Neoverse N1 Errata #1165347 |
| 136 | * This applies to revision <=r2p0 of Neoverse N1. |
| 137 | * Inputs: |
| 138 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 139 | * Shall clobber: x0-x17 |
| 140 | * -------------------------------------------------- |
| 141 | */ |
| 142 | func errata_n1_1165347_wa |
| 143 | /* Compare x0 against revision r2p0 */ |
| 144 | mov x17, x30 |
| 145 | bl check_errata_1165347 |
| 146 | cbz x0, 1f |
| 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 |
lauwal01 | f2adb13 | 2019-06-24 11:32:40 -0500 | [diff] [blame] | 151 | 1: |
| 152 | ret x17 |
| 153 | endfunc errata_n1_1165347_wa |
| 154 | |
| 155 | func check_errata_1165347 |
| 156 | /* Applies to <=r2p0 */ |
| 157 | mov x1, #0x20 |
| 158 | b cpu_rev_var_ls |
| 159 | endfunc check_errata_1165347 |
| 160 | |
| 161 | /* -------------------------------------------------- |
lauwal01 | e159044 | 2019-06-24 11:35:37 -0500 | [diff] [blame] | 162 | * Errata Workaround for Neoverse N1 Errata #1207823 |
| 163 | * This applies to revision <=r2p0 of Neoverse N1. |
| 164 | * Inputs: |
| 165 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 166 | * Shall clobber: x0-x17 |
| 167 | * -------------------------------------------------- |
| 168 | */ |
| 169 | func errata_n1_1207823_wa |
| 170 | /* Compare x0 against revision r2p0 */ |
| 171 | mov x17, x30 |
| 172 | bl check_errata_1207823 |
| 173 | cbz x0, 1f |
| 174 | mrs x1, NEOVERSE_N1_CPUACTLR2_EL1 |
| 175 | orr x1, x1, NEOVERSE_N1_CPUACTLR2_EL1_BIT_11 |
| 176 | msr NEOVERSE_N1_CPUACTLR2_EL1, x1 |
lauwal01 | e159044 | 2019-06-24 11:35:37 -0500 | [diff] [blame] | 177 | 1: |
| 178 | ret x17 |
| 179 | endfunc errata_n1_1207823_wa |
| 180 | |
| 181 | func check_errata_1207823 |
| 182 | /* Applies to <=r2p0 */ |
| 183 | mov x1, #0x20 |
| 184 | b cpu_rev_var_ls |
| 185 | endfunc check_errata_1207823 |
| 186 | |
| 187 | /* -------------------------------------------------- |
lauwal01 | 197f14c | 2019-06-24 11:38:53 -0500 | [diff] [blame] | 188 | * Errata Workaround for Neoverse N1 Errata #1220197 |
| 189 | * This applies to revision <=r2p0 of Neoverse N1. |
| 190 | * Inputs: |
| 191 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 192 | * Shall clobber: x0-x17 |
| 193 | * -------------------------------------------------- |
| 194 | */ |
| 195 | func errata_n1_1220197_wa |
| 196 | /* Compare x0 against revision r2p0 */ |
| 197 | mov x17, x30 |
| 198 | bl check_errata_1220197 |
| 199 | cbz x0, 1f |
| 200 | mrs x1, NEOVERSE_N1_CPUECTLR_EL1 |
| 201 | orr x1, x1, NEOVERSE_N1_WS_THR_L2_MASK |
| 202 | msr NEOVERSE_N1_CPUECTLR_EL1, x1 |
lauwal01 | 197f14c | 2019-06-24 11:38:53 -0500 | [diff] [blame] | 203 | 1: |
| 204 | ret x17 |
| 205 | endfunc errata_n1_1220197_wa |
| 206 | |
| 207 | func check_errata_1220197 |
| 208 | /* Applies to <=r2p0 */ |
| 209 | mov x1, #0x20 |
| 210 | b cpu_rev_var_ls |
| 211 | endfunc check_errata_1220197 |
| 212 | |
| 213 | /* -------------------------------------------------- |
lauwal01 | 07c2a23 | 2019-06-24 11:42:02 -0500 | [diff] [blame] | 214 | * Errata Workaround for Neoverse N1 Errata #1257314 |
| 215 | * This applies to revision <=r3p0 of Neoverse N1. |
| 216 | * Inputs: |
| 217 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 218 | * Shall clobber: x0-x17 |
| 219 | * -------------------------------------------------- |
| 220 | */ |
| 221 | func errata_n1_1257314_wa |
| 222 | /* Compare x0 against revision r3p0 */ |
| 223 | mov x17, x30 |
| 224 | bl check_errata_1257314 |
| 225 | cbz x0, 1f |
| 226 | mrs x1, NEOVERSE_N1_CPUACTLR3_EL1 |
| 227 | orr x1, x1, NEOVERSE_N1_CPUACTLR3_EL1_BIT_10 |
| 228 | msr NEOVERSE_N1_CPUACTLR3_EL1, x1 |
lauwal01 | 07c2a23 | 2019-06-24 11:42:02 -0500 | [diff] [blame] | 229 | 1: |
| 230 | ret x17 |
| 231 | endfunc errata_n1_1257314_wa |
| 232 | |
| 233 | func check_errata_1257314 |
| 234 | /* Applies to <=r3p0 */ |
| 235 | mov x1, #0x30 |
| 236 | b cpu_rev_var_ls |
| 237 | endfunc check_errata_1257314 |
| 238 | |
| 239 | /* -------------------------------------------------- |
lauwal01 | 42771af | 2019-06-24 11:44:58 -0500 | [diff] [blame] | 240 | * Errata Workaround for Neoverse N1 Errata #1262606 |
| 241 | * This applies to revision <=r3p0 of Neoverse N1. |
| 242 | * Inputs: |
| 243 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 244 | * Shall clobber: x0-x17 |
| 245 | * -------------------------------------------------- |
| 246 | */ |
| 247 | func errata_n1_1262606_wa |
| 248 | /* Compare x0 against revision r3p0 */ |
| 249 | mov x17, x30 |
| 250 | bl check_errata_1262606 |
| 251 | cbz x0, 1f |
| 252 | mrs x1, NEOVERSE_N1_CPUACTLR_EL1 |
| 253 | orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 |
| 254 | msr NEOVERSE_N1_CPUACTLR_EL1, x1 |
lauwal01 | 42771af | 2019-06-24 11:44:58 -0500 | [diff] [blame] | 255 | 1: |
| 256 | ret x17 |
| 257 | endfunc errata_n1_1262606_wa |
| 258 | |
| 259 | func check_errata_1262606 |
| 260 | /* Applies to <=r3p0 */ |
| 261 | mov x1, #0x30 |
| 262 | b cpu_rev_var_ls |
| 263 | endfunc check_errata_1262606 |
| 264 | |
| 265 | /* -------------------------------------------------- |
lauwal01 | 00396bf | 2019-06-24 11:47:30 -0500 | [diff] [blame] | 266 | * Errata Workaround for Neoverse N1 Errata #1262888 |
| 267 | * This applies to revision <=r3p0 of Neoverse N1. |
| 268 | * Inputs: |
| 269 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 270 | * Shall clobber: x0-x17 |
| 271 | * -------------------------------------------------- |
| 272 | */ |
| 273 | func errata_n1_1262888_wa |
| 274 | /* Compare x0 against revision r3p0 */ |
| 275 | mov x17, x30 |
| 276 | bl check_errata_1262888 |
| 277 | cbz x0, 1f |
| 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 |
lauwal01 | 00396bf | 2019-06-24 11:47:30 -0500 | [diff] [blame] | 281 | 1: |
| 282 | ret x17 |
| 283 | endfunc errata_n1_1262888_wa |
| 284 | |
| 285 | func check_errata_1262888 |
| 286 | /* Applies to <=r3p0 */ |
| 287 | mov x1, #0x30 |
| 288 | b cpu_rev_var_ls |
| 289 | endfunc check_errata_1262888 |
| 290 | |
| 291 | /* -------------------------------------------------- |
lauwal01 | 644b6ed | 2019-06-24 11:49:01 -0500 | [diff] [blame] | 292 | * Errata Workaround for Neoverse N1 Errata #1275112 |
| 293 | * This applies to revision <=r3p0 of Neoverse N1. |
| 294 | * Inputs: |
| 295 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 296 | * Shall clobber: x0-x17 |
| 297 | * -------------------------------------------------- |
| 298 | */ |
| 299 | func errata_n1_1275112_wa |
| 300 | /* Compare x0 against revision r3p0 */ |
| 301 | mov x17, x30 |
| 302 | bl check_errata_1275112 |
| 303 | cbz x0, 1f |
| 304 | mrs x1, NEOVERSE_N1_CPUACTLR_EL1 |
| 305 | orr x1, x1, NEOVERSE_N1_CPUACTLR_EL1_BIT_13 |
| 306 | msr NEOVERSE_N1_CPUACTLR_EL1, x1 |
lauwal01 | 644b6ed | 2019-06-24 11:49:01 -0500 | [diff] [blame] | 307 | 1: |
| 308 | ret x17 |
| 309 | endfunc errata_n1_1275112_wa |
| 310 | |
| 311 | func check_errata_1275112 |
| 312 | /* Applies to <=r3p0 */ |
| 313 | mov x1, #0x30 |
| 314 | b cpu_rev_var_ls |
| 315 | endfunc check_errata_1275112 |
| 316 | |
| 317 | /* -------------------------------------------------- |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 318 | * Errata Workaround for Neoverse N1 Erratum 1315703. |
| 319 | * This applies to revision <= r3p0 of Neoverse N1. |
| 320 | * Inputs: |
| 321 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 322 | * Shall clobber: x0-x17 |
| 323 | * -------------------------------------------------- |
| 324 | */ |
| 325 | func errata_n1_1315703_wa |
| 326 | /* Compare x0 against revision r3p1 */ |
| 327 | mov x17, x30 |
| 328 | bl check_errata_1315703 |
| 329 | cbz x0, 1f |
| 330 | |
| 331 | mrs x0, NEOVERSE_N1_CPUACTLR2_EL1 |
| 332 | orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_16 |
| 333 | msr NEOVERSE_N1_CPUACTLR2_EL1, x0 |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 334 | |
| 335 | 1: |
| 336 | ret x17 |
| 337 | endfunc errata_n1_1315703_wa |
| 338 | |
| 339 | func check_errata_1315703 |
| 340 | /* Applies to everything <= r3p0. */ |
| 341 | mov x1, #0x30 |
| 342 | b cpu_rev_var_ls |
| 343 | endfunc check_errata_1315703 |
| 344 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 345 | /* -------------------------------------------------- |
| 346 | * Errata Workaround for Neoverse N1 Erratum 1542419. |
| 347 | * This applies to revisions r3p0 - r4p0 of Neoverse N1 |
| 348 | * Inputs: |
| 349 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 350 | * Shall clobber: x0-x17 |
| 351 | * -------------------------------------------------- |
| 352 | */ |
| 353 | func errata_n1_1542419_wa |
| 354 | /* Compare x0 against revision r3p0 and r4p0 */ |
| 355 | mov x17, x30 |
| 356 | bl check_errata_1542419 |
| 357 | cbz x0, 1f |
| 358 | |
| 359 | /* Apply instruction patching sequence */ |
| 360 | ldr x0, =0x0 |
| 361 | msr CPUPSELR_EL3, x0 |
| 362 | ldr x0, =0xEE670D35 |
| 363 | msr CPUPOR_EL3, x0 |
| 364 | ldr x0, =0xFFFF0FFF |
| 365 | msr CPUPMR_EL3, x0 |
| 366 | ldr x0, =0x08000020007D |
| 367 | msr CPUPCR_EL3, x0 |
| 368 | isb |
| 369 | 1: |
| 370 | ret x17 |
| 371 | endfunc errata_n1_1542419_wa |
| 372 | |
| 373 | func check_errata_1542419 |
| 374 | /* Applies to everything r3p0 - r4p0. */ |
| 375 | mov x1, #0x30 |
| 376 | mov x2, #0x40 |
| 377 | b cpu_rev_var_range |
| 378 | endfunc check_errata_1542419 |
| 379 | |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 380 | func neoverse_n1_reset_func |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 381 | mov x19, x30 |
John Tsichritzis | 1f9ff49 | 2019-03-04 16:41:26 +0000 | [diff] [blame] | 382 | |
Sami Mujawar | a8722e9 | 2019-05-10 14:28:37 +0100 | [diff] [blame] | 383 | bl neoverse_n1_disable_speculative_loads |
John Tsichritzis | 1f9ff49 | 2019-03-04 16:41:26 +0000 | [diff] [blame] | 384 | |
Louis Mayencourt | b58142b | 2019-04-18 14:34:11 +0100 | [diff] [blame] | 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 |
| 389 | isb |
| 390 | |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 391 | bl cpu_get_rev_var |
| 392 | mov x18, x0 |
| 393 | |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 394 | #if ERRATA_N1_1043202 |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 395 | mov x0, x18 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 396 | bl errata_n1_1043202_wa |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 397 | #endif |
| 398 | |
lauwal01 | bd555f4 | 2019-06-24 11:23:50 -0500 | [diff] [blame] | 399 | #if ERRATA_N1_1073348 |
| 400 | mov x0, x18 |
| 401 | bl errata_n1_1073348_wa |
| 402 | #endif |
| 403 | |
lauwal01 | 363ee3c | 2019-06-24 11:28:34 -0500 | [diff] [blame] | 404 | #if ERRATA_N1_1130799 |
| 405 | mov x0, x18 |
| 406 | bl errata_n1_1130799_wa |
| 407 | #endif |
| 408 | |
lauwal01 | f2adb13 | 2019-06-24 11:32:40 -0500 | [diff] [blame] | 409 | #if ERRATA_N1_1165347 |
| 410 | mov x0, x18 |
| 411 | bl errata_n1_1165347_wa |
| 412 | #endif |
| 413 | |
lauwal01 | e159044 | 2019-06-24 11:35:37 -0500 | [diff] [blame] | 414 | #if ERRATA_N1_1207823 |
| 415 | mov x0, x18 |
| 416 | bl errata_n1_1207823_wa |
| 417 | #endif |
| 418 | |
lauwal01 | 197f14c | 2019-06-24 11:38:53 -0500 | [diff] [blame] | 419 | #if ERRATA_N1_1220197 |
| 420 | mov x0, x18 |
| 421 | bl errata_n1_1220197_wa |
| 422 | #endif |
| 423 | |
lauwal01 | 07c2a23 | 2019-06-24 11:42:02 -0500 | [diff] [blame] | 424 | #if ERRATA_N1_1257314 |
| 425 | mov x0, x18 |
| 426 | bl errata_n1_1257314_wa |
| 427 | #endif |
| 428 | |
lauwal01 | 42771af | 2019-06-24 11:44:58 -0500 | [diff] [blame] | 429 | #if ERRATA_N1_1262606 |
| 430 | mov x0, x18 |
| 431 | bl errata_n1_1262606_wa |
| 432 | #endif |
| 433 | |
lauwal01 | 00396bf | 2019-06-24 11:47:30 -0500 | [diff] [blame] | 434 | #if ERRATA_N1_1262888 |
| 435 | mov x0, x18 |
| 436 | bl errata_n1_1262888_wa |
| 437 | #endif |
| 438 | |
lauwal01 | 644b6ed | 2019-06-24 11:49:01 -0500 | [diff] [blame] | 439 | #if ERRATA_N1_1275112 |
| 440 | mov x0, x18 |
| 441 | bl errata_n1_1275112_wa |
| 442 | #endif |
| 443 | |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 444 | #if ERRATA_N1_1315703 |
| 445 | mov x0, x18 |
| 446 | bl errata_n1_1315703_wa |
| 447 | #endif |
| 448 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 449 | #if ERRATA_N1_1542419 |
| 450 | mov x0, x18 |
| 451 | bl errata_n1_1542419_wa |
| 452 | #endif |
| 453 | |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 454 | #if ENABLE_AMU |
| 455 | /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */ |
| 456 | mrs x0, actlr_el3 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 457 | orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 458 | msr actlr_el3, x0 |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 459 | |
| 460 | /* Make sure accesses from EL0/EL1 are not trapped to EL2 */ |
| 461 | mrs x0, actlr_el2 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 462 | orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 463 | msr actlr_el2, x0 |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 464 | |
| 465 | /* Enable group0 counters */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 466 | mov x0, #NEOVERSE_N1_AMU_GROUP0_MASK |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 467 | msr CPUAMCNTENSET_EL0, x0 |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 468 | #endif |
Louis Mayencourt | 8b8b13b | 2019-06-10 16:43:39 +0100 | [diff] [blame] | 469 | |
| 470 | #if ERRATA_DSU_936184 |
| 471 | bl errata_dsu_936184_wa |
| 472 | #endif |
| 473 | |
lauwal01 | cf12f26 | 2019-06-27 11:03:25 -0500 | [diff] [blame] | 474 | isb |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 475 | ret x19 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 476 | endfunc neoverse_n1_reset_func |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 477 | |
| 478 | /* --------------------------------------------- |
| 479 | * HW will do the cache maintenance while powering down |
| 480 | * --------------------------------------------- |
| 481 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 482 | func neoverse_n1_core_pwr_dwn |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 483 | /* --------------------------------------------- |
| 484 | * Enable CPU power down bit in power control register |
| 485 | * --------------------------------------------- |
| 486 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 487 | mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1 |
| 488 | orr x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK |
| 489 | msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0 |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 490 | isb |
| 491 | ret |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 492 | endfunc neoverse_n1_core_pwr_dwn |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 493 | |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 494 | #if REPORT_ERRATA |
| 495 | /* |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 496 | * Errata printing function for Neoverse N1. Must follow AAPCS. |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 497 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 498 | func neoverse_n1_errata_report |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 499 | stp x8, x30, [sp, #-16]! |
| 500 | |
| 501 | bl cpu_get_rev_var |
| 502 | mov x8, x0 |
| 503 | |
| 504 | /* |
| 505 | * Report all errata. The revision-variant information is passed to |
| 506 | * checking functions of each errata. |
| 507 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 508 | report_errata ERRATA_N1_1043202, neoverse_n1, 1043202 |
lauwal01 | bd555f4 | 2019-06-24 11:23:50 -0500 | [diff] [blame] | 509 | report_errata ERRATA_N1_1073348, neoverse_n1, 1073348 |
lauwal01 | 363ee3c | 2019-06-24 11:28:34 -0500 | [diff] [blame] | 510 | report_errata ERRATA_N1_1130799, neoverse_n1, 1130799 |
lauwal01 | f2adb13 | 2019-06-24 11:32:40 -0500 | [diff] [blame] | 511 | report_errata ERRATA_N1_1165347, neoverse_n1, 1165347 |
lauwal01 | e159044 | 2019-06-24 11:35:37 -0500 | [diff] [blame] | 512 | report_errata ERRATA_N1_1207823, neoverse_n1, 1207823 |
lauwal01 | 197f14c | 2019-06-24 11:38:53 -0500 | [diff] [blame] | 513 | report_errata ERRATA_N1_1220197, neoverse_n1, 1220197 |
lauwal01 | 07c2a23 | 2019-06-24 11:42:02 -0500 | [diff] [blame] | 514 | report_errata ERRATA_N1_1257314, neoverse_n1, 1257314 |
lauwal01 | 42771af | 2019-06-24 11:44:58 -0500 | [diff] [blame] | 515 | report_errata ERRATA_N1_1262606, neoverse_n1, 1262606 |
lauwal01 | 00396bf | 2019-06-24 11:47:30 -0500 | [diff] [blame] | 516 | report_errata ERRATA_N1_1262888, neoverse_n1, 1262888 |
lauwal01 | 644b6ed | 2019-06-24 11:49:01 -0500 | [diff] [blame] | 517 | report_errata ERRATA_N1_1275112, neoverse_n1, 1275112 |
Andre Przywara | b934740 | 2019-05-20 14:57:06 +0100 | [diff] [blame] | 518 | report_errata ERRATA_N1_1315703, neoverse_n1, 1315703 |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 519 | report_errata ERRATA_N1_1542419, neoverse_n1, 1542419 |
Louis Mayencourt | 8b8b13b | 2019-06-10 16:43:39 +0100 | [diff] [blame] | 520 | report_errata ERRATA_DSU_936184, neoverse_n1, dsu_936184 |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 521 | |
| 522 | ldp x8, x30, [sp], #16 |
| 523 | ret |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 524 | endfunc neoverse_n1_errata_report |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 525 | #endif |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 526 | |
| 527 | /* |
| 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. |
| 530 | * |
| 531 | * x1: Exception Syndrome |
| 532 | */ |
| 533 | func neoverse_n1_errata_ic_trap_handler |
| 534 | cmp x1, #NEOVERSE_N1_EC_IC_TRAP |
| 535 | b.ne 1f |
| 536 | tlbi vae3is, xzr |
| 537 | dsb sy |
| 538 | |
| 539 | # Skip the IC instruction itself |
| 540 | mrs x3, elr_el3 |
| 541 | add x3, x3, #4 |
| 542 | msr elr_el3, x3 |
| 543 | |
| 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] |
| 548 | |
| 549 | #if IMAGE_BL31 && RAS_EXTENSION |
| 550 | /* |
| 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 |
| 554 | * DISR_EL1 register. |
| 555 | */ |
| 556 | esb |
| 557 | #endif |
| 558 | eret |
| 559 | 1: |
| 560 | ret |
| 561 | endfunc neoverse_n1_errata_ic_trap_handler |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 562 | |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 563 | /* --------------------------------------------- |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 564 | * This function provides neoverse_n1 specific |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 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 |
| 569 | * reported. |
| 570 | * --------------------------------------------- |
| 571 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 572 | .section .rodata.neoverse_n1_regs, "aS" |
| 573 | neoverse_n1_regs: /* The ascii list of register names to be reported */ |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 574 | .asciz "cpuectlr_el1", "" |
| 575 | |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 576 | func neoverse_n1_cpu_reg_dump |
| 577 | adr x6, neoverse_n1_regs |
| 578 | mrs x8, NEOVERSE_N1_CPUECTLR_EL1 |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 579 | ret |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 580 | endfunc neoverse_n1_cpu_reg_dump |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 581 | |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 582 | declare_cpu_ops_eh neoverse_n1, NEOVERSE_N1_MIDR, \ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 583 | neoverse_n1_reset_func, \ |
laurenw-arm | 94accd3 | 2019-08-20 15:51:24 -0500 | [diff] [blame] | 584 | neoverse_n1_errata_ic_trap_handler, \ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 585 | neoverse_n1_core_pwr_dwn |