cortex_a55.S 8.18 KB
Newer Older
1
/*
2
 * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
3
4
5
6
7
8
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <arch.h>
#include <asm_macros.S>
9
#include <common/bl_common.h>
Isla Mitchell's avatar
Isla Mitchell committed
10
#include <cortex_a55.h>
11
12
13
#include <cpu_macros.S>
#include <plat_macros.S>

14
15
16
17
18
/* Hardware handled coherency */
#if HW_ASSISTED_COHERENCY == 0
#error "Cortex-A55 must be compiled with HW_ASSISTED_COHERENCY enabled"
#endif

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
	/* --------------------------------------------------
	 * Errata Workaround for Cortex A55 Errata #768277.
	 * This applies only to revision r0p0 of Cortex A55.
	 * Inputs:
	 * x0: variant[4:7] and revision[0:3] of current cpu.
	 * Shall clobber: x0-x17
	 * --------------------------------------------------
	 */
func errata_a55_768277_wa
	/*
	 * Compare x0 against revision r0p0
	 */
	mov	x17, x30
	bl	check_errata_768277
	cbz	x0, 1f
	mrs	x1, CORTEX_A55_CPUACTLR_EL1
	orr	x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_DUAL_ISSUE
	msr	CORTEX_A55_CPUACTLR_EL1, x1
	isb
1:
	ret	x17
endfunc errata_a55_768277_wa

func check_errata_768277
	mov	x1, #0x00
	b	cpu_rev_var_ls
endfunc check_errata_768277

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
	/* ------------------------------------------------------------------
	 * Errata Workaround for Cortex A55 Errata #778703.
	 * This applies only to revision r0p0 of Cortex A55 where L2 cache is
	 * not configured.
	 * Inputs:
	 * x0: variant[4:7] and revision[0:3] of current cpu.
	 * Shall clobber: x0-x17
	 * ------------------------------------------------------------------
	 */
func errata_a55_778703_wa
	/*
	 * Compare x0 against revision r0p0 and check that no private L2 cache
	 * is configured
	 */
	mov	x17, x30
	bl	check_errata_778703
	cbz	x0, 1f
	mrs	x1, CORTEX_A55_CPUECTLR_EL1
	orr	x1, x1, #CORTEX_A55_CPUECTLR_EL1_L1WSCTL
	msr	CORTEX_A55_CPUECTLR_EL1, x1
	mrs	x1, CORTEX_A55_CPUACTLR_EL1
	orr	x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_WRITE_STREAMING
	msr	CORTEX_A55_CPUACTLR_EL1, x1
	isb
1:
	ret	x17
endfunc errata_a55_778703_wa

func check_errata_778703
	mov	x16, x30
	mov	x1, #0x00
	bl	cpu_rev_var_ls
	/*
	 * Check that no private L2 cache is configured
	 */
	mrs	x1, CORTEX_A55_CLIDR_EL1
	and	x1, x1, CORTEX_A55_CLIDR_EL1_CTYPE3
	cmp	x1, #0
	mov	x2, #ERRATA_NOT_APPLIES
	csel	x0, x0, x2, eq
	ret	x16
endfunc check_errata_778703

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
	/* --------------------------------------------------
	 * Errata Workaround for Cortex A55 Errata #798797.
	 * This applies only to revision r0p0 of Cortex A55.
	 * Inputs:
	 * x0: variant[4:7] and revision[0:3] of current cpu.
	 * Shall clobber: x0-x17
	 * --------------------------------------------------
	 */
func errata_a55_798797_wa
	/*
	 * Compare x0 against revision r0p0
	 */
	mov	x17, x30
	bl	check_errata_798797
	cbz	x0, 1f
	mrs	x1, CORTEX_A55_CPUACTLR_EL1
	orr	x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_L1_PAGEWALKS
	msr	CORTEX_A55_CPUACTLR_EL1, x1
	isb
1:
	ret	x17
endfunc errata_a55_798797_wa

func check_errata_798797
	mov	x1, #0x00
	b	cpu_rev_var_ls
endfunc check_errata_798797

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
	/* --------------------------------------------------------------------
	 * Errata Workaround for Cortex A55 Errata #846532.
	 * This applies only to revisions <= r0p1 of Cortex A55.
	 * Disabling dual-issue has a small impact on performance. Disabling a
	 * power optimization feature is an alternate workaround with no impact
	 * on performance but with an increase in power consumption (see errata
	 * notice).
	 * Inputs:
	 * x0: variant[4:7] and revision[0:3] of current cpu.
	 * Shall clobber: x0-x17
	 * --------------------------------------------------------------------
	 */
func errata_a55_846532_wa
	/*
	 * Compare x0 against revision r0p1
	 */
	mov	x17, x30
	bl	check_errata_846532
	cbz	x0, 1f
	mrs	x1, CORTEX_A55_CPUACTLR_EL1
	orr	x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_DUAL_ISSUE
	msr	CORTEX_A55_CPUACTLR_EL1, x1
	isb
1:
	ret	x17
endfunc errata_a55_846532_wa

func check_errata_846532
	mov	x1, #0x01
	b	cpu_rev_var_ls
endfunc check_errata_846532

150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
	/* -----------------------------------------------------
	 * Errata Workaround for Cortex A55 Errata #903758.
	 * This applies only to revisions <= r0p1 of Cortex A55.
	 * Inputs:
	 * x0: variant[4:7] and revision[0:3] of current cpu.
	 * Shall clobber: x0-x17
	 * -----------------------------------------------------
	 */
func errata_a55_903758_wa
	/*
	 * Compare x0 against revision r0p1
	 */
	mov	x17, x30
	bl	check_errata_903758
	cbz	x0, 1f
	mrs	x1, CORTEX_A55_CPUACTLR_EL1
	orr	x1, x1, #CORTEX_A55_CPUACTLR_EL1_DISABLE_L1_PAGEWALKS
	msr	CORTEX_A55_CPUACTLR_EL1, x1
	isb
1:
	ret	x17
endfunc errata_a55_903758_wa

func check_errata_903758
	mov	x1, #0x01
	b	cpu_rev_var_ls
endfunc check_errata_903758

178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
	/* -----------------------------------------------------
	 * Errata Workaround for Cortex A55 Errata #1221012.
	 * This applies only to revisions <= r1p0 of Cortex A55.
	 * Inputs:
	 * x0: variant[4:7] and revision[0:3] of current cpu.
	 * Shall clobber: x0-x17
	 * -----------------------------------------------------
	 */
func errata_a55_1221012_wa
	/*
	 * Compare x0 against revision r1p0
	 */
	mov	x17, x30
	bl	check_errata_1221012
	cbz	x0, 1f
	mov	x0, #0x0020
	movk	x0, #0x0850, lsl #16
	msr	CPUPOR_EL3, x0
	mov	x0, #0x0000
	movk	x0, #0x1FF0, lsl #16
	movk	x0, #0x2, lsl #32
	msr	CPUPMR_EL3, x0
	mov	x0, #0x03fd
	movk	x0, #0x0110, lsl #16
	msr	CPUPCR_EL3, x0
	mov	x0, #0x1
	msr	CPUPSELR_EL3, x0
	mov	x0, #0x0040
	movk	x0, #0x08D0, lsl #16
	msr	CPUPOR_EL3, x0
	mov	x0, #0x0040
	movk	x0, #0x1FF0, lsl #16
	movk	x0, #0x2, lsl #32
	msr	CPUPMR_EL3, x0
	mov	x0, #0x03fd
	movk	x0, #0x0110, lsl #16
	msr	CPUPCR_EL3, x0
	isb
1:
	ret	x17
endfunc errata_a55_1221012_wa

func check_errata_1221012
	mov	x1, #0x10
	b	cpu_rev_var_ls
endfunc check_errata_1221012

225
226
func cortex_a55_reset_func
	mov	x19, x30
227

228
229
230
231
#if ERRATA_DSU_798953
	bl	errata_dsu_798953_wa
#endif

232
233
234
#if ERRATA_DSU_936184
	bl	errata_dsu_936184_wa
#endif
235
236
237
238
239
240
241
242
243

	bl	cpu_get_rev_var
	mov	x18, x0

#if ERRATA_A55_768277
	mov	x0, x18
	bl	errata_a55_768277_wa
#endif

244
245
246
247
248
#if ERRATA_A55_778703
	mov	x0, x18
	bl	errata_a55_778703_wa
#endif

249
250
251
252
253
#if ERRATA_A55_798797
	mov	x0, x18
	bl	errata_a55_798797_wa
#endif

254
255
256
257
258
#if ERRATA_A55_846532
	mov	x0, x18
	bl	errata_a55_846532_wa
#endif

259
260
261
262
263
#if ERRATA_A55_903758
	mov	x0, x18
	bl	errata_a55_903758_wa
#endif

264
265
266
267
268
#if ERRATA_A55_1221012
	mov	x0, x18
	bl	errata_a55_1221012_wa
#endif

269
270
271
	ret	x19
endfunc cortex_a55_reset_func

272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
	/* ---------------------------------------------
	 * HW will do the cache maintenance while powering down
	 * ---------------------------------------------
	 */
func cortex_a55_core_pwr_dwn
	/* ---------------------------------------------
	 * Enable CPU power down bit in power control register
	 * ---------------------------------------------
	 */
	mrs	x0, CORTEX_A55_CPUPWRCTLR_EL1
	orr	x0, x0, #CORTEX_A55_CORE_PWRDN_EN_MASK
	msr	CORTEX_A55_CPUPWRCTLR_EL1, x0
	isb
	ret
endfunc cortex_a55_core_pwr_dwn

288
289
290
291
292
293
294
295
296
297
298
299
300
#if REPORT_ERRATA
/*
 * Errata printing function for Cortex A55. Must follow AAPCS & can use stack.
 */
func cortex_a55_errata_report
	stp	x8, x30, [sp, #-16]!
	bl	cpu_get_rev_var
	mov	x8, x0

	/*
	 * Report all errata. The revision variant information is at x8, where
	 * "report_errata" is expecting it and it doesn't corrupt it.
	 */
301
	report_errata ERRATA_DSU_798953, cortex_a55, dsu_798953
302
	report_errata ERRATA_DSU_936184, cortex_a55, dsu_936184
303
	report_errata ERRATA_A55_768277, cortex_a55, 768277
304
	report_errata ERRATA_A55_778703, cortex_a55, 778703
305
	report_errata ERRATA_A55_798797, cortex_a55, 798797
306
	report_errata ERRATA_A55_846532, cortex_a55, 846532
307
	report_errata ERRATA_A55_903758, cortex_a55, 903758
308
	report_errata ERRATA_A55_1221012, cortex_a55, 1221012
309
310
311
312
313
314

	ldp	x8, x30, [sp], #16
	ret
endfunc cortex_a55_errata_report
#endif

315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
	/* ---------------------------------------------
	 * This function provides cortex_a55 specific
	 * register information for crash reporting.
	 * It needs to return with x6 pointing to
	 * a list of register names in ascii and
	 * x8 - x15 having values of registers to be
	 * reported.
	 * ---------------------------------------------
	 */
.section .rodata.cortex_a55_regs, "aS"
cortex_a55_regs:  /* The ascii list of register names to be reported */
	.asciz	"cpuectlr_el1", ""

func cortex_a55_cpu_reg_dump
	adr	x6, cortex_a55_regs
	mrs	x8, CORTEX_A55_CPUECTLR_EL1
	ret
endfunc cortex_a55_cpu_reg_dump

declare_cpu_ops cortex_a55, CORTEX_A55_MIDR, \
335
	cortex_a55_reset_func, \
336
	cortex_a55_core_pwr_dwn