From patchwork Thu May 30 08:52:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 2634151 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id B4A1D3FD2B for ; Thu, 30 May 2013 08:49:24 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UhyVT-0004aO-Ty; Thu, 30 May 2013 08:46:51 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UhyUj-0001fj-J3; Thu, 30 May 2013 08:46:01 +0000 Received: from mail-pb0-x229.google.com ([2607:f8b0:400e:c01::229]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UhyUQ-0001cq-Ob for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2013 08:45:44 +0000 Received: by mail-pb0-f41.google.com with SMTP id xb12so10695120pbc.0 for ; Thu, 30 May 2013 01:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:in-reply-to:references:subject; bh=2hEWMTs9+Ada+kJOlQytBzsKX/9ha4DMe2ZGtkufCwM=; b=fFop9W6LuhCOkbQeLoqNeyJ5wQG6CcNB5oJL66FnhWLfYou0A7IjLRkUbOzGpz7lyu ayJULGSYBVKEH0/+xXFW267nOlm1jmuZgIJuO/Ii2bP2g2QmOC/lbtPoPofE8631GhxD KX0jK1N/ZhJ2dV7GYhUeNIg7bTKWZuV9IdqYA8wLywp/ZSSgQzF2QWMmGlc+2ZUXE+Vk i/rWRcw6dcc8NaRzo6MYwhD4hfbDac4fO3tWHwngKhgQVJ1pICfh6oDiuUonrUfhXsw6 66j5YG5n1g9kqNZeoHguJCXNNUwsbrVvYcRuU4t5yewoLNeqUPhEkYW7Ls+DHGgoI0Sw TVnw== X-Received: by 10.68.251.200 with SMTP id zm8mr6841445pbc.54.1369903521274; Thu, 30 May 2013 01:45:21 -0700 (PDT) Received: from [127.0.0.1] (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id vv6sm43825913pab.6.2013.05.30.01.45.18 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 May 2013 01:45:20 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Date: Thu, 30 May 2013 17:52:40 +0900 Message-Id: <20130530085240.24374.65991.sendpatchset@w520> In-Reply-To: <20130530085152.24374.64208.sendpatchset@w520> References: <20130530085152.24374.64208.sendpatchset@w520> Subject: [PATCH 05/05] ARM: shmobile: r8a73a4 CA7 setup arch timer X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130530_044542_987891_C2D2D843 X-CRM114-Status: GOOD ( 11.50 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (magnus.damm[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: arnd@arndb.de, Magnus Damm , horms@verge.net.au, ulrich.hecht@gmail.com, olof@lixom.net, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Magnus Damm Setup the CA7 arch timer in r8a73a4 at boot up. Thanks to Kevin Bracey at Renesas Mobile for initial implementation. We need to discuss if some of this can be moved into the common arch timer driver or not. It may also need to be shared with R-Car H2. So this is not ready for merge. Without this patch the interrupt count for the per-cpu arch timers for CA7 are stuck at zero. Not-yet-Signed-off-by: Magnus Damm --- arch/arm/mach-shmobile/smp-r8a73a4.c | 37 +++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) --- 0005/arch/arm/mach-shmobile/smp-r8a73a4.c +++ work/arch/arm/mach-shmobile/smp-r8a73a4.c 2013-05-30 17:13:01.000000000 +0900 @@ -50,6 +50,8 @@ #define CCI_SNOOP 0x0000 #define CCI_STATUS 0x000c +#define CNTFID0 0xe6080020 + static inline void r8a73a4_execute_wfe_as_nop(void) { unsigned int v; @@ -64,6 +66,32 @@ static inline void r8a73a4_execute_wfe_a : "cc"); } +static u32 r8a73a4_arch_freq; + +static inline void r8a73a4_reset_arch_timer(void) +{ + /* Program CNTFRQ from the frequency table */ + asm volatile("mcr p15, 0, %0, c14, c0, 0" : : "r" (r8a73a4_arch_freq)); + + /* CNTVOFF has to be initialized either from non-secure Hypervisor + * mode or secure Monitor mode with SCR.NS==1. If TrustZone is enabled + * then it should be handled by the secure code + */ + asm volatile( + "cps 0x16 @ Monitor mode" + "mrc p15, 0, r1, c1, c1, 0" + "orr r0, r1, #1 @ Set SCR.NS (non-secure)" + "mcr p15, 0, r0, c1, c1, 0" + "isb" + "mov r0, #0" + "mcrr p15, 4, r0, r0, c14 @ CNTVOFF" + "isb" + "mcr p15, 0, r1, c1, c1, 0 @ Restore SCR" + "isb" + "cps 0x13 @ Back to SVC mode" + : : : "r0", "r1"); +} + static void __init r8a73a4_smp_prepare_cpus(unsigned int max_cpus) { u32 bar; @@ -94,6 +122,11 @@ static void __init r8a73a4_smp_prepare_c /* wait for pending bit low */; iounmap(p); + /* Retrieve frequency to be able to later program CNTFRQ */ + p = ioremap_nocache(CNTFID0, 16); + r8a73a4_arch_freq = __raw_readl(p); + iounmap(p); + r8a73a4_execute_wfe_as_nop(); } @@ -115,9 +148,11 @@ static int __cpuinit r8a73a4_boot_second static void __cpuinit r8a73a4_secondary_init(unsigned int cpu) { - /* CA15 need SW workaround */ + /* CA15 and CA7 need SW workaround */ if (cpu_logical_map(cpu) < 4) r8a73a4_execute_wfe_as_nop(); + else + r8a73a4_reset_arch_timer(); } #ifdef CONFIG_HOTPLUG_CPU