xref: /rk3399_ARM-atf/lib/extensions/cpa2/cpa2.c (revision 156943e1e1605096fe43daf8803d6388197fe08f)
1*a1032bebSJohn Powell /*
2*a1032bebSJohn Powell  * Copyright (c) 2025, Arm Limited. All rights reserved.
3*a1032bebSJohn Powell  *
4*a1032bebSJohn Powell  * SPDX-License-Identifier: BSD-3-Clause
5*a1032bebSJohn Powell  */
6*a1032bebSJohn Powell 
7*a1032bebSJohn Powell #include <arch.h>
8*a1032bebSJohn Powell #include <arch_features.h>
9*a1032bebSJohn Powell 
10*a1032bebSJohn Powell /*
11*a1032bebSJohn Powell  * Check that the platform virtual address is less than or equal to 54 bits, if
12*a1032bebSJohn Powell  * not then CPA will corrupt the addresses.
13*a1032bebSJohn Powell  */
14*a1032bebSJohn Powell #if PLAT_VIRT_ADDR_SPACE_SIZE >= (1 << 54)
15*a1032bebSJohn Powell #error "FEAT_CPA2 can only be enabled with VA <= 54 bits! See Arm ARM rule IQDPCR."
16*a1032bebSJohn Powell #endif
17*a1032bebSJohn Powell 
cpa2_enable_el3(void)18*a1032bebSJohn Powell void cpa2_enable_el3(void)
19*a1032bebSJohn Powell {
20*a1032bebSJohn Powell 	write_sctlr2_el3(read_sctlr2_el3() | SCTLR2_CPTA_BIT |
21*a1032bebSJohn Powell 			 SCTLR2_CPTM_BIT);
22*a1032bebSJohn Powell }
23