blob: dd03c0f022bfbbc95e82317b5d798aaeecbb15fd [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Ambroise Vincent1b0db762019-02-21 16:35:07 +00002 * Copyright (c) 2014-2019, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005 */
Achin Gupta4f6ad662013-10-25 09:08:21 +01006#include <arch.h>
Andrew Thoelke38bde412014-03-18 13:46:55 +00007#include <asm_macros.S>
Soby Mathew802f8652014-08-14 16:19:29 +01008#include <assert_macros.S>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <common/bl_common.h>
10#include <common/debug.h>
Soby Mathew8e2f2872014-08-14 12:49:05 +010011#include <cortex_a57.h>
Soby Mathewc704cbc2014-08-14 11:33:56 +010012#include <cpu_macros.S>
13#include <plat_macros.S>
Achin Gupta4f6ad662013-10-25 09:08:21 +010014
Soby Mathew8e2f2872014-08-14 12:49:05 +010015 /* ---------------------------------------------
16 * Disable L1 data cache and unified L2 cache
17 * ---------------------------------------------
18 */
19func cortex_a57_disable_dcache
20 mrs x1, sctlr_el3
21 bic x1, x1, #SCTLR_C_BIT
22 msr sctlr_el3, x1
23 isb
24 ret
Kévin Petita877c252015-03-24 14:03:57 +000025endfunc cortex_a57_disable_dcache
Soby Mathew8e2f2872014-08-14 12:49:05 +010026
27 /* ---------------------------------------------
28 * Disable all types of L2 prefetches.
29 * ---------------------------------------------
30 */
31func cortex_a57_disable_l2_prefetch
Varun Wadekar1384a162017-06-05 14:54:46 -070032 mrs x0, CORTEX_A57_ECTLR_EL1
33 orr x0, x0, #CORTEX_A57_ECTLR_DIS_TWD_ACC_PFTCH_BIT
34 mov x1, #CORTEX_A57_ECTLR_L2_IPFTCH_DIST_MASK
35 orr x1, x1, #CORTEX_A57_ECTLR_L2_DPFTCH_DIST_MASK
Soby Mathew8e2f2872014-08-14 12:49:05 +010036 bic x0, x0, x1
Varun Wadekar1384a162017-06-05 14:54:46 -070037 msr CORTEX_A57_ECTLR_EL1, x0
Soby Mathew8e2f2872014-08-14 12:49:05 +010038 isb
Soby Mathew1604fa02014-09-22 12:15:26 +010039 dsb ish
Soby Mathew8e2f2872014-08-14 12:49:05 +010040 ret
Kévin Petita877c252015-03-24 14:03:57 +000041endfunc cortex_a57_disable_l2_prefetch
Soby Mathew8e2f2872014-08-14 12:49:05 +010042
43 /* ---------------------------------------------
44 * Disable intra-cluster coherency
45 * ---------------------------------------------
46 */
47func cortex_a57_disable_smp
Varun Wadekar1384a162017-06-05 14:54:46 -070048 mrs x0, CORTEX_A57_ECTLR_EL1
49 bic x0, x0, #CORTEX_A57_ECTLR_SMP_BIT
50 msr CORTEX_A57_ECTLR_EL1, x0
Soby Mathew8e2f2872014-08-14 12:49:05 +010051 ret
Kévin Petita877c252015-03-24 14:03:57 +000052endfunc cortex_a57_disable_smp
Soby Mathew8e2f2872014-08-14 12:49:05 +010053
54 /* ---------------------------------------------
55 * Disable debug interfaces
56 * ---------------------------------------------
57 */
58func cortex_a57_disable_ext_debug
59 mov x0, #1
60 msr osdlr_el1, x0
61 isb
Ambroise Vincentaa2c0292019-02-21 16:35:49 +000062#if ERRATA_A57_817169
63 /*
64 * Invalidate any TLB address
65 */
66 mov x0, #0
67 tlbi vae3, x0
68#endif
Soby Mathew8e2f2872014-08-14 12:49:05 +010069 dsb sy
70 ret
Kévin Petita877c252015-03-24 14:03:57 +000071endfunc cortex_a57_disable_ext_debug
Achin Gupta4f6ad662013-10-25 09:08:21 +010072
Soby Mathewc0884332014-09-22 12:11:36 +010073 /* --------------------------------------------------
74 * Errata Workaround for Cortex A57 Errata #806969.
75 * This applies only to revision r0p0 of Cortex A57.
76 * Inputs:
77 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000078 * Shall clobber: x0-x17
Soby Mathewc0884332014-09-22 12:11:36 +010079 * --------------------------------------------------
Soby Mathew802f8652014-08-14 16:19:29 +010080 */
Soby Mathewc0884332014-09-22 12:11:36 +010081func errata_a57_806969_wa
82 /*
83 * Compare x0 against revision r0p0
84 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000085 mov x17, x30
86 bl check_errata_806969
87 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +010088 mrs x1, CORTEX_A57_CPUACTLR_EL1
89 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_NO_ALLOC_WBWA
90 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000911:
92 ret x17
Kévin Petita877c252015-03-24 14:03:57 +000093endfunc errata_a57_806969_wa
Soby Mathewc0884332014-09-22 12:11:36 +010094
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000095func check_errata_806969
96 mov x1, #0x00
97 b cpu_rev_var_ls
98endfunc check_errata_806969
Soby Mathewc0884332014-09-22 12:11:36 +010099
100 /* ---------------------------------------------------
Antonio Nino Diaz3f13c352017-02-24 11:39:22 +0000101 * Errata Workaround for Cortex A57 Errata #813419.
102 * This applies only to revision r0p0 of Cortex A57.
103 * ---------------------------------------------------
104 */
105func check_errata_813419
106 /*
107 * Even though this is only needed for revision r0p0, it
108 * is always applied due to limitations of the current
109 * errata framework.
110 */
111 mov x0, #ERRATA_APPLIES
112 ret
113endfunc check_errata_813419
114
115 /* ---------------------------------------------------
Soby Mathewc0884332014-09-22 12:11:36 +0100116 * Errata Workaround for Cortex A57 Errata #813420.
117 * This applies only to revision r0p0 of Cortex A57.
118 * Inputs:
119 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000120 * Shall clobber: x0-x17
Soby Mathewc0884332014-09-22 12:11:36 +0100121 * ---------------------------------------------------
122 */
123func errata_a57_813420_wa
124 /*
125 * Compare x0 against revision r0p0
126 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000127 mov x17, x30
128 bl check_errata_813420
129 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100130 mrs x1, CORTEX_A57_CPUACTLR_EL1
131 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_DCC_AS_DCCI
132 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00001331:
134 ret x17
Kévin Petita877c252015-03-24 14:03:57 +0000135endfunc errata_a57_813420_wa
Soby Mathewc0884332014-09-22 12:11:36 +0100136
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000137func check_errata_813420
138 mov x1, #0x00
139 b cpu_rev_var_ls
140endfunc check_errata_813420
141
Ambroise Vincent1b0db762019-02-21 16:35:07 +0000142 /* ---------------------------------------------------
143 * Errata Workaround for Cortex A57 Errata #814670.
144 * This applies only to revision r0p0 of Cortex A57.
145 * Inputs:
146 * x0: variant[4:7] and revision[0:3] of current cpu.
147 * Shall clobber: x0-x17
148 * ---------------------------------------------------
149 */
150func errata_a57_814670_wa
151 /*
152 * Compare x0 against revision r0p0
153 */
154 mov x17, x30
155 bl check_errata_814670
156 cbz x0, 1f
157 mrs x1, CORTEX_A57_CPUACTLR_EL1
158 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_DIS_DMB_NULLIFICATION
159 msr CORTEX_A57_CPUACTLR_EL1, x1
160 isb
1611:
162 ret x17
163endfunc errata_a57_814670_wa
164
165func check_errata_814670
166 mov x1, #0x00
167 b cpu_rev_var_ls
168endfunc check_errata_814670
169
Ambroise Vincentaa2c0292019-02-21 16:35:49 +0000170 /* ----------------------------------------------------
171 * Errata Workaround for Cortex A57 Errata #817169.
172 * This applies only to revision <= r0p1 of Cortex A57.
173 * ----------------------------------------------------
174 */
175func check_errata_817169
176 /*
177 * Even though this is only needed for revision <= r0p1, it
178 * is always applied because of the low cost of the workaround.
179 */
180 mov x0, #ERRATA_APPLIES
181 ret
182endfunc check_errata_817169
183
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000184 /* --------------------------------------------------------------------
185 * Disable the over-read from the LDNP instruction.
186 *
187 * This applies to all revisions <= r1p2. The performance degradation
188 * observed with LDNP/STNP has been fixed on r1p3 and onwards.
189 *
190 * Inputs:
191 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000192 * Shall clobber: x0-x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000193 * ---------------------------------------------------------------------
194 */
195func a57_disable_ldnp_overread
196 /*
197 * Compare x0 against revision r1p2
198 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000199 mov x17, x30
200 bl check_errata_disable_ldnp_overread
201 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100202 mrs x1, CORTEX_A57_CPUACTLR_EL1
203 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_DIS_OVERREAD
204 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00002051:
206 ret x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000207endfunc a57_disable_ldnp_overread
208
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000209func check_errata_disable_ldnp_overread
210 mov x1, #0x12
211 b cpu_rev_var_ls
212endfunc check_errata_disable_ldnp_overread
213
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100214 /* ---------------------------------------------------
215 * Errata Workaround for Cortex A57 Errata #826974.
216 * This applies only to revision <= r1p1 of Cortex A57.
217 * Inputs:
218 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000219 * Shall clobber: x0-x17
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100220 * ---------------------------------------------------
221 */
222func errata_a57_826974_wa
223 /*
224 * Compare x0 against revision r1p1
225 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000226 mov x17, x30
227 bl check_errata_826974
228 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100229 mrs x1, CORTEX_A57_CPUACTLR_EL1
230 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_DIS_LOAD_PASS_DMB
231 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00002321:
233 ret x17
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100234endfunc errata_a57_826974_wa
235
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000236func check_errata_826974
237 mov x1, #0x11
238 b cpu_rev_var_ls
239endfunc check_errata_826974
240
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100241 /* ---------------------------------------------------
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100242 * Errata Workaround for Cortex A57 Errata #826977.
243 * This applies only to revision <= r1p1 of Cortex A57.
244 * Inputs:
245 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000246 * Shall clobber: x0-x17
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100247 * ---------------------------------------------------
248 */
249func errata_a57_826977_wa
250 /*
251 * Compare x0 against revision r1p1
252 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000253 mov x17, x30
254 bl check_errata_826977
255 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100256 mrs x1, CORTEX_A57_CPUACTLR_EL1
257 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_GRE_NGRE_AS_NGNRE
258 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00002591:
260 ret x17
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100261endfunc errata_a57_826977_wa
262
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000263func check_errata_826977
264 mov x1, #0x11
265 b cpu_rev_var_ls
266endfunc check_errata_826977
267
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100268 /* ---------------------------------------------------
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100269 * Errata Workaround for Cortex A57 Errata #828024.
270 * This applies only to revision <= r1p1 of Cortex A57.
271 * Inputs:
272 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000273 * Shall clobber: x0-x17
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100274 * ---------------------------------------------------
275 */
276func errata_a57_828024_wa
277 /*
278 * Compare x0 against revision r1p1
279 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000280 mov x17, x30
281 bl check_errata_828024
282 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100283 mrs x1, CORTEX_A57_CPUACTLR_EL1
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100284 /*
285 * Setting the relevant bits in CPUACTLR_EL1 has to be done in 2
286 * instructions here because the resulting bitmask doesn't fit in a
287 * 16-bit value so it cannot be encoded in a single instruction.
288 */
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100289 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_NO_ALLOC_WBWA
290 orr x1, x1, #(CORTEX_A57_CPUACTLR_EL1_DIS_L1_STREAMING | \
291 CORTEX_A57_CPUACTLR_EL1_DIS_STREAMING)
292 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00002931:
294 ret x17
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100295endfunc errata_a57_828024_wa
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100296
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000297func check_errata_828024
298 mov x1, #0x11
299 b cpu_rev_var_ls
300endfunc check_errata_828024
301
Sandrine Bailleux48cbe852016-04-14 14:18:07 +0100302 /* ---------------------------------------------------
303 * Errata Workaround for Cortex A57 Errata #829520.
304 * This applies only to revision <= r1p2 of Cortex A57.
305 * Inputs:
306 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000307 * Shall clobber: x0-x17
Sandrine Bailleux48cbe852016-04-14 14:18:07 +0100308 * ---------------------------------------------------
309 */
310func errata_a57_829520_wa
311 /*
312 * Compare x0 against revision r1p2
313 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000314 mov x17, x30
315 bl check_errata_829520
316 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100317 mrs x1, CORTEX_A57_CPUACTLR_EL1
318 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_DIS_INDIRECT_PREDICTOR
319 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00003201:
321 ret x17
Sandrine Bailleux48cbe852016-04-14 14:18:07 +0100322endfunc errata_a57_829520_wa
323
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000324func check_errata_829520
325 mov x1, #0x12
326 b cpu_rev_var_ls
327endfunc check_errata_829520
328
Sandrine Bailleux143ef1a2016-04-21 11:10:52 +0100329 /* ---------------------------------------------------
330 * Errata Workaround for Cortex A57 Errata #833471.
331 * This applies only to revision <= r1p2 of Cortex A57.
332 * Inputs:
333 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000334 * Shall clobber: x0-x17
Sandrine Bailleux143ef1a2016-04-21 11:10:52 +0100335 * ---------------------------------------------------
336 */
337func errata_a57_833471_wa
338 /*
339 * Compare x0 against revision r1p2
340 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000341 mov x17, x30
342 bl check_errata_833471
343 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100344 mrs x1, CORTEX_A57_CPUACTLR_EL1
345 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_FORCE_FPSCR_FLUSH
346 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00003471:
348 ret x17
Sandrine Bailleux143ef1a2016-04-21 11:10:52 +0100349endfunc errata_a57_833471_wa
350
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000351func check_errata_833471
352 mov x1, #0x12
353 b cpu_rev_var_ls
354endfunc check_errata_833471
355
Eleanor Bonnici0c9bd272017-08-02 16:35:04 +0100356 /* --------------------------------------------------
357 * Errata Workaround for Cortex A57 Errata #859972.
358 * This applies only to revision <= r1p3 of Cortex A57.
359 * Inputs:
360 * x0: variant[4:7] and revision[0:3] of current cpu.
361 * Shall clobber:
362 * --------------------------------------------------
363 */
364func errata_a57_859972_wa
365 mov x17, x30
366 bl check_errata_859972
367 cbz x0, 1f
368 mrs x1, CORTEX_A57_CPUACTLR_EL1
369 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_DIS_INSTR_PREFETCH
370 msr CORTEX_A57_CPUACTLR_EL1, x1
3711:
372 ret x17
373endfunc errata_a57_859972_wa
374
375func check_errata_859972
376 mov x1, #0x13
377 b cpu_rev_var_ls
378endfunc check_errata_859972
379
Dimitris Papastamos858bd612018-01-16 10:32:47 +0000380func check_errata_cve_2017_5715
381#if WORKAROUND_CVE_2017_5715
382 mov x0, #ERRATA_APPLIES
383#else
384 mov x0, #ERRATA_MISSING
385#endif
386 ret
387endfunc check_errata_cve_2017_5715
388
Dimitris Papastamose6625ec2018-04-05 14:38:26 +0100389func check_errata_cve_2018_3639
390#if WORKAROUND_CVE_2018_3639
391 mov x0, #ERRATA_APPLIES
392#else
393 mov x0, #ERRATA_MISSING
394#endif
395 ret
396endfunc check_errata_cve_2018_3639
397
Soby Mathewc0884332014-09-22 12:11:36 +0100398 /* -------------------------------------------------
399 * The CPU Ops reset function for Cortex-A57.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000400 * Shall clobber: x0-x19
Soby Mathewc0884332014-09-22 12:11:36 +0100401 * -------------------------------------------------
402 */
403func cortex_a57_reset_func
404 mov x19, x30
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000405 bl cpu_get_rev_var
406 mov x18, x0
Soby Mathewc0884332014-09-22 12:11:36 +0100407
408#if ERRATA_A57_806969
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000409 mov x0, x18
Soby Mathewc0884332014-09-22 12:11:36 +0100410 bl errata_a57_806969_wa
Soby Mathew802f8652014-08-14 16:19:29 +0100411#endif
412
Soby Mathewc0884332014-09-22 12:11:36 +0100413#if ERRATA_A57_813420
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000414 mov x0, x18
Soby Mathewc0884332014-09-22 12:11:36 +0100415 bl errata_a57_813420_wa
416#endif
Yatharth Kochar36433d12014-11-20 18:09:41 +0000417
Ambroise Vincent1b0db762019-02-21 16:35:07 +0000418#if ERRATA_A57_814670
419 mov x0, x18
420 bl errata_a57_814670_wa
421#endif
422
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000423#if A57_DISABLE_NON_TEMPORAL_HINT
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000424 mov x0, x18
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000425 bl a57_disable_ldnp_overread
426#endif
427
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100428#if ERRATA_A57_826974
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000429 mov x0, x18
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100430 bl errata_a57_826974_wa
431#endif
432
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100433#if ERRATA_A57_826977
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000434 mov x0, x18
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100435 bl errata_a57_826977_wa
436#endif
437
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100438#if ERRATA_A57_828024
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000439 mov x0, x18
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100440 bl errata_a57_828024_wa
441#endif
Sandrine Bailleux48cbe852016-04-14 14:18:07 +0100442
443#if ERRATA_A57_829520
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000444 mov x0, x18
Sandrine Bailleux48cbe852016-04-14 14:18:07 +0100445 bl errata_a57_829520_wa
446#endif
447
Sandrine Bailleux143ef1a2016-04-21 11:10:52 +0100448#if ERRATA_A57_833471
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000449 mov x0, x18
Sandrine Bailleux143ef1a2016-04-21 11:10:52 +0100450 bl errata_a57_833471_wa
451#endif
452
Eleanor Bonnici0c9bd272017-08-02 16:35:04 +0100453#if ERRATA_A57_859972
454 mov x0, x18
455 bl errata_a57_859972_wa
456#endif
457
Dimitris Papastamos446f7f12017-11-30 14:53:53 +0000458#if IMAGE_BL31 && WORKAROUND_CVE_2017_5715
Dimitris Papastamos570c06a2018-04-06 15:29:34 +0100459 adr x0, wa_cve_2017_5715_mmu_vbar
Dimitris Papastamos446f7f12017-11-30 14:53:53 +0000460 msr vbar_el3, x0
Dimitris Papastamosbb0aa392018-06-07 13:20:19 +0100461 /* isb will be performed before returning from this function */
Dimitris Papastamos446f7f12017-11-30 14:53:53 +0000462#endif
463
Dimitris Papastamose6625ec2018-04-05 14:38:26 +0100464#if WORKAROUND_CVE_2018_3639
465 mrs x0, CORTEX_A57_CPUACTLR_EL1
466 orr x0, x0, #CORTEX_A57_CPUACTLR_EL1_DIS_LOAD_PASS_STORE
467 msr CORTEX_A57_CPUACTLR_EL1, x0
468 isb
469 dsb sy
470#endif
471
Achin Gupta4f6ad662013-10-25 09:08:21 +0100472 /* ---------------------------------------------
Sandrine Bailleuxf12a31d2016-01-29 14:37:58 +0000473 * Enable the SMP bit.
Achin Gupta4f6ad662013-10-25 09:08:21 +0100474 * ---------------------------------------------
475 */
Varun Wadekar1384a162017-06-05 14:54:46 -0700476 mrs x0, CORTEX_A57_ECTLR_EL1
477 orr x0, x0, #CORTEX_A57_ECTLR_SMP_BIT
478 msr CORTEX_A57_ECTLR_EL1, x0
Andrew Thoelke42e75a72014-04-28 12:28:39 +0100479 isb
Soby Mathewc0884332014-09-22 12:11:36 +0100480 ret x19
Kévin Petita877c252015-03-24 14:03:57 +0000481endfunc cortex_a57_reset_func
Soby Mathewc704cbc2014-08-14 11:33:56 +0100482
Soby Mathewc0884332014-09-22 12:11:36 +0100483 /* ----------------------------------------------------
484 * The CPU Ops core power down function for Cortex-A57.
485 * ----------------------------------------------------
486 */
Soby Mathew8e2f2872014-08-14 12:49:05 +0100487func cortex_a57_core_pwr_dwn
488 mov x18, x30
489
490 /* ---------------------------------------------
491 * Turn off caches.
492 * ---------------------------------------------
493 */
494 bl cortex_a57_disable_dcache
495
496 /* ---------------------------------------------
497 * Disable the L2 prefetches.
498 * ---------------------------------------------
499 */
500 bl cortex_a57_disable_l2_prefetch
501
502 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100503 * Flush L1 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100504 * ---------------------------------------------
505 */
506 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100507 bl dcsw_op_level1
Soby Mathew8e2f2872014-08-14 12:49:05 +0100508
509 /* ---------------------------------------------
510 * Come out of intra cluster coherency
511 * ---------------------------------------------
512 */
513 bl cortex_a57_disable_smp
514
515 /* ---------------------------------------------
516 * Force the debug interfaces to be quiescent
517 * ---------------------------------------------
518 */
519 mov x30, x18
520 b cortex_a57_disable_ext_debug
Kévin Petita877c252015-03-24 14:03:57 +0000521endfunc cortex_a57_core_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100522
Soby Mathewc0884332014-09-22 12:11:36 +0100523 /* -------------------------------------------------------
524 * The CPU Ops cluster power down function for Cortex-A57.
525 * -------------------------------------------------------
526 */
Soby Mathew8e2f2872014-08-14 12:49:05 +0100527func cortex_a57_cluster_pwr_dwn
528 mov x18, x30
529
530 /* ---------------------------------------------
531 * Turn off caches.
532 * ---------------------------------------------
533 */
534 bl cortex_a57_disable_dcache
535
536 /* ---------------------------------------------
537 * Disable the L2 prefetches.
538 * ---------------------------------------------
539 */
540 bl cortex_a57_disable_l2_prefetch
541
Soby Mathew937488b2014-09-22 14:13:34 +0100542#if !SKIP_A57_L1_FLUSH_PWR_DWN
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100543 /* -------------------------------------------------
544 * Flush the L1 caches.
545 * -------------------------------------------------
546 */
547 mov x0, #DCCISW
548 bl dcsw_op_level1
Soby Mathew937488b2014-09-22 14:13:34 +0100549#endif
Soby Mathew8e2f2872014-08-14 12:49:05 +0100550 /* ---------------------------------------------
551 * Disable the optional ACP.
552 * ---------------------------------------------
553 */
554 bl plat_disable_acp
555
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100556 /* -------------------------------------------------
557 * Flush the L2 caches.
558 * -------------------------------------------------
Soby Mathew8e2f2872014-08-14 12:49:05 +0100559 */
560 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100561 bl dcsw_op_level2
Soby Mathew8e2f2872014-08-14 12:49:05 +0100562
563 /* ---------------------------------------------
564 * Come out of intra cluster coherency
565 * ---------------------------------------------
566 */
567 bl cortex_a57_disable_smp
568
569 /* ---------------------------------------------
570 * Force the debug interfaces to be quiescent
571 * ---------------------------------------------
572 */
573 mov x30, x18
574 b cortex_a57_disable_ext_debug
Kévin Petita877c252015-03-24 14:03:57 +0000575endfunc cortex_a57_cluster_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100576
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000577#if REPORT_ERRATA
578/*
579 * Errata printing function for Cortex A57. Must follow AAPCS.
580 */
581func cortex_a57_errata_report
582 stp x8, x30, [sp, #-16]!
583
584 bl cpu_get_rev_var
585 mov x8, x0
586
587 /*
588 * Report all errata. The revision-variant information is passed to
589 * checking functions of each errata.
590 */
591 report_errata ERRATA_A57_806969, cortex_a57, 806969
Antonio Nino Diaz3f13c352017-02-24 11:39:22 +0000592 report_errata ERRATA_A57_813419, cortex_a57, 813419
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000593 report_errata ERRATA_A57_813420, cortex_a57, 813420
Ambroise Vincent1b0db762019-02-21 16:35:07 +0000594 report_errata ERRATA_A57_814670, cortex_a57, 814670
Ambroise Vincentaa2c0292019-02-21 16:35:49 +0000595 report_errata ERRATA_A57_817169, cortex_a57, 817169
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000596 report_errata A57_DISABLE_NON_TEMPORAL_HINT, cortex_a57, \
597 disable_ldnp_overread
598 report_errata ERRATA_A57_826974, cortex_a57, 826974
599 report_errata ERRATA_A57_826977, cortex_a57, 826977
600 report_errata ERRATA_A57_828024, cortex_a57, 828024
601 report_errata ERRATA_A57_829520, cortex_a57, 829520
602 report_errata ERRATA_A57_833471, cortex_a57, 833471
Eleanor Bonnici0c9bd272017-08-02 16:35:04 +0100603 report_errata ERRATA_A57_859972, cortex_a57, 859972
Dimitris Papastamos858bd612018-01-16 10:32:47 +0000604 report_errata WORKAROUND_CVE_2017_5715, cortex_a57, cve_2017_5715
Dimitris Papastamose6625ec2018-04-05 14:38:26 +0100605 report_errata WORKAROUND_CVE_2018_3639, cortex_a57, cve_2018_3639
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000606
607 ldp x8, x30, [sp], #16
608 ret
609endfunc cortex_a57_errata_report
610#endif
611
Soby Mathew38b4bc92014-08-14 13:36:41 +0100612 /* ---------------------------------------------
613 * This function provides cortex_a57 specific
614 * register information for crash reporting.
615 * It needs to return with x6 pointing to
616 * a list of register names in ascii and
617 * x8 - x15 having values of registers to be
618 * reported.
619 * ---------------------------------------------
620 */
621.section .rodata.cortex_a57_regs, "aS"
622cortex_a57_regs: /* The ascii list of register names to be reported */
Naga Sureshkumar Relli6a72a912016-07-01 12:52:41 +0530623 .asciz "cpuectlr_el1", "cpumerrsr_el1", "l2merrsr_el1", ""
Soby Mathew38b4bc92014-08-14 13:36:41 +0100624
625func cortex_a57_cpu_reg_dump
626 adr x6, cortex_a57_regs
Varun Wadekar1384a162017-06-05 14:54:46 -0700627 mrs x8, CORTEX_A57_ECTLR_EL1
628 mrs x9, CORTEX_A57_MERRSR_EL1
629 mrs x10, CORTEX_A57_L2MERRSR_EL1
Soby Mathew38b4bc92014-08-14 13:36:41 +0100630 ret
Kévin Petita877c252015-03-24 14:03:57 +0000631endfunc cortex_a57_cpu_reg_dump
Soby Mathew38b4bc92014-08-14 13:36:41 +0100632
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100633declare_cpu_ops_wa cortex_a57, CORTEX_A57_MIDR, \
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000634 cortex_a57_reset_func, \
Dimitris Papastamos914757c2018-03-12 14:47:09 +0000635 check_errata_cve_2017_5715, \
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100636 CPU_NO_EXTRA2_FUNC, \
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000637 cortex_a57_core_pwr_dwn, \
638 cortex_a57_cluster_pwr_dwn