aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandrine Bailleux <sandrine.bailleux@arm.com>2019-05-07 07:29:21 +0000
committerTrustedFirmware Code Review <review@review.trustedfirmware.org>2019-05-07 07:29:21 +0000
commit1f018ba629bd534a14bbf133d4e9fa61e2f09686 (patch)
treeeae0800de352250121d33417c78520ae16012291
parent3da9cb1fcad88d5c7ca60141c067ad5559cdb399 (diff)
parent8d84b4c68c5f015b1315034dd1d64767ce5401e8 (diff)
downloadtf-a-tests-1f018ba629bd534a14bbf133d4e9fa61e2f09686.tar.gz
Merge "Add topology helper to get parent node"
-rw-r--r--include/plat/common/plat_topology.h10
-rw-r--r--plat/common/plat_topology.c18
2 files changed, 28 insertions, 0 deletions
diff --git a/include/plat/common/plat_topology.h b/include/plat/common/plat_topology.h
index 0da0b5ee7..0ca5effce 100644
--- a/include/plat/common/plat_topology.h
+++ b/include/plat/common/plat_topology.h
@@ -161,6 +161,16 @@ unsigned int tftf_topology_next_cpu(unsigned int cpu_node);
*/
unsigned int tftf_get_mpidr_from_node(unsigned int cpu_node);
+
+/*
+ * Returns the index corresponding to the parent power domain at `pwrlvl` of the
+ * CPU specified by `mpidr`. Returns POWER_DOMAIN_INIT if any of input arguments
+ * are incorrect.
+ */
+unsigned int tftf_get_parent_node_from_mpidr(unsigned int mpidr,
+ unsigned int pwrlvl);
+
+
/*
* Query the platform topology to find another CPU than the one specified
* as an argument.
diff --git a/plat/common/plat_topology.c b/plat/common/plat_topology.c
index a7920c37b..01e346191 100644
--- a/plat/common/plat_topology.c
+++ b/plat/common/plat_topology.c
@@ -317,6 +317,24 @@ unsigned int tftf_topology_next_cpu(unsigned int cpu_node)
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)
{