blob: 8e60445516275c284631b7b4a580da62fa1e9f4f [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Dimitris Papastamos858bd612018-01-16 10:32:47 +00002 * Copyright (c) 2014-2018, 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>
Yatharth Kochar36433d12014-11-20 18:09:41 +00009#include <bl_common.h>
Soby Mathew8e2f2872014-08-14 12:49:05 +010010#include <cortex_a57.h>
Soby Mathewc704cbc2014-08-14 11:33:56 +010011#include <cpu_macros.S>
Soby Mathew6b28c572016-03-21 10:36:47 +000012#include <debug.h>
Soby Mathewc704cbc2014-08-14 11:33:56 +010013#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
62 dsb sy
63 ret
Kévin Petita877c252015-03-24 14:03:57 +000064endfunc cortex_a57_disable_ext_debug
Achin Gupta4f6ad662013-10-25 09:08:21 +010065
Soby Mathewc0884332014-09-22 12:11:36 +010066 /* --------------------------------------------------
67 * Errata Workaround for Cortex A57 Errata #806969.
68 * This applies only to revision r0p0 of Cortex A57.
69 * Inputs:
70 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000071 * Shall clobber: x0-x17
Soby Mathewc0884332014-09-22 12:11:36 +010072 * --------------------------------------------------
Soby Mathew802f8652014-08-14 16:19:29 +010073 */
Soby Mathewc0884332014-09-22 12:11:36 +010074func errata_a57_806969_wa
75 /*
76 * Compare x0 against revision r0p0
77 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000078 mov x17, x30
79 bl check_errata_806969
80 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +010081 mrs x1, CORTEX_A57_CPUACTLR_EL1
82 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_NO_ALLOC_WBWA
83 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000841:
85 ret x17
Kévin Petita877c252015-03-24 14:03:57 +000086endfunc errata_a57_806969_wa
Soby Mathewc0884332014-09-22 12:11:36 +010087
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000088func check_errata_806969
89 mov x1, #0x00
90 b cpu_rev_var_ls
91endfunc check_errata_806969
Soby Mathewc0884332014-09-22 12:11:36 +010092
93 /* ---------------------------------------------------
Antonio Nino Diaz3f13c352017-02-24 11:39:22 +000094 * Errata Workaround for Cortex A57 Errata #813419.
95 * This applies only to revision r0p0 of Cortex A57.
96 * ---------------------------------------------------
97 */
98func check_errata_813419
99 /*
100 * Even though this is only needed for revision r0p0, it
101 * is always applied due to limitations of the current
102 * errata framework.
103 */
104 mov x0, #ERRATA_APPLIES
105 ret
106endfunc check_errata_813419
107
108 /* ---------------------------------------------------
Soby Mathewc0884332014-09-22 12:11:36 +0100109 * Errata Workaround for Cortex A57 Errata #813420.
110 * This applies only to revision r0p0 of Cortex A57.
111 * Inputs:
112 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000113 * Shall clobber: x0-x17
Soby Mathewc0884332014-09-22 12:11:36 +0100114 * ---------------------------------------------------
115 */
116func errata_a57_813420_wa
117 /*
118 * Compare x0 against revision r0p0
119 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000120 mov x17, x30
121 bl check_errata_813420
122 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100123 mrs x1, CORTEX_A57_CPUACTLR_EL1
124 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_DCC_AS_DCCI
125 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00001261:
127 ret x17
Kévin Petita877c252015-03-24 14:03:57 +0000128endfunc errata_a57_813420_wa
Soby Mathewc0884332014-09-22 12:11:36 +0100129
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000130func check_errata_813420
131 mov x1, #0x00
132 b cpu_rev_var_ls
133endfunc check_errata_813420
134
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000135 /* --------------------------------------------------------------------
136 * Disable the over-read from the LDNP instruction.
137 *
138 * This applies to all revisions <= r1p2. The performance degradation
139 * observed with LDNP/STNP has been fixed on r1p3 and onwards.
140 *
141 * Inputs:
142 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000143 * Shall clobber: x0-x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000144 * ---------------------------------------------------------------------
145 */
146func a57_disable_ldnp_overread
147 /*
148 * Compare x0 against revision r1p2
149 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000150 mov x17, x30
151 bl check_errata_disable_ldnp_overread
152 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100153 mrs x1, CORTEX_A57_CPUACTLR_EL1
154 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_DIS_OVERREAD
155 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00001561:
157 ret x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000158endfunc a57_disable_ldnp_overread
159
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000160func check_errata_disable_ldnp_overread
161 mov x1, #0x12
162 b cpu_rev_var_ls
163endfunc check_errata_disable_ldnp_overread
164
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100165 /* ---------------------------------------------------
166 * Errata Workaround for Cortex A57 Errata #826974.
167 * This applies only to revision <= r1p1 of Cortex A57.
168 * Inputs:
169 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000170 * Shall clobber: x0-x17
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100171 * ---------------------------------------------------
172 */
173func errata_a57_826974_wa
174 /*
175 * Compare x0 against revision r1p1
176 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000177 mov x17, x30
178 bl check_errata_826974
179 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100180 mrs x1, CORTEX_A57_CPUACTLR_EL1
181 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_DIS_LOAD_PASS_DMB
182 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00001831:
184 ret x17
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100185endfunc errata_a57_826974_wa
186
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000187func check_errata_826974
188 mov x1, #0x11
189 b cpu_rev_var_ls
190endfunc check_errata_826974
191
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100192 /* ---------------------------------------------------
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100193 * Errata Workaround for Cortex A57 Errata #826977.
194 * This applies only to revision <= r1p1 of Cortex A57.
195 * Inputs:
196 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000197 * Shall clobber: x0-x17
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100198 * ---------------------------------------------------
199 */
200func errata_a57_826977_wa
201 /*
202 * Compare x0 against revision r1p1
203 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000204 mov x17, x30
205 bl check_errata_826977
206 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100207 mrs x1, CORTEX_A57_CPUACTLR_EL1
208 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_GRE_NGRE_AS_NGNRE
209 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00002101:
211 ret x17
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100212endfunc errata_a57_826977_wa
213
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000214func check_errata_826977
215 mov x1, #0x11
216 b cpu_rev_var_ls
217endfunc check_errata_826977
218
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100219 /* ---------------------------------------------------
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100220 * Errata Workaround for Cortex A57 Errata #828024.
221 * This applies only to revision <= r1p1 of Cortex A57.
222 * Inputs:
223 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000224 * Shall clobber: x0-x17
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100225 * ---------------------------------------------------
226 */
227func errata_a57_828024_wa
228 /*
229 * Compare x0 against revision r1p1
230 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000231 mov x17, x30
232 bl check_errata_828024
233 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100234 mrs x1, CORTEX_A57_CPUACTLR_EL1
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100235 /*
236 * Setting the relevant bits in CPUACTLR_EL1 has to be done in 2
237 * instructions here because the resulting bitmask doesn't fit in a
238 * 16-bit value so it cannot be encoded in a single instruction.
239 */
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100240 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_NO_ALLOC_WBWA
241 orr x1, x1, #(CORTEX_A57_CPUACTLR_EL1_DIS_L1_STREAMING | \
242 CORTEX_A57_CPUACTLR_EL1_DIS_STREAMING)
243 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00002441:
245 ret x17
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100246endfunc errata_a57_828024_wa
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100247
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000248func check_errata_828024
249 mov x1, #0x11
250 b cpu_rev_var_ls
251endfunc check_errata_828024
252
Sandrine Bailleux48cbe852016-04-14 14:18:07 +0100253 /* ---------------------------------------------------
254 * Errata Workaround for Cortex A57 Errata #829520.
255 * This applies only to revision <= r1p2 of Cortex A57.
256 * Inputs:
257 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000258 * Shall clobber: x0-x17
Sandrine Bailleux48cbe852016-04-14 14:18:07 +0100259 * ---------------------------------------------------
260 */
261func errata_a57_829520_wa
262 /*
263 * Compare x0 against revision r1p2
264 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000265 mov x17, x30
266 bl check_errata_829520
267 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100268 mrs x1, CORTEX_A57_CPUACTLR_EL1
269 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_DIS_INDIRECT_PREDICTOR
270 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00002711:
272 ret x17
Sandrine Bailleux48cbe852016-04-14 14:18:07 +0100273endfunc errata_a57_829520_wa
274
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000275func check_errata_829520
276 mov x1, #0x12
277 b cpu_rev_var_ls
278endfunc check_errata_829520
279
Sandrine Bailleux143ef1a2016-04-21 11:10:52 +0100280 /* ---------------------------------------------------
281 * Errata Workaround for Cortex A57 Errata #833471.
282 * This applies only to revision <= r1p2 of Cortex A57.
283 * Inputs:
284 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000285 * Shall clobber: x0-x17
Sandrine Bailleux143ef1a2016-04-21 11:10:52 +0100286 * ---------------------------------------------------
287 */
288func errata_a57_833471_wa
289 /*
290 * Compare x0 against revision r1p2
291 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000292 mov x17, x30
293 bl check_errata_833471
294 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100295 mrs x1, CORTEX_A57_CPUACTLR_EL1
296 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_FORCE_FPSCR_FLUSH
297 msr CORTEX_A57_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00002981:
299 ret x17
Sandrine Bailleux143ef1a2016-04-21 11:10:52 +0100300endfunc errata_a57_833471_wa
301
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000302func check_errata_833471
303 mov x1, #0x12
304 b cpu_rev_var_ls
305endfunc check_errata_833471
306
Eleanor Bonnici0c9bd272017-08-02 16:35:04 +0100307 /* --------------------------------------------------
308 * Errata Workaround for Cortex A57 Errata #859972.
309 * This applies only to revision <= r1p3 of Cortex A57.
310 * Inputs:
311 * x0: variant[4:7] and revision[0:3] of current cpu.
312 * Shall clobber:
313 * --------------------------------------------------
314 */
315func errata_a57_859972_wa
316 mov x17, x30
317 bl check_errata_859972
318 cbz x0, 1f
319 mrs x1, CORTEX_A57_CPUACTLR_EL1
320 orr x1, x1, #CORTEX_A57_CPUACTLR_EL1_DIS_INSTR_PREFETCH
321 msr CORTEX_A57_CPUACTLR_EL1, x1
3221:
323 ret x17
324endfunc errata_a57_859972_wa
325
326func check_errata_859972
327 mov x1, #0x13
328 b cpu_rev_var_ls
329endfunc check_errata_859972
330
Dimitris Papastamos858bd612018-01-16 10:32:47 +0000331func check_errata_cve_2017_5715
332#if WORKAROUND_CVE_2017_5715
333 mov x0, #ERRATA_APPLIES
334#else
335 mov x0, #ERRATA_MISSING
336#endif
337 ret
338endfunc check_errata_cve_2017_5715
339
Dimitris Papastamose6625ec2018-04-05 14:38:26 +0100340func check_errata_cve_2018_3639
341#if WORKAROUND_CVE_2018_3639
342 mov x0, #ERRATA_APPLIES
343#else
344 mov x0, #ERRATA_MISSING
345#endif
346 ret
347endfunc check_errata_cve_2018_3639
348
Soby Mathewc0884332014-09-22 12:11:36 +0100349 /* -------------------------------------------------
350 * The CPU Ops reset function for Cortex-A57.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000351 * Shall clobber: x0-x19
Soby Mathewc0884332014-09-22 12:11:36 +0100352 * -------------------------------------------------
353 */
354func cortex_a57_reset_func
355 mov x19, x30
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000356 bl cpu_get_rev_var
357 mov x18, x0
Soby Mathewc0884332014-09-22 12:11:36 +0100358
359#if ERRATA_A57_806969
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000360 mov x0, x18
Soby Mathewc0884332014-09-22 12:11:36 +0100361 bl errata_a57_806969_wa
Soby Mathew802f8652014-08-14 16:19:29 +0100362#endif
363
Soby Mathewc0884332014-09-22 12:11:36 +0100364#if ERRATA_A57_813420
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000365 mov x0, x18
Soby Mathewc0884332014-09-22 12:11:36 +0100366 bl errata_a57_813420_wa
367#endif
Yatharth Kochar36433d12014-11-20 18:09:41 +0000368
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000369#if A57_DISABLE_NON_TEMPORAL_HINT
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000370 mov x0, x18
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000371 bl a57_disable_ldnp_overread
372#endif
373
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100374#if ERRATA_A57_826974
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000375 mov x0, x18
Sandrine Bailleuxa7e0c532016-04-14 13:32:31 +0100376 bl errata_a57_826974_wa
377#endif
378
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100379#if ERRATA_A57_826977
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000380 mov x0, x18
Sandrine Bailleuxadcbd552016-04-14 14:24:13 +0100381 bl errata_a57_826977_wa
382#endif
383
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100384#if ERRATA_A57_828024
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000385 mov x0, x18
Sandrine Bailleuxc11116f2016-04-14 14:04:48 +0100386 bl errata_a57_828024_wa
387#endif
Sandrine Bailleux48cbe852016-04-14 14:18:07 +0100388
389#if ERRATA_A57_829520
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000390 mov x0, x18
Sandrine Bailleux48cbe852016-04-14 14:18:07 +0100391 bl errata_a57_829520_wa
392#endif
393
Sandrine Bailleux143ef1a2016-04-21 11:10:52 +0100394#if ERRATA_A57_833471
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000395 mov x0, x18
Sandrine Bailleux143ef1a2016-04-21 11:10:52 +0100396 bl errata_a57_833471_wa
397#endif
398
Eleanor Bonnici0c9bd272017-08-02 16:35:04 +0100399#if ERRATA_A57_859972
400 mov x0, x18
401 bl errata_a57_859972_wa
402#endif
403
Dimitris Papastamos446f7f12017-11-30 14:53:53 +0000404#if IMAGE_BL31 && WORKAROUND_CVE_2017_5715
Dimitris Papastamos570c06a2018-04-06 15:29:34 +0100405 adr x0, wa_cve_2017_5715_mmu_vbar
Dimitris Papastamos446f7f12017-11-30 14:53:53 +0000406 msr vbar_el3, x0
Dimitris Papastamosbb0aa392018-06-07 13:20:19 +0100407 /* isb will be performed before returning from this function */
Dimitris Papastamos446f7f12017-11-30 14:53:53 +0000408#endif
409
Dimitris Papastamose6625ec2018-04-05 14:38:26 +0100410#if WORKAROUND_CVE_2018_3639
411 mrs x0, CORTEX_A57_CPUACTLR_EL1
412 orr x0, x0, #CORTEX_A57_CPUACTLR_EL1_DIS_LOAD_PASS_STORE
413 msr CORTEX_A57_CPUACTLR_EL1, x0
414 isb
415 dsb sy
416#endif
417
Achin Gupta4f6ad662013-10-25 09:08:21 +0100418 /* ---------------------------------------------
Sandrine Bailleuxf12a31d2016-01-29 14:37:58 +0000419 * Enable the SMP bit.
Achin Gupta4f6ad662013-10-25 09:08:21 +0100420 * ---------------------------------------------
421 */
Varun Wadekar1384a162017-06-05 14:54:46 -0700422 mrs x0, CORTEX_A57_ECTLR_EL1
423 orr x0, x0, #CORTEX_A57_ECTLR_SMP_BIT
424 msr CORTEX_A57_ECTLR_EL1, x0
Andrew Thoelke42e75a72014-04-28 12:28:39 +0100425 isb
Soby Mathewc0884332014-09-22 12:11:36 +0100426 ret x19
Kévin Petita877c252015-03-24 14:03:57 +0000427endfunc cortex_a57_reset_func
Soby Mathewc704cbc2014-08-14 11:33:56 +0100428
Soby Mathewc0884332014-09-22 12:11:36 +0100429 /* ----------------------------------------------------
430 * The CPU Ops core power down function for Cortex-A57.
431 * ----------------------------------------------------
432 */
Soby Mathew8e2f2872014-08-14 12:49:05 +0100433func cortex_a57_core_pwr_dwn
434 mov x18, x30
435
436 /* ---------------------------------------------
437 * Turn off caches.
438 * ---------------------------------------------
439 */
440 bl cortex_a57_disable_dcache
441
442 /* ---------------------------------------------
443 * Disable the L2 prefetches.
444 * ---------------------------------------------
445 */
446 bl cortex_a57_disable_l2_prefetch
447
448 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100449 * Flush L1 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100450 * ---------------------------------------------
451 */
452 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100453 bl dcsw_op_level1
Soby Mathew8e2f2872014-08-14 12:49:05 +0100454
455 /* ---------------------------------------------
456 * Come out of intra cluster coherency
457 * ---------------------------------------------
458 */
459 bl cortex_a57_disable_smp
460
461 /* ---------------------------------------------
462 * Force the debug interfaces to be quiescent
463 * ---------------------------------------------
464 */
465 mov x30, x18
466 b cortex_a57_disable_ext_debug
Kévin Petita877c252015-03-24 14:03:57 +0000467endfunc cortex_a57_core_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100468
Soby Mathewc0884332014-09-22 12:11:36 +0100469 /* -------------------------------------------------------
470 * The CPU Ops cluster power down function for Cortex-A57.
471 * -------------------------------------------------------
472 */
Soby Mathew8e2f2872014-08-14 12:49:05 +0100473func cortex_a57_cluster_pwr_dwn
474 mov x18, x30
475
476 /* ---------------------------------------------
477 * Turn off caches.
478 * ---------------------------------------------
479 */
480 bl cortex_a57_disable_dcache
481
482 /* ---------------------------------------------
483 * Disable the L2 prefetches.
484 * ---------------------------------------------
485 */
486 bl cortex_a57_disable_l2_prefetch
487
Soby Mathew937488b2014-09-22 14:13:34 +0100488#if !SKIP_A57_L1_FLUSH_PWR_DWN
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100489 /* -------------------------------------------------
490 * Flush the L1 caches.
491 * -------------------------------------------------
492 */
493 mov x0, #DCCISW
494 bl dcsw_op_level1
Soby Mathew937488b2014-09-22 14:13:34 +0100495#endif
Soby Mathew8e2f2872014-08-14 12:49:05 +0100496 /* ---------------------------------------------
497 * Disable the optional ACP.
498 * ---------------------------------------------
499 */
500 bl plat_disable_acp
501
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100502 /* -------------------------------------------------
503 * Flush the L2 caches.
504 * -------------------------------------------------
Soby Mathew8e2f2872014-08-14 12:49:05 +0100505 */
506 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100507 bl dcsw_op_level2
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_cluster_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100522
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000523#if REPORT_ERRATA
524/*
525 * Errata printing function for Cortex A57. Must follow AAPCS.
526 */
527func cortex_a57_errata_report
528 stp x8, x30, [sp, #-16]!
529
530 bl cpu_get_rev_var
531 mov x8, x0
532
533 /*
534 * Report all errata. The revision-variant information is passed to
535 * checking functions of each errata.
536 */
537 report_errata ERRATA_A57_806969, cortex_a57, 806969
Antonio Nino Diaz3f13c352017-02-24 11:39:22 +0000538 report_errata ERRATA_A57_813419, cortex_a57, 813419
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000539 report_errata ERRATA_A57_813420, cortex_a57, 813420
540 report_errata A57_DISABLE_NON_TEMPORAL_HINT, cortex_a57, \
541 disable_ldnp_overread
542 report_errata ERRATA_A57_826974, cortex_a57, 826974
543 report_errata ERRATA_A57_826977, cortex_a57, 826977
544 report_errata ERRATA_A57_828024, cortex_a57, 828024
545 report_errata ERRATA_A57_829520, cortex_a57, 829520
546 report_errata ERRATA_A57_833471, cortex_a57, 833471
Eleanor Bonnici0c9bd272017-08-02 16:35:04 +0100547 report_errata ERRATA_A57_859972, cortex_a57, 859972
Dimitris Papastamos858bd612018-01-16 10:32:47 +0000548 report_errata WORKAROUND_CVE_2017_5715, cortex_a57, cve_2017_5715
Dimitris Papastamose6625ec2018-04-05 14:38:26 +0100549 report_errata WORKAROUND_CVE_2018_3639, cortex_a57, cve_2018_3639
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000550
551 ldp x8, x30, [sp], #16
552 ret
553endfunc cortex_a57_errata_report
554#endif
555
Soby Mathew38b4bc92014-08-14 13:36:41 +0100556 /* ---------------------------------------------
557 * This function provides cortex_a57 specific
558 * register information for crash reporting.
559 * It needs to return with x6 pointing to
560 * a list of register names in ascii and
561 * x8 - x15 having values of registers to be
562 * reported.
563 * ---------------------------------------------
564 */
565.section .rodata.cortex_a57_regs, "aS"
566cortex_a57_regs: /* The ascii list of register names to be reported */
Naga Sureshkumar Relli6a72a912016-07-01 12:52:41 +0530567 .asciz "cpuectlr_el1", "cpumerrsr_el1", "l2merrsr_el1", ""
Soby Mathew38b4bc92014-08-14 13:36:41 +0100568
569func cortex_a57_cpu_reg_dump
570 adr x6, cortex_a57_regs
Varun Wadekar1384a162017-06-05 14:54:46 -0700571 mrs x8, CORTEX_A57_ECTLR_EL1
572 mrs x9, CORTEX_A57_MERRSR_EL1
573 mrs x10, CORTEX_A57_L2MERRSR_EL1
Soby Mathew38b4bc92014-08-14 13:36:41 +0100574 ret
Kévin Petita877c252015-03-24 14:03:57 +0000575endfunc cortex_a57_cpu_reg_dump
Soby Mathew38b4bc92014-08-14 13:36:41 +0100576
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100577declare_cpu_ops_wa cortex_a57, CORTEX_A57_MIDR, \
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000578 cortex_a57_reset_func, \
Dimitris Papastamos914757c2018-03-12 14:47:09 +0000579 check_errata_cve_2017_5715, \
Dimitris Papastamosba51d9e2018-05-16 11:36:14 +0100580 CPU_NO_EXTRA2_FUNC, \
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000581 cortex_a57_core_pwr_dwn, \
582 cortex_a57_cluster_pwr_dwn