xref: /rk3399_ARM-atf/plat/renesas/rcar_gen4/plat_topology.c (revision 04cf04c72d403e0c057505882fac9002d39d4102)
1 /*
2  * Copyright (c) 2021-2025, Renesas Electronics Corporation. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <common/debug.h>
8 #include <lib/psci/psci.h>
9 #include <plat_helpers.h>
10 #include <platform_def.h>
11 
12 #include "rcar_private.h"
13 
14 const unsigned char *plat_get_power_domain_tree_desc(void)
15 {
16 	static const unsigned char rcar_power_domain_tree_desc[] = {
17 		1,
18 		PLATFORM_CLUSTER_COUNT,
19 		PLATFORM_CLUSTER0_CORE_COUNT,
20 		PLATFORM_CLUSTER1_CORE_COUNT,
21 		PLATFORM_CLUSTER2_CORE_COUNT,
22 		PLATFORM_CLUSTER3_CORE_COUNT
23 	};
24 
25 	return rcar_power_domain_tree_desc;
26 }
27 
28 int plat_core_pos_by_mpidr(u_register_t mpidr)
29 {
30 	u_register_t cpu;
31 
32 	/* ARMv8.2 arch */
33 	if ((mpidr & (MPIDR_AFFLVL_MASK << MPIDR_AFF0_SHIFT)) != 0)
34 		return -1;
35 
36 	cpu = plat_renesas_calc_core_pos(mpidr);
37 	if (cpu >= PLATFORM_CORE_COUNT)
38 		return -1;
39 
40 	return (int)cpu;
41 }
42 
43 int32_t rcar_cluster_pos_by_mpidr(u_register_t mpidr)
44 {
45 	u_register_t cluster;
46 
47 	/* ARMv8.2 arch */
48 	if ((mpidr & (MPIDR_AFFLVL_MASK << MPIDR_AFF0_SHIFT)) != 0)
49 		return -1;
50 
51 	cluster = MPIDR_AFFLVL2_VAL(mpidr);
52 	if (cluster >= PLATFORM_CLUSTER_COUNT)
53 		return -1;
54 
55 	return (int32_t)cluster;
56 }
57