diff options
author | Ulf Hansson <ulf.hansson@linaro.org> | 2014-01-14 17:17:36 -0500 |
---|---|---|
committer | Chris Ball <chris@printf.net> | 2014-02-23 10:40:49 -0500 |
commit | cb962e04b04fb67dbaf1455d3c60d64297ef4933 (patch) | |
tree | dbd9e0de9822e0a79c931d77c7db75f643da693e | |
parent | 57de31f6351ecad9212a26d2112b546e4c8b4a5b (diff) |
mmc: core: Respect host's max_busy_timeout when sending sleep cmd
When sending the sleep command for host drivers supporting
MMC_CAP_WAIT_WHILE_BUSY, we need to confirm that max_busy_timeout is
big enough comparing to the sleep timeout specified from card's
EXT_CSD. If this isn't case, we use a R1 response instead of R1B and
fallback to use a delay instead.
Do note that a max_busy_timeout set to zero by the host, is interpreted
as it can cope with whatever timeout the mmc core provides it with.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
-rw-r--r-- | drivers/mmc/core/mmc.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 6b7ccef51beb..1ab5f3a0af5b 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -1358,6 +1358,7 @@ static int mmc_sleep(struct mmc_host *host) | |||
1358 | { | 1358 | { |
1359 | struct mmc_command cmd = {0}; | 1359 | struct mmc_command cmd = {0}; |
1360 | struct mmc_card *card = host->card; | 1360 | struct mmc_card *card = host->card; |
1361 | unsigned int timeout_ms = DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000); | ||
1361 | int err; | 1362 | int err; |
1362 | 1363 | ||
1363 | err = mmc_deselect_cards(host); | 1364 | err = mmc_deselect_cards(host); |
@@ -1368,7 +1369,19 @@ static int mmc_sleep(struct mmc_host *host) | |||
1368 | cmd.arg = card->rca << 16; | 1369 | cmd.arg = card->rca << 16; |
1369 | cmd.arg |= 1 << 15; | 1370 | cmd.arg |= 1 << 15; |
1370 | 1371 | ||
1371 | cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; | 1372 | /* |
1373 | * If the max_busy_timeout of the host is specified, validate it against | ||
1374 | * the sleep cmd timeout. A failure means we need to prevent the host | ||
1375 | * from doing hw busy detection, which is done by converting to a R1 | ||
1376 | * response instead of a R1B. | ||
1377 | */ | ||
1378 | if (host->max_busy_timeout && (timeout_ms > host->max_busy_timeout)) { | ||
1379 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; | ||
1380 | } else { | ||
1381 | cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; | ||
1382 | cmd.busy_timeout = timeout_ms; | ||
1383 | } | ||
1384 | |||
1372 | err = mmc_wait_for_cmd(host, &cmd, 0); | 1385 | err = mmc_wait_for_cmd(host, &cmd, 0); |
1373 | if (err) | 1386 | if (err) |
1374 | return err; | 1387 | return err; |
@@ -1379,8 +1392,8 @@ static int mmc_sleep(struct mmc_host *host) | |||
1379 | * SEND_STATUS command to poll the status because that command (and most | 1392 | * SEND_STATUS command to poll the status because that command (and most |
1380 | * others) is invalid while the card sleeps. | 1393 | * others) is invalid while the card sleeps. |
1381 | */ | 1394 | */ |
1382 | if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY)) | 1395 | if (!cmd.busy_timeout || !(host->caps & MMC_CAP_WAIT_WHILE_BUSY)) |
1383 | mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000)); | 1396 | mmc_delay(timeout_ms); |
1384 | 1397 | ||
1385 | return err; | 1398 | return err; |
1386 | } | 1399 | } |