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: 24125 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 69D28202FA for ; Tue, 4 Feb 2014 16:05:56 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf23094874pab.3 for ; Tue, 04 Feb 2014 08:05:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=3o7pnPeRwtX1hSM3LDtivdH6Fs2RfEWP5EimO2a4jbg=; b=i0AaAHGvLkLLIjoofS1WMZAU/D/gKIZZZS1ccSE6dY8Oe0Lxy+ja3UzMxV/7RVBs1N KL0D7nHjBpZAFKHM1+SvsD9mvilNsmzJs6dUzOW28iX2VZNWzaDPxYdgiPLtDmHg1jxm 1ff7hgTPSOcQJfHdyvzU2iIizHqMkQ8HuPbra0GyQkIPvC3MQpEzPWDOQdziNi2+r4bK 6rF72gziTSBU0uIkxJWMa/32K6pyTUUyaEBiWou5rnrN20sNJmVEn7dxJ7WsBf+18BUg 1st/zpol0/i/YxSgUj0AU20Rz+aDL/CL9bz/E/JdD82KRs5OY4SF36wWF2QEILHCQh+Z RYmw== X-Gm-Message-State: ALoCoQkp7lCh2dpR1C7i0CggRY9U1cB3r6k7B4MTg70gdXcvlcoHsNMsnGYx+bb5u+qWgsdhK1xK X-Received: by 10.66.182.137 with SMTP id ee9mr16153323pac.0.1391529573588; Tue, 04 Feb 2014 07:59:33 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.24.49 with SMTP id 46ls2356954qgq.21.gmail; Tue, 04 Feb 2014 07:59:33 -0800 (PST) X-Received: by 10.58.200.229 with SMTP id jv5mr1393792vec.15.1391529573473; Tue, 04 Feb 2014 07:59:33 -0800 (PST) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by mx.google.com with ESMTPS id sl9si8315917veb.21.2014.02.04.07.59.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 07:59:33 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.47; Received: by mail-vb0-f47.google.com with SMTP id p6so5783918vbe.6 for ; Tue, 04 Feb 2014 07:59:33 -0800 (PST) X-Received: by 10.58.90.202 with SMTP id by10mr32202032veb.6.1391529573404; Tue, 04 Feb 2014 07:59:33 -0800 (PST) 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.220.174.196 with SMTP id u4csp245352vcz; Tue, 4 Feb 2014 07:59:32 -0800 (PST) X-Received: by 10.112.64.37 with SMTP id l5mr2021181lbs.49.1391529572130; Tue, 04 Feb 2014 07:59:32 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx.google.com with ESMTPS id kv5si12970674lbc.36.2014.02.04.07.59.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 07:59:32 -0800 (PST) Received-SPF: neutral (google.com: 209.85.217.178 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id u14so6563861lbd.37 for ; Tue, 04 Feb 2014 07:59:31 -0800 (PST) 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> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.47 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: , 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) };