• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <common/bl_common.h>
10#include <cortex_a77.h>
11#include <cpu_macros.S>
12#include <plat_macros.S>
13
14/* Hardware handled coherency */
15#if HW_ASSISTED_COHERENCY == 0
16#error "Cortex-A77 must be compiled with HW_ASSISTED_COHERENCY enabled"
17#endif
18
19/* 64-bit only core */
20#if CTX_INCLUDE_AARCH32_REGS == 1
21#error "Cortex-A77 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
22#endif
23
24	/* --------------------------------------------------
25	 * Errata Workaround for Cortex A77 Errata #1508412.
26	 * This applies only to revision <= r1p0 of Cortex A77.
27	 * Inputs:
28	 * x0: variant[4:7] and revision[0:3] of current cpu.
29	 * Shall clobber: x0-x17
30	 * --------------------------------------------------
31	 */
32func errata_a77_1508412_wa
33	/*
34	 * Compare x0 against revision r1p0
35	 */
36	mov	x17, x30
37	bl	check_errata_1508412
38	cbz	x0, 3f
39	/*
40	 * Compare x0 against revision r0p0
41	 */
42	bl	check_errata_1508412_0
43	cbz	x0, 1f
44	ldr	x0, =0x0
45	msr	CORTEX_A77_CPUPSELR_EL3, x0
46	ldr 	x0, =0x00E8400000
47	msr	CORTEX_A77_CPUPOR_EL3, x0
48	ldr	x0, =0x00FFE00000
49	msr	CORTEX_A77_CPUPMR_EL3, x0
50	ldr	x0, =0x4004003FF
51	msr	CORTEX_A77_CPUPCR_EL3, x0
52	ldr	x0, =0x1
53	msr	CORTEX_A77_CPUPSELR_EL3, x0
54	ldr	x0, =0x00E8C00040
55	msr	CORTEX_A77_CPUPOR_EL3, x0
56	ldr	x0, =0x00FFE00040
57	msr	CORTEX_A77_CPUPMR_EL3, x0
58	b	2f
591:
60	ldr	x0, =0x0
61	msr	CORTEX_A77_CPUPSELR_EL3, x0
62	ldr	x0, =0x00E8400000
63	msr	CORTEX_A77_CPUPOR_EL3, x0
64	ldr	x0, =0x00FF600000
65	msr	CORTEX_A77_CPUPMR_EL3, x0
66	ldr	x0, =0x00E8E00080
67	msr	CORTEX_A77_CPUPOR2_EL3, x0
68	ldr	x0, =0x00FFE000C0
69	msr	CORTEX_A77_CPUPMR2_EL3, x0
702:
71	ldr	x0, =0x04004003FF
72	msr	CORTEX_A77_CPUPCR_EL3, x0
73	isb
743:
75	ret	x17
76endfunc errata_a77_1508412_wa
77
78func check_errata_1508412
79	mov	x1, #0x10
80	b	cpu_rev_var_ls
81endfunc check_errata_1508412
82
83func check_errata_1508412_0
84	mov	x1, #0x0
85	b	cpu_rev_var_ls
86endfunc check_errata_1508412_0
87
88	/* --------------------------------------------------
89	 * Errata Workaround for Cortex A77 Errata #1925769.
90	 * This applies to revision <= r1p1 of Cortex A77.
91	 * Inputs:
92	 * x0: variant[4:7] and revision[0:3] of current cpu.
93	 * Shall clobber: x0-x17
94	 * --------------------------------------------------
95	 */
96func errata_a77_1925769_wa
97	/* Compare x0 against revision <= r1p1 */
98	mov	x17, x30
99	bl	check_errata_1925769
100	cbz	x0, 1f
101
102	/* Set bit 8 in ECTLR_EL1 */
103	mrs	x1, CORTEX_A77_CPUECTLR_EL1
104	orr	x1, x1, #CORTEX_A77_CPUECTLR_EL1_BIT_8
105	msr	CORTEX_A77_CPUECTLR_EL1, x1
106	isb
1071:
108	ret	x17
109endfunc errata_a77_1925769_wa
110
111func check_errata_1925769
112	/* Applies to everything <= r1p1 */
113	mov	x1, #0x11
114	b	cpu_rev_var_ls
115endfunc check_errata_1925769
116
117	/* -------------------------------------------------
118	 * The CPU Ops reset function for Cortex-A77.
119	 * Shall clobber: x0-x19
120	 * -------------------------------------------------
121	 */
122func cortex_a77_reset_func
123	mov	x19, x30
124	bl	cpu_get_rev_var
125	mov	x18, x0
126
127#if ERRATA_A77_1508412
128	mov	x0, x18
129	bl	errata_a77_1508412_wa
130#endif
131
132#if ERRATA_A77_1925769
133	mov	x0, x18
134	bl	errata_a77_1925769_wa
135#endif
136
137	ret	x19
138endfunc cortex_a77_reset_func
139
140	/* ---------------------------------------------
141	 * HW will do the cache maintenance while powering down
142	 * ---------------------------------------------
143	 */
144func cortex_a77_core_pwr_dwn
145	/* ---------------------------------------------
146	 * Enable CPU power down bit in power control register
147	 * ---------------------------------------------
148	 */
149	mrs	x0, CORTEX_A77_CPUPWRCTLR_EL1
150	orr	x0, x0, #CORTEX_A77_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
151	msr	CORTEX_A77_CPUPWRCTLR_EL1, x0
152	isb
153	ret
154endfunc cortex_a77_core_pwr_dwn
155
156#if REPORT_ERRATA
157/*
158 * Errata printing function for Cortex-A77. Must follow AAPCS.
159 */
160func cortex_a77_errata_report
161	stp	x8, x30, [sp, #-16]!
162
163	bl	cpu_get_rev_var
164	mov	x8, x0
165
166	/*
167	 * Report all errata. The revision-variant information is passed to
168	 * checking functions of each errata.
169	 */
170	report_errata ERRATA_A77_1508412, cortex_a77, 1508412
171	report_errata ERRATA_A77_1925769, cortex_a77, 1925769
172
173	ldp	x8, x30, [sp], #16
174	ret
175endfunc cortex_a77_errata_report
176#endif
177
178
179	/* ---------------------------------------------
180	 * This function provides Cortex-A77 specific
181	 * register information for crash reporting.
182	 * It needs to return with x6 pointing to
183	 * a list of register names in ascii and
184	 * x8 - x15 having values of registers to be
185	 * reported.
186	 * ---------------------------------------------
187	 */
188.section .rodata.cortex_a77_regs, "aS"
189cortex_a77_regs:  /* The ascii list of register names to be reported */
190	.asciz	"cpuectlr_el1", ""
191
192func cortex_a77_cpu_reg_dump
193	adr	x6, cortex_a77_regs
194	mrs	x8, CORTEX_A77_CPUECTLR_EL1
195	ret
196endfunc cortex_a77_cpu_reg_dump
197
198declare_cpu_ops cortex_a77, CORTEX_A77_MIDR, \
199	cortex_a77_reset_func, \
200	cortex_a77_core_pwr_dwn
201