From patchwork Thu Jul 7 15:50:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 953362 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 p67FwHn1020855 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Jul 2011 15:58:38 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qeqwf-00029i-M2; Thu, 07 Jul 2011 15:56: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 1Qeqwe-0006QP-Ks; Thu, 07 Jul 2011 15:56:52 +0000 Received: from service87.mimecast.com ([94.185.240.25]) by canuck.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1QeqwY-0006Mc-QH for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2011 15:56:48 +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:51:59 +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:50 +0100 From: Lorenzo Pieralisi To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 09/17] ARM: kernel: v7 resets support Date: Thu, 7 Jul 2011 16:50:22 +0100 Message-Id: <1310053830-23779-10-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:51.0030 (UTC) FILETIME=[A5845360:01CC3CBD] X-MC-Unique: 111070716515909101 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110707_115647_172668_78563E7F X-CRM114-Status: GOOD ( 14.05 ) 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 15:58:38 +0000 (UTC) This patch provides reset entry point for A9, A8, A5 processors. The reset functions invalidate I$ and D$ depending on the processor needs and jump to the save/restore entry point in sr_entry.S. The reset address is obtained through the arch_reset_handler() function that returns a function pointer, detected dynamically through cpu id. Signed-off-by: Lorenzo Pieralisi --- arch/arm/kernel/reset_v7.S | 109 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 109 insertions(+), 0 deletions(-) create mode 100644 arch/arm/kernel/reset_v7.S diff --git a/arch/arm/kernel/reset_v7.S b/arch/arm/kernel/reset_v7.S new file mode 100644 index 0000000..287074c --- /dev/null +++ b/arch/arm/kernel/reset_v7.S @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2008-2011 ARM Ltd + * Author(s): Jon Callan, Lorenzo Pieralisi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include "sr.h" + +#define SCTLR_I (1<<12) +#define SCTLR_Z (1<<11) + +ENTRY(platform_a8_reset_handler) + b sr_reset_entry_point +ENDPROC(platform_a8_reset_handler) + +ENTRY(invalidate_icache_v7_pou) + mov r0, #0 + mcr p15, 0, r0, c7, c5, 0 @ iciallu + bx lr +ENDPROC(invalidate_icache_v7_pou) + +ENTRY(invalidate_dcache_v7_all) + @ must iterate over the caches in order to synthesise a complete + @ invalidation of data/unified cache + mrc p15, 1, r0, c0, c0, 1 @ read clidr + ands r3, r0, #0x7000000 @ extract loc from clidr + mov r3, r3, lsr #23 @ left align loc bit field + beq finished @ if loc is 0, then no need to + @ clean + mov r10, #0 @ start clean at cache level 0 + @ (in r10) +loop1: + add r2, r10, r10, lsr #1 @ work out 3x current cache + @ level + mov r12, r0, lsr r2 @ extract cache type bits from + @ clidr + and r12, r12, #7 @ mask of bits for current + @ cache only + cmp r12, #2 @ see what cache we have at + @ this level + blt skip @ skip if no cache, or just + @ i-cache + mcr p15, 2, r10, c0, c0, 0 @ select current cache level + @ in cssr + mov r12, #0 + mcr p15, 0, r12, c7, c5, 4 @ prefetchflush to sync new + @ cssr&csidr + mrc p15, 1, r12, c0, c0, 0 @ read the new csidr + and r2, r12, #7 @ extract the length of the + @ cache lines + add r2, r2, #4 @ add 4 (line length offset) + ldr r6, =0x3ff + ands r6, r6, r12, lsr #3 @ find maximum number on the + @ way size + clz r5, r6 @ find bit pos of way size + @ increment + ldr r7, =0x7fff + ands r7, r7, r12, lsr #13 @ extract max number of the + @ index size +loop2: + mov r8, r6 @ create working copy of max + @ way size +loop3: + orr r11, r10, r8, lsl r5 @ factor way and cache number + @ into r11 + orr r11, r11, r7, lsl r2 @ factor index number into r11 + mcr p15, 0, r11, c7, c6, 2 @ invalidate by set/way + subs r8, r8, #1 @ decrement the way + bge loop3 + subs r7, r7, #1 @ decrement the index + bge loop2 +skip: + add r10, r10, #2 @ increment cache number + cmp r3, r10 + bgt loop1 +finished: + mov r10, #0 + + mcr p15, 0, r10, c7, c10, 4 @ drain write buffer + mcr p15, 0, r10, c8, c7, 0 @ invalidate i + d tlbs + mcr p15, 0, r10, c2, c0, 2 @ ttb control register + bx lr +ENDPROC(invalidate_dcache_v7_all) + +ENTRY(platform_a9_reset_handler) + @ Work out whether caches need to be invalidated: A9 - yes, A5 - no + mrc p15, 0, r0, c0, c0, 0 + ldr r1, =CPU_A5 + cmp r0, r1 + beq icache + + bl invalidate_icache_v7_pou + + @ Turn I cache and branch prediction on +icache: + mrc p15, 0, r0, c1, c0, 0 + orr r0, r0, #(SCTLR_I | SCTLR_Z) + mcr p15, 0, r0, c1, c0, 0 + + @ Clear all data cache levels visible to CPU + blne invalidate_dcache_v7_all + + b sr_reset_entry_point +ENDPROC(platform_a9_reset_handler)