]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
mmc: separate out reading EXT_CSD
authorPierre Ossman <drzeus@drzeus.cx>
Tue, 1 May 2007 13:08:30 +0000 (15:08 +0200)
committerPierre Ossman <drzeus@drzeus.cx>
Tue, 1 May 2007 13:08:30 +0000 (15:08 +0200)
Separate the reading and decoding of the EXT_CSD register with the
actions taken on it.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
drivers/mmc/core/mmc.c

index c2e120b11bef7cebe71c5916fa866bf6f02bbfe0..47449e870131f70ee4be7f3d0b9e657a21fa9cc9 100644 (file)
@@ -152,10 +152,9 @@ static void mmc_decode_csd(struct mmc_card *card)
 }
 
 /*
- * Read and decode extended CSD. Switch to high-speed and wide bus
- * if supported.
+ * Read and decode extended CSD.
  */
-static int mmc_process_ext_csd(struct mmc_card *card)
+static int mmc_read_ext_csd(struct mmc_card *card)
 {
        int err;
        u8 *ext_csd;
@@ -223,39 +222,6 @@ static int mmc_process_ext_csd(struct mmc_card *card)
                goto out;
        }
 
-       if (card->host->caps & MMC_CAP_MMC_HIGHSPEED) {
-               /* Activate highspeed support. */
-               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-                       EXT_CSD_HS_TIMING, 1);
-               if (err != MMC_ERR_NONE) {
-                       printk(KERN_WARNING "%s: failed to switch "
-                               "card to mmc v4 high-speed mode.\n",
-                              mmc_hostname(card->host));
-                       err = MMC_ERR_NONE;
-                       goto out;
-               }
-
-               mmc_card_set_highspeed(card);
-
-               mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
-       }
-
-       /* Check for host support for wide-bus modes. */
-       if (card->host->caps & MMC_CAP_4_BIT_DATA) {
-               /* Activate 4-bit support. */
-               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-                       EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4);
-               if (err != MMC_ERR_NONE) {
-                       printk(KERN_WARNING "%s: failed to switch "
-                               "card to mmc v4 4-bit bus mode.\n",
-                              mmc_hostname(card->host));
-                       err = MMC_ERR_NONE;
-                       goto out;
-               }
-
-               mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4);
-       }
-
 out:
        kfree(ext_csd);
 
@@ -391,18 +357,34 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
        mmc_decode_cid(card);
 
        /*
-        * Fetch and process extened CSD.
-        * This will switch into high-speed and wide bus modes,
-        * as available.
+        * Select card, as all following commands rely on that.
         */
        err = mmc_select_card(card);
        if (err != MMC_ERR_NONE)
                goto free_card;
 
-       err = mmc_process_ext_csd(card);
+       /*
+        * Fetch and process extened CSD.
+        */
+       err = mmc_read_ext_csd(card);
        if (err != MMC_ERR_NONE)
                goto free_card;
 
+       /*
+        * Activate high speed (if supported)
+        */
+       if ((card->ext_csd.hs_max_dtr != 0) &&
+               (host->caps & MMC_CAP_MMC_HIGHSPEED)) {
+               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+                       EXT_CSD_HS_TIMING, 1);
+               if (err != MMC_ERR_NONE)
+                       goto free_card;
+
+               mmc_card_set_highspeed(card);
+
+               mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
+       }
+
        /*
         * Compute bus speed.
         */
@@ -417,6 +399,19 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
 
        mmc_set_clock(host, max_dtr);
 
+       /*
+        * Activate wide bus (if supported).
+        */
+       if ((card->csd.mmca_vsn >= CSD_SPEC_VER_4) &&
+               (host->caps & MMC_CAP_4_BIT_DATA)) {
+               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+                       EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4);
+               if (err != MMC_ERR_NONE)
+                       goto free_card;
+
+               mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4);
+       }
+
        host->card = card;
 
        mmc_release_host(host);