xref: /optee_os/core/arch/arm/plat-automotive_rd/rd1ae_core_pos.S (revision 4936f055618d2a6a57ad6be12d557f2fb47a6e88)
1/* SPDX-License-Identifier: BSD-2-Clause */
2/*
3 * Copyright (c) 2024 - 2025, Arm Limited
4 */
5
6#include <asm.S>
7#include <arm.h>
8#include "platform_config.h"
9
10FUNC get_core_pos_mpidr , :
11        mov     x4, x0
12
13        /*
14         * The MT bit in MPIDR is always set and the
15         * affinity level 0 corresponds to thread affinity level.
16         */
17
18        /* Extract individual affinity fields from MPIDR */
19        ubfx    x0, x4, #MPIDR_AFF0_SHIFT, #MPIDR_AFFINITY_BITS
20        ubfx    x1, x4, #MPIDR_AFF1_SHIFT, #MPIDR_AFFINITY_BITS
21        ubfx    x2, x4, #MPIDR_AFF2_SHIFT, #MPIDR_AFFINITY_BITS
22        ubfx    x3, x4, #MPIDR_AFF3_SHIFT, #MPIDR_AFFINITY_BITS
23
24        /* Compute linear position */
25        mov     x4, #RD1AE_MAX_CLUSTERS_PER_CHIP
26        madd    x2, x3, x4, x2
27        mov     x4, #RD1AE_MAX_CPUS_PER_CLUSTER
28        madd    x1, x2, x4, x1
29        mov     x4, #RD1AE_MAX_PE_PER_CPU
30        madd    x0, x1, x4, x0
31        ret
32END_FUNC get_core_pos_mpidr
33