xref: /arm-trusted-firmware/lib/cpus/aarch64/cortex_a78c.S (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu/*
2*91f16700Schasinglulu * Copyright (c) 2021-2023, Arm Limited. All rights reserved.
3*91f16700Schasinglulu *
4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause
5*91f16700Schasinglulu */
6*91f16700Schasinglulu
7*91f16700Schasinglulu#include <arch.h>
8*91f16700Schasinglulu#include <asm_macros.S>
9*91f16700Schasinglulu#include <common/bl_common.h>
10*91f16700Schasinglulu#include <cortex_a78c.h>
11*91f16700Schasinglulu#include <cpu_macros.S>
12*91f16700Schasinglulu#include <plat_macros.S>
13*91f16700Schasinglulu#include "wa_cve_2022_23960_bhb_vector.S"
14*91f16700Schasinglulu
15*91f16700Schasinglulu/* Hardware handled coherency */
16*91f16700Schasinglulu#if HW_ASSISTED_COHERENCY == 0
17*91f16700Schasinglulu#error "cortex_a78c must be compiled with HW_ASSISTED_COHERENCY enabled"
18*91f16700Schasinglulu#endif
19*91f16700Schasinglulu
20*91f16700Schasinglulu#if WORKAROUND_CVE_2022_23960
21*91f16700Schasinglulu	wa_cve_2022_23960_bhb_vector_table CORTEX_A78C_BHB_LOOP_COUNT, cortex_a78c
22*91f16700Schasinglulu#endif /* WORKAROUND_CVE_2022_23960 */
23*91f16700Schasinglulu
24*91f16700Schasingluluworkaround_reset_start cortex_a78c, ERRATUM(1827430), ERRATA_A78C_1827430
25*91f16700Schasinglulu	/* Disable allocation of splintered pages in the L2 TLB */
26*91f16700Schasinglulu	sysreg_bit_set CORTEX_A78C_CPUECTLR_EL1, CORTEX_A78C_CPUECTLR_EL1_MM_ASP_EN
27*91f16700Schasingluluworkaround_reset_end cortex_a78c, ERRATUM(1827430)
28*91f16700Schasinglulu
29*91f16700Schasinglulucheck_erratum_ls cortex_a78c, ERRATUM(1827430), CPU_REV(0, 0)
30*91f16700Schasinglulu
31*91f16700Schasingluluworkaround_reset_start cortex_a78c, ERRATUM(1827440), ERRATA_A78C_1827440
32*91f16700Schasinglulu	/* Force Atomic Store to WB memory be done in L1 data cache */
33*91f16700Schasinglulu	sysreg_bit_set CORTEX_A78C_CPUACTLR2_EL1, BIT(2)
34*91f16700Schasingluluworkaround_reset_end cortex_a78c, ERRATUM(1827440)
35*91f16700Schasinglulu
36*91f16700Schasinglulucheck_erratum_ls cortex_a78c, ERRATUM(1827440), CPU_REV(0, 0)
37*91f16700Schasinglulu
38*91f16700Schasingluluworkaround_reset_start cortex_a78c, ERRATUM(2132064), ERRATA_A78C_2132064
39*91f16700Schasinglulu	/* --------------------------------------------------------
40*91f16700Schasinglulu	 * Place the data prefetcher in the most conservative mode
41*91f16700Schasinglulu	 * to reduce prefetches by writing the following bits to
42*91f16700Schasinglulu	 * the value indicated: ecltr[7:6], PF_MODE = 2'b11
43*91f16700Schasinglulu	 * --------------------------------------------------------
44*91f16700Schasinglulu	 */
45*91f16700Schasinglulu	sysreg_bit_set CORTEX_A78C_CPUECTLR_EL1, (CORTEX_A78C_CPUECTLR_EL1_BIT_6 | CORTEX_A78C_CPUECTLR_EL1_BIT_7)
46*91f16700Schasingluluworkaround_reset_end cortex_a78c, ERRATUM(2132064)
47*91f16700Schasinglulu
48*91f16700Schasinglulucheck_erratum_range cortex_a78c, ERRATUM(2132064), CPU_REV(0, 1), CPU_REV(0, 2)
49*91f16700Schasinglulu
50*91f16700Schasingluluworkaround_reset_start cortex_a78c, ERRATUM(2242638), ERRATA_A78C_2242638
51*91f16700Schasinglulu	ldr	x0, =0x5
52*91f16700Schasinglulu	msr	CORTEX_A78C_IMP_CPUPSELR_EL3, x0
53*91f16700Schasinglulu	ldr	x0, =0x10F600E000
54*91f16700Schasinglulu	msr	CORTEX_A78C_IMP_CPUPOR_EL3, x0
55*91f16700Schasinglulu	ldr	x0, =0x10FF80E000
56*91f16700Schasinglulu	msr	CORTEX_A78C_IMP_CPUPMR_EL3, x0
57*91f16700Schasinglulu	ldr	x0, =0x80000000003FF
58*91f16700Schasinglulu	msr	CORTEX_A78C_IMP_CPUPCR_EL3, x0
59*91f16700Schasingluluworkaround_reset_end cortex_a78c, ERRATUM(2242638)
60*91f16700Schasinglulu
61*91f16700Schasinglulucheck_erratum_range cortex_a78c, ERRATUM(2242638), CPU_REV(0, 1), CPU_REV(0, 2)
62*91f16700Schasinglulu
63*91f16700Schasingluluworkaround_reset_start cortex_a78c, ERRATUM(2376749), ERRATA_A78C_2376749
64*91f16700Schasinglulu	sysreg_bit_set CORTEX_A78C_CPUACTLR2_EL1, CORTEX_A78C_CPUACTLR2_EL1_BIT_0
65*91f16700Schasingluluworkaround_reset_end cortex_a78c, ERRATUM(2376749)
66*91f16700Schasinglulu
67*91f16700Schasinglulucheck_erratum_range cortex_a78c, ERRATUM(2376749), CPU_REV(0, 1), CPU_REV(0, 2)
68*91f16700Schasinglulu
69*91f16700Schasingluluworkaround_reset_start cortex_a78c, ERRATUM(2395411), ERRATA_A78C_2395411
70*91f16700Schasinglulu	sysreg_bit_set CORTEX_A78C_CPUACTLR2_EL1, CORTEX_A78C_CPUACTLR2_EL1_BIT_40
71*91f16700Schasingluluworkaround_reset_end cortex_a78c, ERRATUM(2395411)
72*91f16700Schasinglulu
73*91f16700Schasinglulucheck_erratum_range cortex_a78c, ERRATUM(2395411), CPU_REV(0, 1), CPU_REV(0, 2)
74*91f16700Schasinglulu
75*91f16700Schasingluluworkaround_runtime_start cortex_a78c, ERRATUM(2772121), ERRATA_A78C_2772121
76*91f16700Schasinglulu	/* dsb before isb of power down sequence */
77*91f16700Schasinglulu	dsb	sy
78*91f16700Schasingluluworkaround_runtime_end cortex_a78c, ERRATUM(2772121)
79*91f16700Schasinglulu
80*91f16700Schasinglulucheck_erratum_ls cortex_a78c, ERRATUM(2772121), CPU_REV(0, 2)
81*91f16700Schasinglulu
82*91f16700Schasingluluworkaround_reset_start cortex_a78c, ERRATUM(2779484), ERRATA_A78C_2779484
83*91f16700Schasinglulu	sysreg_bit_set CORTEX_A78C_ACTLR3_EL1, BIT(47)
84*91f16700Schasingluluworkaround_reset_end cortex_a78c, ERRATUM(2779484)
85*91f16700Schasinglulu
86*91f16700Schasinglulucheck_erratum_range cortex_a78c, ERRATUM(2779484), CPU_REV(0, 1), CPU_REV(0, 2)
87*91f16700Schasinglulu
88*91f16700Schasinglulucheck_erratum_chosen cortex_a78c, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
89*91f16700Schasinglulu
90*91f16700Schasingluluworkaround_reset_start cortex_a78c, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
91*91f16700Schasinglulu#if IMAGE_BL31
92*91f16700Schasinglulu	/*
93*91f16700Schasinglulu	 * The Cortex-A78c generic vectors are overridden to apply errata
94*91f16700Schasinglulu	 * mitigation on exception entry from lower ELs.
95*91f16700Schasinglulu	 */
96*91f16700Schasinglulu	override_vector_table wa_cve_vbar_cortex_a78c
97*91f16700Schasinglulu#endif /* IMAGE_BL31 */
98*91f16700Schasingluluworkaround_reset_end cortex_a78c, CVE(2022, 23960)
99*91f16700Schasinglulu
100*91f16700Schasinglulucpu_reset_func_start cortex_a78c
101*91f16700Schasinglulucpu_reset_func_end cortex_a78c
102*91f16700Schasinglulu
103*91f16700Schasingluluerrata_report_shim cortex_a78c
104*91f16700Schasinglulu
105*91f16700Schasinglulu	/* ----------------------------------------------------
106*91f16700Schasinglulu	 * HW will do the cache maintenance while powering down
107*91f16700Schasinglulu	 * ----------------------------------------------------
108*91f16700Schasinglulu	 */
109*91f16700Schasinglulufunc cortex_a78c_core_pwr_dwn
110*91f16700Schasinglulu	/* ---------------------------------------------------
111*91f16700Schasinglulu	 * Enable CPU power down bit in power control register
112*91f16700Schasinglulu	 * ---------------------------------------------------
113*91f16700Schasinglulu	 */
114*91f16700Schasinglulu	sysreg_bit_set CORTEX_A78C_CPUPWRCTLR_EL1, CORTEX_A78C_CPUPWRCTLR_EL1_CORE_PWRDN_EN_BIT
115*91f16700Schasinglulu
116*91f16700Schasinglulu	apply_erratum cortex_a78c, ERRATUM(2772121), ERRATA_A78C_2772121
117*91f16700Schasinglulu
118*91f16700Schasinglulu	isb
119*91f16700Schasinglulu	ret
120*91f16700Schasingluluendfunc cortex_a78c_core_pwr_dwn
121*91f16700Schasinglulu
122*91f16700Schasinglulu	/* ---------------------------------------------
123*91f16700Schasinglulu	 * This function provides cortex_a78c specific
124*91f16700Schasinglulu	 * register information for crash reporting.
125*91f16700Schasinglulu	 * It needs to return with x6 pointing to
126*91f16700Schasinglulu	 * a list of register names in ascii and
127*91f16700Schasinglulu	 * x8 - x15 having values of registers to be
128*91f16700Schasinglulu	 * reported.
129*91f16700Schasinglulu	 * ---------------------------------------------
130*91f16700Schasinglulu	 */
131*91f16700Schasinglulu.section .rodata.cortex_a78c_regs, "aS"
132*91f16700Schasinglulucortex_a78c_regs:  /* The ascii list of register names to be reported */
133*91f16700Schasinglulu	.asciz	"cpuectlr_el1", ""
134*91f16700Schasinglulu
135*91f16700Schasinglulufunc cortex_a78c_cpu_reg_dump
136*91f16700Schasinglulu	adr	x6, cortex_a78c_regs
137*91f16700Schasinglulu	mrs	x8, CORTEX_A78C_CPUECTLR_EL1
138*91f16700Schasinglulu	ret
139*91f16700Schasingluluendfunc cortex_a78c_cpu_reg_dump
140*91f16700Schasinglulu
141*91f16700Schasingluludeclare_cpu_ops cortex_a78c, CORTEX_A78C_MIDR, \
142*91f16700Schasinglulu	cortex_a78c_reset_func, \
143*91f16700Schasinglulu	cortex_a78c_core_pwr_dwn
144