xref: /rk3399_ARM-atf/plat/arm/board/juno/juno_topology.c (revision fd116b9f6c26d7fd49c7aa0cdbfb3d93871daec3)
10108047aSSoby Mathew /*
2*fd116b9fSRoberto Vargas  * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
30108047aSSoby Mathew  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
50108047aSSoby Mathew  */
60108047aSSoby Mathew 
70108047aSSoby Mathew #include <arm_def.h>
8*fd116b9fSRoberto Vargas #include <css_pm.h>
90108047aSSoby Mathew #include <plat_arm.h>
10*fd116b9fSRoberto Vargas #include <platform.h>
110108047aSSoby Mathew #include "juno_def.h"
120108047aSSoby Mathew 
130108047aSSoby Mathew /*
140108047aSSoby Mathew  * On Juno, the system power level is the highest power level.
150108047aSSoby Mathew  * The first entry in the power domain descriptor specifies the
160108047aSSoby Mathew  * number of system power domains i.e. 1.
170108047aSSoby Mathew  */
180108047aSSoby Mathew #define JUNO_PWR_DOMAINS_AT_MAX_PWR_LVL	 ARM_SYSTEM_COUNT
190108047aSSoby Mathew 
200108047aSSoby Mathew /*
210108047aSSoby Mathew  * The Juno power domain tree descriptor. The cluster power domains
220108047aSSoby Mathew  * are arranged so that when the PSCI generic code creates the power
230108047aSSoby Mathew  * domain tree, the indices of the CPU power domain nodes it allocates
240108047aSSoby Mathew  * match the linear indices returned by plat_core_pos_by_mpidr()
250108047aSSoby Mathew  * i.e. CLUSTER1 CPUs are allocated indices from 0 to 3 and the higher
260108047aSSoby Mathew  * indices for CLUSTER0 CPUs.
270108047aSSoby Mathew  */
28*fd116b9fSRoberto Vargas static const unsigned char juno_power_domain_tree_desc[] = {
290108047aSSoby Mathew 	/* No of root nodes */
300108047aSSoby Mathew 	JUNO_PWR_DOMAINS_AT_MAX_PWR_LVL,
310108047aSSoby Mathew 	/* No of children for the root node */
320108047aSSoby Mathew 	JUNO_CLUSTER_COUNT,
330108047aSSoby Mathew 	/* No of children for the first cluster node */
340108047aSSoby Mathew 	JUNO_CLUSTER1_CORE_COUNT,
350108047aSSoby Mathew 	/* No of children for the second cluster node */
360108047aSSoby Mathew 	JUNO_CLUSTER0_CORE_COUNT
370108047aSSoby Mathew };
380108047aSSoby Mathew 
390108047aSSoby Mathew /*******************************************************************************
400108047aSSoby Mathew  * This function returns the Juno topology tree information.
410108047aSSoby Mathew  ******************************************************************************/
420108047aSSoby Mathew const unsigned char *plat_get_power_domain_tree_desc(void)
430108047aSSoby Mathew {
440108047aSSoby Mathew 	return juno_power_domain_tree_desc;
450108047aSSoby Mathew }
460108047aSSoby Mathew 
470108047aSSoby Mathew /*******************************************************************************
480108047aSSoby Mathew  * This function returns the core count within the cluster corresponding to
490108047aSSoby Mathew  * `mpidr`.
500108047aSSoby Mathew  ******************************************************************************/
510108047aSSoby Mathew unsigned int plat_arm_get_cluster_core_count(u_register_t mpidr)
520108047aSSoby Mathew {
530108047aSSoby Mathew 	return (((mpidr) & 0x100) ? JUNO_CLUSTER1_CORE_COUNT :\
540108047aSSoby Mathew 				JUNO_CLUSTER0_CORE_COUNT);
550108047aSSoby Mathew }
5640111d44SSoby Mathew 
5740111d44SSoby Mathew /*
5840111d44SSoby Mathew  * The array mapping platform core position (implemented by plat_my_core_pos())
5940111d44SSoby Mathew  * to the SCMI power domain ID implemented by SCP.
6040111d44SSoby Mathew  */
6140111d44SSoby Mathew const uint32_t plat_css_core_pos_to_scmi_dmn_id_map[PLATFORM_CORE_COUNT] = {
6240111d44SSoby Mathew 			2, 3, 4, 5, 0, 1 };
63