blob: e6fb08a4e28c0907231d39492fdf0e9ecdd81bd6 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +01002 * Copyright (c) 2014-2023, 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>
12#include <plat_macros.S>
Boyan Karatotev5d38cb32023-01-27 09:37:07 +000013#include <lib/cpus/errata.h>
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_a53_disable_dcache
Boyan Karatotev6ad97252023-04-05 16:02:34 +010020 sysreg_bit_clear sctlr_el3, SCTLR_C_BIT
Soby Mathew8e2f2872014-08-14 12:49:05 +010021 isb
22 ret
Kévin Petita877c252015-03-24 14:03:57 +000023endfunc cortex_a53_disable_dcache
Soby Mathew8e2f2872014-08-14 12:49:05 +010024
25 /* ---------------------------------------------
26 * Disable intra-cluster coherency
27 * ---------------------------------------------
28 */
29func cortex_a53_disable_smp
Boyan Karatotev6ad97252023-04-05 16:02:34 +010030 sysreg_bit_clear CORTEX_A53_ECTLR_EL1, CORTEX_A53_ECTLR_SMP_BIT
Soby Mathew8e2f2872014-08-14 12:49:05 +010031 isb
32 dsb sy
33 ret
Kévin Petita877c252015-03-24 14:03:57 +000034endfunc cortex_a53_disable_smp
Achin Gupta4f6ad662013-10-25 09:08:21 +010035
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010036/* Due to the nature of the errata it is applied unconditionally when chosen */
Boyan Karatotev6ad97252023-04-05 16:02:34 +010037check_erratum_ls cortex_a53, ERRATUM(819472), CPU_REV(0, 1)
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010038/* erratum workaround is interleaved with generic code */
39add_erratum_entry cortex_a53, ERRATUM(819472), ERRATUM_ALWAYS_CHOSEN, NO_APPLY_AT_RESET
40
41/* Due to the nature of the errata it is applied unconditionally when chosen */
Boyan Karatotev6ad97252023-04-05 16:02:34 +010042check_erratum_ls cortex_a53, ERRATUM(824069), CPU_REV(0, 2)
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010043/* erratum workaround is interleaved with generic code */
44add_erratum_entry cortex_a53, ERRATUM(824069), ERRATUM_ALWAYS_CHOSEN, NO_APPLY_AT_RESET
45
46workaround_reset_start cortex_a53, ERRATUM(826319), ERRATA_A53_826319
Varun Wadekar1384a162017-06-05 14:54:46 -070047 mrs x1, CORTEX_A53_L2ACTLR_EL1
48 bic x1, x1, #CORTEX_A53_L2ACTLR_ENABLE_UNIQUECLEAN
49 orr x1, x1, #CORTEX_A53_L2ACTLR_DISABLE_CLEAN_PUSH
50 msr CORTEX_A53_L2ACTLR_EL1, x1
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010051workaround_reset_end cortex_a53, ERRATUM(826319)
developer4fceaca2015-07-29 20:55:31 +080052
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010053check_erratum_ls cortex_a53, ERRATUM(826319), CPU_REV(0, 2)
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +000054
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010055/* Due to the nature of the errata it is applied unconditionally when chosen */
Boyan Karatotev6ad97252023-04-05 16:02:34 +010056check_erratum_ls cortex_a53, ERRATUM(827319), CPU_REV(0, 2)
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010057/* erratum workaround is interleaved with generic code */
58add_erratum_entry cortex_a53, ERRATUM(827319), ERRATUM_ALWAYS_CHOSEN, NO_APPLY_AT_RESET
59
60check_erratum_custom_start cortex_a53, ERRATUM(835769)
Boyan Karatotev6ad97252023-04-05 16:02:34 +010061 cmp x0, CPU_REV(0, 4)
Boyan Karatotev6f20c7f2023-04-03 16:28:10 +010062 b.hi errata_not_applies
63 /*
64 * Fix potentially available for revisions r0p2, r0p3 and r0p4.
65 * If r0p2, r0p3 or r0p4; check for fix in REVIDR, else exit.
66 */
67 cmp x0, #0x01
68 mov x0, #ERRATA_APPLIES
69 b.ls exit_check_errata_835769
70 /* Load REVIDR. */
71 mrs x1, revidr_el1
72 /* If REVIDR[7] is set (fix exists) set ERRATA_NOT_APPLIES, else exit. */
73 tbz x1, #7, exit_check_errata_835769
74errata_not_applies:
75 mov x0, #ERRATA_NOT_APPLIES
76exit_check_errata_835769:
77 ret
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010078check_erratum_custom_end cortex_a53, ERRATUM(835769)
Boyan Karatotev6f20c7f2023-04-03 16:28:10 +010079
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010080/* workaround at build time */
81add_erratum_entry cortex_a53, ERRATUM(835769), ERRATA_A53_835769, NO_APPLY_AT_RESET
82
83 /*
Sandrine Bailleuxd4817592016-01-13 14:57:38 +000084 * Disable the cache non-temporal hint.
85 *
86 * This ignores the Transient allocation hint in the MAIR and treats
87 * allocations the same as non-transient allocation types. As a result,
88 * the LDNP and STNP instructions in AArch64 behave the same as the
89 * equivalent LDP and STP instructions.
developer4fceaca2015-07-29 20:55:31 +080090 */
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010091workaround_reset_start cortex_a53, ERRATUM(836870), ERRATA_A53_836870 | A53_DISABLE_NON_TEMPORAL_HINT
Boyan Karatotev6ad97252023-04-05 16:02:34 +010092 sysreg_bit_set CORTEX_A53_CPUACTLR_EL1, CORTEX_A53_CPUACTLR_EL1_DTAH
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010093workaround_reset_end cortex_a53, ERRATUM(836870)
developer4fceaca2015-07-29 20:55:31 +080094
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010095check_erratum_ls cortex_a53, ERRATUM(836870), CPU_REV(0, 3)
Boyan Karatotev6f20c7f2023-04-03 16:28:10 +010096
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +010097check_erratum_custom_start cortex_a53, ERRATUM(843419)
Boyan Karatotev6f20c7f2023-04-03 16:28:10 +010098 mov x1, #ERRATA_APPLIES
99 mov x2, #ERRATA_NOT_APPLIES
Boyan Karatotev6ad97252023-04-05 16:02:34 +0100100 cmp x0, CPU_REV(0, 4)
Boyan Karatotev6f20c7f2023-04-03 16:28:10 +0100101 csel x0, x1, x2, ls
102 /*
103 * Fix potentially available for revision r0p4.
104 * If r0p4 check for fix in REVIDR, else exit.
105 */
106 b.ne exit_check_errata_843419
107 /* Load REVIDR. */
108 mrs x3, revidr_el1
109 /* If REVIDR[8] is set (fix exists) set ERRATA_NOT_APPLIES, else exit. */
110 tbz x3, #8, exit_check_errata_843419
111 mov x0, x2
112exit_check_errata_843419:
113 ret
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +0100114check_erratum_custom_end cortex_a53, ERRATUM(843419)
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000115
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +0100116/* workaround at build time */
117add_erratum_entry cortex_a53, ERRATUM(843419), ERRATA_A53_843419, NO_APPLY_AT_RESET
118
119 /*
Andre Przywara00eefd92016-10-06 16:54:53 +0100120 * Earlier revisions of the core are affected as well, but don't
121 * have the chicken bit in the CPUACTLR register. It is expected that
122 * the rich OS takes care of that, especially as the workaround is
123 * shared with other erratas in those revisions of the CPU.
Andre Przywara00eefd92016-10-06 16:54:53 +0100124 */
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +0100125workaround_reset_start cortex_a53, ERRATUM(855873), ERRATA_A53_855873
Boyan Karatotev6ad97252023-04-05 16:02:34 +0100126 sysreg_bit_set CORTEX_A53_CPUACTLR_EL1, CORTEX_A53_CPUACTLR_EL1_ENDCCASCI
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +0100127workaround_reset_end cortex_a53, ERRATUM(855873)
Andre Przywara00eefd92016-10-06 16:54:53 +0100128
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +0100129check_erratum_hs cortex_a53, ERRATUM(855873), CPU_REV(0, 3)
Andre Przywara00eefd92016-10-06 16:54:53 +0100130
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +0100131check_erratum_chosen cortex_a53, ERRATUM(1530924), ERRATA_A53_1530924
developer4fceaca2015-07-29 20:55:31 +0800132
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +0100133/* erratum has no workaround in the cpu. Generic code must take care */
134add_erratum_entry cortex_a53, ERRATUM(1530924), ERRATA_A53_1530924, NO_APPLY_AT_RESET
developer4fceaca2015-07-29 20:55:31 +0800135
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +0100136cpu_reset_func_start cortex_a53
Boyan Karatotev6ad97252023-04-05 16:02:34 +0100137 /* Enable the SMP bit. */
138 sysreg_bit_set CORTEX_A53_ECTLR_EL1, CORTEX_A53_ECTLR_SMP_BIT
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +0100139cpu_reset_func_end cortex_a53
Soby Mathewc704cbc2014-08-14 11:33:56 +0100140
Soby Mathew8e2f2872014-08-14 12:49:05 +0100141func cortex_a53_core_pwr_dwn
142 mov x18, x30
143
144 /* ---------------------------------------------
145 * Turn off caches.
146 * ---------------------------------------------
147 */
148 bl cortex_a53_disable_dcache
149
150 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100151 * Flush L1 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100152 * ---------------------------------------------
153 */
154 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100155 bl dcsw_op_level1
Soby Mathew8e2f2872014-08-14 12:49:05 +0100156
157 /* ---------------------------------------------
158 * Come out of intra cluster coherency
159 * ---------------------------------------------
160 */
161 mov x30, x18
162 b cortex_a53_disable_smp
Kévin Petita877c252015-03-24 14:03:57 +0000163endfunc cortex_a53_core_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100164
165func cortex_a53_cluster_pwr_dwn
166 mov x18, x30
167
168 /* ---------------------------------------------
169 * Turn off caches.
170 * ---------------------------------------------
171 */
172 bl cortex_a53_disable_dcache
173
174 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100175 * Flush L1 caches.
176 * ---------------------------------------------
177 */
178 mov x0, #DCCISW
179 bl dcsw_op_level1
180
181 /* ---------------------------------------------
Soby Mathew8e2f2872014-08-14 12:49:05 +0100182 * Disable the optional ACP.
183 * ---------------------------------------------
184 */
185 bl plat_disable_acp
186
187 /* ---------------------------------------------
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100188 * Flush L2 caches.
Soby Mathew8e2f2872014-08-14 12:49:05 +0100189 * ---------------------------------------------
190 */
191 mov x0, #DCCISW
Soby Mathew42aa5eb2014-09-02 10:47:33 +0100192 bl dcsw_op_level2
Soby Mathew8e2f2872014-08-14 12:49:05 +0100193
194 /* ---------------------------------------------
195 * Come out of intra cluster coherency
196 * ---------------------------------------------
197 */
198 mov x30, x18
199 b cortex_a53_disable_smp
Kévin Petita877c252015-03-24 14:03:57 +0000200endfunc cortex_a53_cluster_pwr_dwn
Soby Mathew8e2f2872014-08-14 12:49:05 +0100201
Boyan Karatoteva6c9cf72023-04-04 11:30:32 +0100202errata_report_shim cortex_a53
Jeenu Viswambharand5ec3672017-01-03 11:01:51 +0000203
Soby Mathew38b4bc92014-08-14 13:36:41 +0100204 /* ---------------------------------------------
205 * This function provides cortex_a53 specific
206 * register information for crash reporting.
207 * It needs to return with x6 pointing to
208 * a list of register names in ascii and
209 * x8 - x15 having values of registers to be
210 * reported.
211 * ---------------------------------------------
212 */
213.section .rodata.cortex_a53_regs, "aS"
214cortex_a53_regs: /* The ascii list of register names to be reported */
Andre Przywara00eefd92016-10-06 16:54:53 +0100215 .asciz "cpuectlr_el1", "cpumerrsr_el1", "l2merrsr_el1", \
216 "cpuactlr_el1", ""
Soby Mathew38b4bc92014-08-14 13:36:41 +0100217
218func cortex_a53_cpu_reg_dump
219 adr x6, cortex_a53_regs
Varun Wadekar1384a162017-06-05 14:54:46 -0700220 mrs x8, CORTEX_A53_ECTLR_EL1
221 mrs x9, CORTEX_A53_MERRSR_EL1
222 mrs x10, CORTEX_A53_L2MERRSR_EL1
Eleanor Bonnici41b61be2017-08-09 16:42:40 +0100223 mrs x11, CORTEX_A53_CPUACTLR_EL1
Soby Mathew38b4bc92014-08-14 13:36:41 +0100224 ret
Kévin Petita877c252015-03-24 14:03:57 +0000225endfunc cortex_a53_cpu_reg_dump
Soby Mathew38b4bc92014-08-14 13:36:41 +0100226
Jeenu Viswambharanee5eb802016-11-18 12:58:28 +0000227declare_cpu_ops cortex_a53, CORTEX_A53_MIDR, \
228 cortex_a53_reset_func, \
229 cortex_a53_core_pwr_dwn, \
230 cortex_a53_cluster_pwr_dwn