10108047aSSoby Mathew /*
231e703f9SAditya Angadi * Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved.
30108047aSSoby Mathew *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
50108047aSSoby Mathew */
60108047aSSoby Mathew
7c411396eSAntonio Nino Diaz #include <drivers/arm/css/css_mhu_doorbell.h>
814928b88SAntonio Nino Diaz #include <drivers/arm/css/scmi.h>
9bd9344f6SAntonio Nino Diaz #include <plat/arm/common/plat_arm.h>
10bd9344f6SAntonio Nino Diaz #include <plat/arm/css/common/css_pm.h>
1109d40e0eSAntonio Nino Diaz #include <plat/common/platform.h>
12234bc7f8SAntonio Nino Diaz #include <platform_def.h>
1309d40e0eSAntonio Nino Diaz
148db71e37SSudeep Holla #if CSS_USE_SCMI_SDS_DRIVER
15b911dddcSChandni Cherukuri static scmi_channel_plat_info_t juno_scmi_plat_info = {
16b911dddcSChandni Cherukuri .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE,
17b911dddcSChandni Cherukuri .db_reg_addr = PLAT_CSS_MHU_BASE + CSS_SCMI_MHU_DB_REG_OFF,
18b911dddcSChandni Cherukuri .db_preserve_mask = 0xfffffffe,
19b911dddcSChandni Cherukuri .db_modify_mask = 0x1,
20b911dddcSChandni Cherukuri .ring_doorbell = &mhu_ring_doorbell,
21b911dddcSChandni Cherukuri };
22b911dddcSChandni Cherukuri
plat_css_get_scmi_info(unsigned int channel_id)23*f0f2c903STony K Nadackal scmi_channel_plat_info_t *plat_css_get_scmi_info(unsigned int channel_id)
24b911dddcSChandni Cherukuri {
25b911dddcSChandni Cherukuri return &juno_scmi_plat_info;
26b911dddcSChandni Cherukuri }
270108047aSSoby Mathew
288db71e37SSudeep Holla #endif
290108047aSSoby Mathew /*
300108047aSSoby Mathew * On Juno, the system power level is the highest power level.
310108047aSSoby Mathew * The first entry in the power domain descriptor specifies the
320108047aSSoby Mathew * number of system power domains i.e. 1.
330108047aSSoby Mathew */
340108047aSSoby Mathew #define JUNO_PWR_DOMAINS_AT_MAX_PWR_LVL ARM_SYSTEM_COUNT
350108047aSSoby Mathew
360108047aSSoby Mathew /*
370108047aSSoby Mathew * The Juno power domain tree descriptor. The cluster power domains
380108047aSSoby Mathew * are arranged so that when the PSCI generic code creates the power
390108047aSSoby Mathew * domain tree, the indices of the CPU power domain nodes it allocates
400108047aSSoby Mathew * match the linear indices returned by plat_core_pos_by_mpidr()
410108047aSSoby Mathew * i.e. CLUSTER1 CPUs are allocated indices from 0 to 3 and the higher
420108047aSSoby Mathew * indices for CLUSTER0 CPUs.
430108047aSSoby Mathew */
44fd116b9fSRoberto Vargas static const unsigned char juno_power_domain_tree_desc[] = {
450108047aSSoby Mathew /* No of root nodes */
460108047aSSoby Mathew JUNO_PWR_DOMAINS_AT_MAX_PWR_LVL,
470108047aSSoby Mathew /* No of children for the root node */
480108047aSSoby Mathew JUNO_CLUSTER_COUNT,
490108047aSSoby Mathew /* No of children for the first cluster node */
500108047aSSoby Mathew JUNO_CLUSTER1_CORE_COUNT,
510108047aSSoby Mathew /* No of children for the second cluster node */
520108047aSSoby Mathew JUNO_CLUSTER0_CORE_COUNT
530108047aSSoby Mathew };
540108047aSSoby Mathew
550108047aSSoby Mathew /*******************************************************************************
560108047aSSoby Mathew * This function returns the Juno topology tree information.
570108047aSSoby Mathew ******************************************************************************/
plat_get_power_domain_tree_desc(void)580108047aSSoby Mathew const unsigned char *plat_get_power_domain_tree_desc(void)
590108047aSSoby Mathew {
600108047aSSoby Mathew return juno_power_domain_tree_desc;
610108047aSSoby Mathew }
620108047aSSoby Mathew
630108047aSSoby Mathew /*******************************************************************************
640108047aSSoby Mathew * This function returns the core count within the cluster corresponding to
650108047aSSoby Mathew * `mpidr`.
660108047aSSoby Mathew ******************************************************************************/
plat_arm_get_cluster_core_count(u_register_t mpidr)670108047aSSoby Mathew unsigned int plat_arm_get_cluster_core_count(u_register_t mpidr)
680108047aSSoby Mathew {
6989509904SSathees Balya return (((mpidr & (u_register_t) 0x100) != 0U) ?
7089509904SSathees Balya JUNO_CLUSTER1_CORE_COUNT : JUNO_CLUSTER0_CORE_COUNT);
710108047aSSoby Mathew }
7240111d44SSoby Mathew
7340111d44SSoby Mathew /*
7440111d44SSoby Mathew * The array mapping platform core position (implemented by plat_my_core_pos())
7540111d44SSoby Mathew * to the SCMI power domain ID implemented by SCP.
7640111d44SSoby Mathew */
7740111d44SSoby Mathew const uint32_t plat_css_core_pos_to_scmi_dmn_id_map[PLATFORM_CORE_COUNT] = {
7840111d44SSoby Mathew 2, 3, 4, 5, 0, 1 };
79