From patchwork Thu May 30 08:52:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 2634121 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 024113FD2B for ; Thu, 30 May 2013 08:46:56 +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 1UhyUa-0004M4-Rf; Thu, 30 May 2013 08:45:54 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UhyU6-0001cp-As; Thu, 30 May 2013 08:45:22 +0000 Received: from mail-pb0-x234.google.com ([2607:f8b0:400e:c01::234]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UhyTv-0001a7-Se for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2013 08:45:12 +0000 Received: by mail-pb0-f52.google.com with SMTP id xa12so307138pbc.39 for ; Thu, 30 May 2013 01:44:50 -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=VOPptUuTsHjyxCwscpRWgboPVNVWKdByONPlJe3pdI0=; b=L9Tkvd7dw74RqjBKhMG2W8pt608nYLQ8CclEosbi8JGmjI+ZIkOY+4sTHOxErhakUs 9XODPRUOcdBrYEJ2k/dzNnX9R81YVUumi02KWJNbzLr1sC5B4ESCU4TfdqJoBTAMJEwB UP42GlDZ5pjHKQgy7vmOJj4afcVmamLPyPPkaJKYoBQcerCatl3s4cQ0AnOUvUUNgTym yZaqUpuwGp7ZEjViptAuSgEB5WbbpF6q1jtfG8RKfGsiK9IOKS4Vw31Faj6jbDoFV5kr OlkFH16PHyc/r1yQYLLPy3rorpMFciSsUHFjetJ6MGRg/a29eR38+Y9Q1yMqWIxxjb2C JUnw== X-Received: by 10.68.184.100 with SMTP id et4mr6780718pbc.48.1369903490383; Thu, 30 May 2013 01:44:50 -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 ue8sm43797448pac.14.2013.05.30.01.44.47 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 May 2013 01:44:49 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Date: Thu, 30 May 2013 17:52:11 +0900 Message-Id: <20130530085211.24374.15664.sendpatchset@w520> In-Reply-To: <20130530085152.24374.64208.sendpatchset@w520> References: <20130530085152.24374.64208.sendpatchset@w520> Subject: [PATCH 02/05] ARM: shmobile: r8a73a4 CPU Hotplug prototype v1 (CA15 x 4) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130530_044512_042079_A5E48305 X-CRM114-Status: GOOD ( 14.15 ) 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 Add CPU Hotplug prototype support for 4 x Cortex-A15 included in r8a73a4. Needs a rewrite to support more generic handling of CPU core power domains. Not ready for merge. Not-yet-Signed-off-by: Magnus Damm --- Developed and tested on top of v3.10-rc2, depends on "[PATCH] ARM: shmobile: r8a73a4 SMP prototype v1 (CA15 x 4)" arch/arm/mach-shmobile/smp-r8a73a4.c | 88 ++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) --- 0005/arch/arm/mach-shmobile/smp-r8a73a4.c +++ work/arch/arm/mach-shmobile/smp-r8a73a4.c 2013-05-22 13:34:18.000000000 +0900 @@ -36,6 +36,8 @@ #define APMU 0xe6150000 #define CA15WUPCR 0x2010 +#define CA15PSTR 0x2040 +#define CA15CPUNCR(n) (0x2100 + (0x10 * (n))) #define MERAM 0xe8080000 #define CCI_BASE 0xf0190000 @@ -83,7 +85,93 @@ static int __cpuinit r8a73a4_boot_second return 0; } +#ifdef CONFIG_HOTPLUG_CPU +static int r8a73a4_cpu_kill(unsigned int cpu) +{ + void __iomem *p; + int ret = 0; + int k; + + /* this function is running on another CPU than the offline target, + * here all we need to do is to wait for the SoC to enter sleep mode. + */ + p = ioremap_nocache(APMU, 0x3000); + for (k = 0; k < 1000; k++) { + if (((__raw_readl(p + CA15PSTR) >> (cpu * 4)) & 0x03) == 3) { + ret = 1; + break; + } + + mdelay(1); + } + iounmap(p); + + return ret; +} + +/* nicked from arch/arm/mach-exynos/hotplug.c */ +static inline void cpu_enter_lowpower_a15(void) +{ + unsigned int v; + + asm volatile( + " mrc p15, 0, %0, c1, c0, 0\n" + " bic %0, %0, %1\n" + " mcr p15, 0, %0, c1, c0, 0\n" + : "=&r" (v) + : "Ir" (CR_C) + : "cc"); + + flush_cache_louis(); + + asm volatile( + /* + * Turn off coherency + */ + " mrc p15, 0, %0, c1, c0, 1\n" + " bic %0, %0, %1\n" + " mcr p15, 0, %0, c1, c0, 1\n" + : "=&r" (v) + : "Ir" (0x40) + : "cc"); + + isb(); + dsb(); +} + +static int r8a73a4_do_idle_core_standby(unsigned long unused) +{ + cpu_do_idle(); /* WFI triggers Core Standby */ + return 0; +} + +static void r8a73a4_cpu_die(unsigned int cpu) +{ + void __iomem *p; + + /* hardware shutdown code running on the CPU that is being offlined */ + + /* select CPU shutdown mode */ + p = ioremap_nocache(APMU, 0x3000); + __raw_writel(3, p + CA15CPUNCR(cpu)); /* CA15 Core Standby */ + iounmap(p); + + cpu_enter_lowpower_a15(); + cpu_suspend(0, r8a73a4_do_idle_core_standby); /* really needed? */ +} + +static int r8a73a4_cpu_disable(unsigned int cpu) +{ + return 0; /* hotplug of any CPU is tested OK */ +} +#endif + struct smp_operations r8a73a4_smp_ops __initdata = { .smp_prepare_cpus = r8a73a4_smp_prepare_cpus, .smp_boot_secondary = r8a73a4_boot_secondary, +#ifdef CONFIG_HOTPLUG_CPU + .cpu_kill = r8a73a4_cpu_kill, + .cpu_die = r8a73a4_cpu_die, + .cpu_disable = r8a73a4_cpu_disable, +#endif };