blob: 0a04c1105d13dca635da6fb071afec9bee3a1ff5 [file] [log] [blame]
Antonio Nino Diaz7298c1f2018-12-05 00:09:30 +00001/*
Carlo Caionee5a30db2019-08-24 17:31:51 +01002 * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
Antonio Nino Diaz7298c1f2018-12-05 00:09:30 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <platform_def.h>
9#include <stdint.h>
10
Carlo Caionee5a30db2019-08-24 17:31:51 +010011#include "aml_private.h"
Antonio Nino Diaz7298c1f2018-12-05 00:09:30 +000012
13/* The power domain tree descriptor */
14static 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 ******************************************************************************/
24const 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 ******************************************************************************/
35int 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 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
44 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
45
46 if (cluster_id >= PLATFORM_CLUSTER_COUNT)
47 return -1;
48
49 if (cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER)
50 return -1;
51
Carlo Caione1afdfb02019-08-24 18:47:06 +010052 return plat_calc_core_pos(mpidr);
Antonio Nino Diaz7298c1f2018-12-05 00:09:30 +000053}