Export maximum affinity using PLATFORM_MAX_AFFLVL macro
This patch removes the plat_get_max_afflvl() platform API
and instead replaces it with a platform macro PLATFORM_MAX_AFFLVL.
This is done because the maximum affinity level for a platform
is a static value and it is more efficient for it to be defined
as a platform macro.
NOTE: PLATFORM PORTS NEED TO BE UPDATED ON MERGE OF THIS COMMIT
Fixes ARM-Software/tf-issues#265
Change-Id: I31d89b30c2ccda30d28271154d869060d50df7bf
diff --git a/services/std_svc/psci/psci_common.c b/services/std_svc/psci/psci_common.c
index a31643e..7ab607d 100644
--- a/services/std_svc/psci/psci_common.c
+++ b/services/std_svc/psci/psci_common.c
@@ -62,6 +62,13 @@
const plat_pm_ops_t *psci_plat_pm_ops;
/*******************************************************************************
+ * Check that the maximum affinity level supported by the platform makes sense
+ * ****************************************************************************/
+CASSERT(PLATFORM_MAX_AFFLVL <= MPIDR_MAX_AFFLVL && \
+ PLATFORM_MAX_AFFLVL >= MPIDR_AFFLVL0, \
+ assert_platform_max_afflvl_check);
+
+/*******************************************************************************
* This function is passed an array of pointers to affinity level nodes in the
* topology tree for an mpidr. It iterates through the nodes to find the highest
* affinity level which is marked as physically powered off.
@@ -150,30 +157,16 @@
/*
* Assume that this cpu was suspended and retrieve its target affinity
* level. If it is invalid then it could only have been turned off
- * earlier. get_max_afflvl() will return the highest affinity level a
+ * earlier. PLATFORM_MAX_AFFLVL will be the highest affinity level a
* cpu can be turned off to.
*/
afflvl = psci_get_suspend_afflvl();
if (afflvl == PSCI_INVALID_DATA)
- afflvl = get_max_afflvl();
+ afflvl = PLATFORM_MAX_AFFLVL;
return afflvl;
}
/*******************************************************************************
- * Simple routine to retrieve the maximum affinity level supported by the
- * platform and check that it makes sense.
- ******************************************************************************/
-int get_max_afflvl(void)
-{
- int aff_lvl;
-
- aff_lvl = plat_get_max_afflvl();
- assert(aff_lvl <= MPIDR_MAX_AFFLVL && aff_lvl >= MPIDR_AFFLVL0);
-
- return aff_lvl;
-}
-
-/*******************************************************************************
* Simple routine to set the id of an affinity instance at a given level in the
* mpidr.
******************************************************************************/
@@ -204,7 +197,7 @@
int psci_check_afflvl_range(int start_afflvl, int end_afflvl)
{
/* Sanity check the parameters passed */
- if (end_afflvl > get_max_afflvl())
+ if (end_afflvl > PLATFORM_MAX_AFFLVL)
return PSCI_E_INVALID_PARAMS;
if (start_afflvl < MPIDR_AFFLVL0)
diff --git a/services/std_svc/psci/psci_main.c b/services/std_svc/psci/psci_main.c
index d8a0009..fcd3b55 100644
--- a/services/std_svc/psci/psci_main.c
+++ b/services/std_svc/psci/psci_main.c
@@ -78,7 +78,7 @@
* levels need to be turned on
*/
start_afflvl = MPIDR_AFFLVL0;
- end_afflvl = get_max_afflvl();
+ end_afflvl = PLATFORM_MAX_AFFLVL;
rc = psci_afflvl_on(target_cpu,
&ep,
start_afflvl,
@@ -106,7 +106,7 @@
/* Sanity check the requested state */
target_afflvl = psci_get_pstate_afflvl(power_state);
- if (target_afflvl > get_max_afflvl())
+ if (target_afflvl > PLATFORM_MAX_AFFLVL)
return PSCI_E_INVALID_PARAMS;
/* Validate the power_state using platform pm_ops */
@@ -170,7 +170,7 @@
int psci_cpu_off(void)
{
int rc;
- int target_afflvl = get_max_afflvl();
+ int target_afflvl = PLATFORM_MAX_AFFLVL;
/*
* Traverse from the highest to the lowest affinity level. When the
@@ -196,7 +196,7 @@
unsigned int aff_state;
aff_map_node_t *node;
- if (lowest_affinity_level > get_max_afflvl())
+ if (lowest_affinity_level > PLATFORM_MAX_AFFLVL)
return rc;
node = psci_get_aff_map_node(target_affinity, lowest_affinity_level);
diff --git a/services/std_svc/psci/psci_private.h b/services/std_svc/psci/psci_private.h
index 5484665..62a0efc 100644
--- a/services/std_svc/psci/psci_private.h
+++ b/services/std_svc/psci/psci_private.h
@@ -113,7 +113,6 @@
* Function prototypes
******************************************************************************/
/* Private exported functions from psci_common.c */
-int get_max_afflvl(void);
unsigned short psci_get_state(aff_map_node_t *node);
unsigned short psci_get_phys_state(aff_map_node_t *node);
void psci_set_state(aff_map_node_t *node, unsigned short state);
diff --git a/services/std_svc/psci/psci_setup.c b/services/std_svc/psci/psci_setup.c
index 02a8786..5ff24d5 100644
--- a/services/std_svc/psci/psci_setup.c
+++ b/services/std_svc/psci/psci_setup.c
@@ -107,7 +107,7 @@
{
int rc;
- if (aff_lvl > get_max_afflvl())
+ if (aff_lvl > PLATFORM_MAX_AFFLVL)
return NULL;
/* Right shift the mpidr to the required affinity level */
@@ -320,7 +320,7 @@
psci_plat_pm_ops = NULL;
/* Find out the maximum affinity level that the platform implements */
- max_afflvl = get_max_afflvl();
+ max_afflvl = PLATFORM_MAX_AFFLVL;
assert(max_afflvl <= MPIDR_MAX_AFFLVL);
/*