From be3f3c0559955d0e2f5578f3228c5c90e1df2341 Mon Sep 17 00:00:00 2001 From: Sven Peter Date: Sun, 21 Jun 2009 17:52:10 +0200 Subject: [PATCH] sdhctrl: allow different timeouts for each command --- sdhc.c | 11 +++++++++-- sdmmc.c | 1 + sdmmcvar.h | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sdhc.c b/sdhc.c index 5b072d9..ad3ec9f 100644 --- a/sdhc.c +++ b/sdhc.c @@ -42,7 +42,7 @@ //#define SDHC_DEBUG -#define SDHC_COMMAND_TIMEOUT 100 +#define SDHC_COMMAND_TIMEOUT 500 #define SDHC_TRANSFER_TIMEOUT 5000 #define HDEVNAME(hp) ((hp)->sc->sc_dev.dv_xname) @@ -578,6 +578,13 @@ sdhc_exec_command(sdmmc_chipset_handle_t sch, struct sdmmc_command *cmd) if (cmd->c_datalen > 0) hp->data_command = 1; + if (cmd->c_timeout == 0) { + if (cmd->c_datalen > 0) + cmd->c_timeout = SDHC_TRANSFER_TIMEOUT; + else + cmd->c_timeout = SDHC_COMMAND_TIMEOUT; + } + /* * Start the MMC command, or mark `cmd' as failed and return. */ @@ -594,7 +601,7 @@ sdhc_exec_command(sdmmc_chipset_handle_t sch, struct sdmmc_command *cmd) * is marked done for any other reason. */ if (!sdhc_wait_intr(hp, SDHC_COMMAND_COMPLETE, - SDHC_COMMAND_TIMEOUT)) { + cmd->c_timeout)) { cmd->c_error = ETIMEDOUT; SET(cmd->c_flags, SCF_ITSDONE); hp->data_command = 0; diff --git a/sdmmc.c b/sdmmc.c index 68cff7c..bd7675d 100644 --- a/sdmmc.c +++ b/sdmmc.c @@ -184,6 +184,7 @@ void sdmmc_needs_discover(struct device *dev) cmd.c_opcode = SD_SEND_IF_COND; cmd.c_arg = 0x1aa; cmd.c_flags = SCF_RSP_R7; + cmd.c_timeout = 100; sdmmc_host_exec_command(c, &cmd); ocr = sdmmc_host_ocr(c); diff --git a/sdmmcvar.h b/sdmmcvar.h index e64fd88..247a080 100644 --- a/sdmmcvar.h +++ b/sdmmcvar.h @@ -90,7 +90,9 @@ struct sdmmc_command { #define SCF_RSP_R5B (SCF_RSP_PRESENT|SCF_RSP_CRC|SCF_RSP_IDX|SCF_RSP_BSY) #define SCF_RSP_R6 (SCF_RSP_PRESENT|SCF_RSP_CRC|SCF_RSP_IDX) #define SCF_RSP_R7 (SCF_RSP_PRESENT|SCF_RSP_CRC|SCF_RSP_IDX) - int c_error; /* errno value on completion */ + int c_error; /* errno value on completion */ + + int c_timeout; /* Host controller owned fields for data xfer in progress */ int c_resid; /* remaining I/O */