xref: /rk3399_ARM-atf/lib/cpus/aarch64/cortex_x925.S (revision e9db137a7f5fa48a6034bcd9054e7656f73b6ed4)
1/*
2 * Copyright (c) 2023-2025, Arm Limited. All rights reserved.
3 *
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_x925.h>
11#include <cpu_macros.S>
12#include <dsu_macros.S>
13#include <plat_macros.S>
14
15/* Hardware handled coherency */
16#if HW_ASSISTED_COHERENCY == 0
17#error "Cortex-X925 must be compiled with HW_ASSISTED_COHERENCY enabled"
18#endif
19
20/* 64-bit only core */
21#if CTX_INCLUDE_AARCH32_REGS == 1
22#error "Cortex-X925 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
23#endif
24
25cpu_reset_prologue cortex_x925
26
27workaround_reset_start cortex_x925, ERRATUM(2900952), ERRATA_DSU_2900952
28	errata_dsu_2900952_wa_apply
29workaround_reset_end cortex_x925, ERRATUM(2900952)
30
31check_erratum_custom_start cortex_x925, ERRATUM(2900952)
32	check_errata_dsu_2900952_applies
33	ret
34check_erratum_custom_end cortex_x925, ERRATUM(2900952)
35
36add_erratum_entry cortex_x925, ERRATUM(3701747), ERRATA_X925_3701747
37
38.global check_erratum_cortex_x925_3701747
39check_erratum_ls cortex_x925, ERRATUM(3701747), CPU_REV(0, 1)
40
41workaround_reset_start cortex_x925, ERRATUM(2963999), ERRATA_X925_2963999
42	/* Add ISB before MRS reads of MPIDR_EL1/MIDR_EL1 */
43	ldr x0, =0x0
44	msr S3_6_c15_c8_0, x0 	/* msr CPUPSELR_EL3, X0 */
45	ldr x0, =0xd5380000
46	msr S3_6_c15_c8_2, x0 	/* msr CPUPOR_EL3, X0 */
47	ldr x0, =0xFFFFFF40
48	msr S3_6_c15_c8_3,x0 	/* msr CPUPMR_EL3, X0 */
49	ldr x0, =0x000080010033f
50	msr S3_6_c15_c8_1, x0	/* msr CPUPCR_EL3, X0 */
51	isb
52workaround_reset_end cortex_x925, ERRATUM(2963999)
53
54check_erratum_ls cortex_x925, ERRATUM(2963999), CPU_REV(0, 0)
55
56/* Disable hardware page aggregation. Enables mitigation for `CVE-2024-5660` */
57workaround_reset_start cortex_x925, CVE(2024, 5660), WORKAROUND_CVE_2024_5660
58	sysreg_bit_set CORTEX_X925_CPUECTLR_EL1, BIT(46)
59workaround_reset_end cortex_x925, CVE(2024, 5660)
60
61check_erratum_ls cortex_x925, CVE(2024, 5660), CPU_REV(0, 1)
62
63	/* ----------------------------------------------------------------
64	 * CVE-2024-7881 is mitigated for Cortex-X925 using erratum 3692980
65	 * workaround by disabling the affected prefetcher setting
66	 * CPUACTLR6_EL1[41].
67	 * ----------------------------------------------------------------
68	 */
69workaround_reset_start cortex_x925, CVE(2024, 7881), WORKAROUND_CVE_2024_7881
70	sysreg_bit_set CORTEX_X925_CPUACTLR6_EL1, BIT(41)
71workaround_reset_end cortex_x925, CVE(2024, 7881)
72
73check_erratum_ls cortex_x925, CVE(2024, 7881), CPU_REV(0, 1)
74
75cpu_reset_func_start cortex_x925
76	/* Disable speculative loads */
77	msr	SSBS, xzr
78	enable_mpmm
79cpu_reset_func_end cortex_x925
80
81	/* ----------------------------------------------------
82	 * HW will do the cache maintenance while powering down
83	 * ----------------------------------------------------
84	 */
85func cortex_x925_core_pwr_dwn
86	/* ---------------------------------------------------
87	 * Enable CPU power down bit in power control register
88	 * ---------------------------------------------------
89	 */
90	sysreg_bit_set CORTEX_X925_CPUPWRCTLR_EL1, CORTEX_X925_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
91	isb
92	ret
93endfunc cortex_x925_core_pwr_dwn
94
95	/* ---------------------------------------------
96	 * This function provides Cortex-X925 specific
97	 * register information for crash reporting.
98	 * It needs to return with x6 pointing to
99	 * a list of register names in ascii and
100	 * x8 - x15 having values of registers to be
101	 * reported.
102	 * ---------------------------------------------
103	 */
104.section .rodata.cortex_x925_regs, "aS"
105cortex_x925_regs:  /* The ascii list of register names to be reported */
106	.asciz	"cpuectlr_el1", ""
107
108func cortex_x925_cpu_reg_dump
109	adr	x6, cortex_x925_regs
110	mrs	x8, CORTEX_X925_CPUECTLR_EL1
111	ret
112endfunc cortex_x925_cpu_reg_dump
113
114declare_cpu_ops cortex_x925, CORTEX_X925_MIDR, \
115	cortex_x925_reset_func, \
116	cortex_x925_core_pwr_dwn
117