summaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/sdio_io.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@fluxnic.net>2010-03-05 13:43:31 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-06 11:26:36 -0800
commitda68c4eb258cd9f3f0b8aeb7e46b8118bb6358b6 (patch)
treeb7767ce0b0d05d16dec6eeeadd21bd70cc458ac7 /drivers/mmc/core/sdio_io.c
parent9e506f35b1dc327c448d4791bc098f07b9b2efe9 (diff)
downloadlinux-stable-da68c4eb258cd9f3f0b8aeb7e46b8118bb6358b6.tar.gz
linux-stable-da68c4eb258cd9f3f0b8aeb7e46b8118bb6358b6.tar.bz2
linux-stable-da68c4eb258cd9f3f0b8aeb7e46b8118bb6358b6.zip
sdio: introduce API for special power management features
This patch series provides the core changes needed to allow SDIO cards to remain powered and active while the host system is suspended, and let them wake up the host system when needed. This is used to implement wake-on-lan with SDIO wireless cards at the moment. Patches to add that support to the libertas driver will be posted separately. This patch: Some SDIO cards have the ability to keep on running autonomously when the host system is suspended, and wake it up when needed. This however requires that the host controller preserve power to the card, and configure itself appropriately for wake-up. There is however 4 layers of abstractions involved: the host controller driver, the MMC core code, the SDIO card management code, and the actual SDIO function driver. To make things simple and manageable, host drivers must advertise their PM capabilities with a feature bitmask, then function drivers can query and set those features from their suspend method. Then each layer in the suspend call chain is expected to act upon those bits accordingly. [akpm@linux-foundation.org: fix typo in comment] Signed-off-by: Nicolas Pitre <nico@marvell.com> Cc: <linux-mmc@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mmc/core/sdio_io.c')
-rw-r--r--drivers/mmc/core/sdio_io.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c
index 87c618904ee2..ff27c8c71355 100644
--- a/drivers/mmc/core/sdio_io.c
+++ b/drivers/mmc/core/sdio_io.c
@@ -640,3 +640,52 @@ void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr,
*err_ret = ret;
}
EXPORT_SYMBOL_GPL(sdio_f0_writeb);
+
+/**
+ * sdio_get_host_pm_caps - get host power management capabilities
+ * @func: SDIO function attached to host
+ *
+ * Returns a capability bitmask corresponding to power management
+ * features supported by the host controller that the card function
+ * might rely upon during a system suspend. The host doesn't need
+ * to be claimed, nor the function active, for this information to be
+ * obtained.
+ */
+mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func)
+{
+ BUG_ON(!func);
+ BUG_ON(!func->card);
+
+ return func->card->host->pm_caps;
+}
+EXPORT_SYMBOL_GPL(sdio_get_host_pm_caps);
+
+/**
+ * sdio_set_host_pm_flags - set wanted host power management capabilities
+ * @func: SDIO function attached to host
+ *
+ * Set a capability bitmask corresponding to wanted host controller
+ * power management features for the upcoming suspend state.
+ * This must be called, if needed, each time the suspend method of
+ * the function driver is called, and must contain only bits that
+ * were returned by sdio_get_host_pm_caps().
+ * The host doesn't need to be claimed, nor the function active,
+ * for this information to be set.
+ */
+int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags)
+{
+ struct mmc_host *host;
+
+ BUG_ON(!func);
+ BUG_ON(!func->card);
+
+ host = func->card->host;
+
+ if (flags & ~host->pm_caps)
+ return -EINVAL;
+
+ /* function suspend methods are serialized, hence no lock needed */
+ host->pm_flags |= flags;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(sdio_set_host_pm_flags);