From patchwork Tue Feb 4 15:58:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 3577511 Return-Path: X-Original-To: patchwork-linux-spi@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 769269F2F5 for ; Tue, 4 Feb 2014 16:04:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A026D20158 for ; Tue, 4 Feb 2014 16:04:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F148120170 for ; Tue, 4 Feb 2014 16:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754808AbaBDQDl (ORCPT ); Tue, 4 Feb 2014 11:03:41 -0500 Received: from mail-lb0-f173.google.com ([209.85.217.173]:48962 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932114AbaBDP7i (ORCPT ); Tue, 4 Feb 2014 10:59:38 -0500 Received: by mail-lb0-f173.google.com with SMTP id y6so6566435lbh.18 for ; Tue, 04 Feb 2014 07:59:37 -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=Y66hI5U9geZa9eo9hJPd3/yhcmAhLayT4OvAMo2Gaww=; b=WaKGi6Dsw6OPD/vphugdx574MP+Cjrs6dXeNVfKTtiynrX5zhTs8FQK8CuGLKc2T8/ X9fXIoxxP9zd02/UyMTRDCYLPTbxfUopGsPn+ICqJnzRtA9HvHzD4MWTHtu0m1nek1Cj +nV3NuuTCNf85CVQuMQvyjI3hcB+zt4p3jp12xTdBqT+Ly7dSGwInuQ1VEO40fK9wbYr xOQWCqxoUCIsmHtyv+AYqjzJhUw6OvL8+tlJUjkKAyS0/XyuW+9HZeF0NwavLyCO7xUZ DTbQFxANUTf2mhhbXxcfuXgLRoz+r9W3+3acOFJrxMpqowefXe3ZlLxiYDfshyluJcVb ME/g== X-Gm-Message-State: ALoCoQks0aRaD/LgerlI/zGRtU2MqE3zr+BfcwzvC05S09a4dCJauX6MLZB88gSC2jTx0pYAF1fj X-Received: by 10.112.173.6 with SMTP id bg6mr17543237lbc.17.1391529576837; Tue, 04 Feb 2014 07:59:36 -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.34 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 07:59:36 -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 07/17] spi: pl022: Don't ignore power domain and amba bus at system suspend Date: Tue, 4 Feb 2014 16:58:48 +0100 Message-Id: <1391529538-21685-8-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-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@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 for CONFIG_PM, we are now able to put the device into complete low power state at system suspend. Previously only the resources controlled by the driver were put into low power state at system suspend. Both the amba bus and a potential power domain were ignored, which now isn't the case any more. Moreover, putting the device into low power state couldn't be done without first bringing it back to full power. This constraint don't exists any more. Cc: Mark Brown Signed-off-by: Ulf Hansson --- drivers/spi/spi-pl022.c | 74 +++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 70fa907..db829a1 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -2288,35 +2288,7 @@ pl022_remove(struct amba_device *adev) return 0; } -#ifdef CONFIG_PM -/* - * These two functions are used from both suspend/resume and - * the runtime counterparts to handle external resources like - * clocks, pins and regulators when going to sleep. - */ -static void pl022_suspend_resources(struct pl022 *pl022, bool runtime) -{ - clk_disable(pl022->clk); - - if (runtime) - pinctrl_pm_select_idle_state(&pl022->adev->dev); - else - pinctrl_pm_select_sleep_state(&pl022->adev->dev); -} - -static void pl022_resume_resources(struct pl022 *pl022, bool runtime) -{ - /* First go to the default state */ - pinctrl_pm_select_default_state(&pl022->adev->dev); - if (!runtime) - /* Then let's idle the pins until the next transfer happens */ - pinctrl_pm_select_idle_state(&pl022->adev->dev); - - clk_enable(pl022->clk); -} -#endif - -#ifdef CONFIG_SUSPEND +#ifdef CONFIG_PM_SLEEP static int pl022_suspend(struct device *dev) { struct pl022 *pl022 = dev_get_drvdata(dev); @@ -2328,8 +2300,23 @@ static int pl022_suspend(struct device *dev) return ret; } - pm_runtime_get_sync(dev); - pl022_suspend_resources(pl022, false); + pm_runtime_disable(dev); + + if (!pm_runtime_status_suspended(dev)) { + 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_enable(dev); + return ret; + } + + pm_runtime_set_suspended(dev); + } + + pinctrl_pm_select_sleep_state(dev); dev_dbg(dev, "suspended\n"); return 0; @@ -2338,10 +2325,19 @@ static int pl022_suspend(struct device *dev) static int pl022_resume(struct device *dev) { struct pl022 *pl022 = dev_get_drvdata(dev); - int ret; + int ret = 0; - pl022_resume_resources(pl022, false); - pm_runtime_put(dev); + 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); + + if (ret) + dev_err(dev, "problem resuming\n"); + else + pm_runtime_set_active(dev); + + pm_runtime_enable(dev); /* Start the queue running */ ret = spi_master_resume(pl022->master); @@ -2352,14 +2348,16 @@ static int pl022_resume(struct device *dev) return ret; } -#endif /* CONFIG_PM */ +#endif #ifdef CONFIG_PM static int pl022_runtime_suspend(struct device *dev) { struct pl022 *pl022 = dev_get_drvdata(dev); - pl022_suspend_resources(pl022, true); + clk_disable(pl022->clk); + pinctrl_pm_select_idle_state(dev); + return 0; } @@ -2367,7 +2365,9 @@ static int pl022_runtime_resume(struct device *dev) { struct pl022 *pl022 = dev_get_drvdata(dev); - pl022_resume_resources(pl022, true); + pinctrl_pm_select_default_state(dev); + clk_enable(pl022->clk); + return 0; } #endif