From patchwork Sun Sep 17 16:45:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9954925 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 64E2C60208 for ; Sun, 17 Sep 2017 16:47:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5498D286DD for ; Sun, 17 Sep 2017 16:47:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4925A289B9; Sun, 17 Sep 2017 16:47:52 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED 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 9C2D0286DD for ; Sun, 17 Sep 2017 16:47:43 +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=OSbEZvx07RVwmYyxF5OzuVYoZ2Ag7byRdRgey6eXOtY=; b=iHMK+EwZaWtlyRtMMC7mgYrOqT dtd/IzzZJ3FvH6O9xeWq58dTm2wy1oRDZfmjEvWOmZkR/VxKC/yyoB3rSAfK05ecUhXPshDbWHUa5 /bMOzpYnwSOiIo5WKtiH6sxSjttvfcERHNKb1Oqq/jdf6k11FH3Zvt3lYy9C1HT2/UxhftBjoaKBd dZDFihgzOv1fZfyvAWS63leGGJA7i5Xuw4J0J8NxwJqkSoHHyAQm6IqH3oiU0kZ0+cHYCppM6q3GM 2WLohyMIWRlK5Xq8qZLanEbfRrK1/CH06c4OYQtV70nryptmGPp4eYrqaNrIVRY7GYFKaxDEjxPnS 1cFduchg==; 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 1dtciw-0006JR-1N; Sun, 17 Sep 2017 16:47:14 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dtchy-0005VO-Ri; Sun, 17 Sep 2017 16:46:28 +0000 Received: by mail-wm0-x244.google.com with SMTP id x17so6730633wmd.5; Sun, 17 Sep 2017 09:45:54 -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=bJffqpgVH77pVk3d76NR+jcdn8XStOssDlqZZt2wKDA=; b=sKxkmaROcc0vQP8G9gkchXy/3u9N1fk4S31M3rN2qjcRzkotKFIXkw+smdh/0dPKbG GHwVfmV8exIi/WmDEoO2hYIXgIkC7hZwxJzx+6ojR6MYiDtI2y2pbTx4VxLTxOX5QMyA keAlYDZcGzk//X1YWJZ1GpHnLJ+cOeM0KzELOELIumxRX49eCsPba10veIWXRfX+krtC JR8v+4YLPJ+j2AaPJSdrxCcWk15feWs8FJXOqOevWvEaplMdUAqyoyxNBLP7FgIHLryT Q6N3UIagVEQahT9r3xL6UR29eCttGoV8MIQ0VmiHH+7iKi4l1DEqC++5w6W9wUr2pONF AJkQ== 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=bJffqpgVH77pVk3d76NR+jcdn8XStOssDlqZZt2wKDA=; b=mM9OYueLU5gp49YVj6D5h9ZdTTcVpBugA12cBBaKBiCqf8hgDkGjkBvEK9boify3av h6TV4hDee6kZ73Ylp9qDdeRPFui+Xo3rv1/akEtk6c2ov3WxLNtw0HafZmL22dXYraHW xhHe0mGTu7ujcGDbqco4BzuninNEFGaoe0bCgeQ2kkKcFvIeF/SHNkbDP+76qemuusEt D1X4o+7lGThj99wZFMSniJ4EqDUihDSZgcnmPOauCfuazTEuUAbASiBzy3ZEZim8G1j7 rOUW29tGlUgI973x4zUURgnAOX1rqQrg3+SSw4NCAUOWSPpaQPW3q2w3VfgiYaQVQKoW 2kNg== X-Gm-Message-State: AHPjjUj5MVolyNwan3IBG6V1VRYdzzP25CFVWpfMclchXvD3wCJZr5so MNb70mK8Iw+udBf9mzY= X-Google-Smtp-Source: AOwi7QAIblaajR1cwFyWmtH7VzpbWAR4lG+qqeV6rJtfSM7xj8w08QQkmv4MzQcO725qRkDRTP6ibw== X-Received: by 10.28.66.202 with SMTP id k71mr7062304wmi.19.1505666752350; Sun, 17 Sep 2017 09:45:52 -0700 (PDT) Received: from blackbox.darklights.net (p200300DCD3D04A042D42E2FA95194724.dip0.t-ipconnect.de. [2003:dc:d3d0:4a04:2d42:e2fa:9519:4724]) by smtp.googlemail.com with ESMTPSA id p59sm6323799wrc.75.2017.09.17.09.45.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Sep 2017 09:45:51 -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 v7 2/6] ARM: smp_scu: add a helper for powering on a specific CPU Date: Sun, 17 Sep 2017 18:45:19 +0200 Message-Id: <20170917164523.6970-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170917164523.6970-1-martin.blumenstingl@googlemail.com> References: <20170917164523.6970-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170917_094615_988131_F879F536 X-CRM114-Status: GOOD ( 10.86 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=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 Acked-by: Russell King --- 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 5983f6bc62d5..4c47bdfd4f61 100644 --- a/arch/arm/include/asm/smp_scu.h +++ b/arch/arm/include/asm/smp_scu.h @@ -27,6 +27,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) { @@ -36,6 +37,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); +}