From patchwork Thu Jul 7 15:50:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 953382 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p67G0xOS024031 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Jul 2011 16:01:21 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qeqyb-0002B7-4x; Thu, 07 Jul 2011 15:58:53 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QeqvU-00065r-9Y; Thu, 07 Jul 2011 15:55:40 +0000 Received: from service87.mimecast.com ([94.185.240.25]) by canuck.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1QequX-0005rJ-6H for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2011 15:54:42 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 07 Jul 2011 16:52:16 +0100 Received: from e102568-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 7 Jul 2011 16:50:53 +0100 From: Lorenzo Pieralisi To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 12/17] ARM: kernel: add SCU reset hook Date: Thu, 7 Jul 2011 16:50:25 +0100 Message-Id: <1310053830-23779-13-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1310053830-23779-1-git-send-email-lorenzo.pieralisi@arm.com> References: <1310053830-23779-1-git-send-email-lorenzo.pieralisi@arm.com> X-OriginalArrivalTime: 07 Jul 2011 15:50:53.0467 (UTC) FILETIME=[A6F82EB0:01CC3CBD] X-MC-Unique: 111070716521600301 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110707_115441_651688_41CF01DB X-CRM114-Status: GOOD ( 16.00 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [94.185.240.25 listed in list.dnswl.org] Cc: Kevin Hilman , Lorenzo Pieralisi , Russell King , Catalin Marinas , Amit Kucheria , Frank Hofmann , Magnus Damm , Santosh Shilimkar , Amit Kachhap , Colin Cross , Linaro Dev X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 07 Jul 2011 16:01:21 +0000 (UTC) When a CLUSTER is powered down the SCU must be reinitialized on warm-boot. This patch adds a hook to reset the SCU, which implies invalidating TAG RAMs and renabling it. The scu virtual address is saved in a static variable when the SCU is first enabled at boot; this allows common idle code to be generic and avoid relying on platform code to get the address at run-time. On warm-boot the SCU TAG RAM is invalidated and the SCU enabled if it is not already enabled. The reset can be skipped altogether thanks to save/restore framework flags. Flushing D$ cache is cumbersome since the system just comes out of reset, which invalidates caches in the process if needed (A9), that is why the scu_enable function is not reused as it is to reset the SCU. If the init function is extended, there might not be a need for a SCU specific hook, since the init function can be reused to reinitialize the SCU at boot provided it is removed from the init section and kept in memory. Signed-off-by: Lorenzo Pieralisi --- arch/arm/include/asm/smp_scu.h | 3 ++- arch/arm/kernel/smp_scu.c | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/smp_scu.h b/arch/arm/include/asm/smp_scu.h index 4eb6d00..cfaa68e 100644 --- a/arch/arm/include/asm/smp_scu.h +++ b/arch/arm/include/asm/smp_scu.h @@ -8,7 +8,8 @@ #ifndef __ASSEMBLER__ unsigned int scu_get_core_count(void __iomem *); void scu_enable(void __iomem *); -int scu_power_mode(void __iomem *, unsigned int); +int scu_power_mode(unsigned int); +void scu_reset(void); #endif #endif diff --git a/arch/arm/kernel/smp_scu.c b/arch/arm/kernel/smp_scu.c index a1e757c..980ced9 100644 --- a/arch/arm/kernel/smp_scu.c +++ b/arch/arm/kernel/smp_scu.c @@ -20,6 +20,7 @@ #define SCU_INVALIDATE 0x0c #define SCU_FPGA_REVISION 0x10 +static void __iomem *scu_va; /* * Get the number of CPU cores from the SCU configuration */ @@ -36,6 +37,7 @@ void __init scu_enable(void __iomem *scu_base) { u32 scu_ctrl; + scu_va = scu_base; scu_ctrl = __raw_readl(scu_base + SCU_CTRL); /* already enabled? */ if (scu_ctrl & 1) @@ -59,7 +61,7 @@ void __init scu_enable(void __iomem *scu_base) * has the side effect of disabling coherency, caches must have been * flushed. Interrupts must also have been disabled. */ -int scu_power_mode(void __iomem *scu_base, unsigned int mode) +int scu_power_mode(unsigned int mode) { unsigned int val; int cpu = smp_processor_id(); @@ -67,9 +69,34 @@ int scu_power_mode(void __iomem *scu_base, unsigned int mode) if (mode > 3 || mode == 1 || cpu > 3) return -EINVAL; - val = __raw_readb(scu_base + SCU_CPU_STATUS + cpu) & ~0x03; + val = __raw_readb(scu_va + SCU_CPU_STATUS + cpu) & ~0x03; val |= mode; - __raw_writeb(val, scu_base + SCU_CPU_STATUS + cpu); + __raw_writeb(val, scu_va + SCU_CPU_STATUS + cpu); return 0; } + +/* + * Reinitialise the SCU after power-down + */ + +void scu_reset(void) +{ + u32 scu_ctrl; + + scu_ctrl = __raw_readl(scu_va + SCU_CTRL); + /* already enabled? */ + if (scu_ctrl & 1) + return; + /* + * SCU TAGS should be invalidated on boot-up + */ + __raw_writel(0xffff, scu_va + SCU_INVALIDATE); + /* + * Coming out of reset, dcache invalidated + * no need to go through the whole hog again + * just enable the SCU and pop out + */ + scu_ctrl |= 1; + __raw_writel(scu_ctrl, scu_va + SCU_CTRL); +}