omap_hsmmc: keep track of power mode

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.

Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Acked-by: Matt Fleming <matt@console-pimps.org>
Cc: Ian Molton <ian@mnementh.co.uk>
Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>
Cc: Denis Karpov <ext-denis.2.karpov@nokia.com>
Cc: Pierre Ossman <pierre@ossman.eu>
Cc: Philip Langdale <philipl@overt.org>
Cc: "Madhusudhan" <madhu.cr@ti.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>
This commit is contained in:
Adrian Hunter 2009-09-22 16:44:42 -07:00 committed by Linus Torvalds
parent 1887bde391
commit a3621465b4

View File

@ -143,6 +143,7 @@ struct mmc_omap_host {
unsigned int dma_len; unsigned int dma_len;
unsigned int dma_sg_idx; unsigned int dma_sg_idx;
unsigned char bus_mode; unsigned char bus_mode;
unsigned char power_mode;
u32 *buffer; u32 *buffer;
u32 bytesleft; u32 bytesleft;
int suspended; int suspended;
@ -863,16 +864,25 @@ static void omap_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
unsigned long regval; unsigned long regval;
unsigned long timeout; unsigned long timeout;
u32 con; u32 con;
int do_send_init_stream = 0;
mmc_host_enable(host->mmc); mmc_host_enable(host->mmc);
switch (ios->power_mode) { if (ios->power_mode != host->power_mode) {
case MMC_POWER_OFF: switch (ios->power_mode) {
mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0); case MMC_POWER_OFF:
break; mmc_slot(host).set_power(host->dev, host->slot_id,
case MMC_POWER_UP: 0, 0);
mmc_slot(host).set_power(host->dev, host->slot_id, 1, ios->vdd); break;
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); con = OMAP_HSMMC_READ(host->base, CON);
@ -938,7 +948,7 @@ static void omap_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
OMAP_HSMMC_WRITE(host->base, SYSCTL, OMAP_HSMMC_WRITE(host->base, SYSCTL,
OMAP_HSMMC_READ(host->base, SYSCTL) | CEN); OMAP_HSMMC_READ(host->base, SYSCTL) | CEN);
if (ios->power_mode == MMC_POWER_ON) if (do_send_init_stream)
send_init_stream(host); send_init_stream(host);
if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
@ -1116,6 +1126,7 @@ static int __init omap_mmc_probe(struct platform_device *pdev)
host->slot_id = 0; host->slot_id = 0;
host->mapbase = res->start; host->mapbase = res->start;
host->base = ioremap(host->mapbase, SZ_4K); host->base = ioremap(host->mapbase, SZ_4K);
host->power_mode = -1;
platform_set_drvdata(pdev, host); platform_set_drvdata(pdev, host);
INIT_WORK(&host->mmc_carddetect_work, mmc_omap_detect); INIT_WORK(&host->mmc_carddetect_work, mmc_omap_detect);