Skip to content
Snippets Groups Projects
Commit 31cacbab authored by Raffaele Recalcati's avatar Raffaele Recalcati Committed by Andy Fleming
Browse files

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: default avatarRaffaele Recalcati <raffaele.recalcati@bticino.it>
Signed-off-by: default avatarAndy Fleming <afleming@freescale.com>
parent 5d4fc8d9
No related branches found
No related tags found
No related merge requests found
...@@ -367,18 +367,33 @@ sd_send_op_cond(struct mmc *mmc) ...@@ -367,18 +367,33 @@ sd_send_op_cond(struct mmc *mmc)
int mmc_send_op_cond(struct mmc *mmc) int mmc_send_op_cond(struct mmc *mmc)
{ {
int timeout = 1000; int timeout = 10000;
struct mmc_cmd cmd; struct mmc_cmd cmd;
int err; int err;
/* Some cards seem to need this */ /* Some cards seem to need this */
mmc_go_idle(mmc); mmc_go_idle(mmc);
/* Asking to the card its capabilities */
cmd.cmdidx = MMC_CMD_SEND_OP_COND;
cmd.resp_type = MMC_RSP_R3;
cmd.cmdarg = 0;
cmd.flags = 0;
err = mmc_send_cmd(mmc, &cmd, NULL);
if (err)
return err;
udelay(1000);
do { do {
cmd.cmdidx = MMC_CMD_SEND_OP_COND; cmd.cmdidx = MMC_CMD_SEND_OP_COND;
cmd.resp_type = MMC_RSP_R3; cmd.resp_type = MMC_RSP_R3;
cmd.cmdarg = OCR_HCS | (mmc_host_is_spi(mmc) ? 0 : cmd.cmdarg = (mmc_host_is_spi(mmc) ? 0 :
mmc->voltages); (mmc->voltages &
(cmd.response[0] & OCR_VOLTAGE_MASK)) |
(cmd.response[0] & OCR_ACCESS_MODE));
cmd.flags = 0; cmd.flags = 0;
err = mmc_send_cmd(mmc, &cmd, NULL); err = mmc_send_cmd(mmc, &cmd, NULL);
......
...@@ -96,6 +96,8 @@ ...@@ -96,6 +96,8 @@
#define OCR_BUSY 0x80000000 #define OCR_BUSY 0x80000000
#define OCR_HCS 0x40000000 #define OCR_HCS 0x40000000
#define OCR_VOLTAGE_MASK 0x007FFF80
#define OCR_ACCESS_MODE 0x60000000
#define MMC_STATUS_MASK (~0x0206BF7F) #define MMC_STATUS_MASK (~0x0206BF7F)
#define MMC_STATUS_RDY_FOR_DATA (1<<8) #define MMC_STATUS_RDY_FOR_DATA (1<<8)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment