blob: c6a5c08f93389de5360b304625369dc3e036cfe6 [file] [log] [blame]
Isla Mitchellea84d6b2017-08-03 16:04:46 +01001/*
John Tsichritzis56369c12019-02-19 13:49:06 +00002 * Copyright (c) 2017-2019, 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>
John Tsichritzis56369c12019-02-19 13:49:06 +00009#include <neoverse_n1.h>
Dimitris Papastamos89736dd2018-02-13 11:28:02 +000010#include <cpuamu.h>
Isla Mitchellea84d6b2017-08-03 16:04:46 +010011#include <cpu_macros.S>
Dimitris Papastamos89736dd2018-02-13 11:28:02 +000012
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010013/* --------------------------------------------------
John Tsichritzis56369c12019-02-19 13:49:06 +000014 * Errata Workaround for Neoverse N1 Errata
15 * This applies to revision r0p0 and r1p0 of Neoverse N1.
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010016 * Inputs:
17 * x0: variant[4:7] and revision[0:3] of current cpu.
18 * Shall clobber: x0-x17
19 * --------------------------------------------------
20 */
John Tsichritzis56369c12019-02-19 13:49:06 +000021func errata_n1_1043202_wa
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010022 /* Compare x0 against revision r1p0 */
23 mov x17, x30
24 bl check_errata_1043202
25 cbz x0, 1f
26
27 /* Apply instruction patching sequence */
28 ldr x0, =0x0
29 msr CPUPSELR_EL3, x0
30 ldr x0, =0xF3BF8F2F
31 msr CPUPOR_EL3, x0
32 ldr x0, =0xFFFFFFFF
33 msr CPUPMR_EL3, x0
34 ldr x0, =0x800200071
35 msr CPUPCR_EL3, x0
36 isb
371:
38 ret x17
John Tsichritzis56369c12019-02-19 13:49:06 +000039endfunc errata_n1_1043202_wa
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010040
41func check_errata_1043202
42 /* Applies to r0p0 and r1p0 */
43 mov x1, #0x10
44 b cpu_rev_var_ls
45endfunc check_errata_1043202
46
John Tsichritzis56369c12019-02-19 13:49:06 +000047func neoverse_n1_reset_func
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010048 mov x19, x30
49 bl cpu_get_rev_var
50 mov x18, x0
51
John Tsichritzis56369c12019-02-19 13:49:06 +000052#if ERRATA_N1_1043202
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010053 mov x0, x18
John Tsichritzis56369c12019-02-19 13:49:06 +000054 bl errata_n1_1043202_wa
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010055#endif
56
Dimitris Papastamos89736dd2018-02-13 11:28:02 +000057#if ENABLE_AMU
58 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
59 mrs x0, actlr_el3
John Tsichritzis56369c12019-02-19 13:49:06 +000060 orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT
Dimitris Papastamos89736dd2018-02-13 11:28:02 +000061 msr actlr_el3, x0
62 isb
63
64 /* Make sure accesses from EL0/EL1 are not trapped to EL2 */
65 mrs x0, actlr_el2
John Tsichritzis56369c12019-02-19 13:49:06 +000066 orr x0, x0, #NEOVERSE_N1_ACTLR_AMEN_BIT
Dimitris Papastamos89736dd2018-02-13 11:28:02 +000067 msr actlr_el2, x0
68 isb
69
70 /* Enable group0 counters */
John Tsichritzis56369c12019-02-19 13:49:06 +000071 mov x0, #NEOVERSE_N1_AMU_GROUP0_MASK
Dimitris Papastamos89736dd2018-02-13 11:28:02 +000072 msr CPUAMCNTENSET_EL0, x0
73 isb
74#endif
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010075 ret x19
John Tsichritzis56369c12019-02-19 13:49:06 +000076endfunc neoverse_n1_reset_func
Isla Mitchellea84d6b2017-08-03 16:04:46 +010077
78 /* ---------------------------------------------
79 * HW will do the cache maintenance while powering down
80 * ---------------------------------------------
81 */
John Tsichritzis56369c12019-02-19 13:49:06 +000082func neoverse_n1_core_pwr_dwn
Isla Mitchellea84d6b2017-08-03 16:04:46 +010083 /* ---------------------------------------------
84 * Enable CPU power down bit in power control register
85 * ---------------------------------------------
86 */
John Tsichritzis56369c12019-02-19 13:49:06 +000087 mrs x0, NEOVERSE_N1_CPUPWRCTLR_EL1
88 orr x0, x0, #NEOVERSE_N1_CORE_PWRDN_EN_MASK
89 msr NEOVERSE_N1_CPUPWRCTLR_EL1, x0
Isla Mitchellea84d6b2017-08-03 16:04:46 +010090 isb
91 ret
John Tsichritzis56369c12019-02-19 13:49:06 +000092endfunc neoverse_n1_core_pwr_dwn
Isla Mitchellea84d6b2017-08-03 16:04:46 +010093
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010094#if REPORT_ERRATA
95/*
John Tsichritzis56369c12019-02-19 13:49:06 +000096 * Errata printing function for Neoverse N1. Must follow AAPCS.
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010097 */
John Tsichritzis56369c12019-02-19 13:49:06 +000098func neoverse_n1_errata_report
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +010099 stp x8, x30, [sp, #-16]!
100
101 bl cpu_get_rev_var
102 mov x8, x0
103
104 /*
105 * Report all errata. The revision-variant information is passed to
106 * checking functions of each errata.
107 */
John Tsichritzis56369c12019-02-19 13:49:06 +0000108 report_errata ERRATA_N1_1043202, neoverse_n1, 1043202
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100109
110 ldp x8, x30, [sp], #16
111 ret
John Tsichritzis56369c12019-02-19 13:49:06 +0000112endfunc neoverse_n1_errata_report
Dimitris Papastamos7ca21db2018-03-26 16:46:01 +0100113#endif
114
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100115 /* ---------------------------------------------
John Tsichritzis56369c12019-02-19 13:49:06 +0000116 * This function provides neoverse_n1 specific
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100117 * register information for crash reporting.
118 * It needs to return with x6 pointing to
119 * a list of register names in ascii and
120 * x8 - x15 having values of registers to be
121 * reported.
122 * ---------------------------------------------
123 */
John Tsichritzis56369c12019-02-19 13:49:06 +0000124.section .rodata.neoverse_n1_regs, "aS"
125neoverse_n1_regs: /* The ascii list of register names to be reported */
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100126 .asciz "cpuectlr_el1", ""
127
John Tsichritzis56369c12019-02-19 13:49:06 +0000128func neoverse_n1_cpu_reg_dump
129 adr x6, neoverse_n1_regs
130 mrs x8, NEOVERSE_N1_CPUECTLR_EL1
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100131 ret
John Tsichritzis56369c12019-02-19 13:49:06 +0000132endfunc neoverse_n1_cpu_reg_dump
Isla Mitchellea84d6b2017-08-03 16:04:46 +0100133
John Tsichritzis56369c12019-02-19 13:49:06 +0000134declare_cpu_ops neoverse_n1, NEOVERSE_N1_MIDR, \
135 neoverse_n1_reset_func, \
136 neoverse_n1_core_pwr_dwn