Skip to contentSkip to conversation

omap_hsmmc: keep track of power mode

PATCH In review [email protected] 1 participant 1 message Sep 23, 2009

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

PATCH 54/232 omap_hsmmc: keep track of power mode

From: Adrian Hunter <[email protected]>

This patch is preparation for adding context save and restore support.

Keep track of the current power mode so that the context restore function can avoid restoring the context for a card if the power has been switched off. If the power is off, the card must be reinitialized anyway which will re-establish the context.

Cc Ian Molton <[email protected]>
Cc "Roberto A. Foglietta" <[email protected]>
Cc Jarkko Lavinen <[email protected]>
Cc Denis Karpov <[email protected]>
Cc Pierre Ossman <[email protected]>
Cc Philip Langdale <[email protected]>
Cc "Madhusudhan" <[email protected]>

---

 drivers/mmc/host/omap_hsmmc.c |   27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/mmc/host/omap_hsmmc.c renamed from drivers/mmc/host/omap_hsmmc.c~omap_hsmmc-keep-track-of-power-mode +19 -8
diff -puN drivers/mmc/host/omap_hsmmc.c~omap_hsmmc-keep-track-of-power-mode drivers/mmc/host/omap_hsmmc.c
@@ -143,6 +143,7 @@ struct mmc_omap_host {
 	unsigned int		dma_len;
 	unsigned int		dma_sg_idx;
 	unsigned char		bus_mode;
+	unsigned char		power_mode;
 	u32			*buffer;
 	u32			bytesleft;
 	int			suspended;
@@ -863,16 +864,25 @@ static void omap_mmc_set_ios(struct mmc_
 	unsigned long regval;
 	unsigned long timeout;
 	u32 con;
+	int do_send_init_stream = 0;
 
 	mmc_host_enable(host->mmc);
 
-	switch (ios->power_mode) {
-	case MMC_POWER_OFF:
-		mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
-		break;
-	case MMC_POWER_UP:
-		mmc_slot(host).set_power(host->dev, host->slot_id, 1, ios->vdd);
-		break;
+	if (ios->power_mode != host->power_mode) {
+		switch (ios->power_mode) {
+		case MMC_POWER_OFF:
+			mmc_slot(host).set_power(host->dev, host->slot_id,
+						 0, 0);
+			break;
+		case MMC_POWER_UP:
+			mmc_slot(host).set_power(host->dev, host->slot_id,
+						 1, ios->vdd);
+			break;
+		case MMC_POWER_ON:
+			do_send_init_stream = 1;
+			break;
+		}
+		host->power_mode = ios->power_mode;
 	}
 
 	con = OMAP_HSMMC_READ(host->base, CON);
@@ -938,7 +948,7 @@ static void omap_mmc_set_ios(struct mmc_
 	OMAP_HSMMC_WRITE(host->base, SYSCTL,
 		OMAP_HSMMC_READ(host->base, SYSCTL) | CEN);
 
-	if (ios->power_mode == MMC_POWER_ON)
+	if (do_send_init_stream)
 		send_init_stream(host);
 
 	if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
@@ -1116,6 +1126,7 @@ static int __init omap_mmc_probe(struct 
 	host->slot_id	= 0;
 	host->mapbase	= res->start;
 	host->base	= ioremap(host->mapbase, SZ_4K);
+	host->power_mode = -1;
 
 	platform_set_drvdata(pdev, host);
 	INIT_WORK(&host->mmc_carddetect_work, mmc_omap_detect);

_