]> err.no Git - linux-2.6/blobdiff - drivers/mmc/core/mmc.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[linux-2.6] / drivers / mmc / core / mmc.c
index cdc38b43b7999e848cb90e79b40c935be7f21d52..65fe28860f54431ed77e5069526c566e5376521a 100644 (file)
@@ -165,8 +165,6 @@ static int mmc_read_ext_csd(struct mmc_card *card)
 
        BUG_ON(!card);
 
-       err = -EIO;
-
        if (card->csd.mmca_vsn < CSD_SPEC_VER_4)
                return 0;
 
@@ -212,8 +210,9 @@ static int mmc_read_ext_csd(struct mmc_card *card)
 
        ext_csd_struct = ext_csd[EXT_CSD_REV];
        if (ext_csd_struct > 2) {
-               printk("%s: unrecognised EXT_CSD structure version %d\n",
-                       mmc_hostname(card->host), ext_csd_struct);
+               printk(KERN_ERR "%s: unrecognised EXT_CSD structure "
+                       "version %d\n", mmc_hostname(card->host),
+                       ext_csd_struct);
                return -EINVAL;
        }
 
@@ -263,7 +262,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
        unsigned int max_dtr;
 
        BUG_ON(!host);
-       BUG_ON(!host->claimed);
+       WARN_ON(!host->claimed);
 
        /*
         * Since we're changing the OCR value, we seem to
@@ -278,10 +277,22 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
        if (err)
                goto err;
 
+       /*
+        * For SPI, enable CRC as appropriate.
+        */
+       if (mmc_host_is_spi(host)) {
+               err = mmc_spi_set_crc(host, use_spi_crc);
+               if (err)
+                       goto err;
+       }
+
        /*
         * Fetch CID from card.
         */
-       err = mmc_all_send_cid(host, cid);
+       if (mmc_host_is_spi(host))
+               err = mmc_send_cid(host, cid);
+       else
+               err = mmc_all_send_cid(host, cid);
        if (err)
                goto err;
 
@@ -308,13 +319,15 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
        }
 
        /*
-        * Set card RCA.
+        * For native busses:  set card RCA and quit open drain mode.
         */
-       err = mmc_set_relative_addr(card);
-       if (err)
-               goto free_card;
+       if (!mmc_host_is_spi(host)) {
+               err = mmc_set_relative_addr(card);
+               if (err)
+                       goto free_card;
 
-       mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL);
+               mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL);
+       }
 
        if (!oldcard) {
                /*
@@ -335,13 +348,15 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
        /*
         * Select card, as all following commands rely on that.
         */
-       err = mmc_select_card(card);
-       if (err)
-               goto free_card;
+       if (!mmc_host_is_spi(host)) {
+               err = mmc_select_card(card);
+               if (err)
+                       goto free_card;
+       }
 
        if (!oldcard) {
                /*
-                * Fetch and process extened CSD.
+                * Fetch and process extended CSD.
                 */
                err = mmc_read_ext_csd(card);
                if (err)
@@ -501,7 +516,8 @@ static void mmc_suspend(struct mmc_host *host)
        BUG_ON(!host->card);
 
        mmc_claim_host(host);
-       mmc_deselect_cards(host);
+       if (!mmc_host_is_spi(host))
+               mmc_deselect_cards(host);
        host->card->state &= ~MMC_STATE_HIGHSPEED;
        mmc_release_host(host);
 }
@@ -557,10 +573,19 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
        int err;
 
        BUG_ON(!host);
-       BUG_ON(!host->claimed);
+       WARN_ON(!host->claimed);
 
        mmc_attach_bus(host, &mmc_ops);
 
+       /*
+        * We need to get OCR a different way for SPI.
+        */
+       if (mmc_host_is_spi(host)) {
+               err = mmc_spi_read_ocr(host, 1, &ocr);
+               if (err)
+                       goto err;
+       }
+
        /*
         * Sanity check the voltages that the card claims to
         * support.