xref: /rk3399_ARM-atf/plat/imx/imx9/common/aarch64/plat_helpers.S (revision c42aefd3eb1b5888ee6f3d1f8645b62ec850cdcc)
1/*
2 * Copyright 2022-2025 NXP.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <asm_macros.S>
8#include <cortex_a55.h>
9
10#include <platform_def.h>
11
12	.globl	plat_is_my_cpu_primary
13	.globl	plat_my_core_pos
14	.globl	plat_calc_core_pos
15	.globl	plat_arm_calc_core_pos
16	.globl	platform_mem_init
17
18	/* ----------------------------------------------
19	 * unsigned int plat_is_my_cpu_primary(void);
20	 * This function checks if this is the primary CPU
21	 * ----------------------------------------------
22	 */
23func plat_is_my_cpu_primary
24	mrs	x0, mpidr_el1
25	mov_imm x1, MPIDR_AFFINITY_MASK
26	and	x0, x0, x1
27	cmp	x0, #PLAT_PRIMARY_CPU
28	cset	x0, eq
29	ret
30endfunc plat_is_my_cpu_primary
31
32	/* ----------------------------------------------
33	 * unsigned int plat_my_core_pos(void)
34	 * This Function uses the plat_calc_core_pos()
35	 * to get the index of the calling CPU.
36	 * ----------------------------------------------
37	 */
38func plat_my_core_pos
39	mrs	x0, mpidr_el1
40	mov	x1, #MPIDR_AFFLVL_MASK
41	and	x0, x1, x0, lsr #MPIDR_AFF1_SHIFT
42	ret
43endfunc plat_my_core_pos
44
45	/*
46	 * unsigned int plat_calc_core_pos(uint64_t mpidr)
47	 * helper function to calculate the core position.
48	 * With this function.
49	 */
50func plat_calc_core_pos
51	mov	x1, #MPIDR_AFFLVL_MASK
52	and	x0, x1, x0, lsr #MPIDR_AFF1_SHIFT
53	ret
54endfunc plat_calc_core_pos
55
56func plat_arm_calc_core_pos
57	b	plat_core_pos_by_mpidr
58endfunc plat_arm_calc_core_pos
59
60func platform_mem_init
61	ret
62endfunc platform_mem_init
63