xref: /rk3399_ARM-atf/plat/arm/board/juno/juno_topology.c (revision 0108047ae425faa91ddf782f264d7ed67d3351d8)
1*0108047aSSoby Mathew /*
2*0108047aSSoby Mathew  * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3*0108047aSSoby Mathew  *
4*0108047aSSoby Mathew  * Redistribution and use in source and binary forms, with or without
5*0108047aSSoby Mathew  * modification, are permitted provided that the following conditions are met:
6*0108047aSSoby Mathew  *
7*0108047aSSoby Mathew  * Redistributions of source code must retain the above copyright notice, this
8*0108047aSSoby Mathew  * list of conditions and the following disclaimer.
9*0108047aSSoby Mathew  *
10*0108047aSSoby Mathew  * Redistributions in binary form must reproduce the above copyright notice,
11*0108047aSSoby Mathew  * this list of conditions and the following disclaimer in the documentation
12*0108047aSSoby Mathew  * and/or other materials provided with the distribution.
13*0108047aSSoby Mathew  *
14*0108047aSSoby Mathew  * Neither the name of ARM nor the names of its contributors may be used
15*0108047aSSoby Mathew  * to endorse or promote products derived from this software without specific
16*0108047aSSoby Mathew  * prior written permission.
17*0108047aSSoby Mathew  *
18*0108047aSSoby Mathew  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19*0108047aSSoby Mathew  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*0108047aSSoby Mathew  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*0108047aSSoby Mathew  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22*0108047aSSoby Mathew  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*0108047aSSoby Mathew  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*0108047aSSoby Mathew  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*0108047aSSoby Mathew  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*0108047aSSoby Mathew  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*0108047aSSoby Mathew  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*0108047aSSoby Mathew  * POSSIBILITY OF SUCH DAMAGE.
29*0108047aSSoby Mathew  */
30*0108047aSSoby Mathew 
31*0108047aSSoby Mathew #include <arm_def.h>
32*0108047aSSoby Mathew #include <plat_arm.h>
33*0108047aSSoby Mathew #include "juno_def.h"
34*0108047aSSoby Mathew 
35*0108047aSSoby Mathew /*
36*0108047aSSoby Mathew  * On Juno, the system power level is the highest power level.
37*0108047aSSoby Mathew  * The first entry in the power domain descriptor specifies the
38*0108047aSSoby Mathew  * number of system power domains i.e. 1.
39*0108047aSSoby Mathew  */
40*0108047aSSoby Mathew #define JUNO_PWR_DOMAINS_AT_MAX_PWR_LVL	 ARM_SYSTEM_COUNT
41*0108047aSSoby Mathew 
42*0108047aSSoby Mathew /*
43*0108047aSSoby Mathew  * The Juno power domain tree descriptor. The cluster power domains
44*0108047aSSoby Mathew  * are arranged so that when the PSCI generic code creates the power
45*0108047aSSoby Mathew  * domain tree, the indices of the CPU power domain nodes it allocates
46*0108047aSSoby Mathew  * match the linear indices returned by plat_core_pos_by_mpidr()
47*0108047aSSoby Mathew  * i.e. CLUSTER1 CPUs are allocated indices from 0 to 3 and the higher
48*0108047aSSoby Mathew  * indices for CLUSTER0 CPUs.
49*0108047aSSoby Mathew  */
50*0108047aSSoby Mathew const unsigned char juno_power_domain_tree_desc[] = {
51*0108047aSSoby Mathew 	/* No of root nodes */
52*0108047aSSoby Mathew 	JUNO_PWR_DOMAINS_AT_MAX_PWR_LVL,
53*0108047aSSoby Mathew 	/* No of children for the root node */
54*0108047aSSoby Mathew 	JUNO_CLUSTER_COUNT,
55*0108047aSSoby Mathew 	/* No of children for the first cluster node */
56*0108047aSSoby Mathew 	JUNO_CLUSTER1_CORE_COUNT,
57*0108047aSSoby Mathew 	/* No of children for the second cluster node */
58*0108047aSSoby Mathew 	JUNO_CLUSTER0_CORE_COUNT
59*0108047aSSoby Mathew };
60*0108047aSSoby Mathew 
61*0108047aSSoby Mathew /*******************************************************************************
62*0108047aSSoby Mathew  * This function returns the Juno topology tree information.
63*0108047aSSoby Mathew  ******************************************************************************/
64*0108047aSSoby Mathew const unsigned char *plat_get_power_domain_tree_desc(void)
65*0108047aSSoby Mathew {
66*0108047aSSoby Mathew 	return juno_power_domain_tree_desc;
67*0108047aSSoby Mathew }
68*0108047aSSoby Mathew 
69*0108047aSSoby Mathew /*******************************************************************************
70*0108047aSSoby Mathew  * This function returns the core count within the cluster corresponding to
71*0108047aSSoby Mathew  * `mpidr`.
72*0108047aSSoby Mathew  ******************************************************************************/
73*0108047aSSoby Mathew unsigned int plat_arm_get_cluster_core_count(u_register_t mpidr)
74*0108047aSSoby Mathew {
75*0108047aSSoby Mathew 	return (((mpidr) & 0x100) ? JUNO_CLUSTER1_CORE_COUNT :\
76*0108047aSSoby Mathew 				JUNO_CLUSTER0_CORE_COUNT);
77*0108047aSSoby Mathew }
78