blob: dadaf98b42aede5bf23791508be5676963a90d6f [file] [log] [blame]
Isla Mitchellabbffe92017-08-03 16:04:46 +01001/*
John Tsichritzisda6d75a2019-02-19 13:49:06 +00002 * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
Isla Mitchellabbffe92017-08-03 16:04:46 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
John Tsichritzisda6d75a2019-02-19 13:49:06 +00009#include <neoverse_n1.h>
Dimitris Papastamos08268e22018-02-13 11:28:02 +000010#include <cpuamu.h>
Isla Mitchellabbffe92017-08-03 16:04:46 +010011#include <cpu_macros.S>
Dimitris Papastamos08268e22018-02-13 11:28:02 +000012
John Tsichritzis076b5f02019-03-19 17:20:52 +000013/* Hardware handled coherency */
14#if HW_ASSISTED_COHERENCY == 0
15#error "Neoverse N1 must be compiled with HW_ASSISTED_COHERENCY enabled"
16#endif
17
John Tsichritzis629d04f2019-06-03 13:54:30 +010018/* 64-bit only core */
19#if CTX_INCLUDE_AARCH32_REGS == 1
20#error "Neoverse-N1 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
21#endif
22
Dimitris Papastamos040b5462018-03-26 16:46:01 +010023/* --------------------------------------------------
John Tsichritzisda6d75a2019-02-19 13:49:06 +000024 * Errata Workaround for Neoverse N1 Errata
25 * This applies to revision r0p0 and r1p0 of Neoverse N1.
Dimitris Papastamos040b5462018-03-26 16:46:01 +010026 * Inputs:
27 * x0: variant[4:7] and revision[0:3] of current cpu.
28 * Shall clobber: x0-x17
29 * --------------------------------------------------
30 */
John Tsichritzisda6d75a2019-02-19 13:49:06 +000031func errata_n1_1043202_wa
Dimitris Papastamos040b5462018-03-26 16:46:01 +010032 /* Compare x0 against revision r1p0 */
33 mov x17, x30
34 bl check_errata_1043202
35 cbz x0, 1f
36
37 /* Apply instruction patching sequence */
38 ldr x0, =0x0
39 msr CPUPSELR_EL3, x0
40 ldr x0, =0xF3BF8F2F
41 msr CPUPOR_EL3, x0
42 ldr x0, =0xFFFFFFFF
43 msr CPUPMR_EL3, x0
44 ldr x0, =0x800200071
45 msr CPUPCR_EL3, x0
46 isb
471:
48 ret x17
John Tsichritzisda6d75a2019-02-19 13:49:06 +000049endfunc errata_n1_1043202_wa
Dimitris Papastamos040b5462018-03-26 16:46:01 +010050
51func check_errata_1043202
52 /* Applies to r0p0 and r1p0 */
53 mov x1, #0x10
54 b cpu_rev_var_ls
55endfunc check_errata_1043202
56
Sami Mujawareca6e452019-05-10 14:28:37 +010057/* --------------------------------------------------
58 * Disable speculative loads if Neoverse N1 supports
59 * SSBS.
60 *
61 * Shall clobber: x0.
62 * --------------------------------------------------
63 */
64func neoverse_n1_disable_speculative_loads
65 /* Check if the PE implements SSBS */
66 mrs x0, id_aa64pfr1_el1
67 tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT)
68 b.eq 1f
69
70 /* Disable speculative loads */
71 msr SSBS, xzr
72 isb
73
741:
75 ret
76endfunc neoverse_n1_disable_speculative_loads
77
John Tsichritzisda6d75a2019-02-19 13:49:06 +000078func neoverse_n1_reset_func
Dimitris Papastamos040b5462018-03-26 16:46:01 +010079 mov x19, x30
John Tsichritzis80744482019-03-04 16:41:26 +000080
Sami Mujawareca6e452019-05-10 14:28:37 +010081 bl neoverse_n1_disable_speculative_loads
John Tsichritzis80744482019-03-04 16:41:26 +000082
Louis Mayencourt632ab3e2019-04-18 14:34:11 +010083 /* Forces all cacheable atomic instructions to be near */
84 mrs x0, NEOVERSE_N1_CPUACTLR2_EL1
85 orr x0, x0, #NEOVERSE_N1_CPUACTLR2_EL1_BIT_2
86 msr NEOVERSE_N1_CPUACTLR2_EL1, x0
87 isb
88
Dimitris Papastamos040b5462018-03-26 16:46:01 +010089 bl cpu_get_rev_var
90 mov x18, x0
91
John Tsichritzisda6d75a2019-02-19 13:49:06 +000092#if ERRATA_N1_1043202
Dimitris Papastamos040b5462018-03-26 16:46:01 +010093 mov x0, x18
John Tsichritzisda6d75a2019-02-19 13:49:06 +000094 bl errata_n1_1043202_wa
Dimitris Papastamos040b5462018-03-26 16:46:01 +010095#endif
96
Dimitris Papastamos08268e22018-02-13 11:28:02 +000097#if ENABLE_AMU
98 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
99 mrs x0, actlr_el3
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000100 orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT
Dimitris Papastamos08268e22018-02-13 11:28:02 +0000101 msr actlr_el3, x0
102 isb
103
104 /* Make sure accesses from EL0/EL1 are not trapped to EL2 */
105 mrs x0, actlr_el2
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000106 orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT
Dimitris Papastamos08268e22018-02-13 11:28:02 +0000107 msr actlr_el2, x0
108 isb
109
110 /* Enable group0 counters */
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000111 mov x0, #NEOVERSE_N1_AMU_GROUP0_MASK
Dimitris Papastamos08268e22018-02-13 11:28:02 +0000112 msr CPUAMCNTENSET_EL0, x0
113 isb
114#endif
Dimitris Papastamos040b5462018-03-26 16:46:01 +0100115 ret x19
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000116endfunc neoverse_n1_reset_func
Isla Mitchellabbffe92017-08-03 16:04:46 +0100117
118 /* ---------------------------------------------
119 * HW will do the cache maintenance while powering down
120 * ---------------------------------------------
121 */
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000122func neoverse_n1_core_pwr_dwn
Isla Mitchellabbffe92017-08-03 16:04:46 +0100123 /* ---------------------------------------------
124 * Enable CPU power down bit in power control register
125 * ---------------------------------------------
126 */
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000127 mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1
128 orr x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK
129 msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0
Isla Mitchellabbffe92017-08-03 16:04:46 +0100130 isb
131 ret
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000132endfunc neoverse_n1_core_pwr_dwn
Isla Mitchellabbffe92017-08-03 16:04:46 +0100133
Dimitris Papastamos040b5462018-03-26 16:46:01 +0100134#if REPORT_ERRATA
135/*
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000136 * Errata printing function for Neoverse N1. Must follow AAPCS.
Dimitris Papastamos040b5462018-03-26 16:46:01 +0100137 */
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000138func neoverse_n1_errata_report
Dimitris Papastamos040b5462018-03-26 16:46:01 +0100139 stp x8, x30, [sp, #-16]!
140
141 bl cpu_get_rev_var
142 mov x8, x0
143
144 /*
145 * Report all errata. The revision-variant information is passed to
146 * checking functions of each errata.
147 */
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000148 report_errata ERRATA_N1_1043202, neoverse_n1, 1043202
Dimitris Papastamos040b5462018-03-26 16:46:01 +0100149
150 ldp x8, x30, [sp], #16
151 ret
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000152endfunc neoverse_n1_errata_report
Dimitris Papastamos040b5462018-03-26 16:46:01 +0100153#endif
154
Isla Mitchellabbffe92017-08-03 16:04:46 +0100155 /* ---------------------------------------------
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000156 * This function provides neoverse_n1 specific
Isla Mitchellabbffe92017-08-03 16:04:46 +0100157 * register information for crash reporting.
158 * It needs to return with x6 pointing to
159 * a list of register names in ascii and
160 * x8 - x15 having values of registers to be
161 * reported.
162 * ---------------------------------------------
163 */
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000164.section .rodata.neoverse_n1_regs, "aS"
165neoverse_n1_regs: /* The ascii list of register names to be reported */
Isla Mitchellabbffe92017-08-03 16:04:46 +0100166 .asciz "cpuectlr_el1", ""
167
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000168func neoverse_n1_cpu_reg_dump
169 adr x6, neoverse_n1_regs
170 mrs x8, NEOVERSE_N1_CPUECTLR_EL1
Isla Mitchellabbffe92017-08-03 16:04:46 +0100171 ret
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000172endfunc neoverse_n1_cpu_reg_dump
Isla Mitchellabbffe92017-08-03 16:04:46 +0100173
John Tsichritzisda6d75a2019-02-19 13:49:06 +0000174declare_cpu_ops neoverse_n1, NEOVERSE_N1_MIDR, \
175 neoverse_n1_reset_func, \
176 neoverse_n1_core_pwr_dwn