blob: f20082d2d6167b14b17e13a20c3c1986bbc76804 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Ambroise Vincentf5fdfbc2019-02-21 14:16:24 +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>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <common/bl_common.h>
9#include <common/debug.h>
Soby Mathew8e2f2872014-08-14 12:49:05 +010010#include <cortex_a53.h>
Soby Mathewc704cbc2014-08-14 11:33:56 +010011#include <cpu_macros.S>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <lib/cpus/errata_report.h>
Soby Mathewc704cbc2014-08-14 11:33:56 +010013#include <plat_macros.S>
Achin Gupta4f6ad662013-10-25 09:08:21 +010014
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000015#if A53_DISABLE_NON_TEMPORAL_HINT
16#undef ERRATA_A53_836870
17#define ERRATA_A53_836870 1
18#endif
19
Soby Mathew8e2f2872014-08-14 12:49:05 +010020 /* ---------------------------------------------
21 * Disable L1 data cache and unified L2 cache
22 * ---------------------------------------------
23 */
24func cortex_a53_disable_dcache
25 mrs x1, sctlr_el3
26 bic x1, x1, #SCTLR_C_BIT
27 msr sctlr_el3, x1
28 isb
29 ret
Kévin Petita877c252015-03-24 14:03:57 +000030endfunc cortex_a53_disable_dcache
Soby Mathew8e2f2872014-08-14 12:49:05 +010031
32 /* ---------------------------------------------
33 * Disable intra-cluster coherency
34 * ---------------------------------------------
35 */
36func cortex_a53_disable_smp
Varun Wadekar1384a162017-06-05 14:54:46 -070037 mrs x0, CORTEX_A53_ECTLR_EL1
38 bic x0, x0, #CORTEX_A53_ECTLR_SMP_BIT
39 msr CORTEX_A53_ECTLR_EL1, x0
Soby Mathew8e2f2872014-08-14 12:49:05 +010040 isb
41 dsb sy
42 ret
Kévin Petita877c252015-03-24 14:03:57 +000043endfunc cortex_a53_disable_smp
Achin Gupta4f6ad662013-10-25 09:08:21 +010044
Ambroise Vincentf5fdfbc2019-02-21 14:16:24 +000045 /* ---------------------------------------------------
46 * Errata Workaround for Cortex A53 Errata #819472.
47 * This applies only to revision <= r0p1 of Cortex A53.
48 * ---------------------------------------------------
49 */
50func check_errata_819472
51 /*
52 * Even though this is only needed for revision <= r0p1, it
53 * is always applied due to limitations of the current
54 * errata framework.
55 */
56 mov x0, #ERRATA_APPLIES
57 ret
58endfunc check_errata_819472
59
60 /* ---------------------------------------------------
61 * Errata Workaround for Cortex A53 Errata #824069.
62 * This applies only to revision <= r0p2 of Cortex A53.
63 * ---------------------------------------------------
64 */
65func check_errata_824069
66 /*
67 * Even though this is only needed for revision <= r0p2, it
68 * is always applied due to limitations of the current
69 * errata framework.
70 */
71 mov x0, #ERRATA_APPLIES
72 ret
73endfunc check_errata_824069
74
developer4fceaca2015-07-29 20:55:31 +080075 /* --------------------------------------------------
76 * Errata Workaround for Cortex A53 Errata #826319.
77 * This applies only to revision <= r0p2 of Cortex A53.
78 * Inputs:
79 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000080 * Shall clobber: x0-x17
developer4fceaca2015-07-29 20:55:31 +080081 * --------------------------------------------------
82 */
83func errata_a53_826319_wa
84 /*
85 * Compare x0 against revision r0p2
86 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000087 mov x17, x30
88 bl check_errata_826319
89 cbz x0, 1f
Varun Wadekar1384a162017-06-05 14:54:46 -070090 mrs x1, CORTEX_A53_L2ACTLR_EL1
91 bic x1, x1, #CORTEX_A53_L2ACTLR_ENABLE_UNIQUECLEAN
92 orr x1, x1, #CORTEX_A53_L2ACTLR_DISABLE_CLEAN_PUSH
93 msr CORTEX_A53_L2ACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000941:
95 ret x17
developer4fceaca2015-07-29 20:55:31 +080096endfunc errata_a53_826319_wa
97
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000098func check_errata_826319
99 mov x1, #0x02
100 b cpu_rev_var_ls
101endfunc check_errata_826319
102
Ambroise Vincentf5fdfbc2019-02-21 14:16:24 +0000103 /* ---------------------------------------------------
104 * Errata Workaround for Cortex A53 Errata #827319.
105 * This applies only to revision <= r0p2 of Cortex A53.
106 * ---------------------------------------------------
107 */
108func check_errata_827319
109 /*
110 * Even though this is only needed for revision <= r0p2, it
111 * is always applied due to limitations of the current
112 * errata framework.
113 */
114 mov x0, #ERRATA_APPLIES
115 ret
116endfunc check_errata_827319
117
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000118 /* ---------------------------------------------------------------------
119 * Disable the cache non-temporal hint.
120 *
121 * This ignores the Transient allocation hint in the MAIR and treats
122 * allocations the same as non-transient allocation types. As a result,
123 * the LDNP and STNP instructions in AArch64 behave the same as the
124 * equivalent LDP and STP instructions.
125 *
126 * This is relevant only for revisions <= r0p3 of Cortex-A53.
127 * From r0p4 and onwards, the bit to disable the hint is enabled by
128 * default at reset.
129 *
developer4fceaca2015-07-29 20:55:31 +0800130 * Inputs:
131 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000132 * Shall clobber: x0-x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000133 * ---------------------------------------------------------------------
developer4fceaca2015-07-29 20:55:31 +0800134 */
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000135func a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +0800136 /*
137 * Compare x0 against revision r0p3
138 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000139 mov x17, x30
140 bl check_errata_disable_non_temporal_hint
141 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100142 mrs x1, CORTEX_A53_CPUACTLR_EL1
143 orr x1, x1, #CORTEX_A53_CPUACTLR_EL1_DTAH
144 msr CORTEX_A53_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00001451:
146 ret x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000147endfunc a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +0800148
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000149func check_errata_disable_non_temporal_hint
150 mov x1, #0x03
151 b cpu_rev_var_ls
152endfunc check_errata_disable_non_temporal_hint
153
Andre Przywara00eefd92016-10-06 16:54:53 +0100154 /* --------------------------------------------------
155 * Errata Workaround for Cortex A53 Errata #855873.
156 *
157 * This applies only to revisions >= r0p3 of Cortex A53.
158 * Earlier revisions of the core are affected as well, but don't
159 * have the chicken bit in the CPUACTLR register. It is expected that
160 * the rich OS takes care of that, especially as the workaround is
161 * shared with other erratas in those revisions of the CPU.
162 * Inputs:
163 * x0: variant[4:7] and revision[0:3] of current cpu.
164 * Shall clobber: x0-x17
165 * --------------------------------------------------
166 */
167func errata_a53_855873_wa
168 /*
169 * Compare x0 against revision r0p3 and higher
170 */
171 mov x17, x30
172 bl check_errata_855873
173 cbz x0, 1f
174
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100175 mrs x1, CORTEX_A53_CPUACTLR_EL1
176 orr x1, x1, #CORTEX_A53_CPUACTLR_EL1_ENDCCASCI
177 msr CORTEX_A53_CPUACTLR_EL1, x1
Andre Przywara00eefd92016-10-06 16:54:53 +01001781:
179 ret x17
180endfunc errata_a53_855873_wa
181
182func check_errata_855873
183 mov x1, #0x03
184 b cpu_rev_var_hs
185endfunc check_errata_855873
186
Douglas Raillardd56fb042017-06-19 15:38:02 +0100187/*
188 * Errata workaround for Cortex A53 Errata #835769.
189 * This applies to revisions <= r0p4 of Cortex A53.
190 * This workaround is statically enabled at build time.
191 */
192func check_errata_835769
Jonathan Wright6e1796e2018-03-28 16:55:54 +0100193 cmp x0, #0x04
194 b.hi errata_not_applies
195 /*
196 * Fix potentially available for revisions r0p2, r0p3 and r0p4.
197 * If r0p2, r0p3 or r0p4; check for fix in REVIDR, else exit.
198 */
199 cmp x0, #0x01
200 mov x0, #ERRATA_APPLIES
201 b.ls exit_check_errata_835769
202 /* Load REVIDR. */
203 mrs x1, revidr_el1
204 /* If REVIDR[7] is set (fix exists) set ERRATA_NOT_APPLIES, else exit. */
205 tbz x1, #7, exit_check_errata_835769
206errata_not_applies:
207 mov x0, #ERRATA_NOT_APPLIES
208exit_check_errata_835769:
209 ret
Douglas Raillardd56fb042017-06-19 15:38:02 +0100210endfunc check_errata_835769
211
212/*
213 * Errata workaround for Cortex A53 Errata #843419.
214 * This applies to revisions <= r0p4 of Cortex A53.
215 * This workaround is statically enabled at build time.
216 */
217func check_errata_843419
Jonathan Wrightefb1f332018-03-28 15:52:03 +0100218 mov x1, #ERRATA_APPLIES
219 mov x2, #ERRATA_NOT_APPLIES
220 cmp x0, #0x04
221 csel x0, x1, x2, ls
222 /*
223 * Fix potentially available for revision r0p4.
224 * If r0p4 check for fix in REVIDR, else exit.
225 */
226 b.ne exit_check_errata_843419
227 /* Load REVIDR. */
228 mrs x3, revidr_el1
229 /* If REVIDR[8] is set (fix exists) set ERRATA_NOT_APPLIES, else exit. */
230 tbz x3, #8, exit_check_errata_843419
231 mov x0, x2
232exit_check_errata_843419:
233 ret
Douglas Raillardd56fb042017-06-19 15:38:02 +0100234endfunc check_errata_843419
235
developer4fceaca2015-07-29 20:55:31 +0800236 /* -------------------------------------------------
237 * The CPU Ops reset function for Cortex-A53.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000238 * Shall clobber: x0-x19
developer4fceaca2015-07-29 20:55:31 +0800239 * -------------------------------------------------
240 */
Soby Mathewc704cbc2014-08-14 11:33:56 +0100241func cortex_a53_reset_func
developer4fceaca2015-07-29 20:55:31 +0800242 mov x19, x30
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000243 bl cpu_get_rev_var
244 mov x18, x0
developer4fceaca2015-07-29 20:55:31 +0800245
developer4fceaca2015-07-29 20:55:31 +0800246
247#if ERRATA_A53_826319
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000248 mov x0, x18
developer4fceaca2015-07-29 20:55:31 +0800249 bl errata_a53_826319_wa
250#endif
251
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000252#if ERRATA_A53_836870
253 mov x0, x18
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000254 bl a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +0800255#endif
256
Andre Przywara00eefd92016-10-06 16:54:53 +0100257#if ERRATA_A53_855873
258 mov x0, x18
259 bl errata_a53_855873_wa
260#endif
261
Achin Gupta4f6ad662013-10-25 09:08:21 +0100262 /* ---------------------------------------------
Sandrine Bailleuxf12a31d2016-01-29 14:37:58 +0000263 * Enable the SMP bit.
Achin Gupta4f6ad662013-10-25 09:08:21 +0100264 * ---------------------------------------------
265 */
Varun Wadekar1384a162017-06-05 14:54:46 -0700266 mrs x0, CORTEX_A53_ECTLR_EL1
267 orr x0, x0, #CORTEX_A53_ECTLR_SMP_BIT
268 msr CORTEX_A53_ECTLR_EL1, x0
developer4fceaca2015-07-29 20:55:31 +0800269 isb
270 ret x19
Kévin Petita877c252015-03-24 14:03:57 +0000271endfunc cortex_a53_reset_func
Soby Mathewc704cbc2014-08-14 11:33:56 +0100272
Soby Mathew8e2f2872014-08-14 12:49:05 +0100273func cortex_a53_core_pwr_dwn
274 mov x18, x30
275
Andrew F. Davis7c461d72018-10-12 15:37:04 -0500276#if !TI_AM65X_WORKAROUND
Soby Mathew8e2f2872014-08-14 12:49:05 +0100277 /* ---------------------------------------------
278 * Turn off caches.
279 * ---------------------------------------------
280 */
281 bl cortex_a53_disable_dcache
Andrew F. Davis7c461d72018-10-12 15:37:04 -0500282#endif
Soby Mathew8e2f2872014-08-14 12:49:05 +0100283
284 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100285 * Flush L1 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100286 * ---------------------------------------------
287 */
288 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100289 bl dcsw_op_level1
Soby Mathew8e2f2872014-08-14 12:49:05 +0100290
291 /* ---------------------------------------------
292 * Come out of intra cluster coherency
293 * ---------------------------------------------
294 */
295 mov x30, x18
296 b cortex_a53_disable_smp
Kévin Petita877c252015-03-24 14:03:57 +0000297endfunc cortex_a53_core_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100298
299func cortex_a53_cluster_pwr_dwn
300 mov x18, x30
301
Andrew F. Davis7c461d72018-10-12 15:37:04 -0500302#if !TI_AM65X_WORKAROUND
Soby Mathew8e2f2872014-08-14 12:49:05 +0100303 /* ---------------------------------------------
304 * Turn off caches.
305 * ---------------------------------------------
306 */
307 bl cortex_a53_disable_dcache
Andrew F. Davis7c461d72018-10-12 15:37:04 -0500308#endif
Soby Mathew8e2f2872014-08-14 12:49:05 +0100309
310 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100311 * Flush L1 caches.
312 * ---------------------------------------------
313 */
314 mov x0, #DCCISW
315 bl dcsw_op_level1
316
317 /* ---------------------------------------------
Soby Mathew8e2f2872014-08-14 12:49:05 +0100318 * Disable the optional ACP.
319 * ---------------------------------------------
320 */
321 bl plat_disable_acp
322
323 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100324 * Flush L2 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100325 * ---------------------------------------------
326 */
327 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100328 bl dcsw_op_level2
Soby Mathew8e2f2872014-08-14 12:49:05 +0100329
330 /* ---------------------------------------------
331 * Come out of intra cluster coherency
332 * ---------------------------------------------
333 */
334 mov x30, x18
335 b cortex_a53_disable_smp
Kévin Petita877c252015-03-24 14:03:57 +0000336endfunc cortex_a53_cluster_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100337
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000338#if REPORT_ERRATA
339/*
340 * Errata printing function for Cortex A53. Must follow AAPCS.
341 */
342func cortex_a53_errata_report
343 stp x8, x30, [sp, #-16]!
344
345 bl cpu_get_rev_var
346 mov x8, x0
347
348 /*
349 * Report all errata. The revision-variant information is passed to
350 * checking functions of each errata.
351 */
Ambroise Vincentf5fdfbc2019-02-21 14:16:24 +0000352 report_errata ERRATA_A53_819472, cortex_a53, 819472
353 report_errata ERRATA_A53_824069, cortex_a53, 824069
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000354 report_errata ERRATA_A53_826319, cortex_a53, 826319
Ambroise Vincentf5fdfbc2019-02-21 14:16:24 +0000355 report_errata ERRATA_A53_827319, cortex_a53, 827319
Douglas Raillardd56fb042017-06-19 15:38:02 +0100356 report_errata ERRATA_A53_835769, cortex_a53, 835769
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000357 report_errata ERRATA_A53_836870, cortex_a53, disable_non_temporal_hint
Douglas Raillardd56fb042017-06-19 15:38:02 +0100358 report_errata ERRATA_A53_843419, cortex_a53, 843419
Andre Przywara00eefd92016-10-06 16:54:53 +0100359 report_errata ERRATA_A53_855873, cortex_a53, 855873
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000360
361 ldp x8, x30, [sp], #16
362 ret
363endfunc cortex_a53_errata_report
364#endif
365
Soby Mathew38b4bc92014-08-14 13:36:41 +0100366 /* ---------------------------------------------
367 * This function provides cortex_a53 specific
368 * register information for crash reporting.
369 * It needs to return with x6 pointing to
370 * a list of register names in ascii and
371 * x8 - x15 having values of registers to be
372 * reported.
373 * ---------------------------------------------
374 */
375.section .rodata.cortex_a53_regs, "aS"
376cortex_a53_regs: /* The ascii list of register names to be reported */
Andre Przywara00eefd92016-10-06 16:54:53 +0100377 .asciz "cpuectlr_el1", "cpumerrsr_el1", "l2merrsr_el1", \
378 "cpuactlr_el1", ""
Soby Mathew38b4bc92014-08-14 13:36:41 +0100379
380func cortex_a53_cpu_reg_dump
381 adr x6, cortex_a53_regs
Varun Wadekar1384a162017-06-05 14:54:46 -0700382 mrs x8, CORTEX_A53_ECTLR_EL1
383 mrs x9, CORTEX_A53_MERRSR_EL1
384 mrs x10, CORTEX_A53_L2MERRSR_EL1
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100385 mrs x11, CORTEX_A53_CPUACTLR_EL1
Soby Mathew38b4bc92014-08-14 13:36:41 +0100386 ret
Kévin Petita877c252015-03-24 14:03:57 +0000387endfunc cortex_a53_cpu_reg_dump
Soby Mathew38b4bc92014-08-14 13:36:41 +0100388
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000389declare_cpu_ops cortex_a53, CORTEX_A53_MIDR, \
390 cortex_a53_reset_func, \
391 cortex_a53_core_pwr_dwn, \
392 cortex_a53_cluster_pwr_dwn