]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mmc/core/core.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc
[linux-2.6-omap-h63xx.git] / drivers / mmc / core / core.c
index 9d29bed820a1eef5da7b2238cc9a3701ac6da18a..09435e0ec6806fa4771fb616227413bbc5c2dd33 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/pagemap.h>
 #include <linux/err.h>
+#include <linux/leds.h>
 #include <asm/scatterlist.h>
 #include <linux/scatterlist.h>
 
@@ -41,6 +42,14 @@ extern int mmc_attach_sdio(struct mmc_host *host, u32 ocr);
 
 static struct workqueue_struct *workqueue;
 
+/*
+ * Enabling software CRCs on the data blocks can be a significant (30%)
+ * performance cost, and for other reasons may not always be desired.
+ * So we allow it it to be disabled.
+ */
+int use_spi_crc = 1;
+module_param(use_spi_crc, bool, 0);
+
 /*
  * Internal function. Schedule delayed work in the MMC work queue.
  */
@@ -71,6 +80,11 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
        struct mmc_command *cmd = mrq->cmd;
        int err = cmd->error;
 
+       if (err && cmd->retries && mmc_host_is_spi(host)) {
+               if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND)
+                       cmd->retries = 0;
+       }
+
        if (err && cmd->retries) {
                pr_debug("%s: req failed (CMD%u): %d, retrying...\n",
                        mmc_hostname(host), cmd->opcode, err);
@@ -79,6 +93,8 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
                cmd->error = 0;
                host->ops->request(host, mrq);
        } else {
+               led_trigger_event(host->led, LED_OFF);
+
                pr_debug("%s: req done (CMD%u): %d: %08x %08x %08x %08x\n",
                        mmc_hostname(host), cmd->opcode, err,
                        cmd->resp[0], cmd->resp[1],
@@ -133,6 +149,8 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
 
        WARN_ON(!host->claimed);
 
+       led_trigger_event(host->led, LED_FULL);
+
        mrq->cmd->error = 0;
        mrq->cmd->mrq = mrq;
        if (mrq->data) {
@@ -202,7 +220,7 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries
 {
        struct mmc_request mrq;
 
-       BUG_ON(!host->claimed);
+       WARN_ON(!host->claimed);
 
        memset(&mrq, 0, sizeof(struct mmc_request));
 
@@ -333,7 +351,7 @@ void mmc_release_host(struct mmc_host *host)
 {
        unsigned long flags;
 
-       BUG_ON(!host->claimed);
+       WARN_ON(!host->claimed);
 
        spin_lock_irqsave(&host->lock, flags);
        host->claimed = 0;
@@ -453,19 +471,32 @@ static void mmc_power_up(struct mmc_host *host)
        int bit = fls(host->ocr_avail) - 1;
 
        host->ios.vdd = bit;
-       host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
-       host->ios.chip_select = MMC_CS_DONTCARE;
+       if (mmc_host_is_spi(host)) {
+               host->ios.chip_select = MMC_CS_HIGH;
+               host->ios.bus_mode = MMC_BUSMODE_PUSHPULL;
+       } else {
+               host->ios.chip_select = MMC_CS_DONTCARE;
+               host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
+       }
        host->ios.power_mode = MMC_POWER_UP;
        host->ios.bus_width = MMC_BUS_WIDTH_1;
        host->ios.timing = MMC_TIMING_LEGACY;
        mmc_set_ios(host);
 
-       mmc_delay(1);
+       /*
+        * This delay should be sufficient to allow the power supply
+        * to reach the minimum voltage.
+        */
+       mmc_delay(2);
 
        host->ios.clock = host->f_min;
        host->ios.power_mode = MMC_POWER_ON;
        mmc_set_ios(host);
 
+       /*
+        * This delay must be at least 74 clock sizes, or 1 ms, or the
+        * time required to reach a stable voltage.
+        */
        mmc_delay(2);
 }
 
@@ -473,8 +504,10 @@ static void mmc_power_off(struct mmc_host *host)
 {
        host->ios.clock = 0;
        host->ios.vdd = 0;
-       host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
-       host->ios.chip_select = MMC_CS_DONTCARE;
+       if (!mmc_host_is_spi(host)) {
+               host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
+               host->ios.chip_select = MMC_CS_DONTCARE;
+       }
        host->ios.power_mode = MMC_POWER_OFF;
        host->ios.bus_width = MMC_BUS_WIDTH_1;
        host->ios.timing = MMC_TIMING_LEGACY;
@@ -531,7 +564,7 @@ void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)
        BUG_ON(!host);
        BUG_ON(!ops);
 
-       BUG_ON(!host->claimed);
+       WARN_ON(!host->claimed);
 
        spin_lock_irqsave(&host->lock, flags);
 
@@ -555,8 +588,8 @@ void mmc_detach_bus(struct mmc_host *host)
 
        BUG_ON(!host);
 
-       BUG_ON(!host->claimed);
-       BUG_ON(!host->bus_ops);
+       WARN_ON(!host->claimed);
+       WARN_ON(!host->bus_ops);
 
        spin_lock_irqsave(&host->lock, flags);
 
@@ -584,7 +617,7 @@ void mmc_detect_change(struct mmc_host *host, unsigned long delay)
 #ifdef CONFIG_MMC_DEBUG
        unsigned long flags;
        spin_lock_irqsave(&host->lock, flags);
-       BUG_ON(host->removed);
+       WARN_ON(host->removed);
        spin_unlock_irqrestore(&host->lock, flags);
 #endif