blob: 3e480bc1fe2ddb1ab111cfa98954f6b5b9a1141e [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00002 * Copyright (c) 2014-2017, 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>
Soby Mathewc704cbc2014-08-14 11:33:56 +010012#include <plat_macros.S>
Achin Gupta4f6ad662013-10-25 09:08:21 +010013
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000014#if A53_DISABLE_NON_TEMPORAL_HINT
15#undef ERRATA_A53_836870
16#define ERRATA_A53_836870 1
17#endif
18
Soby Mathew8e2f2872014-08-14 12:49:05 +010019 /* ---------------------------------------------
20 * Disable L1 data cache and unified L2 cache
21 * ---------------------------------------------
22 */
23func cortex_a53_disable_dcache
24 mrs x1, sctlr_el3
25 bic x1, x1, #SCTLR_C_BIT
26 msr sctlr_el3, x1
27 isb
28 ret
Kévin Petita877c252015-03-24 14:03:57 +000029endfunc cortex_a53_disable_dcache
Soby Mathew8e2f2872014-08-14 12:49:05 +010030
31 /* ---------------------------------------------
32 * Disable intra-cluster coherency
33 * ---------------------------------------------
34 */
35func cortex_a53_disable_smp
Varun Wadekar1384a162017-06-05 14:54:46 -070036 mrs x0, CORTEX_A53_ECTLR_EL1
37 bic x0, x0, #CORTEX_A53_ECTLR_SMP_BIT
38 msr CORTEX_A53_ECTLR_EL1, x0
Soby Mathew8e2f2872014-08-14 12:49:05 +010039 isb
40 dsb sy
41 ret
Kévin Petita877c252015-03-24 14:03:57 +000042endfunc cortex_a53_disable_smp
Achin Gupta4f6ad662013-10-25 09:08:21 +010043
developer4fceaca2015-07-29 20:55:31 +080044 /* --------------------------------------------------
45 * Errata Workaround for Cortex A53 Errata #826319.
46 * This applies only to revision <= r0p2 of Cortex A53.
47 * Inputs:
48 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000049 * Shall clobber: x0-x17
developer4fceaca2015-07-29 20:55:31 +080050 * --------------------------------------------------
51 */
52func errata_a53_826319_wa
53 /*
54 * Compare x0 against revision r0p2
55 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000056 mov x17, x30
57 bl check_errata_826319
58 cbz x0, 1f
Varun Wadekar1384a162017-06-05 14:54:46 -070059 mrs x1, CORTEX_A53_L2ACTLR_EL1
60 bic x1, x1, #CORTEX_A53_L2ACTLR_ENABLE_UNIQUECLEAN
61 orr x1, x1, #CORTEX_A53_L2ACTLR_DISABLE_CLEAN_PUSH
62 msr CORTEX_A53_L2ACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000631:
64 ret x17
developer4fceaca2015-07-29 20:55:31 +080065endfunc errata_a53_826319_wa
66
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000067func check_errata_826319
68 mov x1, #0x02
69 b cpu_rev_var_ls
70endfunc check_errata_826319
71
Sandrine Bailleuxd4817592016-01-13 14:57:38 +000072 /* ---------------------------------------------------------------------
73 * Disable the cache non-temporal hint.
74 *
75 * This ignores the Transient allocation hint in the MAIR and treats
76 * allocations the same as non-transient allocation types. As a result,
77 * the LDNP and STNP instructions in AArch64 behave the same as the
78 * equivalent LDP and STP instructions.
79 *
80 * This is relevant only for revisions <= r0p3 of Cortex-A53.
81 * From r0p4 and onwards, the bit to disable the hint is enabled by
82 * default at reset.
83 *
developer4fceaca2015-07-29 20:55:31 +080084 * Inputs:
85 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000086 * Shall clobber: x0-x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +000087 * ---------------------------------------------------------------------
developer4fceaca2015-07-29 20:55:31 +080088 */
Sandrine Bailleuxd4817592016-01-13 14:57:38 +000089func a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +080090 /*
91 * Compare x0 against revision r0p3
92 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000093 mov x17, x30
94 bl check_errata_disable_non_temporal_hint
95 cbz x0, 1f
Eleanor Bonnici41b61be2017-08-09 16:42:40 +010096 mrs x1, CORTEX_A53_CPUACTLR_EL1
97 orr x1, x1, #CORTEX_A53_CPUACTLR_EL1_DTAH
98 msr CORTEX_A53_CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000991:
100 ret x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000101endfunc a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +0800102
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000103func check_errata_disable_non_temporal_hint
104 mov x1, #0x03
105 b cpu_rev_var_ls
106endfunc check_errata_disable_non_temporal_hint
107
Andre Przywara00eefd92016-10-06 16:54:53 +0100108 /* --------------------------------------------------
109 * Errata Workaround for Cortex A53 Errata #855873.
110 *
111 * This applies only to revisions >= r0p3 of Cortex A53.
112 * Earlier revisions of the core are affected as well, but don't
113 * have the chicken bit in the CPUACTLR register. It is expected that
114 * the rich OS takes care of that, especially as the workaround is
115 * shared with other erratas in those revisions of the CPU.
116 * Inputs:
117 * x0: variant[4:7] and revision[0:3] of current cpu.
118 * Shall clobber: x0-x17
119 * --------------------------------------------------
120 */
121func errata_a53_855873_wa
122 /*
123 * Compare x0 against revision r0p3 and higher
124 */
125 mov x17, x30
126 bl check_errata_855873
127 cbz x0, 1f
128
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100129 mrs x1, CORTEX_A53_CPUACTLR_EL1
130 orr x1, x1, #CORTEX_A53_CPUACTLR_EL1_ENDCCASCI
131 msr CORTEX_A53_CPUACTLR_EL1, x1
Andre Przywara00eefd92016-10-06 16:54:53 +01001321:
133 ret x17
134endfunc errata_a53_855873_wa
135
136func check_errata_855873
137 mov x1, #0x03
138 b cpu_rev_var_hs
139endfunc check_errata_855873
140
Douglas Raillardd56fb042017-06-19 15:38:02 +0100141/*
142 * Errata workaround for Cortex A53 Errata #835769.
143 * This applies to revisions <= r0p4 of Cortex A53.
144 * This workaround is statically enabled at build time.
145 */
146func check_errata_835769
147 mov x1, #0x04
148 b cpu_rev_var_ls
149endfunc check_errata_835769
150
151/*
152 * Errata workaround for Cortex A53 Errata #843419.
153 * This applies to revisions <= r0p4 of Cortex A53.
154 * This workaround is statically enabled at build time.
155 */
156func check_errata_843419
157 mov x1, #0x04
158 b cpu_rev_var_ls
159endfunc check_errata_843419
160
developer4fceaca2015-07-29 20:55:31 +0800161 /* -------------------------------------------------
162 * The CPU Ops reset function for Cortex-A53.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000163 * Shall clobber: x0-x19
developer4fceaca2015-07-29 20:55:31 +0800164 * -------------------------------------------------
165 */
Soby Mathewc704cbc2014-08-14 11:33:56 +0100166func cortex_a53_reset_func
developer4fceaca2015-07-29 20:55:31 +0800167 mov x19, x30
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000168 bl cpu_get_rev_var
169 mov x18, x0
developer4fceaca2015-07-29 20:55:31 +0800170
developer4fceaca2015-07-29 20:55:31 +0800171
172#if ERRATA_A53_826319
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000173 mov x0, x18
developer4fceaca2015-07-29 20:55:31 +0800174 bl errata_a53_826319_wa
175#endif
176
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000177#if ERRATA_A53_836870
178 mov x0, x18
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000179 bl a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +0800180#endif
181
Andre Przywara00eefd92016-10-06 16:54:53 +0100182#if ERRATA_A53_855873
183 mov x0, x18
184 bl errata_a53_855873_wa
185#endif
186
Achin Gupta4f6ad662013-10-25 09:08:21 +0100187 /* ---------------------------------------------
Sandrine Bailleuxf12a31d2016-01-29 14:37:58 +0000188 * Enable the SMP bit.
Achin Gupta4f6ad662013-10-25 09:08:21 +0100189 * ---------------------------------------------
190 */
Varun Wadekar1384a162017-06-05 14:54:46 -0700191 mrs x0, CORTEX_A53_ECTLR_EL1
192 orr x0, x0, #CORTEX_A53_ECTLR_SMP_BIT
193 msr CORTEX_A53_ECTLR_EL1, x0
developer4fceaca2015-07-29 20:55:31 +0800194 isb
195 ret x19
Kévin Petita877c252015-03-24 14:03:57 +0000196endfunc cortex_a53_reset_func
Soby Mathewc704cbc2014-08-14 11:33:56 +0100197
Soby Mathew8e2f2872014-08-14 12:49:05 +0100198func cortex_a53_core_pwr_dwn
199 mov x18, x30
200
201 /* ---------------------------------------------
202 * Turn off caches.
203 * ---------------------------------------------
204 */
205 bl cortex_a53_disable_dcache
206
207 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100208 * Flush L1 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100209 * ---------------------------------------------
210 */
211 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100212 bl dcsw_op_level1
Soby Mathew8e2f2872014-08-14 12:49:05 +0100213
214 /* ---------------------------------------------
215 * Come out of intra cluster coherency
216 * ---------------------------------------------
217 */
218 mov x30, x18
219 b cortex_a53_disable_smp
Kévin Petita877c252015-03-24 14:03:57 +0000220endfunc cortex_a53_core_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100221
222func cortex_a53_cluster_pwr_dwn
223 mov x18, x30
224
225 /* ---------------------------------------------
226 * Turn off caches.
227 * ---------------------------------------------
228 */
229 bl cortex_a53_disable_dcache
230
231 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100232 * Flush L1 caches.
233 * ---------------------------------------------
234 */
235 mov x0, #DCCISW
236 bl dcsw_op_level1
237
238 /* ---------------------------------------------
Soby Mathew8e2f2872014-08-14 12:49:05 +0100239 * Disable the optional ACP.
240 * ---------------------------------------------
241 */
242 bl plat_disable_acp
243
244 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100245 * Flush L2 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100246 * ---------------------------------------------
247 */
248 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100249 bl dcsw_op_level2
Soby Mathew8e2f2872014-08-14 12:49:05 +0100250
251 /* ---------------------------------------------
252 * Come out of intra cluster coherency
253 * ---------------------------------------------
254 */
255 mov x30, x18
256 b cortex_a53_disable_smp
Kévin Petita877c252015-03-24 14:03:57 +0000257endfunc cortex_a53_cluster_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100258
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000259#if REPORT_ERRATA
260/*
261 * Errata printing function for Cortex A53. Must follow AAPCS.
262 */
263func cortex_a53_errata_report
264 stp x8, x30, [sp, #-16]!
265
266 bl cpu_get_rev_var
267 mov x8, x0
268
269 /*
270 * Report all errata. The revision-variant information is passed to
271 * checking functions of each errata.
272 */
273 report_errata ERRATA_A53_826319, cortex_a53, 826319
Douglas Raillardd56fb042017-06-19 15:38:02 +0100274 report_errata ERRATA_A53_835769, cortex_a53, 835769
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000275 report_errata ERRATA_A53_836870, cortex_a53, disable_non_temporal_hint
Douglas Raillardd56fb042017-06-19 15:38:02 +0100276 report_errata ERRATA_A53_843419, cortex_a53, 843419
Andre Przywara00eefd92016-10-06 16:54:53 +0100277 report_errata ERRATA_A53_855873, cortex_a53, 855873
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000278
279 ldp x8, x30, [sp], #16
280 ret
281endfunc cortex_a53_errata_report
282#endif
283
Soby Mathew38b4bc92014-08-14 13:36:41 +0100284 /* ---------------------------------------------
285 * This function provides cortex_a53 specific
286 * register information for crash reporting.
287 * It needs to return with x6 pointing to
288 * a list of register names in ascii and
289 * x8 - x15 having values of registers to be
290 * reported.
291 * ---------------------------------------------
292 */
293.section .rodata.cortex_a53_regs, "aS"
294cortex_a53_regs: /* The ascii list of register names to be reported */
Andre Przywara00eefd92016-10-06 16:54:53 +0100295 .asciz "cpuectlr_el1", "cpumerrsr_el1", "l2merrsr_el1", \
296 "cpuactlr_el1", ""
Soby Mathew38b4bc92014-08-14 13:36:41 +0100297
298func cortex_a53_cpu_reg_dump
299 adr x6, cortex_a53_regs
Varun Wadekar1384a162017-06-05 14:54:46 -0700300 mrs x8, CORTEX_A53_ECTLR_EL1
301 mrs x9, CORTEX_A53_MERRSR_EL1
302 mrs x10, CORTEX_A53_L2MERRSR_EL1
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100303 mrs x11, CORTEX_A53_CPUACTLR_EL1
Soby Mathew38b4bc92014-08-14 13:36:41 +0100304 ret
Kévin Petita877c252015-03-24 14:03:57 +0000305endfunc cortex_a53_cpu_reg_dump
Soby Mathew38b4bc92014-08-14 13:36:41 +0100306
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000307declare_cpu_ops cortex_a53, CORTEX_A53_MIDR, \
308 cortex_a53_reset_func, \
309 cortex_a53_core_pwr_dwn, \
310 cortex_a53_cluster_pwr_dwn