From ec55fb7961f55a095e16178d597d135e01ece42c Mon Sep 17 00:00:00 2001 From: Philipp Tomsich Date: Mon, 29 Aug 2016 21:43:44 +0200 Subject: ARM: sun9i: Update mcpm to common mcpm machinery --- arch/arm/mach-sunxi/mcpm.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-sunxi/mcpm.c b/arch/arm/mach-sunxi/mcpm.c index e74e8aab2560..37e9416b6bf6 100644 --- a/arch/arm/mach-sunxi/mcpm.c +++ b/arch/arm/mach-sunxi/mcpm.c @@ -247,11 +247,34 @@ static int sunxi_cluster_powerup(unsigned int cluster) static void sunxi_cpu_powerdown_prepare(unsigned int cpu, unsigned int cluster) { - gic_cpu_if_down(); + gic_cpu_if_down(0); } +static int sunxi_cluster_powerdown(unsigned int cluster); + static void sunxi_cluster_powerdown_prepare(unsigned int cluster) { + int ret; + u32 reg; + + pr_debug("%s: cluster %u\n", __func__, cluster); + BUG_ON(cluster >= SUNXI_NR_CLUSTERS); + + /* last man standing, assert ACINACTM */ + reg = readl(cpucfg_base + CPUCFG_CX_CTRL_REG1(cluster)); + reg |= CPUCFG_CX_CTRL_REG1_ACINACTM; + writel(reg, cpucfg_base + CPUCFG_CX_CTRL_REG1(cluster)); + + /* wait for cluster L2 WFI */ + ret = readl_poll_timeout(cpucfg_base + CPUCFG_CX_STATUS(cluster), reg, + reg & CPUCFG_CX_STATUS_STANDBYWFIL2, + 1000, 100000); + if (ret) { + pr_warn("%s: cluster %u time out waiting for STANDBYWFIL2\n", + __func__, cluster); + } + + sunxi_cluster_powerdown(cluster); } static void sunxi_cpu_cache_disable(void) @@ -325,7 +348,7 @@ static int sunxi_cluster_powerdown(unsigned int cluster) static int sunxi_wait_for_powerdown(unsigned int cpu, unsigned int cluster) { - int ret; + int ret; u32 reg; pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster); @@ -341,6 +364,7 @@ static int sunxi_wait_for_powerdown(unsigned int cpu, unsigned int cluster) /* power down CPU core */ sunxi_cpu_powerdown(cpu, cluster); +#if 0 if (__mcpm_cluster_state(cluster) != CLUSTER_DOWN) return 0; @@ -360,6 +384,7 @@ static int sunxi_wait_for_powerdown(unsigned int cpu, unsigned int cluster) } sunxi_cluster_powerdown(cluster); +#endif return 0; } -- cgit v1.2.3