Skip to contentSkip to conversation

mmc: sdhci: fixed regulator control when suspend/resume

PATCH In review Jaehoon Chung 3 participants 3 messages Apr 7, 2011 – Apr 9, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci: fixed regulator control when suspend/resume

Suspend/resume is working always enable regulator after resuming. (if there is host->vmmc)
I assume that if regulator is enabled, card is inserted. Then We need to restore "vmmc".

---
 drivers/mmc/host/sdhci.c  |    8 +++++---
 include/linux/mmc/sdhci.h |    1 +
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +5 -3
index 9e15f41..70cbbd6 100644
@@ -1663,8 +1663,10 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)
 
 	free_irq(host->irq, host);
 
-	if (host->vmmc)
+	if (host->vmmc && regulator_is_enabled(host->vmmc)) {
 		ret = regulator_disable(host->vmmc);
+		host->restore_vmmc = true;
+	}
 
 	return ret;
 }
@@ -1675,8 +1677,8 @@ int sdhci_resume_host(struct sdhci_host *host)
 {
 	int ret;
 
-	if (host->vmmc) {
-		int ret = regulator_enable(host->vmmc);
+	if (host->vmmc && host->restore_vmmc) {
+		ret = regulator_enable(host->vmmc);
 		if (ret)
 			return ret;
 	}
include/linux/mmc/sdhci.h +1 -0
index 83bd9f7..1c38261 100644
@@ -92,6 +92,7 @@ struct sdhci_host {
 	const struct sdhci_ops *ops;	/* Low level hw interface */
 
 	struct regulator *vmmc;	/* Power regulator */
+	bool restore_vmmc;	/* Restore vmmc */
 
 	/* Internal data */
 	struct mmc_host *mmc;	/* MMC structure */
#1 lore raw
Quoted 2 lines · Jaehoon Chung

Suspend/resume is working always enable regulator after resuming. (if there is host->vmmc)

The regulator is enabled during add_host. How could it not be enabled in suspend?

include/linux/mmc/sdhci.h struct sdhci_host { · line 95

Quoted 2 lines
include/linux/mmc/sdhci.h +1 -0
 	struct regulator *vmmc;	/* Power regulator */
+	bool restore_vmmc;	/* Restore vmmc */

If you can explain the above, this should be turned into a SDHCI_-flag IMHO.

Regards,

Wolfram

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#2 lore raw

Hi, Wolfram..

2011/4/9 Wolfram Sang <[email protected]>:

Quoted 6 lines · Jaehoon Chung
Quoted 2 lines

Suspend/resume is working always enable regulator after resuming. (if there is host->vmmc)

The regulator is enabled during add_host. How could it not be enabled in suspend?

you're right..When running add_host, enabled the regulator "vmmc". I'm missing this patch.sorry ^^
Actually,If controller didn't detect the card, i added disable function in sdhci-s3c.c.
Then regulator is disabled when enter suspend. :)

But i didn't find methed to disable in sdhci.c.
(i think that should be find to use CDn pin)

I'll resend the modified patch.
If you have other method, let me know your opinion.

Thanks very much for your comment.

Quoted 23 lines
Quoted 3 lines

      struct regulator *vmmc; /* Power regulator */
+     bool restore_vmmc;      /* Restore vmmc */

If you can explain the above, this should be turned into a SDHCI_-flag IMHO.

Regards,

  Wolfram

--
Pengutronix e.K.                           | Wolfram Sang                | Industrial Linux Solutions                 | http://www.pengutronix.de/  |

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAk2fWC4ACgkQD27XaX1/VRuTAwCghHV5u2l8tAqnLPAwBf3fz+iV MVoAnRB+hXXCZU3xZQghwVVBcm7iu5+H
=cDOF
-----END PGP SIGNATURE-----