From patchwork Mon Aug 14 21:58:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9900213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A188E602BA for ; Mon, 14 Aug 2017 22:00:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 934F22874C for ; Mon, 14 Aug 2017 22:00:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86E6E28758; Mon, 14 Aug 2017 22:00:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DEA032874C for ; Mon, 14 Aug 2017 22:00:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=F5vfKx1VOsZlxPDn6OcLV+AzxlwBBXn+48hHFWeUng0=; b=WECoHBEDqVxRaSAtP/BE46AbeN ViqNJCbXiepO/nJClOOYz8bgytikMzFvqKfK1cO7YMoLHp0AYf09eE91y10QjjDl0IhxYZUO6m1+e X6nF43lmuJ030WoAvaUmskF2ujhB2UTUoWOanq5q01bTqYw7Ms/VLB5tHTMQvj/kICR2fdn3bGA4y jXQNt8MPffh34XWejsRcYoPKNgd+bNwarI+m1OrThysONPLevytJUIRRTI8bKEOOMi4QNNHrsQHy9 DIE2Kfc3P8hEBRmkWDgqntdVFmLzlcFleOSK/bFieJQpyhgSDCMvEViVvKD8zqJbrFdZFb0DP4sKb JVXf41zw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dhNPE-00021H-1S; Mon, 14 Aug 2017 22:00:16 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dhNOf-0000lS-Ef; Mon, 14 Aug 2017 21:59:43 +0000 Received: by mail-wr0-x243.google.com with SMTP id u89so2009532wrc.2; Mon, 14 Aug 2017 14:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=82l/L/J8GeA65i3/WeCCLc1mNWO9YuFkZtCe4yW2RvM=; b=KAZYF5mIYRkAcCaVmSNExRIoRTD+IZC2KUi4GPV81jimZhBPN+gOWNgN1uEuuPmClR R9gZEKH6ngvZlSzWtwHTS8s8WNL8QM1mDpzd+aaMKyD73hNCgxIcpCEw+k+D5zROIPoK rMMPHSQehAwQiq2ZAQt1BRC7bum3yDSW8AYAKgORAaOtxmmxWlU3iOB/JBe84wKL9ECL DxzA1PKwYBXHLPYaT8uItemBmpHu3wTUzY/4EOBQQl1N143RkG1ffKfXItnj3pmrm0d3 9V0B22DDq4a0+BeCfBGDD+j+4HO4IiBiL1T2l1qgfqcNLxjnbnaGR0UndFLoPBYF9kmg 7KWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=82l/L/J8GeA65i3/WeCCLc1mNWO9YuFkZtCe4yW2RvM=; b=P9U2LTN8y/JEtu/NH91gST1djUu+n6WaLzLehhh7r9eOU7201I2JKe/IdMnYpj40UH eksB4QSGdm3a4zuUP+bfoIgSgX6WOH8xJ3lEyiH8bgy/qV8LkCrwdM+ozF1Hk3DzJ7cE zz0p9S9cFNn5+p/D4/ovtjyxsouvA2wgVF/3Pw2akEov67I4rW32uHXAPC9Bdgbf3oJL cIIL2cHy31brRICchPe8lqr9FZPs/s3b9aLd/aJ2LBW7rwASTL/BVn8hH4DkRxZ9vsuT K4dDZ9b9xEIR9py55JGEITKR6F5kIMTzYk7muOKoE8jG/Om/RKZClsoWL3xJQh3OAyP9 IGRg== X-Gm-Message-State: AHYfb5jSTQrjd5F1B473HensXWZfGyu0cZSdyd7HzWCdW9X0O3qsLSQi /YDLBPag0M5mIfFzjYA= X-Received: by 10.223.177.152 with SMTP id q24mr938032wra.290.1502747958988; Mon, 14 Aug 2017 14:59:18 -0700 (PDT) Received: from blackbox.darklights.net (p200300DCD3C22104BDB11DC365F26026.dip0.t-ipconnect.de. [2003:dc:d3c2:2104:bdb1:1dc3:65f2:6026]) by smtp.googlemail.com with ESMTPSA id a21sm2764441wrc.64.2017.08.14.14.59.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Aug 2017 14:59:18 -0700 (PDT) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, khilman@baylibre.com, carlo@caione.org, linux@armlinux.org.uk Subject: [PATCH v6 2/6] ARM: smp_scu: add a helper for powering on a specific CPU Date: Mon, 14 Aug 2017 23:58:56 +0200 Message-Id: <20170814215900.1032-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170814215900.1032-1-martin.blumenstingl@googlemail.com> References: <20170814215900.1032-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170814_145941_671312_A03F8F16 X-CRM114-Status: GOOD ( 10.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, f.fainelli@gmail.com, arnd@arndb.de, Martin Blumenstingl , robh+dt@kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To boot the secondary CPUs on the Amlogic Meson8/Meson8m2 (Cortex-A9) and Meson8b (Cortex-A5) SoCs we have to enable SCU mode SCU_PM_NORMAL, otherwise the secondary cores will not start. This patch adds a scu_cpu_power_enable() function which can be used to enable SCU_PM_NORMAL for a specific (logical) CPU. An internal helper function is also created, to avoid code duplication with scu_power_mode(). Signed-off-by: Martin Blumenstingl --- arch/arm/include/asm/smp_scu.h | 6 ++++++ arch/arm/kernel/smp_scu.c | 35 +++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/arch/arm/include/asm/smp_scu.h b/arch/arm/include/asm/smp_scu.h index bfe163c40024..11e636f33ed9 100644 --- a/arch/arm/include/asm/smp_scu.h +++ b/arch/arm/include/asm/smp_scu.h @@ -26,6 +26,7 @@ static inline unsigned long scu_a9_get_base(void) #ifdef CONFIG_HAVE_ARM_SCU unsigned int scu_get_core_count(void __iomem *); int scu_power_mode(void __iomem *, unsigned int); +int scu_cpu_power_enable(void __iomem *, unsigned int); #else static inline unsigned int scu_get_core_count(void __iomem *scu_base) { @@ -35,6 +36,11 @@ static inline int scu_power_mode(void __iomem *scu_base, unsigned int mode) { return -EINVAL; } +static inline int scu_cpu_power_enable(void __iomem *scu_base, + unsigned int mode) +{ + return -EINVAL; +} #endif #if defined(CONFIG_SMP) && defined(CONFIG_HAVE_ARM_SCU) diff --git a/arch/arm/kernel/smp_scu.c b/arch/arm/kernel/smp_scu.c index 72f9241ad5db..1d549c16b5fc 100644 --- a/arch/arm/kernel/smp_scu.c +++ b/arch/arm/kernel/smp_scu.c @@ -72,18 +72,12 @@ void scu_enable(void __iomem *scu_base) } #endif -/* - * Set the executing CPUs power mode as defined. This will be in - * preparation for it executing a WFI instruction. - * - * This function must be called with preemption disabled, and as it - * 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) +static int scu_set_power_mode_internal(void __iomem *scu_base, + unsigned int logical_cpu, + unsigned int mode) { unsigned int val; - int cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(smp_processor_id()), 0); + int cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(logical_cpu), 0); if (mode > 3 || mode == 1 || cpu > 3) return -EINVAL; @@ -94,3 +88,24 @@ int scu_power_mode(void __iomem *scu_base, unsigned int mode) return 0; } + +/* + * Set the executing CPUs power mode as defined. This will be in + * preparation for it executing a WFI instruction. + * + * This function must be called with preemption disabled, and as it + * 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) +{ + return scu_set_power_mode_internal(scu_base, smp_processor_id(), mode); +} + +/* + * Set the given (logical) CPU's power mode to SCU_PM_NORMAL. + */ +int scu_cpu_power_enable(void __iomem *scu_base, unsigned int cpu) +{ + return scu_set_power_mode_internal(scu_base, cpu, SCU_PM_NORMAL); +}