Commit 31cacbabf07ce00f5250b9826d5e48d4bbee1f94

Authored by Raffaele Recalcati
Committed by Andy Fleming
1 parent 5d4fc8d907

mmc: SEND_OP_COND considers card capabilities (voltage)

The first SEND_OP_COND (CMD1) command added is used to ask card capabilities.
After it an AND operation is done between card capabilities and host
capabilities (at the moment only for the voltage field).
Finally the correct value is sent to the MMC, waiting that the card
exits from busy state.

Signed-off-by: Raffaele Recalcati <raffaele.recalcati@bticino.it>
Signed-off-by: Andy Fleming <afleming@freescale.com>

Showing 2 changed files with 20 additions and 3 deletions Side-by-side Diff

... ... @@ -367,18 +367,33 @@
367 367  
368 368 int mmc_send_op_cond(struct mmc *mmc)
369 369 {
370   - int timeout = 1000;
  370 + int timeout = 10000;
371 371 struct mmc_cmd cmd;
372 372 int err;
373 373  
374 374 /* Some cards seem to need this */
375 375 mmc_go_idle(mmc);
376 376  
  377 + /* Asking to the card its capabilities */
  378 + cmd.cmdidx = MMC_CMD_SEND_OP_COND;
  379 + cmd.resp_type = MMC_RSP_R3;
  380 + cmd.cmdarg = 0;
  381 + cmd.flags = 0;
  382 +
  383 + err = mmc_send_cmd(mmc, &cmd, NULL);
  384 +
  385 + if (err)
  386 + return err;
  387 +
  388 + udelay(1000);
  389 +
377 390 do {
378 391 cmd.cmdidx = MMC_CMD_SEND_OP_COND;
379 392 cmd.resp_type = MMC_RSP_R3;
380   - cmd.cmdarg = OCR_HCS | (mmc_host_is_spi(mmc) ? 0 :
381   - mmc->voltages);
  393 + cmd.cmdarg = (mmc_host_is_spi(mmc) ? 0 :
  394 + (mmc->voltages &
  395 + (cmd.response[0] & OCR_VOLTAGE_MASK)) |
  396 + (cmd.response[0] & OCR_ACCESS_MODE));
382 397 cmd.flags = 0;
383 398  
384 399 err = mmc_send_cmd(mmc, &cmd, NULL);
... ... @@ -96,6 +96,8 @@
96 96  
97 97 #define OCR_BUSY 0x80000000
98 98 #define OCR_HCS 0x40000000
  99 +#define OCR_VOLTAGE_MASK 0x007FFF80
  100 +#define OCR_ACCESS_MODE 0x60000000
99 101  
100 102 #define MMC_STATUS_MASK (~0x0206BF7F)
101 103 #define MMC_STATUS_RDY_FOR_DATA (1<<8)