Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 41442
b: refs/heads/master
c: e45a1bd
h: refs/heads/master
v: v3
  • Loading branch information
Philip Langdale authored and Pierre Ossman committed Dec 1, 2006
1 parent 6409235 commit b1fd9c5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 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: bce40a36de574376f41f1ff3c4d212a7da2a3c90
refs/heads/master: e45a1bd20fa5b920901879e85cdf5eda21f78d7c
51 changes: 37 additions & 14 deletions trunk/drivers/mmc/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,23 +397,23 @@ static int mmc_select_card(struct mmc_host *host, struct mmc_card *card)
return err;

/*
* Default bus width is 1 bit.
*/
host->ios.bus_width = MMC_BUS_WIDTH_1;

/*
* We can only change the bus width of the selected
* card so therefore we have to put the handling
* We can only change the bus width of SD cards when
* they are selected so we have to put the handling
* here.
*
* The card is in 1 bit mode by default so
* we only need to change if it supports the
* wider version.
*/
if (host->caps & MMC_CAP_4_BIT_DATA) {
if (mmc_card_sd(card) &&
(card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {

/*
* The card is in 1 bit mode by default so
* we only need to change if it supports the
* wider version.
*/
if (mmc_card_sd(card) &&
(card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
* Default bus width is 1 bit.
*/
host->ios.bus_width = MMC_BUS_WIDTH_1;

if (host->caps & MMC_CAP_4_BIT_DATA) {
struct mmc_command cmd;
cmd.opcode = SD_APP_SET_BUS_WIDTH;
cmd.arg = SD_BUS_WIDTH_4;
Expand Down Expand Up @@ -1055,6 +1055,29 @@ static void mmc_process_ext_csds(struct mmc_host *host)
}

mmc_card_set_highspeed(card);

/* Check for host support for wide-bus modes. */
if (!(host->caps & MMC_CAP_4_BIT_DATA)) {
continue;
}

/* Activate 4-bit support. */
cmd.opcode = MMC_SWITCH;
cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
(EXT_CSD_BUS_WIDTH << 16) |
(EXT_CSD_BUS_WIDTH_4 << 8) |
EXT_CSD_CMD_SET_NORMAL;
cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;

err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
if (err != MMC_ERR_NONE) {
printk("%s: failed to switch card to "
"mmc v4 4-bit bus mode.\n",
mmc_hostname(card->host));
continue;
}

host->ios.bus_width = MMC_BUS_WIDTH_4;
}

kfree(ext_csd);
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/linux/mmc/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ struct _mmc_csd {
* EXT_CSD fields
*/

#define EXT_CSD_BUS_WIDTH 183 /* R/W */
#define EXT_CSD_HS_TIMING 185 /* R/W */
#define EXT_CSD_CARD_TYPE 196 /* RO */

Expand All @@ -270,6 +271,10 @@ struct _mmc_csd {
#define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */
#define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */

#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */
#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */

/*
* MMC_SWITCH access modes
*/
Expand Down

0 comments on commit b1fd9c5

Please sign in to comment.