Makefile: remove extra include paths in INCLUDES
[project/bcm63xx/atf.git] / plat / nvidia / tegra / common / tegra_topology.c
1 /*
2 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <platform_def.h>
8
9 #include <arch.h>
10 #include <lib/psci/psci.h>
11 #include <plat/common/platform.h>
12
13 #pragma weak plat_core_pos_by_mpidr
14
15 /*******************************************************************************
16 * This function implements a part of the critical interface between the psci
17 * generic layer and the platform that allows the former to query the platform
18 * to convert an MPIDR to a unique linear index. An error code (-1) is returned
19 * in case the MPIDR is invalid.
20 ******************************************************************************/
21 int32_t plat_core_pos_by_mpidr(u_register_t mpidr)
22 {
23 u_register_t cluster_id, cpu_id;
24 int32_t result;
25
26 cluster_id = (mpidr >> (u_register_t)MPIDR_AFF1_SHIFT) &
27 (u_register_t)MPIDR_AFFLVL_MASK;
28 cpu_id = (mpidr >> (u_register_t)MPIDR_AFF0_SHIFT) &
29 (u_register_t)MPIDR_AFFLVL_MASK;
30
31 /* CorePos = CoreId + (ClusterId * cpus per cluster) */
32 result = (int32_t)cpu_id + ((int32_t)cluster_id *
33 PLATFORM_MAX_CPUS_PER_CLUSTER);
34
35 if (cluster_id >= (u_register_t)PLATFORM_CLUSTER_COUNT) {
36 result = PSCI_E_NOT_PRESENT;
37 }
38
39 /*
40 * Validate cpu_id by checking whether it represents a CPU in
41 * one of the two clusters present on the platform.
42 */
43 if (cpu_id >= (u_register_t)PLATFORM_MAX_CPUS_PER_CLUSTER) {
44 result = PSCI_E_NOT_PRESENT;
45 }
46
47 return result;
48 }