aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mmc/mmc.c51
-rw-r--r--include/linux/mmc/protocol.h5
2 files changed, 42 insertions, 14 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 2d5b93000dee..1593a6a632cf 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -397,23 +397,23 @@ static int mmc_select_card(struct mmc_host *host, struct mmc_card *card)
397 return err; 397 return err;
398 398
399 /* 399 /*
400 * Default bus width is 1 bit. 400 * We can only change the bus width of SD cards when
401 */ 401 * they are selected so we have to put the handling
402 host->ios.bus_width = MMC_BUS_WIDTH_1;
403
404 /*
405 * We can only change the bus width of the selected
406 * card so therefore we have to put the handling
407 * here. 402 * here.
403 *
404 * The card is in 1 bit mode by default so
405 * we only need to change if it supports the
406 * wider version.
408 */ 407 */
409 if (host->caps & MMC_CAP_4_BIT_DATA) { 408 if (mmc_card_sd(card) &&
409 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
410
410 /* 411 /*
411 * The card is in 1 bit mode by default so 412 * Default bus width is 1 bit.
412 * we only need to change if it supports the 413 */
413 * wider version. 414 host->ios.bus_width = MMC_BUS_WIDTH_1;
414 */ 415
415 if (mmc_card_sd(card) && 416 if (host->caps & MMC_CAP_4_BIT_DATA) {
416 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
417 struct mmc_command cmd; 417 struct mmc_command cmd;
418 cmd.opcode = SD_APP_SET_BUS_WIDTH; 418 cmd.opcode = SD_APP_SET_BUS_WIDTH;
419 cmd.arg = SD_BUS_WIDTH_4; 419 cmd.arg = SD_BUS_WIDTH_4;
@@ -1055,6 +1055,29 @@ static void mmc_process_ext_csds(struct mmc_host *host)
1055 } 1055 }
1056 1056
1057 mmc_card_set_highspeed(card); 1057 mmc_card_set_highspeed(card);
1058
1059 /* Check for host support for wide-bus modes. */
1060 if (!(host->caps & MMC_CAP_4_BIT_DATA)) {
1061 continue;
1062 }
1063
1064 /* Activate 4-bit support. */
1065 cmd.opcode = MMC_SWITCH;
1066 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
1067 (EXT_CSD_BUS_WIDTH << 16) |
1068 (EXT_CSD_BUS_WIDTH_4 << 8) |
1069 EXT_CSD_CMD_SET_NORMAL;
1070 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
1071
1072 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1073 if (err != MMC_ERR_NONE) {
1074 printk("%s: failed to switch card to "
1075 "mmc v4 4-bit bus mode.\n",
1076 mmc_hostname(card->host));
1077 continue;
1078 }
1079
1080 host->ios.bus_width = MMC_BUS_WIDTH_4;
1058 } 1081 }
1059 1082
1060 kfree(ext_csd); 1083 kfree(ext_csd);
diff --git a/include/linux/mmc/protocol.h b/include/linux/mmc/protocol.h
index 311b6547f561..45c51fd85786 100644
--- a/include/linux/mmc/protocol.h
+++ b/include/linux/mmc/protocol.h
@@ -256,6 +256,7 @@ struct _mmc_csd {
256 * EXT_CSD fields 256 * EXT_CSD fields
257 */ 257 */
258 258
259#define EXT_CSD_BUS_WIDTH 183 /* R/W */
259#define EXT_CSD_HS_TIMING 185 /* R/W */ 260#define EXT_CSD_HS_TIMING 185 /* R/W */
260#define EXT_CSD_CARD_TYPE 196 /* RO */ 261#define EXT_CSD_CARD_TYPE 196 /* RO */
261 262
@@ -270,6 +271,10 @@ struct _mmc_csd {
270#define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */ 271#define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */
271#define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */ 272#define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */
272 273
274#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
275#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */
276#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */
277
273/* 278/*
274 * MMC_SWITCH access modes 279 * MMC_SWITCH access modes
275 */ 280 */