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: 24114 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 10742202FA for ; Tue, 4 Feb 2014 15:59:39 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id m1sf38590088oag.9 for ; Tue, 04 Feb 2014 07:59:38 -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=Y66hI5U9geZa9eo9hJPd3/yhcmAhLayT4OvAMo2Gaww=; b=H3i+awnhkceHwXKOYK4+U/PTGBLzYXs+oDU4RxL2RCyVA/UO6zURy0yzU/Nn4roLkj AKOsJEoOpoMOAMG+UihuFgR/Clmwk5VmEr3IdPTsF8t7dWb23bWBoTbUCBF1LXNDm/Gp sqLt6kbrQoCIQZgrJZ6y3nnFrZ6IZwqjyu9aaK/JF0c4g2vY1x3C2QYOqoi5b1PcTa6h k9UaSRfO1ShijHlbTmYMX6oStsiSB4NgpRTI4v4V0+4ACCNXVUsAjkScXDv/0tOyFv+W 3z8Sq3nA62Zt+1/rWggKvkM6I8zRibpe02Oq9pSGgu2RvapXU0UaIEVZkh8056j/lx4q NlFQ== X-Gm-Message-State: ALoCoQk3lTy/fgjQWrNp8KXlgKQikBtAxWlTsdyaIWG7KoZxvB+ofNvdsYnzuBAgfcUBkZReNUWD X-Received: by 10.50.153.69 with SMTP id ve5mr8120326igb.7.1391529578865; Tue, 04 Feb 2014 07:59:38 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.52 with SMTP id j49ls2344054qge.7.gmail; Tue, 04 Feb 2014 07:59:38 -0800 (PST) X-Received: by 10.58.155.162 with SMTP id vx2mr369306veb.46.1391529578782; Tue, 04 Feb 2014 07:59:38 -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 w1si8305700vet.125.2014.02.04.07.59.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 07:59:38 -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 p6so5804968vbe.20 for ; Tue, 04 Feb 2014 07:59:38 -0800 (PST) X-Received: by 10.58.209.36 with SMTP id mj4mr372501vec.47.1391529578676; Tue, 04 Feb 2014 07:59:38 -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 u4csp245363vcz; Tue, 4 Feb 2014 07:59:37 -0800 (PST) X-Received: by 10.152.6.132 with SMTP id b4mr838623laa.64.1391529577443; Tue, 04 Feb 2014 07:59:37 -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 ap10si12971836lac.5.2014.02.04.07.59.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Feb 2014 07:59:37 -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 u14so6563972lbd.37 for ; Tue, 04 Feb 2014 07:59:36 -0800 (PST) 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> 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 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