linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / mmc / mmc.c
index 6201f30..1888060 100644 (file)
 
 #include "mmc.h"
 
+#ifdef CONFIG_MMC_DEBUG
+#define DBG(x...)      printk(KERN_DEBUG x)
+#else
+#define DBG(x...)      do { } while (0)
+#endif
+
 #define CMD_RETRIES    3
 
 /*
@@ -59,23 +65,20 @@ static const unsigned int tacc_mant[] = {
 
 
 /**
- *     mmc_request_done - finish processing an MMC request
- *     @host: MMC host which completed request
- *     @mrq: MMC request which request
+ *     mmc_request_done - finish processing an MMC command
+ *     @host: MMC host which completed command
+ *     @mrq: MMC request which completed
  *
  *     MMC drivers should call this function when they have completed
- *     their processing of a request.
+ *     their processing of a command.  This should be called before the
+ *     data part of the command has completed.
  */
 void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
 {
        struct mmc_command *cmd = mrq->cmd;
-       int err = cmd->error;
-
-       pr_debug("%s: req done (CMD%u): %d/%d/%d: %08x %08x %08x %08x\n",
-                mmc_hostname(host), cmd->opcode, err,
-                mrq->data ? mrq->data->error : 0,
-                mrq->stop ? mrq->stop->error : 0,
-                cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]);
+       int err = mrq->cmd->error;
+       DBG("MMC: req done (%02x): %d: %08x %08x %08x %08x\n", cmd->opcode,
+           err, cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]);
 
        if (err && cmd->retries) {
                cmd->retries--;
@@ -99,9 +102,8 @@ EXPORT_SYMBOL(mmc_request_done);
 void
 mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
 {
-       pr_debug("%s: starting CMD%u arg %08x flags %08x\n",
-                mmc_hostname(host), mrq->cmd->opcode,
-                mrq->cmd->arg, mrq->cmd->flags);
+       DBG("MMC: starting cmd %02x arg %08x flags %08x\n",
+           mrq->cmd->opcode, mrq->cmd->arg, mrq->cmd->flags);
 
        WARN_ON(host->card_busy == NULL);
 
@@ -315,18 +317,6 @@ void mmc_release_host(struct mmc_host *host)
 
 EXPORT_SYMBOL(mmc_release_host);
 
-static inline void mmc_set_ios(struct mmc_host *host)
-{
-       struct mmc_ios *ios = &host->ios;
-
-       pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n",
-                mmc_hostname(host), ios->clock, ios->bus_mode,
-                ios->power_mode, ios->chip_select, ios->vdd,
-                ios->bus_width);
-       
-       host->ops->set_ios(host, ios);
-}
-
 static int mmc_select_card(struct mmc_host *host, struct mmc_card *card)
 {
        int err;
@@ -379,7 +369,7 @@ static int mmc_select_card(struct mmc_host *host, struct mmc_card *card)
                }
        }
 
-       mmc_set_ios(host);
+       host->ops->set_ios(host, &host->ios);
 
        return MMC_ERR_NONE;
 }
@@ -430,7 +420,7 @@ static u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
                ocr = 3 << bit;
 
                host->ios.vdd = bit;
-               mmc_set_ios(host);
+               host->ops->set_ios(host, &host->ios);
        } else {
                ocr = 0;
        }
@@ -564,7 +554,6 @@ static void mmc_decode_csd(struct mmc_card *card)
                csd->read_partial = UNSTUFF_BITS(resp, 79, 1);
                csd->write_misalign = UNSTUFF_BITS(resp, 78, 1);
                csd->read_misalign = UNSTUFF_BITS(resp, 77, 1);
-               csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3);
                csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4);
                csd->write_partial = UNSTUFF_BITS(resp, 21, 1);
        } else {
@@ -599,7 +588,6 @@ static void mmc_decode_csd(struct mmc_card *card)
                csd->read_partial = UNSTUFF_BITS(resp, 79, 1);
                csd->write_misalign = UNSTUFF_BITS(resp, 78, 1);
                csd->read_misalign = UNSTUFF_BITS(resp, 77, 1);
-               csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3);
                csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4);
                csd->write_partial = UNSTUFF_BITS(resp, 21, 1);
        }
@@ -683,7 +671,7 @@ static void mmc_idle_cards(struct mmc_host *host)
        struct mmc_command cmd;
 
        host->ios.chip_select = MMC_CS_HIGH;
-       mmc_set_ios(host);
+       host->ops->set_ios(host, &host->ios);
 
        mmc_delay(1);
 
@@ -696,7 +684,7 @@ static void mmc_idle_cards(struct mmc_host *host)
        mmc_delay(1);
 
        host->ios.chip_select = MMC_CS_DONTCARE;
-       mmc_set_ios(host);
+       host->ops->set_ios(host, &host->ios);
 
        mmc_delay(1);
 }
@@ -721,13 +709,13 @@ static void mmc_power_up(struct mmc_host *host)
        host->ios.chip_select = MMC_CS_DONTCARE;
        host->ios.power_mode = MMC_POWER_UP;
        host->ios.bus_width = MMC_BUS_WIDTH_1;
-       mmc_set_ios(host);
+       host->ops->set_ios(host, &host->ios);
 
        mmc_delay(1);
 
        host->ios.clock = host->f_min;
        host->ios.power_mode = MMC_POWER_ON;
-       mmc_set_ios(host);
+       host->ops->set_ios(host, &host->ios);
 
        mmc_delay(2);
 }
@@ -740,7 +728,7 @@ static void mmc_power_off(struct mmc_host *host)
        host->ios.chip_select = MMC_CS_DONTCARE;
        host->ios.power_mode = MMC_POWER_OFF;
        host->ios.bus_width = MMC_BUS_WIDTH_1;
-       mmc_set_ios(host);
+       host->ops->set_ios(host, &host->ios);
 }
 
 static int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
@@ -951,7 +939,6 @@ static void mmc_read_scrs(struct mmc_host *host)
                data.timeout_ns = card->csd.tacc_ns * 10;
                data.timeout_clks = card->csd.tacc_clks * 10;
                data.blksz_bits = 3;
-               data.blksz = 1 << 3;
                data.blocks = 1;
                data.flags = MMC_DATA_READ;
                data.sg = &sg;
@@ -989,9 +976,8 @@ static unsigned int mmc_calculate_clock(struct mmc_host *host)
                if (!mmc_card_dead(card) && max_dtr > card->csd.max_dtr)
                        max_dtr = card->csd.max_dtr;
 
-       pr_debug("%s: selected %d.%03dMHz transfer rate\n",
-                mmc_hostname(host),
-                max_dtr / 1000000, (max_dtr / 1000) % 1000);
+       DBG("MMC: selected %d.%03dMHz transfer rate\n",
+           max_dtr / 1000000, (max_dtr / 1000) % 1000);
 
        return max_dtr;
 }
@@ -1065,7 +1051,7 @@ static void mmc_setup(struct mmc_host *host)
        } else {
                host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
                host->ios.clock = host->f_min;
-               mmc_set_ios(host);
+               host->ops->set_ios(host, &host->ios);
 
                /*
                 * We should remember the OCR mask from the existing
@@ -1101,7 +1087,7 @@ static void mmc_setup(struct mmc_host *host)
         * Ok, now switch to push-pull mode.
         */
        host->ios.bus_mode = MMC_BUSMODE_PUSHPULL;
-       mmc_set_ios(host);
+       host->ops->set_ios(host, &host->ios);
 
        mmc_read_csds(host);
 
@@ -1147,7 +1133,7 @@ static void mmc_rescan(void *data)
                 * attached cards and the host support.
                 */
                host->ios.clock = mmc_calculate_clock(host);
-               mmc_set_ios(host);
+               host->ops->set_ios(host, &host->ios);
        }
 
        mmc_release_host(host);