Skip to content

Commit

Permalink
sdio: put active devices into 1-bit mode during suspend
Browse files Browse the repository at this point in the history
And bring them back to 4-bit mode during resume.

Signed-off-by: Daniel Drake <dsd@laptop.org>
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>
  • Loading branch information
Daniel Drake authored and Linus Torvalds committed Mar 6, 2010
1 parent 4021684 commit 6b5eda3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
43 changes: 43 additions & 0 deletions drivers/mmc/core/sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,40 @@ static int sdio_disable_cd(struct mmc_card *card)
return mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_IF, ctrl, NULL);
}

/*
* Devices that remain active during a system suspend are
* put back into 1-bit mode.
*/
static int sdio_disable_wide(struct mmc_card *card)
{
int ret;
u8 ctrl;

if (!(card->host->caps & MMC_CAP_4_BIT_DATA))
return 0;

if (card->cccr.low_speed && !card->cccr.wide_bus)
return 0;

ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_IF, 0, &ctrl);
if (ret)
return ret;

if (!(ctrl & SDIO_BUS_WIDTH_4BIT))
return 0;

ctrl &= ~SDIO_BUS_WIDTH_4BIT;
ctrl |= SDIO_BUS_ASYNC_INT;

ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_IF, ctrl, NULL);
if (ret)
return ret;

mmc_set_bus_width(card->host, MMC_BUS_WIDTH_1);

return 0;
}

/*
* Test if the card supports high-speed mode and, if so, switch to it.
*/
Expand Down Expand Up @@ -427,6 +461,12 @@ static int mmc_sdio_suspend(struct mmc_host *host)
}
}

if (!err && host->pm_flags & MMC_PM_KEEP_POWER) {
mmc_claim_host(host);
sdio_disable_wide(host->card);
mmc_release_host(host);
}

return err;
}

Expand All @@ -441,6 +481,9 @@ static int mmc_sdio_resume(struct mmc_host *host)
mmc_claim_host(host);
err = mmc_sdio_init_card(host, host->ocr, host->card,
(host->pm_flags & MMC_PM_KEEP_POWER));
if (!err)
/* We may have switched to 1-bit mode during suspend. */
err = sdio_enable_wide(host->card);
if (!err && host->sdio_irqs)
mmc_signal_sdio_irq(host);
mmc_release_host(host);
Expand Down
2 changes: 2 additions & 0 deletions include/linux/mmc/sdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
#define SDIO_BUS_WIDTH_1BIT 0x00
#define SDIO_BUS_WIDTH_4BIT 0x02

#define SDIO_BUS_ASYNC_INT 0x20

#define SDIO_BUS_CD_DISABLE 0x80 /* disable pull-up on DAT3 (pin 1) */

#define SDIO_CCCR_CAPS 0x08
Expand Down

0 comments on commit 6b5eda3

Please sign in to comment.