From patchwork Fri Jun 7 06:39:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 17666 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9655725DEA for ; Fri, 7 Jun 2013 06:45:14 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id 10sf816689lbf.3 for ; Thu, 06 Jun 2013 23:45:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-transfer-encoding; bh=mAcYJsWuMZ5TBg8af3iV0xF61j6bvJRqoTxAHtuE+JM=; b=k4++2bJvJizksQQ3ycxB2YBdsbIIPYlzcTKWSqbWwwGzGlq6Mtig/AAbQq5juXx3b+ 5zZbq2eqkfmAlyf8pRmtF+eIAZW4J3ToHwtNBTDfGaYN07JNIXYIzs/m/7bBP0bYczOR OSFzKkznEpBP4Ro6YuCIKKyxmNQ52WQgTOdYboivgtbkYcA/z0rBqkkxWfgXtzcCwwyK Jep7YztHOiJerX7JALTKwB/tL3ywqbylP/ko9rw0Rae+kiXDv4UpIPnzVMm8AsfKNiaX WkD8zWpDmh4cKZ+53mmKS62pHo0yAT+ybTGE6lFm9OTs/CptBZa8Gb3fhmfGseeeJB4x hbtA== X-Received: by 10.180.185.115 with SMTP id fb19mr303316wic.0.1370587513109; Thu, 06 Jun 2013 23:45:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.36.77 with SMTP id o13ls104908wij.22.gmail; Thu, 06 Jun 2013 23:45:12 -0700 (PDT) X-Received: by 10.194.20.97 with SMTP id m1mr5887397wje.31.1370587512919; Thu, 06 Jun 2013 23:45:12 -0700 (PDT) Received: from mail-ve0-x22f.google.com (mail-ve0-x22f.google.com [2607:f8b0:400c:c01::22f]) by mx.google.com with ESMTPS id hm7si9016076wib.13.2013.06.06.23.45.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Jun 2013 23:45:12 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22f is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22f; Received: by mail-ve0-f175.google.com with SMTP id da11so2766358veb.20 for ; Thu, 06 Jun 2013 23:45:11 -0700 (PDT) X-Received: by 10.58.106.77 with SMTP id gs13mr483851veb.22.1370587157444; Thu, 06 Jun 2013 23:39:17 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.10.206 with SMTP id pb14csp100487vcb; Thu, 6 Jun 2013 23:39:17 -0700 (PDT) X-Received: by 10.229.69.34 with SMTP id x34mr14672050qci.75.1370587156459; Thu, 06 Jun 2013 23:39:16 -0700 (PDT) Received: from relais.videotron.ca (relais.videotron.ca. [24.201.245.36]) by mx.google.com with ESMTP id w8si1223844qag.118.2013.06.06.23.39.16 for ; Thu, 06 Jun 2013 23:39:16 -0700 (PDT) Received-SPF: neutral (google.com: 24.201.245.36 is neither permitted nor denied by best guess record for domain of nicolas.pitre@linaro.org) client-ip=24.201.245.36; Received: from yoda.home ([70.83.209.44]) by VL-VM-MR005.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0MO0007FVFTF6S20@VL-VM-MR005.ip.videotron.ca> for patches@linaro.org; Fri, 07 Jun 2013 02:39:15 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id A38F32DA053F; Fri, 07 Jun 2013 02:39:15 -0400 (EDT) From: Nicolas Pitre To: linux-arm-kernel@lists.infradead.org Cc: dave.martin@arm.com, lorenzo.pieralisi@arm.com, pawel.moll@arm.com, patches@linaro.org Subject: [PATCH 2/2] ARM: vexpress/TC2: implement PM suspend method Date: Fri, 07 Jun 2013 02:39:12 -0400 Message-id: <1370587152-4630-3-git-send-email-nicolas.pitre@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-reply-to: <1370587152-4630-1-git-send-email-nicolas.pitre@linaro.org> References: <1370587152-4630-1-git-send-email-nicolas.pitre@linaro.org> X-Gm-Message-State: ALoCoQlBHBTaHiIqy79Ec4c0mm8Gqp6IWbX7N77jpjLNDUo3mm0nlfuyp62I3T2J93olteNFzKmM X-Original-Sender: nicolas.pitre@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22f is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-transfer-encoding: 7BIT From: Nicolas Pitre This is simplistic for the moment as the expected residency is used to prevent the shutting down of L2 and the cluster if the residency for the last man is lower than 5 ms. To make this right, the shutdown latency for each CPU would need to be recorded and taken into account. On a suspend, the firmware mailbox address has to be set prior entering low power mode. Signed-off-by: Nicolas Pitre --- arch/arm/mach-vexpress/tc2_pm.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-vexpress/tc2_pm.c b/arch/arm/mach-vexpress/tc2_pm.c index a3ea524372..7901528566 100644 --- a/arch/arm/mach-vexpress/tc2_pm.c +++ b/arch/arm/mach-vexpress/tc2_pm.c @@ -79,7 +79,7 @@ static int tc2_pm_power_up(unsigned int cpu, unsigned int cluster) return 0; } -static void tc2_pm_power_down(void) +static void tc2_pm_down(u64 residency) { unsigned int mpidr, cpu, cluster; bool last_man = false, skip_wfi = false; @@ -100,7 +100,8 @@ static void tc2_pm_power_down(void) vexpress_spc_set_cpu_wakeup_irq(cpu, cluster, 1); if (!tc2_pm_use_count[0][cluster] && !tc2_pm_use_count[1][cluster] && - !tc2_pm_use_count[2][cluster]) { + !tc2_pm_use_count[2][cluster] && + (!residency || residency > 5000)) { vexpress_spc_powerdown_enable(cluster, 1); vexpress_spc_set_global_wakeup_intr(1); last_man = true; @@ -161,6 +162,23 @@ static void tc2_pm_power_down(void) /* Not dead at this point? Let our caller cope. */ } +static void tc2_pm_power_down(void) +{ + tc2_pm_down(0); +} + +static void tc2_pm_suspend(u64 residency) +{ + unsigned int mpidr, cpu, cluster; + + mpidr = read_cpuid_mpidr(); + cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0); + cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1); + vexpress_spc_write_resume_reg(cluster, cpu, + virt_to_phys(mcpm_entry_point)); + tc2_pm_down(residency); +} + static void tc2_pm_powered_up(void) { unsigned int mpidr, cpu, cluster; @@ -196,6 +214,7 @@ static void tc2_pm_powered_up(void) static const struct mcpm_platform_ops tc2_pm_power_ops = { .power_up = tc2_pm_power_up, .power_down = tc2_pm_power_down, + .suspend = tc2_pm_suspend, .powered_up = tc2_pm_powered_up, };