blob: 35b293f3549f32609f7283d719fa3fd2f4af7aa6 [file] [log] [blame]
Rex-BC Chen749b2112021-09-28 11:24:09 +08001/*
2 * Copyright (c) 2021, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <platform_def.h>
10
11 .globl plat_is_my_cpu_primary
12 .globl plat_my_core_pos
13 .globl plat_mediatek_calc_core_pos
14
15func plat_is_my_cpu_primary
16 mrs x0, mpidr_el1
17 and x0, x0, #(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)
18 cmp x0, #PLAT_PRIMARY_CPU
19 cset x0, eq
20 ret
21endfunc plat_is_my_cpu_primary
22
23 /* -----------------------------------------------------
24 * unsigned int plat_my_core_pos(void)
25 * This function uses the plat_mediatek_calc_core_pos()
26 * definition to get the index of the calling CPU.
27 * -----------------------------------------------------
28 */
29func plat_my_core_pos
30 mrs x0, mpidr_el1
31 b plat_mediatek_calc_core_pos
32endfunc plat_my_core_pos
33
34 /* -----------------------------------------------------
35 * unsigned int plat_mediatek_calc_core_pos(u_register_t mpidr);
36 *
37 * With this function: CorePos = CoreID (AFF1)
38 * we do it with x0 = (x0 >> 8) & 0xff
39 * -----------------------------------------------------
40 */
41func plat_mediatek_calc_core_pos
42 mov x1, #MPIDR_AFFLVL_MASK
43 and x0, x1, x0, lsr #MPIDR_AFF1_SHIFT
44 ret
45endfunc plat_mediatek_calc_core_pos