blob: 3a23e025fac0f302acc25be8f9507d69a29681a3 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Jonathan Wrightefb1f332018-03-28 15:52:03 +01002 * 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>
Yatharth Kochar36433d12014-11-20 18:09:41 +00008#include <bl_common.h>
Soby Mathew8e2f2872014-08-14 12:49:05 +01009#include <cortex_a53.h>
Soby Mathewc704cbc2014-08-14 11:33:56 +010010#include <cpu_macros.S>
Soby Mathew6b28c572016-03-21 10:36:47 +000011#include <debug.h>
Jonathan Wrightefb1f332018-03-28 15:52:03 +010012#include <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
developer4fceaca2015-07-29 20:55:31 +080045 /* --------------------------------------------------
46 * Errata Workaround for Cortex A53 Errata #826319.
47 * This applies only to revision <= r0p2 of Cortex A53.
48 * Inputs:
49 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000050 * Shall clobber: x0-x17
developer4fceaca2015-07-29 20:55:31 +080051 * --------------------------------------------------
52 */
53func errata_a53_826319_wa
54 /*
55 * Compare x0 against revision r0p2
56 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000057 mov x17, x30
58 bl check_errata_826319
59 cbz x0, 1f
Varun Wadekar1384a162017-06-05 14:54:46 -070060 mrs x1, CORTEX_A53_L2ACTLR_EL1
61 bic x1, x1, #CORTEX_A53_L2ACTLR_ENABLE_UNIQUECLEAN
62 orr x1, x1, #CORTEX_A53_L2ACTLR_DISABLE_CLEAN_PUSH
63 msr CORTEX_A53_L2ACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000641:
65 ret x17
developer4fceaca2015-07-29 20:55:31 +080066endfunc errata_a53_826319_wa
67
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000068func check_errata_826319
69 mov x1, #0x02
70 b cpu_rev_var_ls
71endfunc check_errata_826319
72
Sandrine Bailleuxd4817592016-01-13 14:57:38 +000073 /* ---------------------------------------------------------------------
74 * Disable the cache non-temporal hint.
75 *
76 * This ignores the Transient allocation hint in the MAIR and treats
77 * allocations the same as non-transient allocation types. As a result,
78 * the LDNP and STNP instructions in AArch64 behave the same as the
79 * equivalent LDP and STP instructions.
80 *
81 * This is relevant only for revisions <= r0p3 of Cortex-A53.
82 * From r0p4 and onwards, the bit to disable the hint is enabled by
83 * default at reset.
84 *
developer4fceaca2015-07-29 20:55:31 +080085 * Inputs:
86 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000087 * Shall clobber: x0-x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +000088 * ---------------------------------------------------------------------
developer4fceaca2015-07-29 20:55:31 +080089 */
Sandrine Bailleuxd4817592016-01-13 14:57:38 +000090func a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +080091 /*
92 * Compare x0 against revision r0p3
93 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000094 mov x17, x30
95 bl check_errata_disable_non_temporal_hint
96 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +010097 mrs x1, CORTEX_A53_CPUACTLR_EL1
98 orr x1, x1, #CORTEX_A53_CPUACTLR_EL1_DTAH
99 msr CORTEX_A53_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00001001:
101 ret x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000102endfunc a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +0800103
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000104func check_errata_disable_non_temporal_hint
105 mov x1, #0x03
106 b cpu_rev_var_ls
107endfunc check_errata_disable_non_temporal_hint
108
Andre Przywara00eefd92016-10-06 16:54:53 +0100109 /* --------------------------------------------------
110 * Errata Workaround for Cortex A53 Errata #855873.
111 *
112 * This applies only to revisions >= r0p3 of Cortex A53.
113 * Earlier revisions of the core are affected as well, but don't
114 * have the chicken bit in the CPUACTLR register. It is expected that
115 * the rich OS takes care of that, especially as the workaround is
116 * shared with other erratas in those revisions of the CPU.
117 * Inputs:
118 * x0: variant[4:7] and revision[0:3] of current cpu.
119 * Shall clobber: x0-x17
120 * --------------------------------------------------
121 */
122func errata_a53_855873_wa
123 /*
124 * Compare x0 against revision r0p3 and higher
125 */
126 mov x17, x30
127 bl check_errata_855873
128 cbz x0, 1f
129
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100130 mrs x1, CORTEX_A53_CPUACTLR_EL1
131 orr x1, x1, #CORTEX_A53_CPUACTLR_EL1_ENDCCASCI
132 msr CORTEX_A53_CPUACTLR_EL1, x1
Andre Przywara00eefd92016-10-06 16:54:53 +01001331:
134 ret x17
135endfunc errata_a53_855873_wa
136
137func check_errata_855873
138 mov x1, #0x03
139 b cpu_rev_var_hs
140endfunc check_errata_855873
141
Douglas Raillardd56fb042017-06-19 15:38:02 +0100142/*
143 * Errata workaround for Cortex A53 Errata #835769.
144 * This applies to revisions <= r0p4 of Cortex A53.
145 * This workaround is statically enabled at build time.
146 */
147func check_errata_835769
Jonathan Wright6e1796e2018-03-28 16:55:54 +0100148 cmp x0, #0x04
149 b.hi errata_not_applies
150 /*
151 * Fix potentially available for revisions r0p2, r0p3 and r0p4.
152 * If r0p2, r0p3 or r0p4; check for fix in REVIDR, else exit.
153 */
154 cmp x0, #0x01
155 mov x0, #ERRATA_APPLIES
156 b.ls exit_check_errata_835769
157 /* Load REVIDR. */
158 mrs x1, revidr_el1
159 /* If REVIDR[7] is set (fix exists) set ERRATA_NOT_APPLIES, else exit. */
160 tbz x1, #7, exit_check_errata_835769
161errata_not_applies:
162 mov x0, #ERRATA_NOT_APPLIES
163exit_check_errata_835769:
164 ret
Douglas Raillardd56fb042017-06-19 15:38:02 +0100165endfunc check_errata_835769
166
167/*
168 * Errata workaround for Cortex A53 Errata #843419.
169 * This applies to revisions <= r0p4 of Cortex A53.
170 * This workaround is statically enabled at build time.
171 */
172func check_errata_843419
Jonathan Wrightefb1f332018-03-28 15:52:03 +0100173 mov x1, #ERRATA_APPLIES
174 mov x2, #ERRATA_NOT_APPLIES
175 cmp x0, #0x04
176 csel x0, x1, x2, ls
177 /*
178 * Fix potentially available for revision r0p4.
179 * If r0p4 check for fix in REVIDR, else exit.
180 */
181 b.ne exit_check_errata_843419
182 /* Load REVIDR. */
183 mrs x3, revidr_el1
184 /* If REVIDR[8] is set (fix exists) set ERRATA_NOT_APPLIES, else exit. */
185 tbz x3, #8, exit_check_errata_843419
186 mov x0, x2
187exit_check_errata_843419:
188 ret
Douglas Raillardd56fb042017-06-19 15:38:02 +0100189endfunc check_errata_843419
190
developer4fceaca2015-07-29 20:55:31 +0800191 /* -------------------------------------------------
192 * The CPU Ops reset function for Cortex-A53.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000193 * Shall clobber: x0-x19
developer4fceaca2015-07-29 20:55:31 +0800194 * -------------------------------------------------
195 */
Soby Mathewc704cbc2014-08-14 11:33:56 +0100196func cortex_a53_reset_func
developer4fceaca2015-07-29 20:55:31 +0800197 mov x19, x30
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000198 bl cpu_get_rev_var
199 mov x18, x0
developer4fceaca2015-07-29 20:55:31 +0800200
developer4fceaca2015-07-29 20:55:31 +0800201
202#if ERRATA_A53_826319
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000203 mov x0, x18
developer4fceaca2015-07-29 20:55:31 +0800204 bl errata_a53_826319_wa
205#endif
206
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000207#if ERRATA_A53_836870
208 mov x0, x18
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000209 bl a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +0800210#endif
211
Andre Przywara00eefd92016-10-06 16:54:53 +0100212#if ERRATA_A53_855873
213 mov x0, x18
214 bl errata_a53_855873_wa
215#endif
216
Achin Gupta4f6ad662013-10-25 09:08:21 +0100217 /* ---------------------------------------------
Sandrine Bailleuxf12a31d2016-01-29 14:37:58 +0000218 * Enable the SMP bit.
Achin Gupta4f6ad662013-10-25 09:08:21 +0100219 * ---------------------------------------------
220 */
Varun Wadekar1384a162017-06-05 14:54:46 -0700221 mrs x0, CORTEX_A53_ECTLR_EL1
222 orr x0, x0, #CORTEX_A53_ECTLR_SMP_BIT
223 msr CORTEX_A53_ECTLR_EL1, x0
developer4fceaca2015-07-29 20:55:31 +0800224 isb
225 ret x19
Kévin Petita877c252015-03-24 14:03:57 +0000226endfunc cortex_a53_reset_func
Soby Mathewc704cbc2014-08-14 11:33:56 +0100227
Soby Mathew8e2f2872014-08-14 12:49:05 +0100228func cortex_a53_core_pwr_dwn
229 mov x18, x30
230
231 /* ---------------------------------------------
232 * Turn off caches.
233 * ---------------------------------------------
234 */
235 bl cortex_a53_disable_dcache
236
237 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100238 * Flush L1 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100239 * ---------------------------------------------
240 */
241 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100242 bl dcsw_op_level1
Soby Mathew8e2f2872014-08-14 12:49:05 +0100243
244 /* ---------------------------------------------
245 * Come out of intra cluster coherency
246 * ---------------------------------------------
247 */
248 mov x30, x18
249 b cortex_a53_disable_smp
Kévin Petita877c252015-03-24 14:03:57 +0000250endfunc cortex_a53_core_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100251
252func cortex_a53_cluster_pwr_dwn
253 mov x18, x30
254
255 /* ---------------------------------------------
256 * Turn off caches.
257 * ---------------------------------------------
258 */
259 bl cortex_a53_disable_dcache
260
261 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100262 * Flush L1 caches.
263 * ---------------------------------------------
264 */
265 mov x0, #DCCISW
266 bl dcsw_op_level1
267
268 /* ---------------------------------------------
Soby Mathew8e2f2872014-08-14 12:49:05 +0100269 * Disable the optional ACP.
270 * ---------------------------------------------
271 */
272 bl plat_disable_acp
273
274 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100275 * Flush L2 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100276 * ---------------------------------------------
277 */
278 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100279 bl dcsw_op_level2
Soby Mathew8e2f2872014-08-14 12:49:05 +0100280
281 /* ---------------------------------------------
282 * Come out of intra cluster coherency
283 * ---------------------------------------------
284 */
285 mov x30, x18
286 b cortex_a53_disable_smp
Kévin Petita877c252015-03-24 14:03:57 +0000287endfunc cortex_a53_cluster_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100288
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000289#if REPORT_ERRATA
290/*
291 * Errata printing function for Cortex A53. Must follow AAPCS.
292 */
293func cortex_a53_errata_report
294 stp x8, x30, [sp, #-16]!
295
296 bl cpu_get_rev_var
297 mov x8, x0
298
299 /*
300 * Report all errata. The revision-variant information is passed to
301 * checking functions of each errata.
302 */
303 report_errata ERRATA_A53_826319, cortex_a53, 826319
Douglas Raillardd56fb042017-06-19 15:38:02 +0100304 report_errata ERRATA_A53_835769, cortex_a53, 835769
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000305 report_errata ERRATA_A53_836870, cortex_a53, disable_non_temporal_hint
Douglas Raillardd56fb042017-06-19 15:38:02 +0100306 report_errata ERRATA_A53_843419, cortex_a53, 843419
Andre Przywara00eefd92016-10-06 16:54:53 +0100307 report_errata ERRATA_A53_855873, cortex_a53, 855873
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000308
309 ldp x8, x30, [sp], #16
310 ret
311endfunc cortex_a53_errata_report
312#endif
313
Soby Mathew38b4bc92014-08-14 13:36:41 +0100314 /* ---------------------------------------------
315 * This function provides cortex_a53 specific
316 * register information for crash reporting.
317 * It needs to return with x6 pointing to
318 * a list of register names in ascii and
319 * x8 - x15 having values of registers to be
320 * reported.
321 * ---------------------------------------------
322 */
323.section .rodata.cortex_a53_regs, "aS"
324cortex_a53_regs: /* The ascii list of register names to be reported */
Andre Przywara00eefd92016-10-06 16:54:53 +0100325 .asciz "cpuectlr_el1", "cpumerrsr_el1", "l2merrsr_el1", \
326 "cpuactlr_el1", ""
Soby Mathew38b4bc92014-08-14 13:36:41 +0100327
328func cortex_a53_cpu_reg_dump
329 adr x6, cortex_a53_regs
Varun Wadekar1384a162017-06-05 14:54:46 -0700330 mrs x8, CORTEX_A53_ECTLR_EL1
331 mrs x9, CORTEX_A53_MERRSR_EL1
332 mrs x10, CORTEX_A53_L2MERRSR_EL1
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100333 mrs x11, CORTEX_A53_CPUACTLR_EL1
Soby Mathew38b4bc92014-08-14 13:36:41 +0100334 ret
Kévin Petita877c252015-03-24 14:03:57 +0000335endfunc cortex_a53_cpu_reg_dump
Soby Mathew38b4bc92014-08-14 13:36:41 +0100336
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000337declare_cpu_ops cortex_a53, CORTEX_A53_MIDR, \
338 cortex_a53_reset_func, \
339 cortex_a53_core_pwr_dwn, \
340 cortex_a53_cluster_pwr_dwn