The busy_timeout value is used by the sdhci_wait_idle and sdhci_wait_idle_data functions to define the timeout to wait on when send a command to the controller. The default value remains unchanged and is set to 10ms. Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@xxxxxxxx> --- Changes v2 -> v3: - Fix email author and signed-off Changes v1 -> v2: - rename SDHCI_CMD_DEFAULT_BUSY_TIMEOUT to SDHCI_CMD_DEFAULT_BUSY_TIMEOUT_MS (suggested by Ahmad Fatoum) --- drivers/mci/sdhci.c | 14 ++++++++++++-- drivers/mci/sdhci.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c index fe033583ad..9b04101c0f 100644 --- a/drivers/mci/sdhci.c +++ b/drivers/mci/sdhci.c @@ -796,9 +796,11 @@ void sdhci_enable_clk(struct sdhci *host, u16 clk) int sdhci_wait_idle(struct sdhci *host, struct mci_cmd *cmd, struct mci_data *data) { u32 mask; + unsigned timeout_ms; int ret; mask = SDHCI_CMD_INHIBIT_CMD; + timeout_ms = SDHCI_CMD_DEFAULT_BUSY_TIMEOUT_MS; if (data || (cmd && (cmd->resp_type & MMC_RSP_BUSY))) mask |= SDHCI_CMD_INHIBIT_DATA; @@ -806,7 +808,10 @@ int sdhci_wait_idle(struct sdhci *host, struct mci_cmd *cmd, struct mci_data *da if (cmd && cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION) mask &= ~SDHCI_CMD_INHIBIT_DATA; - ret = wait_on_timeout(10 * MSECOND, + if (cmd && cmd->busy_timeout != 0) + timeout_ms = cmd->busy_timeout; + + ret = wait_on_timeout(timeout_ms * MSECOND, !(sdhci_read32(host, SDHCI_PRESENT_STATE) & mask)); if (ret) { @@ -821,14 +826,19 @@ int sdhci_wait_idle(struct sdhci *host, struct mci_cmd *cmd, struct mci_data *da int sdhci_wait_idle_data(struct sdhci *host, struct mci_cmd *cmd) { u32 mask; + unsigned timeout_ms; int ret; mask = SDHCI_CMD_INHIBIT_CMD | SDHCI_CMD_INHIBIT_DATA; + timeout_ms = SDHCI_CMD_DEFAULT_BUSY_TIMEOUT_MS; if (cmd && cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION) mask &= ~SDHCI_CMD_INHIBIT_DATA; - ret = wait_on_timeout(10 * MSECOND, + if (cmd && cmd->busy_timeout != 0) + timeout_ms = cmd->busy_timeout; + + ret = wait_on_timeout(timeout_ms * MSECOND, !(sdhci_read32(host, SDHCI_PRESENT_STATE) & mask)); if (ret) { diff --git a/drivers/mci/sdhci.h b/drivers/mci/sdhci.h index 5de85239b1..2a8456545d 100644 --- a/drivers/mci/sdhci.h +++ b/drivers/mci/sdhci.h @@ -200,6 +200,8 @@ #define SDHCI_MAX_DIV_SPEC_200 256 #define SDHCI_MAX_DIV_SPEC_300 2046 +#define SDHCI_CMD_DEFAULT_BUSY_TIMEOUT_MS 10 + struct sdhci { u32 (*read32)(struct sdhci *host, int reg); u16 (*read16)(struct sdhci *host, int reg); -- 2.47.0