linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aaron Lu <aaron.lu@intel.com>
To: Chris Ball <cjb@laptop.org>, "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: linux-mmc@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-acpi@vger.kernel.org, Aaron Lu <aaron.lwe@gmail.com>
Subject: [RFC PATCH 4/4] sdio: pm: set device's power state after driver runtime suspended it
Date: Fri, 12 Oct 2012 11:12:41 +0800	[thread overview]
Message-ID: <1350011561-21039-5-git-send-email-aaron.lu@intel.com> (raw)
In-Reply-To: <1350011561-21039-1-git-send-email-aaron.lu@intel.com>

In sdio bus level runtime callback function, after call the driver's
runtime suspend callback, we will check if the device supports a
platform level power management, and if so, a proper power state is
chosen by the corresponding platform callback and then set.

Platform level runtime wakeup is also set, if device is enabled for
runtime wakeup by its driver, it will be armed the ability to generate
a wakeup event by the platform.

Signed-off-by: Aaron Lu <aaron.lu@intel.com>
---
 drivers/mmc/core/sdio_bus.c | 49 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index aaec9e2..d83dea8 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -23,6 +23,7 @@
 
 #include "sdio_cis.h"
 #include "sdio_bus.h"
+#include "sdio.h"
 #include "sdio_acpi.h"
 
 /* show configuration fields */
@@ -194,10 +195,54 @@ static int sdio_bus_remove(struct device *dev)
 }
 
 #ifdef CONFIG_PM
+
+static int sdio_bus_runtime_suspend(struct device *dev)
+{
+	int ret;
+	sdio_power_t state;
+
+	ret = pm_generic_runtime_suspend(dev);
+	if (ret)
+		goto out;
+
+	if (!platform_sdio_power_manageable(dev))
+		goto out;
+
+	platform_sdio_run_wake(dev, true);
+
+	state = platform_sdio_choose_power_state(dev);
+	if (state == SDIO_POWER_ERROR) {
+		ret = -EIO;
+		goto out;
+	}
+
+	ret = platform_sdio_set_power_state(dev, state);
+
+out:
+	return ret;
+}
+
+static int sdio_bus_runtime_resume(struct device *dev)
+{
+	int ret;
+
+	if (platform_sdio_power_manageable(dev)) {
+		platform_sdio_run_wake(dev, false);
+		ret = platform_sdio_set_power_state(dev, SDIO_D0);
+		if (ret)
+			goto out;
+	}
+
+	ret = pm_generic_runtime_resume(dev);
+
+out:
+	return ret;
+}
+
 static const struct dev_pm_ops sdio_bus_pm_ops = {
 	SET_RUNTIME_PM_OPS(
-		pm_generic_runtime_suspend,
-		pm_generic_runtime_resume,
+		sdio_bus_runtime_suspend,
+		sdio_bus_runtime_resume,
 		pm_generic_runtime_idle
 	)
 };
-- 
1.7.12.21.g871e293


  parent reply	other threads:[~2012-10-12  3:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-12  3:12 [RFC PATCH 0/4] Enable setting of sdio device power state with ACPI Aaron Lu
2012-10-12  3:12 ` [RFC PATCH 1/4] sdhci: add slot number into sdhci_host structure Aaron Lu
2012-10-12  3:12 ` [RFC PATCH 2/4] mmc: sdio: bind sdio device with acpi device Aaron Lu
2012-10-18 23:25   ` Rafael J. Wysocki
2012-10-20  7:12     ` Aaron Lu
2012-10-12  3:12 ` [RFC PATCH 3/4] sdio: introduce sdio_platform_pm_ops Aaron Lu
2012-10-18 23:30   ` Rafael J. Wysocki
2012-10-12  3:12 ` Aaron Lu [this message]
2012-10-18 23:39   ` [RFC PATCH 4/4] sdio: pm: set device's power state after driver runtime suspended it Rafael J. Wysocki
2012-10-19 18:08     ` Rafael J. Wysocki
2012-10-20  7:15       ` Aaron Lu
2012-10-21 19:57         ` Rafael J. Wysocki
2012-10-22  0:49           ` Aaron Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350011561-21039-5-git-send-email-aaron.lu@intel.com \
    --to=aaron.lu@intel.com \
    --cc=aaron.lwe@gmail.com \
    --cc=cjb@laptop.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@sisk.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).