blob: d19c69386e92b711f24d8741c48f595b67e78f18 [file] [log] [blame]
Bipin Ravi4da1b0b2021-03-16 15:20:58 -05001/*
Bipin Ravie0b52cc2023-01-18 11:03:21 -06002 * Copyright (c) 2021-2023, 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
Govindraj Raja20a92952023-06-15 11:47:33 -050075workaround_runtime_start cortex_a78c, ERRATUM(2772121), ERRATA_A78C_2772121
Bipin Ravie0b52cc2023-01-18 11:03:21 -060076 /* dsb before isb of power down sequence */
77 dsb sy
Govindraj Raja20a92952023-06-15 11:47:33 -050078workaround_runtime_end cortex_a78c, ERRATUM(2772121)
Bipin Ravie0b52cc2023-01-18 11:03:21 -060079
Govindraj Raja20a92952023-06-15 11:47:33 -050080check_erratum_ls cortex_a78c, ERRATUM(2772121), CPU_REV(0, 2)
Bipin Ravidb091082023-02-28 16:21:51 -060081
Govindraj Raja20a92952023-06-15 11:47:33 -050082workaround_reset_start cortex_a78c, ERRATUM(2779484), ERRATA_A78C_2779484
Govindraj Rajaf37b2872023-06-15 11:57:16 -050083 sysreg_bit_set CORTEX_A78C_ACTLR3_EL1, BIT(47)
Govindraj Raja20a92952023-06-15 11:47:33 -050084workaround_reset_end cortex_a78c, ERRATUM(2779484)
Bipin Ravidb091082023-02-28 16:21:51 -060085
Govindraj Raja20a92952023-06-15 11:47:33 -050086check_erratum_range cortex_a78c, ERRATUM(2779484), CPU_REV(0, 1), CPU_REV(0, 2)
Bipin Ravibf205fc2023-03-14 10:04:23 -050087
Govindraj Raja20a92952023-06-15 11:47:33 -050088check_erratum_chosen cortex_a78c, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
Bipin Ravie49c7042023-03-14 11:03:24 -050089
Govindraj Raja20a92952023-06-15 11:47:33 -050090workaround_reset_start cortex_a78c, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
91#if IMAGE_BL31
Bipin Ravieb4d12b2022-03-12 01:58:02 -060092 /*
93 * The Cortex-A78c generic vectors are overridden to apply errata
94 * mitigation on exception entry from lower ELs.
95 */
Govindraj Rajaf37b2872023-06-15 11:57:16 -050096 override_vector_table wa_cve_vbar_cortex_a78c
Govindraj Raja20a92952023-06-15 11:47:33 -050097#endif /* IMAGE_BL31 */
98workaround_reset_end cortex_a78c, CVE(2022, 23960)
laurenw-arm4dc18872022-07-12 10:43:52 -050099
Govindraj Raja20a92952023-06-15 11:47:33 -0500100cpu_reset_func_start cortex_a78c
101cpu_reset_func_end cortex_a78c
102
103errata_report_shim cortex_a78c
Bipin Ravieb4d12b2022-03-12 01:58:02 -0600104
Bipin Ravi4da1b0b2021-03-16 15:20:58 -0500105 /* ----------------------------------------------------
106 * HW will do the cache maintenance while powering down
107 * ----------------------------------------------------
108 */
109func cortex_a78c_core_pwr_dwn
110 /* ---------------------------------------------------
111 * Enable CPU power down bit in power control register
112 * ---------------------------------------------------
113 */
Govindraj Rajaf37b2872023-06-15 11:57:16 -0500114 sysreg_bit_set CORTEX_A78C_CPUPWRCTLR_EL1, CORTEX_A78C_CPUPWRCTLR_EL1_CORE_PWRDN_EN_BIT
Govindraj Raja20a92952023-06-15 11:47:33 -0500115
116 apply_erratum cortex_a78c, ERRATUM(2772121), ERRATA_A78C_2772121
117
Bipin Ravi4da1b0b2021-03-16 15:20:58 -0500118 isb
119 ret
120endfunc cortex_a78c_core_pwr_dwn
121
Bipin Ravi4da1b0b2021-03-16 15:20:58 -0500122 /* ---------------------------------------------
123 * This function provides cortex_a78c specific
124 * register information for crash reporting.
125 * It needs to return with x6 pointing to
126 * a list of register names in ascii and
127 * x8 - x15 having values of registers to be
128 * reported.
129 * ---------------------------------------------
130 */
131.section .rodata.cortex_a78c_regs, "aS"
132cortex_a78c_regs: /* The ascii list of register names to be reported */
133 .asciz "cpuectlr_el1", ""
134
135func cortex_a78c_cpu_reg_dump
136 adr x6, cortex_a78c_regs
137 mrs x8, CORTEX_A78C_CPUECTLR_EL1
138 ret
139endfunc cortex_a78c_cpu_reg_dump
140
141declare_cpu_ops cortex_a78c, CORTEX_A78C_MIDR, \
Bipin Ravieb4d12b2022-03-12 01:58:02 -0600142 cortex_a78c_reset_func, \
Bipin Ravi4da1b0b2021-03-16 15:20:58 -0500143 cortex_a78c_core_pwr_dwn