1 /*
2  * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <arch.h>
8 #include <plat/common/platform.h>
9 
10 #include "uniphier.h"
11 
12 static unsigned char uniphier_power_domain_tree_desc[UNIPHIER_CLUSTER_COUNT + 1];
13 
plat_get_power_domain_tree_desc(void)14 const unsigned char *plat_get_power_domain_tree_desc(void)
15 {
16 	int i;
17 
18 	uniphier_power_domain_tree_desc[0] = UNIPHIER_CLUSTER_COUNT;
19 
20 	for (i = 0; i < UNIPHIER_CLUSTER_COUNT; i++)
21 		uniphier_power_domain_tree_desc[i + 1] =
22 						UNIPHIER_MAX_CPUS_PER_CLUSTER;
23 
24 	return uniphier_power_domain_tree_desc;
25 }
26 
plat_core_pos_by_mpidr(u_register_t mpidr)27 int plat_core_pos_by_mpidr(u_register_t mpidr)
28 {
29 	unsigned int cluster_id, cpu_id;
30 
31 	cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
32 	if (cluster_id >= UNIPHIER_CLUSTER_COUNT)
33 		return -1;
34 
35 	cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
36 	if (cpu_id >= UNIPHIER_MAX_CPUS_PER_CLUSTER)
37 		return -1;
38 
39 	return uniphier_calc_core_pos(mpidr);
40 }
41