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