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> |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 12 | |
John Tsichritzis | fe6df39 | 2019-03-19 17:20:52 +0000 | [diff] [blame] | 13 | /* Hardware handled coherency */ |
| 14 | #if HW_ASSISTED_COHERENCY == 0 |
| 15 | #error "Neoverse N1 must be compiled with HW_ASSISTED_COHERENCY enabled" |
| 16 | #endif |
| 17 | |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 18 | /* -------------------------------------------------- |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 19 | * Errata Workaround for Neoverse N1 Errata |
| 20 | * This applies to revision r0p0 and r1p0 of Neoverse N1. |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 21 | * Inputs: |
| 22 | * x0: variant[4:7] and revision[0:3] of current cpu. |
| 23 | * Shall clobber: x0-x17 |
| 24 | * -------------------------------------------------- |
| 25 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 26 | func errata_n1_1043202_wa |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 27 | /* Compare x0 against revision r1p0 */ |
| 28 | mov x17, x30 |
| 29 | bl check_errata_1043202 |
| 30 | cbz x0, 1f |
| 31 | |
| 32 | /* Apply instruction patching sequence */ |
| 33 | ldr x0, =0x0 |
| 34 | msr CPUPSELR_EL3, x0 |
| 35 | ldr x0, =0xF3BF8F2F |
| 36 | msr CPUPOR_EL3, x0 |
| 37 | ldr x0, =0xFFFFFFFF |
| 38 | msr CPUPMR_EL3, x0 |
| 39 | ldr x0, =0x800200071 |
| 40 | msr CPUPCR_EL3, x0 |
| 41 | isb |
| 42 | 1: |
| 43 | ret x17 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 44 | endfunc errata_n1_1043202_wa |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 45 | |
| 46 | func check_errata_1043202 |
| 47 | /* Applies to r0p0 and r1p0 */ |
| 48 | mov x1, #0x10 |
| 49 | b cpu_rev_var_ls |
| 50 | endfunc check_errata_1043202 |
| 51 | |
Sami Mujawar | a8722e9 | 2019-05-10 14:28:37 +0100 | [diff] [blame] | 52 | /* -------------------------------------------------- |
| 53 | * Disable speculative loads if Neoverse N1 supports |
| 54 | * SSBS. |
| 55 | * |
| 56 | * Shall clobber: x0. |
| 57 | * -------------------------------------------------- |
| 58 | */ |
| 59 | func neoverse_n1_disable_speculative_loads |
| 60 | /* Check if the PE implements SSBS */ |
| 61 | mrs x0, id_aa64pfr1_el1 |
| 62 | tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT) |
| 63 | b.eq 1f |
| 64 | |
| 65 | /* Disable speculative loads */ |
| 66 | msr SSBS, xzr |
| 67 | isb |
| 68 | |
| 69 | 1: |
| 70 | ret |
| 71 | endfunc neoverse_n1_disable_speculative_loads |
| 72 | |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 73 | func neoverse_n1_reset_func |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 74 | mov x19, x30 |
John Tsichritzis | 1f9ff49 | 2019-03-04 16:41:26 +0000 | [diff] [blame] | 75 | |
Sami Mujawar | a8722e9 | 2019-05-10 14:28:37 +0100 | [diff] [blame] | 76 | bl neoverse_n1_disable_speculative_loads |
John Tsichritzis | 1f9ff49 | 2019-03-04 16:41:26 +0000 | [diff] [blame] | 77 | |
Louis Mayencourt | b58142b | 2019-04-18 14:34:11 +0100 | [diff] [blame] | 78 | /* Forces all cacheable atomic instructions to be near */ |
| 79 | mrs x0, NEOVERSE_N1_CPUACTLR2_EL1 |
| 80 | orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_2 |
| 81 | msr NEOVERSE_N1_CPUACTLR2_EL1, x0 |
| 82 | isb |
| 83 | |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 84 | bl cpu_get_rev_var |
| 85 | mov x18, x0 |
| 86 | |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 87 | #if ERRATA_N1_1043202 |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 88 | mov x0, x18 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 89 | bl errata_n1_1043202_wa |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 90 | #endif |
| 91 | |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 92 | #if ENABLE_AMU |
| 93 | /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */ |
| 94 | mrs x0, actlr_el3 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 95 | orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 96 | msr actlr_el3, x0 |
| 97 | isb |
| 98 | |
| 99 | /* Make sure accesses from EL0/EL1 are not trapped to EL2 */ |
| 100 | mrs x0, actlr_el2 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 101 | orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 102 | msr actlr_el2, x0 |
| 103 | isb |
| 104 | |
| 105 | /* Enable group0 counters */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 106 | mov x0, #NEOVERSE_N1_AMU_GROUP0_MASK |
Dimitris Papastamos | 89736dd | 2018-02-13 11:28:02 +0000 | [diff] [blame] | 107 | msr CPUAMCNTENSET_EL0, x0 |
| 108 | isb |
| 109 | #endif |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 110 | ret x19 |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 111 | endfunc neoverse_n1_reset_func |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 112 | |
| 113 | /* --------------------------------------------- |
| 114 | * HW will do the cache maintenance while powering down |
| 115 | * --------------------------------------------- |
| 116 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 117 | func neoverse_n1_core_pwr_dwn |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 118 | /* --------------------------------------------- |
| 119 | * Enable CPU power down bit in power control register |
| 120 | * --------------------------------------------- |
| 121 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 122 | mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1 |
| 123 | orr x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK |
| 124 | msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0 |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 125 | isb |
| 126 | ret |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 127 | endfunc neoverse_n1_core_pwr_dwn |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 128 | |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 129 | #if REPORT_ERRATA |
| 130 | /* |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 131 | * Errata printing function for Neoverse N1. Must follow AAPCS. |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 132 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 133 | func neoverse_n1_errata_report |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 134 | stp x8, x30, [sp, #-16]! |
| 135 | |
| 136 | bl cpu_get_rev_var |
| 137 | mov x8, x0 |
| 138 | |
| 139 | /* |
| 140 | * Report all errata. The revision-variant information is passed to |
| 141 | * checking functions of each errata. |
| 142 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 143 | report_errata ERRATA_N1_1043202, neoverse_n1, 1043202 |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 144 | |
| 145 | ldp x8, x30, [sp], #16 |
| 146 | ret |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 147 | endfunc neoverse_n1_errata_report |
Dimitris Papastamos | 7ca21db | 2018-03-26 16:46:01 +0100 | [diff] [blame] | 148 | #endif |
| 149 | |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 150 | /* --------------------------------------------- |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 151 | * This function provides neoverse_n1 specific |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 152 | * register information for crash reporting. |
| 153 | * It needs to return with x6 pointing to |
| 154 | * a list of register names in ascii and |
| 155 | * x8 - x15 having values of registers to be |
| 156 | * reported. |
| 157 | * --------------------------------------------- |
| 158 | */ |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 159 | .section .rodata.neoverse_n1_regs, "aS" |
| 160 | neoverse_n1_regs: /* The ascii list of register names to be reported */ |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 161 | .asciz "cpuectlr_el1", "" |
| 162 | |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 163 | func neoverse_n1_cpu_reg_dump |
| 164 | adr x6, neoverse_n1_regs |
| 165 | mrs x8, NEOVERSE_N1_CPUECTLR_EL1 |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 166 | ret |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 167 | endfunc neoverse_n1_cpu_reg_dump |
Isla Mitchell | ea84d6b | 2017-08-03 16:04:46 +0100 | [diff] [blame] | 168 | |
John Tsichritzis | 56369c1 | 2019-02-19 13:49:06 +0000 | [diff] [blame] | 169 | declare_cpu_ops neoverse_n1, NEOVERSE_N1_MIDR, \ |
| 170 | neoverse_n1_reset_func, \ |
| 171 | neoverse_n1_core_pwr_dwn |