Commit e2bf08d6 authored by Adrian Hunter's avatar Adrian Hunter Committed by Linus Torvalds

omap_hsmmc: set a large data timeout for commands with busy signal

Commands like SWITCH (CMD6) send a response and then signal busy while the
operation is completed.  These commands are expected to always succeed
(otherwise the response would have indicated an error).

Set an arbitrarily large data timeout value (100ms) for these commands to
ensure that premature timeouts do not occur.
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@nokia.com>
Acked-by: default avatarMatt Fleming <matt@console-pimps.org>
Cc: Ian Molton <ian@mnementh.co.uk>
Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>
Cc: Denis Karpov <ext-denis.2.karpov@nokia.com>
Cc: Pierre Ossman <pierre@ossman.eu>
Cc: Philip Langdale <philipl@overt.org>
Cc: "Madhusudhan" <madhu.cr@ti.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2bec0893
...@@ -997,7 +997,8 @@ static int omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host, ...@@ -997,7 +997,8 @@ static int omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host,
} }
static void set_data_timeout(struct omap_hsmmc_host *host, static void set_data_timeout(struct omap_hsmmc_host *host,
struct mmc_request *req) unsigned int timeout_ns,
unsigned int timeout_clks)
{ {
unsigned int timeout, cycle_ns; unsigned int timeout, cycle_ns;
uint32_t reg, clkd, dto = 0; uint32_t reg, clkd, dto = 0;
...@@ -1008,8 +1009,8 @@ static void set_data_timeout(struct omap_hsmmc_host *host, ...@@ -1008,8 +1009,8 @@ static void set_data_timeout(struct omap_hsmmc_host *host,
clkd = 1; clkd = 1;
cycle_ns = 1000000000 / (clk_get_rate(host->fclk) / clkd); cycle_ns = 1000000000 / (clk_get_rate(host->fclk) / clkd);
timeout = req->data->timeout_ns / cycle_ns; timeout = timeout_ns / cycle_ns;
timeout += req->data->timeout_clks; timeout += timeout_clks;
if (timeout) { if (timeout) {
while ((timeout & 0x80000000) == 0) { while ((timeout & 0x80000000) == 0) {
dto += 1; dto += 1;
...@@ -1043,12 +1044,18 @@ omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req) ...@@ -1043,12 +1044,18 @@ omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req)
if (req->data == NULL) { if (req->data == NULL) {
OMAP_HSMMC_WRITE(host->base, BLK, 0); OMAP_HSMMC_WRITE(host->base, BLK, 0);
/*
* Set an arbitrary 100ms data timeout for commands with
* busy signal.
*/
if (req->cmd->flags & MMC_RSP_BUSY)
set_data_timeout(host, 100000000U, 0);
return 0; return 0;
} }
OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz) OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz)
| (req->data->blocks << 16)); | (req->data->blocks << 16));
set_data_timeout(host, req); set_data_timeout(host, req->data->timeout_ns, req->data->timeout_clks);
if (host->use_dma) { if (host->use_dma) {
ret = omap_hsmmc_start_dma_transfer(host, req); ret = omap_hsmmc_start_dma_transfer(host, req);
......
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