blob: 1dd8a8650d52be36a15b68456565fa08b86b621d [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 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
Achin Gupta4f6ad662013-10-25 09:08:21 +010030#include <arch.h>
Andrew Thoelke38bde412014-03-18 13:46:55 +000031#include <asm_macros.S>
Yatharth Kochar36433d12014-11-20 18:09:41 +000032#include <bl_common.h>
Soby Mathew8e2f2872014-08-14 12:49:05 +010033#include <cortex_a53.h>
Soby Mathewc704cbc2014-08-14 11:33:56 +010034#include <cpu_macros.S>
Soby Mathew6b28c572016-03-21 10:36:47 +000035#include <debug.h>
Soby Mathewc704cbc2014-08-14 11:33:56 +010036#include <plat_macros.S>
Achin Gupta4f6ad662013-10-25 09:08:21 +010037
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000038#if A53_DISABLE_NON_TEMPORAL_HINT
39#undef ERRATA_A53_836870
40#define ERRATA_A53_836870 1
41#endif
42
Soby Mathew8e2f2872014-08-14 12:49:05 +010043 /* ---------------------------------------------
44 * Disable L1 data cache and unified L2 cache
45 * ---------------------------------------------
46 */
47func cortex_a53_disable_dcache
48 mrs x1, sctlr_el3
49 bic x1, x1, #SCTLR_C_BIT
50 msr sctlr_el3, x1
51 isb
52 ret
Kévin Petita877c252015-03-24 14:03:57 +000053endfunc cortex_a53_disable_dcache
Soby Mathew8e2f2872014-08-14 12:49:05 +010054
55 /* ---------------------------------------------
56 * Disable intra-cluster coherency
57 * ---------------------------------------------
58 */
59func cortex_a53_disable_smp
60 mrs x0, CPUECTLR_EL1
61 bic x0, x0, #CPUECTLR_SMP_BIT
62 msr CPUECTLR_EL1, x0
63 isb
64 dsb sy
65 ret
Kévin Petita877c252015-03-24 14:03:57 +000066endfunc cortex_a53_disable_smp
Achin Gupta4f6ad662013-10-25 09:08:21 +010067
developer4fceaca2015-07-29 20:55:31 +080068 /* --------------------------------------------------
69 * Errata Workaround for Cortex A53 Errata #826319.
70 * This applies only to revision <= r0p2 of Cortex A53.
71 * Inputs:
72 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000073 * Shall clobber: x0-x17
developer4fceaca2015-07-29 20:55:31 +080074 * --------------------------------------------------
75 */
76func errata_a53_826319_wa
77 /*
78 * Compare x0 against revision r0p2
79 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000080 mov x17, x30
81 bl check_errata_826319
82 cbz x0, 1f
developer4fceaca2015-07-29 20:55:31 +080083 mrs x1, L2ACTLR_EL1
84 bic x1, x1, #L2ACTLR_ENABLE_UNIQUECLEAN
85 orr x1, x1, #L2ACTLR_DISABLE_CLEAN_PUSH
86 msr L2ACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000871:
88 ret x17
developer4fceaca2015-07-29 20:55:31 +080089endfunc errata_a53_826319_wa
90
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000091func check_errata_826319
92 mov x1, #0x02
93 b cpu_rev_var_ls
94endfunc check_errata_826319
95
Sandrine Bailleuxd4817592016-01-13 14:57:38 +000096 /* ---------------------------------------------------------------------
97 * Disable the cache non-temporal hint.
98 *
99 * This ignores the Transient allocation hint in the MAIR and treats
100 * allocations the same as non-transient allocation types. As a result,
101 * the LDNP and STNP instructions in AArch64 behave the same as the
102 * equivalent LDP and STP instructions.
103 *
104 * This is relevant only for revisions <= r0p3 of Cortex-A53.
105 * From r0p4 and onwards, the bit to disable the hint is enabled by
106 * default at reset.
107 *
developer4fceaca2015-07-29 20:55:31 +0800108 * Inputs:
109 * x0: variant[4:7] and revision[0:3] of current cpu.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000110 * Shall clobber: x0-x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000111 * ---------------------------------------------------------------------
developer4fceaca2015-07-29 20:55:31 +0800112 */
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000113func a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +0800114 /*
115 * Compare x0 against revision r0p3
116 */
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000117 mov x17, x30
118 bl check_errata_disable_non_temporal_hint
119 cbz x0, 1f
developer4fceaca2015-07-29 20:55:31 +0800120 mrs x1, CPUACTLR_EL1
121 orr x1, x1, #CPUACTLR_DTAH
122 msr CPUACTLR_EL1, x1
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +00001231:
124 ret x17
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000125endfunc a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +0800126
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000127func check_errata_disable_non_temporal_hint
128 mov x1, #0x03
129 b cpu_rev_var_ls
130endfunc check_errata_disable_non_temporal_hint
131
developer4fceaca2015-07-29 20:55:31 +0800132 /* -------------------------------------------------
133 * The CPU Ops reset function for Cortex-A53.
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000134 * Shall clobber: x0-x19
developer4fceaca2015-07-29 20:55:31 +0800135 * -------------------------------------------------
136 */
Soby Mathewc704cbc2014-08-14 11:33:56 +0100137func cortex_a53_reset_func
developer4fceaca2015-07-29 20:55:31 +0800138 mov x19, x30
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000139 bl cpu_get_rev_var
140 mov x18, x0
developer4fceaca2015-07-29 20:55:31 +0800141
developer4fceaca2015-07-29 20:55:31 +0800142
143#if ERRATA_A53_826319
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000144 mov x0, x18
developer4fceaca2015-07-29 20:55:31 +0800145 bl errata_a53_826319_wa
146#endif
147
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000148#if ERRATA_A53_836870
149 mov x0, x18
Sandrine Bailleuxd4817592016-01-13 14:57:38 +0000150 bl a53_disable_non_temporal_hint
developer4fceaca2015-07-29 20:55:31 +0800151#endif
152
Achin Gupta4f6ad662013-10-25 09:08:21 +0100153 /* ---------------------------------------------
Sandrine Bailleuxf12a31d2016-01-29 14:37:58 +0000154 * Enable the SMP bit.
Achin Gupta4f6ad662013-10-25 09:08:21 +0100155 * ---------------------------------------------
156 */
Andrew Thoelkef977ed82014-04-28 12:32:02 +0100157 mrs x0, CPUECTLR_EL1
Achin Gupta4f6ad662013-10-25 09:08:21 +0100158 orr x0, x0, #CPUECTLR_SMP_BIT
Andrew Thoelkef977ed82014-04-28 12:32:02 +0100159 msr CPUECTLR_EL1, x0
developer4fceaca2015-07-29 20:55:31 +0800160 isb
161 ret x19
Kévin Petita877c252015-03-24 14:03:57 +0000162endfunc cortex_a53_reset_func
Soby Mathewc704cbc2014-08-14 11:33:56 +0100163
Soby Mathew8e2f2872014-08-14 12:49:05 +0100164func cortex_a53_core_pwr_dwn
165 mov x18, x30
166
167 /* ---------------------------------------------
168 * Turn off caches.
169 * ---------------------------------------------
170 */
171 bl cortex_a53_disable_dcache
172
173 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100174 * Flush L1 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100175 * ---------------------------------------------
176 */
177 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100178 bl dcsw_op_level1
Soby Mathew8e2f2872014-08-14 12:49:05 +0100179
180 /* ---------------------------------------------
181 * Come out of intra cluster coherency
182 * ---------------------------------------------
183 */
184 mov x30, x18
185 b cortex_a53_disable_smp
Kévin Petita877c252015-03-24 14:03:57 +0000186endfunc cortex_a53_core_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100187
188func cortex_a53_cluster_pwr_dwn
189 mov x18, x30
190
191 /* ---------------------------------------------
192 * Turn off caches.
193 * ---------------------------------------------
194 */
195 bl cortex_a53_disable_dcache
196
197 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100198 * Flush L1 caches.
199 * ---------------------------------------------
200 */
201 mov x0, #DCCISW
202 bl dcsw_op_level1
203
204 /* ---------------------------------------------
Soby Mathew8e2f2872014-08-14 12:49:05 +0100205 * Disable the optional ACP.
206 * ---------------------------------------------
207 */
208 bl plat_disable_acp
209
210 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100211 * Flush L2 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100212 * ---------------------------------------------
213 */
214 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100215 bl dcsw_op_level2
Soby Mathew8e2f2872014-08-14 12:49:05 +0100216
217 /* ---------------------------------------------
218 * Come out of intra cluster coherency
219 * ---------------------------------------------
220 */
221 mov x30, x18
222 b cortex_a53_disable_smp
Kévin Petita877c252015-03-24 14:03:57 +0000223endfunc cortex_a53_cluster_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100224
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000225#if REPORT_ERRATA
226/*
227 * Errata printing function for Cortex A53. Must follow AAPCS.
228 */
229func cortex_a53_errata_report
230 stp x8, x30, [sp, #-16]!
231
232 bl cpu_get_rev_var
233 mov x8, x0
234
235 /*
236 * Report all errata. The revision-variant information is passed to
237 * checking functions of each errata.
238 */
239 report_errata ERRATA_A53_826319, cortex_a53, 826319
240 report_errata ERRATA_A53_836870, cortex_a53, disable_non_temporal_hint
241
242 ldp x8, x30, [sp], #16
243 ret
244endfunc cortex_a53_errata_report
245#endif
246
Soby Mathew38b4bc92014-08-14 13:36:41 +0100247 /* ---------------------------------------------
248 * This function provides cortex_a53 specific
249 * register information for crash reporting.
250 * It needs to return with x6 pointing to
251 * a list of register names in ascii and
252 * x8 - x15 having values of registers to be
253 * reported.
254 * ---------------------------------------------
255 */
256.section .rodata.cortex_a53_regs, "aS"
257cortex_a53_regs: /* The ascii list of register names to be reported */
Naga Sureshkumar Relli6a72a912016-07-01 12:52:41 +0530258 .asciz "cpuectlr_el1", "cpumerrsr_el1", "l2merrsr_el1", ""
Soby Mathew38b4bc92014-08-14 13:36:41 +0100259
260func cortex_a53_cpu_reg_dump
261 adr x6, cortex_a53_regs
262 mrs x8, CPUECTLR_EL1
Naga Sureshkumar Relli6a72a912016-07-01 12:52:41 +0530263 mrs x9, CPUMERRSR_EL1
264 mrs x10, L2MERRSR_EL1
Soby Mathew38b4bc92014-08-14 13:36:41 +0100265 ret
Kévin Petita877c252015-03-24 14:03:57 +0000266endfunc cortex_a53_cpu_reg_dump
Soby Mathew38b4bc92014-08-14 13:36:41 +0100267
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000268declare_cpu_ops cortex_a53, CORTEX_A53_MIDR, \
269 cortex_a53_reset_func, \
270 cortex_a53_core_pwr_dwn, \
271 cortex_a53_cluster_pwr_dwn