Commit d3a8d95d authored by Andrei Warkentin's avatar Andrei Warkentin Committed by Chris Ball

mmc: core: Allow setting CMD timeout for CMD6 (SWITCH).

CMD6 is an R1B-type command, where DAT is used as busy. Depending
on register written using CMD6, timeout value can be different
as per spec.
Signed-off-by: default avatarAndrei Warkentin <andreiw@motorola.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent a3c7778f
...@@ -548,7 +548,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, ...@@ -548,7 +548,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
*/ */
if (card->ext_csd.enhanced_area_en) { if (card->ext_csd.enhanced_area_en) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_ERASE_GROUP_DEF, 1); EXT_CSD_ERASE_GROUP_DEF, 1, 0);
if (err && err != -EBADMSG) if (err && err != -EBADMSG)
goto free_card; goto free_card;
...@@ -579,7 +579,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, ...@@ -579,7 +579,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
if (card->ext_csd.bootconfig & 0x7) { if (card->ext_csd.bootconfig & 0x7) {
card->ext_csd.bootconfig &= ~0x7; card->ext_csd.bootconfig &= ~0x7;
mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_CONFIG, mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_CONFIG,
card->ext_csd.bootconfig); card->ext_csd.bootconfig, 0);
} }
/* /*
...@@ -588,7 +588,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, ...@@ -588,7 +588,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
if ((card->ext_csd.hs_max_dtr != 0) && if ((card->ext_csd.hs_max_dtr != 0) &&
(host->caps & MMC_CAP_MMC_HIGHSPEED)) { (host->caps & MMC_CAP_MMC_HIGHSPEED)) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_HS_TIMING, 1); EXT_CSD_HS_TIMING, 1, 0);
if (err && err != -EBADMSG) if (err && err != -EBADMSG)
goto free_card; goto free_card;
...@@ -655,7 +655,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, ...@@ -655,7 +655,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
ddr = 0; /* no DDR for 1-bit width */ ddr = 0; /* no DDR for 1-bit width */
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH,
ext_csd_bits[idx][0]); ext_csd_bits[idx][0],
0);
if (!err) { if (!err) {
mmc_set_bus_width_ddr(card->host, mmc_set_bus_width_ddr(card->host,
bus_width, MMC_SDR_MODE); bus_width, MMC_SDR_MODE);
...@@ -675,7 +676,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, ...@@ -675,7 +676,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
if (!err && ddr) { if (!err && ddr) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH,
ext_csd_bits[idx][1]); ext_csd_bits[idx][1],
0);
} }
if (err) { if (err) {
printk(KERN_WARNING "%s: switch to bus width %d ddr %d " printk(KERN_WARNING "%s: switch to bus width %d ddr %d "
......
...@@ -387,7 +387,19 @@ int mmc_spi_set_crc(struct mmc_host *host, int use_crc) ...@@ -387,7 +387,19 @@ int mmc_spi_set_crc(struct mmc_host *host, int use_crc)
return err; return err;
} }
int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value) /**
* mmc_switch - modify EXT_CSD register
* @card: the MMC card associated with the data transfer
* @set: cmd set values
* @index: EXT_CSD register index
* @value: value to program into EXT_CSD register
* @timeout_ms: timeout (ms) for operation performed by register write,
* timeout of zero implies maximum possible timeout
*
* Modifies the EXT_CSD register for selected card.
*/
int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
unsigned int timeout_ms)
{ {
int err; int err;
struct mmc_command cmd; struct mmc_command cmd;
...@@ -404,6 +416,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value) ...@@ -404,6 +416,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)
(value << 8) | (value << 8) |
set; set;
cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
cmd.cmd_timeout_ms = timeout_ms;
err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
if (err) if (err)
...@@ -433,6 +446,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value) ...@@ -433,6 +446,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(mmc_switch);
int mmc_send_status(struct mmc_card *card, u32 *status) int mmc_send_status(struct mmc_card *card, u32 *status)
{ {
......
...@@ -20,7 +20,6 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid); ...@@ -20,7 +20,6 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid);
int mmc_set_relative_addr(struct mmc_card *card); int mmc_set_relative_addr(struct mmc_card *card);
int mmc_send_csd(struct mmc_card *card, u32 *csd); int mmc_send_csd(struct mmc_card *card, u32 *csd);
int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd); int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd);
int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value);
int mmc_send_status(struct mmc_card *card, u32 *status); int mmc_send_status(struct mmc_card *card, u32 *status);
int mmc_send_cid(struct mmc_host *host, u32 *cid); int mmc_send_cid(struct mmc_host *host, u32 *cid);
int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp); int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp);
......
...@@ -135,6 +135,7 @@ extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *); ...@@ -135,6 +135,7 @@ extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int); extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *, extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
struct mmc_command *, int); struct mmc_command *, int);
extern int mmc_switch(struct mmc_card *, u8, u8, u8, unsigned int);
#define MMC_ERASE_ARG 0x00000000 #define MMC_ERASE_ARG 0x00000000
#define MMC_SECURE_ERASE_ARG 0x80000000 #define MMC_SECURE_ERASE_ARG 0x80000000
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment