All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: sdio: reset card during power_restore
@ 2011-06-25 18:20 Daniel Drake
  2011-06-26 12:33 ` Ohad Ben-Cohen
  2011-06-26 15:23 ` Chris Ball
  0 siblings, 2 replies; 45+ messages in thread
From: Daniel Drake @ 2011-06-25 18:20 UTC (permalink / raw)
  To: cjb; +Cc: linux-mmc, ohad

mmc_sdio_power_restore() skips some steps that are performed in other
power-related codepaths which are necessary to fully reset the card.
Without this, runtime PM fails for SD8686 SDIO wifi on OLPC XO-1.5.

Signed-off-by: Daniel Drake <dsd@laptop.org>
---
 drivers/mmc/core/sdio.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

Replaces existing patch with the same name

diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index 4d0c15b..262fff0 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -691,15 +691,54 @@ static int mmc_sdio_resume(struct mmc_host *host)
 static int mmc_sdio_power_restore(struct mmc_host *host)
 {
 	int ret;
+	u32 ocr;
 
 	BUG_ON(!host);
 	BUG_ON(!host->card);
 
 	mmc_claim_host(host);
+
+	/*
+	 * Reset the card by performing the same steps that are taken by
+	 * mmc_rescan_try_freq() and mmc_attach_sdio() during a "normal" probe.
+	 *
+	 * sdio_reset() is technically not needed. Having just powered up the
+	 * hardware, it should already be in reset state. However, some
+	 * platforms (such as SD8686 on OLPC) do not instantly cut power,
+	 * meaning that a reset is required when restoring power soon after
+	 * powering off. It is harmless in other cases.
+	 *
+	 * The CMD5 reset (mmc_send_io_op_cond()), according to the SDIO spec,
+	 * is not necessary for non-removable cards. However, it is required
+	 * for OLPC SD8686 (which expects a [CMD5,5,3,7] init sequence), and
+	 * harmless in other situations.
+	 *
+	 * With these steps taken, mmc_select_voltage() is also required to
+	 * restore the correct voltage setting of the card.
+	 */
+	sdio_reset(host);
+	mmc_go_idle(host);
+	mmc_send_if_cond(host, host->ocr_avail);
+
+	ret = mmc_send_io_op_cond(host, 0, &ocr);
+	if (ret)
+		goto out;
+
+	if (host->ocr_avail_sdio)
+		host->ocr_avail = host->ocr_avail_sdio;
+
+	host->ocr = mmc_select_voltage(host, ocr & ~0x7F);
+	if (!host->ocr) {
+		ret = -EINVAL;
+		goto out;
+	}
+
 	ret = mmc_sdio_init_card(host, host->ocr, host->card,
 				mmc_card_keep_power(host));
 	if (!ret && host->sdio_irqs)
 		mmc_signal_sdio_irq(host);
+
+out:
 	mmc_release_host(host);
 
 	return ret;
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 45+ messages in thread
* [PATCH] mmc: sdio: reset card during power_restore
@ 2011-06-05 12:38 Daniel Drake
  2011-06-05 13:48 ` Ohad Ben-Cohen
  0 siblings, 1 reply; 45+ messages in thread
From: Daniel Drake @ 2011-06-05 12:38 UTC (permalink / raw)
  To: linux-mmc; +Cc: ohad

mmc_sdio_power_restore() skips some steps that are performed in other
power-related codepaths which are necessary to fully reset the card.
Without this, the card can't be powered up and probe fails.

All these steps are needed, to satisfy the cases of both normal
runtime PM and also suspend/resume situations.

Tested on sd8686 libertas wifi on XO-1.5.

Signed-off-by: Daniel Drake <dsd@laptop.org>
---
 drivers/mmc/core/sdio.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index 8af3330..9170ea2 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -706,10 +706,25 @@ static int mmc_sdio_power_restore(struct mmc_host *host)
 	BUG_ON(!host->card);
 
 	mmc_claim_host(host);
+
+	/*
+	 * Reset the card by performing the same steps that are taken by
+	 * mmc_rescan_try_freq() and mmc_attach_sdio() during a "normal" probe
+	 */
+	sdio_reset(host);
+	mmc_go_idle(host);
+	mmc_send_if_cond(host, host->ocr_avail);
+
+	ret = mmc_send_io_op_cond(host, 0, NULL);
+	if (ret)
+		goto out;
+
 	ret = mmc_sdio_init_card(host, host->ocr, host->card,
 				mmc_card_keep_power(host));
 	if (!ret && host->sdio_irqs)
 		mmc_signal_sdio_irq(host);
+
+out:
 	mmc_release_host(host);
 
 	return ret;
-- 
1.7.5.2


^ permalink raw reply related	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2011-06-29 15:25 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-25 18:20 [PATCH] mmc: sdio: reset card during power_restore Daniel Drake
2011-06-26 12:33 ` Ohad Ben-Cohen
2011-06-26 15:23 ` Chris Ball
  -- strict thread matches above, loose matches on Subject: below --
2011-06-05 12:38 Daniel Drake
2011-06-05 13:48 ` Ohad Ben-Cohen
2011-06-07 16:41   ` Daniel Drake
2011-06-07 20:52     ` Ohad Ben-Cohen
2011-06-08  9:20       ` Daniel Drake
2011-06-08  9:33         ` Ohad Ben-Cohen
2011-06-08 13:36           ` Daniel Drake
2011-06-08 14:02             ` Ohad Ben-Cohen
2011-06-08 14:21               ` Daniel Drake
2011-06-08 20:05                 ` Ohad Ben-Cohen
2011-06-08 20:58                   ` Daniel Drake
2011-06-09  3:23                     ` Ohad Ben-Cohen
2011-06-09 15:51                   ` Daniel Drake
2011-06-09 15:59                     ` Ohad Ben-Cohen
2011-06-09 16:21                       ` Daniel Drake
2011-06-09 16:30                         ` Ohad Ben-Cohen
2011-06-09 16:44                           ` Daniel Drake
2011-06-09 17:27                             ` Ohad Ben-Cohen
2011-06-09 17:56                               ` Daniel Drake
2011-06-09 18:25                                 ` Ohad Ben-Cohen
2011-06-09 19:55                                   ` Daniel Drake
2011-06-09 23:27                                     ` Ohad Ben-Cohen
2011-06-10 16:15                                       ` Daniel Drake
2011-06-13 19:52                                         ` Ohad Ben-Cohen
2011-06-16 17:27                                           ` Daniel Drake
2011-06-16 19:03                                             ` Philip Rakity
2011-06-16 21:22                                             ` Ohad Ben-Cohen
2011-06-17 13:58                                               ` Daniel Drake
2011-06-17 14:31                                                 ` Ohad Ben-Cohen
2011-06-17 15:19                                                   ` Daniel Drake
2011-06-19 10:33                                                   ` Daniel Drake
2011-06-19 11:00                                                     ` Ohad Ben-Cohen
2011-06-25 18:23                                                       ` Daniel Drake
2011-06-27 20:26                                                         ` Ohad Ben-Cohen
2011-06-28  9:13                                                           ` zhangfei gao
2011-06-28 11:10                                                             ` Ohad Ben-Cohen
2011-06-29  8:43                                                               ` zhangfei gao
2011-06-29  8:57                                                                 ` Ohad Ben-Cohen
2011-06-29  9:19                                                                   ` zhangfei gao
2011-06-29 15:25                                                                     ` Ohad Ben-Cohen
2011-06-29  8:56                                                             ` Daniel Drake
2011-06-07 21:01     ` Ohad Ben-Cohen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.