blob: 0e03ec3298fe82931b5d6bd72ce7be5361e7c510 [file] [log] [blame]
Antonio Nino Diazae6779e2017-11-06 14:49:04 +00001/*
2 * Copyright (c) 2015-2017, 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 <sys/types.h>
10
11#include "rpi3_private.h"
12
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
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}