From patchwork Wed Feb 19 14:33:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 24962 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 92FE02054E for ; Wed, 19 Feb 2014 14:33:54 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id le5sf656204vcb.7 for ; Wed, 19 Feb 2014 06:33:54 -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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=EUoaVoZCu9r6vME2MsolcWV0Td/a0B+6/BRAMaxd/wA=; b=U3dsvQkEVK05n6qvPi6nsXmzBHs84rCr+R2lhiqmlQRpgPCjMFdFQ5H/ISLEO8KyZC siqf99TfzsP3lti2SHEnRTkgJmRK3mHH/bcvkK4iimiaiI2qoLiEUNgq6ZZFPrd+dYIy LdNsQL7dEJRVu2/uv3o/1TJ9EvdO4wTbcC4cTOBfZJwrw8BXpvjWJyNn3NexkBPfbSsI UBQPIYSKlryzxneAEfDsfeUyz6DcSnGc/GJdl/n5XmN3RZiZhyENJyPmJfKxTNCEvuNG 88KUKOJy5Iftq21wz0k5QN4mr7+UD5QBqTkUmEfySTZRXCGkX3BHhIGX03Pa3Ynr6YmJ U7Fw== X-Gm-Message-State: ALoCoQkbVC5hqi0jF6AbBr3wSYJK3wymb87/Js6Dmjyat2zsg7BDLwbgqCpPqawx6Uxif++IMnz3 X-Received: by 10.52.187.41 with SMTP id fp9mr13460218vdc.5.1392820434367; Wed, 19 Feb 2014 06:33:54 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.69 with SMTP id n63ls114888qge.96.gmail; Wed, 19 Feb 2014 06:33:54 -0800 (PST) X-Received: by 10.52.109.3 with SMTP id ho3mr532473vdb.76.1392820434279; Wed, 19 Feb 2014 06:33:54 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id tt2si144512vdc.48.2014.02.19.06.33.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Feb 2014 06:33:54 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ks9so447005vcb.39 for ; Wed, 19 Feb 2014 06:33:54 -0800 (PST) X-Received: by 10.220.192.71 with SMTP id dp7mr1981527vcb.45.1392820434190; Wed, 19 Feb 2014 06:33:54 -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 u4csp301984vcz; Wed, 19 Feb 2014 06:33:53 -0800 (PST) X-Received: by 10.152.88.82 with SMTP id be18mr26148902lab.3.1392820432932; Wed, 19 Feb 2014 06:33:52 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) by mx.google.com with ESMTPS id pc5si777995lbb.90.2014.02.19.06.33.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Feb 2014 06:33:52 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.52 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id c6so339045lan.39 for ; Wed, 19 Feb 2014 06:33:52 -0800 (PST) X-Received: by 10.152.201.197 with SMTP id kc5mr652476lac.77.1392820432223; Wed, 19 Feb 2014 06:33:52 -0800 (PST) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id y2sm529715lal.10.2014.02.19.06.33.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Feb 2014 06:33:51 -0800 (PST) From: Ulf Hansson To: Mark Brown , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org Cc: Russell King , linux-arm-kernel@lists.infradead.org, Linus Walleij , Wolfram Sang , Ulf Hansson Subject: [PATCH V2 07/17] spi: pl022: Don't ignore power domain and amba bus at system suspend Date: Wed, 19 Feb 2014 15:33:38 +0100 Message-Id: <1392820418-6972-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 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.220.180 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 --- Changes in v2: Rebased on top of latest spi-pl022 patches. Note, currently this patch shall not be applied since first we want to sort out the result from another patch to the PM core. http://marc.info/?l=linux-pm&m=139228211505423&w=2 --- 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 6dfcabf..7b016a2 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -2277,35 +2277,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_unprepare(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_prepare_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); @@ -2317,8 +2289,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; @@ -2327,10 +2314,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); @@ -2341,14 +2337,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; } @@ -2356,7 +2354,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