Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164712
b: refs/heads/master
c: ef0b27d
h: refs/heads/master
v: v3
  • Loading branch information
Adrian Hunter authored and Linus Torvalds committed Sep 23, 2009
1 parent 7f8dd36 commit 30a0c43
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 53509f0fe28e049e772897aa8fa1f5183b6823a2
refs/heads/master: ef0b27d4ccacac32afc3d1c0e8a95e4091dfbc8c
24 changes: 18 additions & 6 deletions trunk/drivers/mmc/core/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,17 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
(host->caps & MMC_CAP_MMC_HIGHSPEED)) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_HS_TIMING, 1);
if (err)
if (err && err != -EBADMSG)
goto free_card;

mmc_card_set_highspeed(card);

mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
if (err) {
printk(KERN_WARNING "%s: switch to highspeed failed\n",
mmc_hostname(card->host));
err = 0;
} else {
mmc_card_set_highspeed(card);
mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
}
}

/*
Expand Down Expand Up @@ -456,10 +461,17 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BUS_WIDTH, ext_csd_bit);

if (err)
if (err && err != -EBADMSG)
goto free_card;

mmc_set_bus_width(card->host, bus_width);
if (err) {
printk(KERN_WARNING "%s: switch to bus width %d "
"failed\n", mmc_hostname(card->host),
1 << bus_width);
err = 0;
} else {
mmc_set_bus_width(card->host, bus_width);
}
}

if (!oldcard)
Expand Down
23 changes: 23 additions & 0 deletions trunk/drivers/mmc/core/mmc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)
{
int err;
struct mmc_command cmd;
u32 status;

BUG_ON(!card);
BUG_ON(!card->host);
Expand All @@ -407,6 +408,28 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)
if (err)
return err;

/* Must check status to be sure of no errors */
do {
err = mmc_send_status(card, &status);
if (err)
return err;
if (card->host->caps & MMC_CAP_WAIT_WHILE_BUSY)
break;
if (mmc_host_is_spi(card->host))
break;
} while (R1_CURRENT_STATE(status) == 7);

if (mmc_host_is_spi(card->host)) {
if (status & R1_SPI_ILLEGAL_COMMAND)
return -EBADMSG;
} else {
if (status & 0xFDFFA000)
printk(KERN_WARNING "%s: unexpected status %#x after "
"switch", mmc_hostname(card->host), status);
if (status & R1_SWITCH_ERROR)
return -EBADMSG;
}

return 0;
}

Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/mmc/mmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
#define R1_STATUS(x) (x & 0xFFFFE000)
#define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */
#define R1_READY_FOR_DATA (1 << 8) /* sx, a */
#define R1_SWITCH_ERROR (1 << 7) /* sx, c */
#define R1_APP_CMD (1 << 5) /* sr, c */

/*
Expand Down

0 comments on commit 30a0c43

Please sign in to comment.