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