blob: 94fa71f7808d418d6dd7ecac8b216d8530207086 [file] [log] [blame]
Usama Arif82e95092019-06-18 16:46:05 +01001/*
2 * Copyright (c) 2019, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <platform_def.h>
8
9/* The A5DS power domain tree descriptor */
10static const unsigned char a5ds_power_domain_tree_desc[] = {
11 1,
12 /* No of children for the root node */
13 A5DS_CLUSTER_COUNT,
14 /* No of children for the first cluster node */
15 A5DS_CORE_COUNT,
16};
17
18/*******************************************************************************
19 * This function returns the topology according to A5DS_CLUSTER_COUNT.
20 ******************************************************************************/
21const unsigned char *plat_get_power_domain_tree_desc(void)
22{
23 return a5ds_power_domain_tree_desc;
24}
25
26/*******************************************************************************
27 * Get core position using mpidr
28 ******************************************************************************/
29int plat_core_pos_by_mpidr(u_register_t mpidr)
30{
31 unsigned int cluster_id, cpu_id;
32
33 mpidr &= MPIDR_AFFINITY_MASK;
34
35 if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK))
36 return -1;
37
38 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
39 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
40
41 if (cluster_id >= A5DS_CLUSTER_COUNT)
42 return -1;
43
44 /*
45 * Validate cpu_id by checking whether it represents a CPU in
46 * one of the two clusters present on the platform.
47 */
48 if (cpu_id >= A5DS_MAX_CPUS_PER_CLUSTER)
49 return -1;
50
51 return (cpu_id + (cluster_id * 4));
52
53}