#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
/*
/**
- * 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--;
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);
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;
}
}
- mmc_set_ios(host);
+ host->ops->set_ios(host, &host->ios);
return MMC_ERR_NONE;
}
ocr = 3 << bit;
host->ios.vdd = bit;
- mmc_set_ios(host);
+ host->ops->set_ios(host, &host->ios);
} else {
ocr = 0;
}
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 {
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);
}
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);
mmc_delay(1);
host->ios.chip_select = MMC_CS_DONTCARE;
- mmc_set_ios(host);
+ host->ops->set_ios(host, &host->ios);
mmc_delay(1);
}
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);
}
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)
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;
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;
}
} 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
* 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);
* 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);