xref: /rk3399_ARM-atf/plat/arm/board/juno/juno_topology.c (revision 14928b88ab9f16aebd492f4d71779fd6f5ac91b2)
10108047aSSoby Mathew /*
2fd116b9fSRoberto 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 
7*14928b88SAntonio Nino Diaz #include <drivers/arm/css/scmi.h>
8bd9344f6SAntonio Nino Diaz #include <plat/arm/common/plat_arm.h>
9bd9344f6SAntonio Nino Diaz #include <plat/arm/css/common/css_pm.h>
1009d40e0eSAntonio Nino Diaz #include <plat/common/platform.h>
11234bc7f8SAntonio Nino Diaz #include <platform_def.h>
1209d40e0eSAntonio Nino Diaz 
13b911dddcSChandni Cherukuri #include "../../css/drivers/mhu/css_mhu_doorbell.h"
14b911dddcSChandni Cherukuri 
158db71e37SSudeep Holla #if CSS_USE_SCMI_SDS_DRIVER
16b911dddcSChandni Cherukuri static scmi_channel_plat_info_t juno_scmi_plat_info = {
17b911dddcSChandni Cherukuri 		.scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE,
18b911dddcSChandni Cherukuri 		.db_reg_addr = PLAT_CSS_MHU_BASE + CSS_SCMI_MHU_DB_REG_OFF,
19b911dddcSChandni Cherukuri 		.db_preserve_mask = 0xfffffffe,
20b911dddcSChandni Cherukuri 		.db_modify_mask = 0x1,
21b911dddcSChandni Cherukuri 		.ring_doorbell = &mhu_ring_doorbell,
22b911dddcSChandni Cherukuri };
23b911dddcSChandni Cherukuri 
24b911dddcSChandni Cherukuri scmi_channel_plat_info_t *plat_css_get_scmi_info()
25b911dddcSChandni Cherukuri {
26b911dddcSChandni Cherukuri 	return &juno_scmi_plat_info;
27b911dddcSChandni Cherukuri }
280108047aSSoby Mathew 
298db71e37SSudeep Holla #endif
300108047aSSoby Mathew /*
310108047aSSoby Mathew  * On Juno, the system power level is the highest power level.
320108047aSSoby Mathew  * The first entry in the power domain descriptor specifies the
330108047aSSoby Mathew  * number of system power domains i.e. 1.
340108047aSSoby Mathew  */
350108047aSSoby Mathew #define JUNO_PWR_DOMAINS_AT_MAX_PWR_LVL	 ARM_SYSTEM_COUNT
360108047aSSoby Mathew 
370108047aSSoby Mathew /*
380108047aSSoby Mathew  * The Juno power domain tree descriptor. The cluster power domains
390108047aSSoby Mathew  * are arranged so that when the PSCI generic code creates the power
400108047aSSoby Mathew  * domain tree, the indices of the CPU power domain nodes it allocates
410108047aSSoby Mathew  * match the linear indices returned by plat_core_pos_by_mpidr()
420108047aSSoby Mathew  * i.e. CLUSTER1 CPUs are allocated indices from 0 to 3 and the higher
430108047aSSoby Mathew  * indices for CLUSTER0 CPUs.
440108047aSSoby Mathew  */
45fd116b9fSRoberto Vargas static const unsigned char juno_power_domain_tree_desc[] = {
460108047aSSoby Mathew 	/* No of root nodes */
470108047aSSoby Mathew 	JUNO_PWR_DOMAINS_AT_MAX_PWR_LVL,
480108047aSSoby Mathew 	/* No of children for the root node */
490108047aSSoby Mathew 	JUNO_CLUSTER_COUNT,
500108047aSSoby Mathew 	/* No of children for the first cluster node */
510108047aSSoby Mathew 	JUNO_CLUSTER1_CORE_COUNT,
520108047aSSoby Mathew 	/* No of children for the second cluster node */
530108047aSSoby Mathew 	JUNO_CLUSTER0_CORE_COUNT
540108047aSSoby Mathew };
550108047aSSoby Mathew 
560108047aSSoby Mathew /*******************************************************************************
570108047aSSoby Mathew  * This function returns the Juno topology tree information.
580108047aSSoby Mathew  ******************************************************************************/
590108047aSSoby Mathew const unsigned char *plat_get_power_domain_tree_desc(void)
600108047aSSoby Mathew {
610108047aSSoby Mathew 	return juno_power_domain_tree_desc;
620108047aSSoby Mathew }
630108047aSSoby Mathew 
640108047aSSoby Mathew /*******************************************************************************
650108047aSSoby Mathew  * This function returns the core count within the cluster corresponding to
660108047aSSoby Mathew  * `mpidr`.
670108047aSSoby Mathew  ******************************************************************************/
680108047aSSoby Mathew unsigned int plat_arm_get_cluster_core_count(u_register_t mpidr)
690108047aSSoby Mathew {
7089509904SSathees Balya 	return (((mpidr & (u_register_t) 0x100) != 0U) ?
7189509904SSathees Balya 			JUNO_CLUSTER1_CORE_COUNT : JUNO_CLUSTER0_CORE_COUNT);
720108047aSSoby Mathew }
7340111d44SSoby Mathew 
7440111d44SSoby Mathew /*
7540111d44SSoby Mathew  * The array mapping platform core position (implemented by plat_my_core_pos())
7640111d44SSoby Mathew  * to the SCMI power domain ID implemented by SCP.
7740111d44SSoby Mathew  */
7840111d44SSoby Mathew const uint32_t plat_css_core_pos_to_scmi_dmn_id_map[PLATFORM_CORE_COUNT] = {
7940111d44SSoby Mathew 			2, 3, 4, 5, 0, 1 };
80