blob: c8cccf278a4a972170b5882851a0c05330bee104 [file] [log] [blame]
Artsem Artsemenkafea97f72019-09-16 15:11:21 +01001/*
Jimmy Brisson3571fb92020-06-01 10:18:22 -05002 * Copyright (c) 2019-2020, ARM Limited. All rights reserved.
Varun Wadekara3110ad2021-07-27 00:39:40 -07003 * Copyright (c) 2021, NVIDIA Corporation. All rights reserved.
Artsem Artsemenkafea97f72019-09-16 15:11:21 +01004 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#include <arch.h>
9#include <asm_macros.S>
10#include <common/bl_common.h>
Jimmy Brisson7cc90c42020-09-30 15:34:51 -050011#include <cortex_a78_ae.h>
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010012#include <cpu_macros.S>
13#include <plat_macros.S>
14
15/* Hardware handled coherency */
16#if HW_ASSISTED_COHERENCY == 0
Jimmy Brisson7cc90c42020-09-30 15:34:51 -050017#error "cortex_a78_ae must be compiled with HW_ASSISTED_COHERENCY enabled"
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010018#endif
19
Varun Wadekara3110ad2021-07-27 00:39:40 -070020/* --------------------------------------------------
21 * Errata Workaround for A78 AE Erratum 1951502.
22 * This applies to revisions r0p0 and r0p1 of A78 AE.
23 * Inputs:
24 * x0: variant[4:7] and revision[0:3] of current cpu.
25 * Shall clobber: x0-x17
26 * --------------------------------------------------
27 */
28func errata_a78_ae_1951502_wa
29 /* Compare x0 against revisions r0p0 - r0p1 */
30 mov x17, x30
31 bl check_errata_1951502
32 cbz x0, 1f
33
34 msr S3_6_c15_c8_0, xzr
35 ldr x0, =0x10E3900002
36 msr S3_6_c15_c8_2, x0
37 ldr x0, =0x10FFF00083
38 msr S3_6_c15_c8_3, x0
39 ldr x0, =0x2001003FF
40 msr S3_6_c15_c8_1, x0
41
42 mov x0, #1
43 msr S3_6_c15_c8_0, x0
44 ldr x0, =0x10E3800082
45 msr S3_6_c15_c8_2, x0
46 ldr x0, =0x10FFF00083
47 msr S3_6_c15_c8_3, x0
48 ldr x0, =0x2001003FF
49 msr S3_6_c15_c8_1, x0
50
51 mov x0, #2
52 msr S3_6_c15_c8_0, x0
53 ldr x0, =0x10E3800200
54 msr S3_6_c15_c8_2, x0
55 ldr x0, =0x10FFF003E0
56 msr S3_6_c15_c8_3, x0
57 ldr x0, =0x2001003FF
58 msr S3_6_c15_c8_1, x0
59
60 isb
611:
62 ret x17
63endfunc errata_a78_ae_1951502_wa
64
65func check_errata_1951502
66 /* Applies to revisions r0p0 and r0p1. */
67 mov x1, #CPU_REV(0, 0)
68 mov x2, #CPU_REV(0, 1)
69 b cpu_rev_var_range
70endfunc check_errata_1951502
71
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010072 /* -------------------------------------------------
Jimmy Brisson7cc90c42020-09-30 15:34:51 -050073 * The CPU Ops reset function for Cortex-A78-AE
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010074 * -------------------------------------------------
75 */
Jimmy Brisson7cc90c42020-09-30 15:34:51 -050076func cortex_a78_ae_reset_func
Varun Wadekara3110ad2021-07-27 00:39:40 -070077 mov x19, x30
78 bl cpu_get_rev_var
79 mov x18, x0
80
81#if ERRATA_A78_AE_1951502
82 mov x0, x18
83 bl errata_a78_ae_1951502_wa
84#endif
85
86#if ENABLE_AMU
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010087 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
88 mrs x0, actlr_el3
Jimmy Brisson3571fb92020-06-01 10:18:22 -050089 bic x0, x0, #CORTEX_A78_ACTLR_TAM_BIT
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010090 msr actlr_el3, x0
91
92 /* Make sure accesses from non-secure EL0/EL1 are not trapped to EL2 */
93 mrs x0, actlr_el2
Jimmy Brisson3571fb92020-06-01 10:18:22 -050094 bic x0, x0, #CORTEX_A78_ACTLR_TAM_BIT
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010095 msr actlr_el2, x0
96
97 /* Enable group0 counters */
Jimmy Brisson3571fb92020-06-01 10:18:22 -050098 mov x0, #CORTEX_A78_AMU_GROUP0_MASK
Artsem Artsemenkafea97f72019-09-16 15:11:21 +010099 msr CPUAMCNTENSET0_EL0, x0
100
101 /* Enable group1 counters */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500102 mov x0, #CORTEX_A78_AMU_GROUP1_MASK
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100103 msr CPUAMCNTENSET1_EL0, x0
Varun Wadekara3110ad2021-07-27 00:39:40 -0700104#endif
105
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100106 isb
107
Varun Wadekara3110ad2021-07-27 00:39:40 -0700108 ret x19
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500109endfunc cortex_a78_ae_reset_func
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100110
111 /* -------------------------------------------------------
112 * HW will do the cache maintenance while powering down
113 * -------------------------------------------------------
114 */
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500115func cortex_a78_ae_core_pwr_dwn
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100116 /* -------------------------------------------------------
117 * Enable CPU power down bit in power control register
118 * -------------------------------------------------------
119 */
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500120 mrs x0, CORTEX_A78_CPUPWRCTLR_EL1
121 orr x0, x0, #CORTEX_A78_CPUPWRCTLR_EL1_CORE_PWRDN_EN_BIT
122 msr CORTEX_A78_CPUPWRCTLR_EL1, x0
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100123 isb
124 ret
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500125endfunc cortex_a78_ae_core_pwr_dwn
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100126
127 /*
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500128 * Errata printing function for cortex_a78_ae. Must follow AAPCS.
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100129 */
130#if REPORT_ERRATA
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500131func cortex_a78_ae_errata_report
Varun Wadekara3110ad2021-07-27 00:39:40 -0700132 stp x8, x30, [sp, #-16]!
133
134 bl cpu_get_rev_var
135 mov x8, x0
136
137 /*
138 * Report all errata. The revision-variant information is passed to
139 * checking functions of each errata.
140 */
141 report_errata ERRATA_A78_AE_1951502, cortex_a78_ae, 1951502
142
143 ldp x8, x30, [sp], #16
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100144 ret
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500145endfunc cortex_a78_ae_errata_report
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100146#endif
147
148 /* -------------------------------------------------------
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500149 * This function provides cortex_a78_ae specific
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100150 * register information for crash reporting.
151 * It needs to return with x6 pointing to
152 * a list of register names in ascii and
153 * x8 - x15 having values of registers to be
154 * reported.
155 * -------------------------------------------------------
156 */
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500157.section .rodata.cortex_a78_ae_regs, "aS"
158cortex_a78_ae_regs: /* The ascii list of register names to be reported */
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100159 .asciz "cpuectlr_el1", ""
160
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500161func cortex_a78_ae_cpu_reg_dump
162 adr x6, cortex_a78_ae_regs
Jimmy Brisson3571fb92020-06-01 10:18:22 -0500163 mrs x8, CORTEX_A78_CPUECTLR_EL1
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100164 ret
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500165endfunc cortex_a78_ae_cpu_reg_dump
Artsem Artsemenkafea97f72019-09-16 15:11:21 +0100166
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500167declare_cpu_ops cortex_a78_ae, CORTEX_A78_AE_MIDR, \
Varun Wadekara3110ad2021-07-27 00:39:40 -0700168 cortex_a78_ae_reset_func, \
Jimmy Brisson7cc90c42020-09-30 15:34:51 -0500169 cortex_a78_ae_core_pwr_dwn