blob: 4951f742a209206f3e43b7ac8829e37439b7a7a2 [file] [log] [blame]
Tien Hock, Lohab34f742019-02-26 09:25:14 +08001/*
2 * Copyright (c) 2019, 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 <lib/psci/psci.h>
10static const unsigned char plat_power_domain_tree_desc[] = {1, 4};
11
12/*******************************************************************************
13 * This function returns the default topology tree information.
14 ******************************************************************************/
15const unsigned char *plat_get_power_domain_tree_desc(void)
16{
17 return plat_power_domain_tree_desc;
18}
19
20/*******************************************************************************
21 * This function implements a part of the critical interface between the psci
22 * generic layer and the platform that allows the former to query the platform
23 * to convert an MPIDR to a unique linear index. An error code (-1) is returned
24 * in case the MPIDR is invalid.
25 ******************************************************************************/
26int plat_core_pos_by_mpidr(u_register_t mpidr)
27{
28 unsigned int cluster_id, cpu_id;
29
30 mpidr &= MPIDR_AFFINITY_MASK;
31
32 if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK))
33 return -1;
34
35 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
36 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
37
38 if (cluster_id >= PLATFORM_CLUSTER_COUNT)
39 return -1;
40
41 /*
42 * Validate cpu_id by checking whether it represents a CPU in
43 * one of the two clusters present on the platform.
44 */
45 if (cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER)
46 return -1;
47
48 return (cpu_id + (cluster_id * 4));
49}
50