sdhctrl: allow different timeouts for each command

This commit is contained in:
Sven Peter 2009-06-21 17:52:10 +02:00 committed by bushing
parent f41e7fdd7c
commit be3f3c0559
3 changed files with 13 additions and 3 deletions

11
sdhc.c
View File

@ -42,7 +42,7 @@
//#define SDHC_DEBUG //#define SDHC_DEBUG
#define SDHC_COMMAND_TIMEOUT 100 #define SDHC_COMMAND_TIMEOUT 500
#define SDHC_TRANSFER_TIMEOUT 5000 #define SDHC_TRANSFER_TIMEOUT 5000
#define HDEVNAME(hp) ((hp)->sc->sc_dev.dv_xname) #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) if (cmd->c_datalen > 0)
hp->data_command = 1; 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. * 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. * is marked done for any other reason.
*/ */
if (!sdhc_wait_intr(hp, SDHC_COMMAND_COMPLETE, if (!sdhc_wait_intr(hp, SDHC_COMMAND_COMPLETE,
SDHC_COMMAND_TIMEOUT)) { cmd->c_timeout)) {
cmd->c_error = ETIMEDOUT; cmd->c_error = ETIMEDOUT;
SET(cmd->c_flags, SCF_ITSDONE); SET(cmd->c_flags, SCF_ITSDONE);
hp->data_command = 0; hp->data_command = 0;

View File

@ -184,6 +184,7 @@ void sdmmc_needs_discover(struct device *dev)
cmd.c_opcode = SD_SEND_IF_COND; cmd.c_opcode = SD_SEND_IF_COND;
cmd.c_arg = 0x1aa; cmd.c_arg = 0x1aa;
cmd.c_flags = SCF_RSP_R7; cmd.c_flags = SCF_RSP_R7;
cmd.c_timeout = 100;
sdmmc_host_exec_command(c, &cmd); sdmmc_host_exec_command(c, &cmd);
ocr = sdmmc_host_ocr(c); ocr = sdmmc_host_ocr(c);

View File

@ -92,6 +92,8 @@ struct sdmmc_command {
#define SCF_RSP_R7 (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 */ /* Host controller owned fields for data xfer in progress */
int c_resid; /* remaining I/O */ int c_resid; /* remaining I/O */
u_char *c_buf; /* remaining data */ u_char *c_buf; /* remaining data */