From patchwork Mon Oct 12 17:41:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 7378121 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-sh@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 F0A269F1D5 for ; Mon, 12 Oct 2015 17:41:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F127120674 for ; Mon, 12 Oct 2015 17:41:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01AAE206F6 for ; Mon, 12 Oct 2015 17:41:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751467AbbJLRld (ORCPT ); Mon, 12 Oct 2015 13:41:33 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:38391 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751401AbbJLRld (ORCPT ); Mon, 12 Oct 2015 13:41:33 -0400 Received: by wieq12 with SMTP id q12so31136979wie.1 for ; Mon, 12 Oct 2015 10:41:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WPZPRafhVDuYqksAQ+GffLgTfZmzfddC5qDkBidNEVI=; b=RGkYoqd3eafpAMadDfcry7DBO0heqV6bQ75MlUtYeuo674trcaCp8BEpwcXl+0tnIe V4WJN2EFUYD5Ka+yfGnphqzNQVTuNgONvY1Mj+rRes+tTS4a2a3a19Clgm52ab0YsfNp BzOUvw40LfeR+b1W1aV+Bt++mJ/Y6AlIjOmfVRffYIZWCJQ+LkYblaFZVjnJwOKfDq0/ fJnz0lqnCpLeAGpWOc3XRcFdpsBKGDkgKBqwcG0YuGtq2M3FSAz6Mh2pwewqCwqzOOOn sq2UwcYdkRQQWZRwgl0MYc3AzF2LRn1lxCTgUNACICrMNqziEw2sOp3UKdL8NqNNwkPL tMrg== X-Gm-Message-State: ALoCoQnywGCDy22pSFQA0zA1qtpGkQ4eOpRIhyxNKOr205Sm/ADS64DhzFK3WXK0sSGotkM3RI6J X-Received: by 10.180.198.48 with SMTP id iz16mr16833376wic.63.1444671691737; Mon, 12 Oct 2015 10:41:31 -0700 (PDT) Received: from localhost.localdomain (LPoitiers-656-1-62-228.w90-63.abo.wanadoo.fr. [90.63.143.228]) by smtp.gmail.com with ESMTPSA id gw8sm50686wib.15.2015.10.12.10.41.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Oct 2015 10:41:31 -0700 (PDT) From: ahaslam@baylibre.com To: magnus.damm@gmail.com, horms@verge.net.au, geert@glider.be Cc: bcousson@baylibre.com, linux-sh@vger.kernel.org, Axel Haslam Subject: [RFC/RFT 2/6] ARM: shmobile: export apmu_power_* functions Date: Mon, 12 Oct 2015 19:41:10 +0200 Message-Id: <1444671674-19275-3-git-send-email-ahaslam@baylibre.com> X-Mailer: git-send-email 2.4.5 In-Reply-To: <1444671674-19275-1-git-send-email-ahaslam@baylibre.com> References: <1444671674-19275-1-git-send-email-ahaslam@baylibre.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Axel Haslam The on/off functions will be called from the mcpm callbacks which are implemented in a separate file. Make it simpler to use this functions by changing the parameters to take only the cpu logical number and remove the wrapper function. Signed-off-by: Axel Haslam --- arch/arm/mach-shmobile/platsmp-apmu.c | 36 ++++++++++++++++++++++------------- arch/arm/mach-shmobile/platsmp-apmu.h | 4 +++- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-shmobile/platsmp-apmu.c b/arch/arm/mach-shmobile/platsmp-apmu.c index 4e54512..d2ff5af 100644 --- a/arch/arm/mach-shmobile/platsmp-apmu.c +++ b/arch/arm/mach-shmobile/platsmp-apmu.c @@ -34,8 +34,14 @@ static struct { #define PSTR_OFFS 0x40 #define CPUNCR_OFFS(n) (0x100 + (0x10 * (n))) -static int __maybe_unused apmu_power_on(void __iomem *p, int bit) +int __maybe_unused apmu_power_on(unsigned int cpu) { + void __iomem *p = apmu_cpus[cpu].iomem; + int bit = apmu_cpus[cpu].bit; + + if (!p) + return -EINVAL; + /* request power on */ writel_relaxed(BIT(bit), p + WUPCR_OFFS); @@ -46,17 +52,28 @@ static int __maybe_unused apmu_power_on(void __iomem *p, int bit) return 0; } -static int __maybe_unused apmu_power_off(void __iomem *p, int bit) +int __maybe_unused apmu_power_off(unsigned int cpu) { + void __iomem *p = apmu_cpus[cpu].iomem; + int bit = apmu_cpus[cpu].bit; + + if (!p) + return -EINVAL; + /* request Core Standby for next WFI */ writel_relaxed(3, p + CPUNCR_OFFS(bit)); return 0; } -static int __maybe_unused apmu_power_off_poll(void __iomem *p, int bit) +int __maybe_unused apmu_power_off_poll(unsigned int cpu) { + void __iomem *p = apmu_cpus[cpu].iomem; + int bit = apmu_cpus[cpu].bit; int k; + if (!p) + return -EINVAL; + for (k = 0; k < 1000; k++) { if (((readl_relaxed(p + PSTR_OFFS) >> (bit * 4)) & 0x03) == 3) return 1; @@ -67,13 +84,6 @@ static int __maybe_unused apmu_power_off_poll(void __iomem *p, int bit) return 0; } -static int __maybe_unused apmu_wrap(int cpu, int (*fn)(void __iomem *p, int cpu)) -{ - void __iomem *p = apmu_cpus[cpu].iomem; - - return p ? fn(p, apmu_cpus[cpu].bit) : -EINVAL; -} - static void apmu_init_cpu(struct resource *res, int cpu, int bit) { if ((cpu >= ARRAY_SIZE(apmu_cpus)) || apmu_cpus[cpu].iomem) @@ -135,7 +145,7 @@ int shmobile_smp_apmu_boot_secondary(unsigned int cpu, struct task_struct *idle) /* For this particular CPU register boot vector */ shmobile_smp_hook(cpu, virt_to_phys(secondary_startup), 0); - return apmu_wrap(cpu, apmu_power_on); + return apmu_power_on(cpu); } #endif @@ -174,7 +184,7 @@ void shmobile_smp_apmu_cpu_shutdown(unsigned int cpu) { /* Select next sleep mode using the APMU */ - apmu_wrap(cpu, apmu_power_off); + apmu_power_off(cpu); /* Do ARM specific CPU shutdown */ cpu_enter_lowpower_a15(); @@ -211,7 +221,7 @@ void shmobile_smp_apmu_cpu_die(unsigned int cpu) int shmobile_smp_apmu_cpu_kill(unsigned int cpu) { - return apmu_wrap(cpu, apmu_power_off_poll); + return apmu_power_off_poll(cpu); } #endif diff --git a/arch/arm/mach-shmobile/platsmp-apmu.h b/arch/arm/mach-shmobile/platsmp-apmu.h index 76512c9..c29adf1 100644 --- a/arch/arm/mach-shmobile/platsmp-apmu.h +++ b/arch/arm/mach-shmobile/platsmp-apmu.h @@ -28,5 +28,7 @@ extern int shmobile_smp_apmu_boot_secondary(unsigned int cpu, struct task_struct *idle); extern void shmobile_smp_apmu_cpu_die(unsigned int cpu); extern int shmobile_smp_apmu_cpu_kill(unsigned int cpu); - +extern int apmu_power_on(unsigned int cpu); +extern int apmu_power_off(unsigned int cpu); +extern int apmu_power_off_poll(unsigned int cpu); #endif /* PLATSMP_APMU_H */