From patchwork Thu May 14 06:10:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 6402821 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C06009F374 for ; Thu, 14 May 2015 06:15:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F1845202B4 for ; Thu, 14 May 2015 06:15:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14033203DA for ; Thu, 14 May 2015 06:15:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YsmOL-00033U-4r; Thu, 14 May 2015 06:13:09 +0000 Received: from smtp.csie.ntu.edu.tw ([140.112.30.61]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YsmMP-0001gv-Dp for linux-arm-kernel@lists.infradead.org; Thu, 14 May 2015 06:11:10 +0000 Received: from mirror2.csie.ntu.edu.tw (mirror2.csie.ntu.edu.tw [140.112.30.76]) (Authenticated sender: b93043) by smtp.csie.ntu.edu.tw (Postfix) with ESMTPSA id C08DB203C8; Thu, 14 May 2015 14:10:21 +0800 (CST) Received: by mirror2.csie.ntu.edu.tw (Postfix, from userid 1000) id A56F05F8A3; Thu, 14 May 2015 14:10:21 +0800 (CST) From: Chen-Yu Tsai To: Maxime Ripard Subject: [RFC 6/7] ARM: sunxi: mcpm: Support cpu0 hotplug Date: Thu, 14 May 2015 14:10:10 +0800 Message-Id: <1431583811-25780-7-git-send-email-wens@csie.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1431583811-25780-1-git-send-email-wens@csie.org> References: <1431583811-25780-1-git-send-email-wens@csie.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150513_231109_757154_827FE80F X-CRM114-Status: GOOD ( 11.31 ) X-Spam-Score: -2.3 (--) Cc: Nicolas Pitre , linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org, Chen-Yu Tsai , Dave Martin , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This sets the flags that makes BROM jump execution on the primary core (cpu0)to the SMP software entry code. Signed-off-by: Chen-Yu Tsai --- arch/arm/mach-sunxi/mcpm.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/arch/arm/mach-sunxi/mcpm.c b/arch/arm/mach-sunxi/mcpm.c index 5ea4b488890c..e74e8aab2560 100644 --- a/arch/arm/mach-sunxi/mcpm.c +++ b/arch/arm/mach-sunxi/mcpm.c @@ -58,8 +58,12 @@ #define PRCM_PWR_SWITCH_REG(c, cpu) (0x140 + 0x10 * (c) + 0x4 * (cpu)) #define PRCM_CPU_SOFT_ENTRY_REG 0x164 +#define CPU0_SUPPORT_HOTPLUG_MAGIC0 0xFA50392F +#define CPU0_SUPPORT_HOTPLUG_MAGIC1 0x790DCA3A + static void __iomem *cpucfg_base; static void __iomem *prcm_base; +static void __iomem *sram_b_smp_base; static int sunxi_cpu_power_switch_set(unsigned int cpu, unsigned int cluster, bool enable) @@ -93,6 +97,17 @@ static int sunxi_cpu_power_switch_set(unsigned int cpu, unsigned int cluster, return 0; } +static void sunxi_cpu0_hotplug_support_set(bool enable) +{ + if (enable) { + writel(CPU0_SUPPORT_HOTPLUG_MAGIC0, sram_b_smp_base); + writel(CPU0_SUPPORT_HOTPLUG_MAGIC1, sram_b_smp_base + 0x4); + } else { + writel(0x0, sram_b_smp_base); + writel(0x0, sram_b_smp_base + 0x4); + } +} + static int sunxi_cpu_powerup(unsigned int cpu, unsigned int cluster) { u32 reg; @@ -101,6 +116,10 @@ static int sunxi_cpu_powerup(unsigned int cpu, unsigned int cluster) if (cpu >= SUNXI_CPUS_PER_CLUSTER || cluster >= SUNXI_NR_CLUSTERS) return -EINVAL; + /* Set hotplug support magic flags for cpu0 */ + if (cluster == 0 && cpu == 0) + sunxi_cpu0_hotplug_support_set(true); + /* assert processor power-on reset */ reg = readl(prcm_base + PRCM_CPU_PO_RST_CTRL(cluster)); reg &= ~PRCM_CPU_PO_RST_CTRL_CORE(cpu); @@ -441,6 +460,19 @@ static int __init sunxi_mcpm_init(void) return -ENOMEM; } + node = of_find_compatible_node(NULL, NULL, + "allwinner,sun9i-smp-sram"); + if (!node) + return -ENODEV; + + sram_b_smp_base = of_iomap(node, 0); + of_node_put(node); + if (!sram_b_smp_base) { + pr_err("%s: failed to map secure SRAM\n", __func__); + iounmap(sram_b_smp_base); + return -ENOMEM; + } + ret = mcpm_platform_register(&sunxi_power_ops); if (!ret) ret = mcpm_sync_init(sunxi_power_up_setup);