OSDN Git Service

mmc: core: Add 8-bit support for SDIO
authorSahitya Tummala <stummala@codeaurora.org>
Mon, 13 Jun 2011 06:09:58 +0000 (11:39 +0530)
committerSubhash Jadavani <subhashj@codeaurora.org>
Tue, 31 May 2016 22:20:52 +0000 (15:20 -0700)
Depending on the host and card's capability SDIO cards can
operate at 8-bit buswidth.

Change-Id: I2ed1c5ecaff521db693db47928b0958ed0289645
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
drivers/mmc/core/sdio.c

index c3e6e56..80966a6 100644 (file)
@@ -210,7 +210,7 @@ static int sdio_enable_wide(struct mmc_card *card)
        int ret;
        u8 ctrl;
 
-       if (!(card->host->caps & MMC_CAP_4_BIT_DATA))
+       if (!(card->host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)))
                return 0;
 
        if (card->cccr.low_speed && !card->cccr.wide_bus)
@@ -226,7 +226,10 @@ static int sdio_enable_wide(struct mmc_card *card)
 
        /* set as 4-bit bus width */
        ctrl &= ~SDIO_BUS_WIDTH_MASK;
-       ctrl |= SDIO_BUS_WIDTH_4BIT;
+       if (card->host->caps & MMC_CAP_8_BIT_DATA)
+               ctrl |= SDIO_BUS_WIDTH_8BIT;
+       else if (card->host->caps & MMC_CAP_4_BIT_DATA)
+               ctrl |= SDIO_BUS_WIDTH_4BIT;
 
        ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_IF, ctrl, NULL);
        if (ret)
@@ -267,7 +270,7 @@ static int sdio_disable_wide(struct mmc_card *card)
        int ret;
        u8 ctrl;
 
-       if (!(card->host->caps & MMC_CAP_4_BIT_DATA))
+       if (!(card->host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)))
                return 0;
 
        if (card->cccr.low_speed && !card->cccr.wide_bus)
@@ -791,7 +794,12 @@ try_again:
                 * Switch to wider bus (if supported).
                 */
                err = sdio_enable_4bit_bus(card);
-               if (err)
+               if (err > 0) {
+                       if (card->host->caps & MMC_CAP_8_BIT_DATA)
+                               mmc_set_bus_width(card->host, MMC_BUS_WIDTH_8);
+                       else if (card->host->caps & MMC_CAP_4_BIT_DATA)
+                               mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4);
+               } else if (err)
                        goto remove;
        }
 finish:
@@ -974,6 +982,13 @@ static int mmc_sdio_resume(struct mmc_host *host)
        } else if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) {
                /* We may have switched to 1-bit mode during suspend */
                err = sdio_enable_4bit_bus(host->card);
+               if (err > 0) {
+                       if (host->caps & MMC_CAP_8_BIT_DATA)
+                               mmc_set_bus_width(host, MMC_BUS_WIDTH_8);
+                       else if (host->caps & MMC_CAP_4_BIT_DATA)
+                               mmc_set_bus_width(host, MMC_BUS_WIDTH_4);
+                       err = 0;
+               }
        }
 
        if (!err && host->sdio_irqs) {