31a22a469b532776a58912be498ca2a2d8b48fd1
[project/bcm63xx/atf.git] / plat / rpi3 / rpi3_topology.c
1 /*
2 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <arch.h>
8 #include <platform_def.h>
9 #include <stdint.h>
10
11 #include "rpi3_private.h"
12
13 /* The power domain tree descriptor */
14 static unsigned char power_domain_tree_desc[] = {
15 /* Number of root nodes */
16 PLATFORM_CLUSTER_COUNT,
17 /* Number of children for the first node */
18 PLATFORM_CLUSTER0_CORE_COUNT,
19 };
20
21 /*******************************************************************************
22 * This function returns the ARM default topology tree information.
23 ******************************************************************************/
24 const unsigned char *plat_get_power_domain_tree_desc(void)
25 {
26 return power_domain_tree_desc;
27 }
28
29 /*******************************************************************************
30 * This function implements a part of the critical interface between the psci
31 * generic layer and the platform that allows the former to query the platform
32 * to convert an MPIDR to a unique linear index. An error code (-1) is returned
33 * in case the MPIDR is invalid.
34 ******************************************************************************/
35 int plat_core_pos_by_mpidr(u_register_t mpidr)
36 {
37 unsigned int cluster_id, cpu_id;
38
39 mpidr &= MPIDR_AFFINITY_MASK;
40 if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) {
41 return -1;
42 }
43
44 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
45 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
46
47 if (cluster_id >= PLATFORM_CLUSTER_COUNT) {
48 return -1;
49 }
50
51 if (cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER) {
52 return -1;
53 }
54
55 return plat_rpi3_calc_core_pos(mpidr);
56 }