xref: /rk3399_ARM-atf/plat/allwinner/common/sunxi_topology.c (revision 09d40e0e08283a249e7dce0e106c07c5141f9b7e)
158032586SSamuel Holland /*
258032586SSamuel Holland  * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
358032586SSamuel Holland  *
458032586SSamuel Holland  * SPDX-License-Identifier: BSD-3-Clause
558032586SSamuel Holland  */
658032586SSamuel Holland 
758032586SSamuel Holland #include <platform_def.h>
858032586SSamuel Holland 
9*09d40e0eSAntonio Nino Diaz #include <arch.h>
10*09d40e0eSAntonio Nino Diaz #include <plat/common/platform.h>
11*09d40e0eSAntonio Nino Diaz 
1258032586SSamuel Holland static unsigned char plat_power_domain_tree_desc[PLAT_MAX_PWR_LVL + 1] = {
1358032586SSamuel Holland 	/* One root node for the SoC */
1458032586SSamuel Holland 	1,
1558032586SSamuel Holland 	/* One node for each cluster */
1658032586SSamuel Holland 	PLATFORM_CLUSTER_COUNT,
1758032586SSamuel Holland 	/* One set of CPUs per cluster */
1858032586SSamuel Holland 	PLATFORM_MAX_CPUS_PER_CLUSTER,
1958032586SSamuel Holland };
2058032586SSamuel Holland 
2158032586SSamuel Holland int plat_core_pos_by_mpidr(u_register_t mpidr)
2258032586SSamuel Holland {
2358032586SSamuel Holland 	unsigned int cluster = MPIDR_AFFLVL1_VAL(mpidr);
2458032586SSamuel Holland 	unsigned int core = MPIDR_AFFLVL0_VAL(mpidr);
2558032586SSamuel Holland 
2658032586SSamuel Holland 	if (MPIDR_AFFLVL3_VAL(mpidr) > 0 ||
2758032586SSamuel Holland 	    MPIDR_AFFLVL2_VAL(mpidr) > 0 ||
2858032586SSamuel Holland 	    cluster >= PLATFORM_CLUSTER_COUNT ||
2958032586SSamuel Holland 	    core >= PLATFORM_MAX_CPUS_PER_CLUSTER) {
3058032586SSamuel Holland 		return -1;
3158032586SSamuel Holland 	}
3258032586SSamuel Holland 
3358032586SSamuel Holland 	return cluster * PLATFORM_MAX_CPUS_PER_CLUSTER + core;
3458032586SSamuel Holland }
3558032586SSamuel Holland 
3658032586SSamuel Holland const unsigned char *plat_get_power_domain_tree_desc(void)
3758032586SSamuel Holland {
3858032586SSamuel Holland 	return plat_power_domain_tree_desc;
3958032586SSamuel Holland }
40