From patchwork Tue Feb 4 15:58:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 3577131 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BC7719F383 for ; Tue, 4 Feb 2014 15:59:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA4FA2017B for ; Tue, 4 Feb 2014 15:59:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 65CBE20181 for ; Tue, 4 Feb 2014 15:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752994AbaBDP7j (ORCPT ); Tue, 4 Feb 2014 10:59:39 -0500 Received: from mail-lb0-f179.google.com ([209.85.217.179]:40867 "EHLO mail-lb0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754617AbaBDP7c (ORCPT ); Tue, 4 Feb 2014 10:59:32 -0500 Received: by mail-lb0-f179.google.com with SMTP id l4so6559447lbv.38 for ; Tue, 04 Feb 2014 07:59:31 -0800 (PST) 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=3o7pnPeRwtX1hSM3LDtivdH6Fs2RfEWP5EimO2a4jbg=; b=KE5xMFApHGtdu1O0txCjg0wX3K8A19xxE21jv2GWt5HL2hH50SFzyCNxut/49x7xoR lrqYPxv2L1rSDUDUeLqbjxrzomJWwsPS0o/Eg1APJE4ILO9R4I7bq1bBBR7dAXL/STEQ dFeFejBGmoHBmyLq1QMfaukPr+B9QMTuH1aBZ+if0ewgbghaOQ8Edla2OvfZ7oDOxhr8 LJj5lMjRqsQKiwjXXKLNxeJOt1DXwMXu7BCAm68/5Dn7pNX+NyABPxC00T9dcwoet6d+ 61UHzRWi/Wzijpb/1DD2z2LLN6Q17jP4G+U0cCE1MGkWNLQbmCI9A2Z44Wu7Y4jN9yhh PByQ== X-Gm-Message-State: ALoCoQlGj4XKzANe3Gfh5wgqwSCZ2w+fBENruBP5nW6PiiDH4Taad5FFZKR8qG7KzpPGCF3JVcxL X-Received: by 10.112.126.164 with SMTP id mz4mr1884793lbb.52.1391529571421; Tue, 04 Feb 2014 07:59:31 -0800 (PST) Received: from localhost.localdomain (host-95-199-220-119.mobileonline.telia.com. [95.199.220.119]) by mx.google.com with ESMTPSA id dm8sm35906603lad.7.2014.02.04.07.59.28 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 07:59:30 -0800 (PST) From: Ulf Hansson To: Russell King , linux-arm-kernel@lists.infradead.org Cc: Alessandro Rubini , Linus Walleij , Wolfram Sang , Chris Ball , Mark Brown , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, linux-mmc@vger.kernel.org, Ulf Hansson Subject: [PATCH 05/17] mmc: mmci: Put the device into low power state at system suspend Date: Tue, 4 Feb 2014 16:58:46 +0100 Message-Id: <1391529538-21685-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391529538-21685-1-git-send-email-ulf.hansson@linaro.org> References: <1391529538-21685-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Due to the available runtime PM callbacks, we are now able to put our device into low power state at system suspend. Earlier we could not accomplish this without trusting a power domain for the device to take care of it. Now we are able to cope with scenarios both with and without a power domain. Cc: Russell King Signed-off-by: Ulf Hansson --- drivers/mmc/host/mmci.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index c88da1c..074e0cb 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1723,33 +1723,38 @@ static int mmci_remove(struct amba_device *dev) return 0; } -#ifdef CONFIG_SUSPEND -static int mmci_suspend(struct device *dev) +#ifdef CONFIG_PM_SLEEP +static int mmci_suspend_late(struct device *dev) { - struct amba_device *adev = to_amba_device(dev); - struct mmc_host *mmc = amba_get_drvdata(adev); + int ret = 0; - if (mmc) { - struct mmci_host *host = mmc_priv(mmc); - pm_runtime_get_sync(dev); - writel(0, host->base + MMCIMASK0); - } + if (pm_runtime_status_suspended(dev)) + return 0; - return 0; + if (dev->pm_domain && dev->pm_domain->ops.runtime_suspend) + ret = dev->pm_domain->ops.runtime_suspend(dev); + else + ret = dev->bus->pm->runtime_suspend(dev); + + if (!ret) + pm_runtime_set_suspended(dev); + + return ret; } -static int mmci_resume(struct device *dev) +static int mmci_resume_early(struct device *dev) { - struct amba_device *adev = to_amba_device(dev); - struct mmc_host *mmc = amba_get_drvdata(adev); + int ret = 0; - if (mmc) { - struct mmci_host *host = mmc_priv(mmc); - writel(MCI_IRQENABLE, host->base + MMCIMASK0); - pm_runtime_put(dev); - } + if (pm_runtime_status_suspended(dev)) + return 0; - return 0; + if (dev->pm_domain && dev->pm_domain->ops.runtime_resume) + ret = dev->pm_domain->ops.runtime_resume(dev); + else + ret = dev->bus->pm->runtime_resume(dev); + + return ret; } #endif @@ -1820,7 +1825,7 @@ static int mmci_runtime_resume(struct device *dev) #endif static const struct dev_pm_ops mmci_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(mmci_suspend, mmci_resume) + SET_LATE_SYSTEM_SLEEP_PM_OPS(mmci_suspend_late, mmci_resume_early) SET_PM_RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL) };