blob: 0dc34f7ac3001d6bea26ddb1a719a4e8488f3e56 [file] [log] [blame]
Bipin Ravi4da1b0b2021-03-16 15:20:58 -05001/*
Bipin Ravi8ca7aba2023-12-20 15:40:44 -06002 * Copyright (c) 2021-2024, Arm Limited. All rights reserved.
Bipin Ravi4da1b0b2021-03-16 15:20:58 -05003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <common/bl_common.h>
10#include <cortex_a78c.h>
11#include <cpu_macros.S>
12#include <plat_macros.S>
Bipin Ravieb4d12b2022-03-12 01:58:02 -060013#include "wa_cve_2022_23960_bhb_vector.S"
Bipin Ravi4da1b0b2021-03-16 15:20:58 -050014
15/* Hardware handled coherency */
16#if HW_ASSISTED_COHERENCY == 0
17#error "cortex_a78c must be compiled with HW_ASSISTED_COHERENCY enabled"
18#endif
19
Govindraj Rajaa4c473e2023-06-15 11:32:07 -050020#if WORKAROUND_CVE_2022_23960
21 wa_cve_2022_23960_bhb_vector_table CORTEX_A78C_BHB_LOOP_COUNT, cortex_a78c
22#endif /* WORKAROUND_CVE_2022_23960 */
23
Govindraj Raja20a92952023-06-15 11:47:33 -050024workaround_reset_start cortex_a78c, ERRATUM(1827430), ERRATA_A78C_1827430
Bipin Ravibf205fc2023-03-14 10:04:23 -050025 /* Disable allocation of splintered pages in the L2 TLB */
Govindraj Rajaf37b2872023-06-15 11:57:16 -050026 sysreg_bit_set CORTEX_A78C_CPUECTLR_EL1, CORTEX_A78C_CPUECTLR_EL1_MM_ASP_EN
Govindraj Raja20a92952023-06-15 11:47:33 -050027workaround_reset_end cortex_a78c, ERRATUM(1827430)
Bipin Ravibf205fc2023-03-14 10:04:23 -050028
Govindraj Raja20a92952023-06-15 11:47:33 -050029check_erratum_ls cortex_a78c, ERRATUM(1827430), CPU_REV(0, 0)
Bipin Ravie49c7042023-03-14 11:03:24 -050030
Govindraj Raja20a92952023-06-15 11:47:33 -050031workaround_reset_start cortex_a78c, ERRATUM(1827440), ERRATA_A78C_1827440
Bipin Ravie49c7042023-03-14 11:03:24 -050032 /* Force Atomic Store to WB memory be done in L1 data cache */
Govindraj Rajaf37b2872023-06-15 11:57:16 -050033 sysreg_bit_set CORTEX_A78C_CPUACTLR2_EL1, BIT(2)
Govindraj Raja20a92952023-06-15 11:47:33 -050034workaround_reset_end cortex_a78c, ERRATUM(1827440)
Bipin Ravie49c7042023-03-14 11:03:24 -050035
Govindraj Raja20a92952023-06-15 11:47:33 -050036check_erratum_ls cortex_a78c, ERRATUM(1827440), CPU_REV(0, 0)
Bipin Ravie49c7042023-03-14 11:03:24 -050037
Govindraj Raja20a92952023-06-15 11:47:33 -050038workaround_reset_start cortex_a78c, ERRATUM(2132064), ERRATA_A78C_2132064
laurenw-arm4dc18872022-07-12 10:43:52 -050039 /* --------------------------------------------------------
40 * Place the data prefetcher in the most conservative mode
41 * to reduce prefetches by writing the following bits to
42 * the value indicated: ecltr[7:6], PF_MODE = 2'b11
43 * --------------------------------------------------------
44 */
Govindraj Rajaf37b2872023-06-15 11:57:16 -050045 sysreg_bit_set CORTEX_A78C_CPUECTLR_EL1, (CORTEX_A78C_CPUECTLR_EL1_BIT_6 | CORTEX_A78C_CPUECTLR_EL1_BIT_7)
Govindraj Raja20a92952023-06-15 11:47:33 -050046workaround_reset_end cortex_a78c, ERRATUM(2132064)
laurenw-arm4dc18872022-07-12 10:43:52 -050047
Govindraj Raja20a92952023-06-15 11:47:33 -050048check_erratum_range cortex_a78c, ERRATUM(2132064), CPU_REV(0, 1), CPU_REV(0, 2)
laurenw-arm4dc18872022-07-12 10:43:52 -050049
Govindraj Raja20a92952023-06-15 11:47:33 -050050workaround_reset_start cortex_a78c, ERRATUM(2242638), ERRATA_A78C_2242638
Bipin Ravi9c36e122022-07-15 17:20:16 -050051 ldr x0, =0x5
52 msr CORTEX_A78C_IMP_CPUPSELR_EL3, x0
53 ldr x0, =0x10F600E000
54 msr CORTEX_A78C_IMP_CPUPOR_EL3, x0
55 ldr x0, =0x10FF80E000
56 msr CORTEX_A78C_IMP_CPUPMR_EL3, x0
57 ldr x0, =0x80000000003FF
58 msr CORTEX_A78C_IMP_CPUPCR_EL3, x0
Govindraj Raja20a92952023-06-15 11:47:33 -050059workaround_reset_end cortex_a78c, ERRATUM(2242638)
Bipin Ravi9c36e122022-07-15 17:20:16 -050060
Govindraj Raja20a92952023-06-15 11:47:33 -050061check_erratum_range cortex_a78c, ERRATUM(2242638), CPU_REV(0, 1), CPU_REV(0, 2)
Bipin Ravi9c36e122022-07-15 17:20:16 -050062
Govindraj Raja20a92952023-06-15 11:47:33 -050063workaround_reset_start cortex_a78c, ERRATUM(2376749), ERRATA_A78C_2376749
Govindraj Rajaf37b2872023-06-15 11:57:16 -050064 sysreg_bit_set CORTEX_A78C_CPUACTLR2_EL1, CORTEX_A78C_CPUACTLR2_EL1_BIT_0
Govindraj Raja20a92952023-06-15 11:47:33 -050065workaround_reset_end cortex_a78c, ERRATUM(2376749)
Govindraj Rajaa4c473e2023-06-15 11:32:07 -050066
Govindraj Raja20a92952023-06-15 11:47:33 -050067check_erratum_range cortex_a78c, ERRATUM(2376749), CPU_REV(0, 1), CPU_REV(0, 2)
Govindraj Rajaa4c473e2023-06-15 11:32:07 -050068
Govindraj Raja20a92952023-06-15 11:47:33 -050069workaround_reset_start cortex_a78c, ERRATUM(2395411), ERRATA_A78C_2395411
Govindraj Rajaf37b2872023-06-15 11:57:16 -050070 sysreg_bit_set CORTEX_A78C_CPUACTLR2_EL1, CORTEX_A78C_CPUACTLR2_EL1_BIT_40
Govindraj Raja20a92952023-06-15 11:47:33 -050071workaround_reset_end cortex_a78c, ERRATUM(2395411)
Govindraj Rajaa4c473e2023-06-15 11:32:07 -050072
Govindraj Raja20a92952023-06-15 11:47:33 -050073check_erratum_range cortex_a78c, ERRATUM(2395411), CPU_REV(0, 1), CPU_REV(0, 2)
Govindraj Rajaa4c473e2023-06-15 11:32:07 -050074
Bipin Ravi8ca7aba2023-12-20 15:40:44 -060075workaround_reset_start cortex_a78c, ERRATUM(2683027), ERRATA_A78C_2683027
76 ldr x0, =0x3
77 msr CORTEX_A78C_IMP_CPUPSELR_EL3, x0
78 ldr x0, =0xEE010F10
79 msr CORTEX_A78C_IMP_CPUPOR_EL3, x0
80 ldr x0, =0xFF1F0FFE
81 msr CORTEX_A78C_IMP_CPUPMR_EL3, x0
82 ldr x0, =0x100000004003FF
83 msr CORTEX_A78C_IMP_CPUPCR_EL3, x0
84workaround_reset_end cortex_a78c, ERRATUM(2683027)
85
86check_erratum_range cortex_a78c, ERRATUM(2683027), CPU_REV(0, 1), CPU_REV(0, 2)
87
Sona Mathewdfde5042023-11-14 14:00:48 -060088workaround_reset_start cortex_a78c, ERRATUM(2743232), ERRATA_A78C_2743232
89 /* Set CPUACTLR5_EL1[56:55] to 2'b01 */
90 sysreg_bit_set CORTEX_A78C_ACTLR5_EL1, BIT(55)
91 sysreg_bit_clear CORTEX_A78C_ACTLR5_EL1, BIT(56)
92workaround_reset_end cortex_a78c, ERRATUM(2743232)
93
94check_erratum_range cortex_a78c, ERRATUM(2743232), CPU_REV(0, 1), CPU_REV(0, 2)
95
Govindraj Raja20a92952023-06-15 11:47:33 -050096workaround_runtime_start cortex_a78c, ERRATUM(2772121), ERRATA_A78C_2772121
Bipin Ravie0b52cc2023-01-18 11:03:21 -060097 /* dsb before isb of power down sequence */
98 dsb sy
Govindraj Raja20a92952023-06-15 11:47:33 -050099workaround_runtime_end cortex_a78c, ERRATUM(2772121)
Bipin Ravie0b52cc2023-01-18 11:03:21 -0600100
Govindraj Raja20a92952023-06-15 11:47:33 -0500101check_erratum_ls cortex_a78c, ERRATUM(2772121), CPU_REV(0, 2)
Bipin Ravidb091082023-02-28 16:21:51 -0600102
Govindraj Raja20a92952023-06-15 11:47:33 -0500103workaround_reset_start cortex_a78c, ERRATUM(2779484), ERRATA_A78C_2779484
Govindraj Rajaf37b2872023-06-15 11:57:16 -0500104 sysreg_bit_set CORTEX_A78C_ACTLR3_EL1, BIT(47)
Govindraj Raja20a92952023-06-15 11:47:33 -0500105workaround_reset_end cortex_a78c, ERRATUM(2779484)
Bipin Ravidb091082023-02-28 16:21:51 -0600106
Govindraj Raja20a92952023-06-15 11:47:33 -0500107check_erratum_range cortex_a78c, ERRATUM(2779484), CPU_REV(0, 1), CPU_REV(0, 2)
Bipin Ravibf205fc2023-03-14 10:04:23 -0500108
Govindraj Raja20a92952023-06-15 11:47:33 -0500109check_erratum_chosen cortex_a78c, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
Bipin Ravie49c7042023-03-14 11:03:24 -0500110
Govindraj Raja20a92952023-06-15 11:47:33 -0500111workaround_reset_start cortex_a78c, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
112#if IMAGE_BL31
Bipin Ravieb4d12b2022-03-12 01:58:02 -0600113 /*
114 * The Cortex-A78c generic vectors are overridden to apply errata
115 * mitigation on exception entry from lower ELs.
116 */
Govindraj Rajaf37b2872023-06-15 11:57:16 -0500117 override_vector_table wa_cve_vbar_cortex_a78c
Govindraj Raja20a92952023-06-15 11:47:33 -0500118#endif /* IMAGE_BL31 */
119workaround_reset_end cortex_a78c, CVE(2022, 23960)
laurenw-arm4dc18872022-07-12 10:43:52 -0500120
Govindraj Raja20a92952023-06-15 11:47:33 -0500121cpu_reset_func_start cortex_a78c
122cpu_reset_func_end cortex_a78c
123
124errata_report_shim cortex_a78c
Bipin Ravieb4d12b2022-03-12 01:58:02 -0600125
Bipin Ravi4da1b0b2021-03-16 15:20:58 -0500126 /* ----------------------------------------------------
127 * HW will do the cache maintenance while powering down
128 * ----------------------------------------------------
129 */
130func cortex_a78c_core_pwr_dwn
131 /* ---------------------------------------------------
132 * Enable CPU power down bit in power control register
133 * ---------------------------------------------------
134 */
Govindraj Rajaf37b2872023-06-15 11:57:16 -0500135 sysreg_bit_set CORTEX_A78C_CPUPWRCTLR_EL1, CORTEX_A78C_CPUPWRCTLR_EL1_CORE_PWRDN_EN_BIT
Govindraj Raja20a92952023-06-15 11:47:33 -0500136
137 apply_erratum cortex_a78c, ERRATUM(2772121), ERRATA_A78C_2772121
138
Bipin Ravi4da1b0b2021-03-16 15:20:58 -0500139 isb
140 ret
141endfunc cortex_a78c_core_pwr_dwn
142
Bipin Ravi4da1b0b2021-03-16 15:20:58 -0500143 /* ---------------------------------------------
144 * This function provides cortex_a78c specific
145 * register information for crash reporting.
146 * It needs to return with x6 pointing to
147 * a list of register names in ascii and
148 * x8 - x15 having values of registers to be
149 * reported.
150 * ---------------------------------------------
151 */
152.section .rodata.cortex_a78c_regs, "aS"
153cortex_a78c_regs: /* The ascii list of register names to be reported */
154 .asciz "cpuectlr_el1", ""
155
156func cortex_a78c_cpu_reg_dump
157 adr x6, cortex_a78c_regs
158 mrs x8, CORTEX_A78C_CPUECTLR_EL1
159 ret
160endfunc cortex_a78c_cpu_reg_dump
161
162declare_cpu_ops cortex_a78c, CORTEX_A78C_MIDR, \
Bipin Ravieb4d12b2022-03-12 01:58:02 -0600163 cortex_a78c_reset_func, \
Bipin Ravi4da1b0b2021-03-16 15:20:58 -0500164 cortex_a78c_core_pwr_dwn