xref: /rk3399_ARM-atf/include/common/par.h (revision 8936321932b2aa840abbdb2fa1374d0efb406328)
1*30655136SGovindraj Raja /*
2*30655136SGovindraj Raja  * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
3*30655136SGovindraj Raja  *
4*30655136SGovindraj Raja  * SPDX-License-Identifier: BSD-3-Clause
5*30655136SGovindraj Raja  */
6*30655136SGovindraj Raja 
7*30655136SGovindraj Raja #ifndef PAR_H
8*30655136SGovindraj Raja #define PAR_H
9*30655136SGovindraj Raja 
10*30655136SGovindraj Raja #include<arch_features.h>
11*30655136SGovindraj Raja #include<lib/extensions/sysreg128.h>
12*30655136SGovindraj Raja 
get_par_el1_pa(sysreg_t par)13*30655136SGovindraj Raja static inline uint64_t get_par_el1_pa(sysreg_t par)
14*30655136SGovindraj Raja {
15*30655136SGovindraj Raja 	uint64_t pa = par & UINT64_MAX;
16*30655136SGovindraj Raja 	/* PA, bits [51:12] is Output address */
17*30655136SGovindraj Raja 	uint64_t mask = PAR_ADDR_MASK;
18*30655136SGovindraj Raja 
19*30655136SGovindraj Raja #if ENABLE_FEAT_D128
20*30655136SGovindraj Raja 	/* If D128 is in use, the PA is in the upper 64-bit word of PAR_EL1 */
21*30655136SGovindraj Raja 	if (is_feat_d128_supported() && (par & PAR_EL1_D128)) {
22*30655136SGovindraj Raja 		pa = (par >> 64) & UINT64_MAX;
23*30655136SGovindraj Raja 		/* PA, bits [55:12] is Output address */
24*30655136SGovindraj Raja 		mask = PAR_D128_ADDR_MASK;
25*30655136SGovindraj Raja 	}
26*30655136SGovindraj Raja #endif
27*30655136SGovindraj Raja 	return pa & mask;
28*30655136SGovindraj Raja }
29*30655136SGovindraj Raja 
30*30655136SGovindraj Raja #endif /* PAR_H */
31