@@ -55,13 +55,21 @@ static void __iomem *ns_sram_base_addr __ro_after_init;
: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
"r9", "r10", "lr", "memory")
+static int exynos_cpunr(unsigned int cpu, unsigned int cluster)
+{
+ if (cpu >= EXYNOS5420_CPUS_PER_CLUSTER ||
+ cluster >= EXYNOS5420_NR_CLUSTERS)
+ return -EINVAL;
+ return cpu + (cluster * EXYNOS5420_CPUS_PER_CLUSTER);
+}
+
static int exynos_cpu_powerup(unsigned int cpu, unsigned int cluster)
{
- unsigned int cpunr = cpu + (cluster * EXYNOS5420_CPUS_PER_CLUSTER);
+ unsigned int cpunr;
pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
- if (cpu >= EXYNOS5420_CPUS_PER_CLUSTER ||
- cluster >= EXYNOS5420_NR_CLUSTERS)
+ cpunr = exynos_cpunr(cpu, cluster);
+ if (cpunr < 0)
return -EINVAL;
if (!exynos_cpu_power_state(cpunr)) {
@@ -104,11 +112,10 @@ static int exynos_cluster_powerup(unsigned int cluster)
static void exynos_cpu_powerdown_prepare(unsigned int cpu, unsigned int cluster)
{
- unsigned int cpunr = cpu + (cluster * EXYNOS5420_CPUS_PER_CLUSTER);
+ unsigned int cpunr = exynos_cpunr(cpu, cluster);
pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
- BUG_ON(cpu >= EXYNOS5420_CPUS_PER_CLUSTER ||
- cluster >= EXYNOS5420_NR_CLUSTERS);
+ BUG_ON(cpunr < 0);
exynos_cpu_power_down(cpunr);
}
@@ -152,11 +159,10 @@ static void exynos_cluster_cache_disable(void)
static int exynos_wait_for_powerdown(unsigned int cpu, unsigned int cluster)
{
unsigned int tries = 100;
- unsigned int cpunr = cpu + (cluster * EXYNOS5420_CPUS_PER_CLUSTER);
+ unsigned int cpunr = exynos_cpunr(cpu, cluster);
pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
- BUG_ON(cpu >= EXYNOS5420_CPUS_PER_CLUSTER ||
- cluster >= EXYNOS5420_NR_CLUSTERS);
+ BUG_ON(cpunr < 0);
/* Wait for the core state to be OFF */
while (tries--) {
The generic MCPM code uses a [cpu,cluster] tuple to identify each core, so the Exynos specific code converts this into a single integer cpunr, which is then used as an offset to registers. Move the current 5420 specific calculations to a new function so we can change this for other devices. Signed-off-by: Stuart Menefy <stuart.menefy@mathembedded.com> --- arch/arm/mach-exynos/mcpm-exynos.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)