Add topology helper to get parent node
It was not possible to get a parent node given an MPIDR
of the CPU using the current topology APIs. This patch adds
the `tftf_get_parent_node_from_mpidr()` API to achieve the same.
Change-Id: I818f1e628689928293c1fdb85606885e851a5785
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
diff --git a/plat/common/plat_topology.c b/plat/common/plat_topology.c
index a7920c3..01e3461 100644
--- a/plat/common/plat_topology.c
+++ b/plat/common/plat_topology.c
@@ -317,6 +317,24 @@
return PWR_DOMAIN_INIT;
}
+unsigned int tftf_get_parent_node_from_mpidr(unsigned int mpidr, unsigned int pwrlvl)
+{
+ unsigned int core_pos = platform_get_core_pos(mpidr);
+ unsigned int node, i;
+
+ if (core_pos >= PLATFORM_CORE_COUNT)
+ return PWR_DOMAIN_INIT;
+
+ if (pwrlvl > PLAT_MAX_PWR_LEVEL)
+ return PWR_DOMAIN_INIT;
+
+ node = tftf_pwr_domain_start_idx[0] + core_pos;
+
+ for (i = 1; i <= pwrlvl; i++)
+ node = tftf_pd_nodes[node].parent_node;
+
+ return node;
+}
unsigned int tftf_get_mpidr_from_node(unsigned int cpu_node)
{