To support HS200 mode, the arasan needs a differernt sdhci_wait_idle function. Remove the default CMD_INHIBIT_DATA, otherwise the sdhci hs200 tuning will timeout. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> Signed-off-by: Steffen Trumtrar <s.trumtrar@xxxxxxxxxxxxxx> --- drivers/mci/arasan-sdhci.c | 2 +- drivers/mci/sdhci.c | 25 +++++++++++++++++++++++++ drivers/mci/sdhci.h | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/mci/arasan-sdhci.c b/drivers/mci/arasan-sdhci.c index c20d901c3f..afddf19de7 100644 --- a/drivers/mci/arasan-sdhci.c +++ b/drivers/mci/arasan-sdhci.c @@ -250,7 +250,7 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, u32 mask, command, xfer; int ret; - ret = sdhci_wait_idle(&host->sdhci, cmd); + ret = sdhci_wait_idle2(&host->sdhci, cmd, data); if (ret) return ret; diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c index 62e6443e64..0f7e3cc193 100644 --- a/drivers/mci/sdhci.c +++ b/drivers/mci/sdhci.c @@ -757,6 +757,31 @@ void sdhci_enable_clk(struct sdhci *host, u16 clk) sdhci_write16(host, SDHCI_CLOCK_CONTROL, clk); } +int sdhci_wait_idle2(struct sdhci *host, struct mci_cmd *cmd, struct mci_data *data) +{ + u32 mask; + int ret; + + mask = SDHCI_CMD_INHIBIT_CMD; + + if (data || (cmd->resp_type & MMC_RSP_BUSY)) + mask |= SDHCI_CMD_INHIBIT_DATA; + + if (cmd && cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION) + mask &= ~SDHCI_CMD_INHIBIT_DATA; + + ret = wait_on_timeout(10 * MSECOND, + !(sdhci_read32(host, SDHCI_PRESENT_STATE) & mask)); + + if (ret) { + dev_err(host->mci->hw_dev, + "SDHCI timeout while waiting for idle\n"); + return -EBUSY; + } + + return 0; +} + int sdhci_wait_idle(struct sdhci *host, struct mci_cmd *cmd) { u32 mask; diff --git a/drivers/mci/sdhci.h b/drivers/mci/sdhci.h index 80916e670f..80c3f98c9c 100644 --- a/drivers/mci/sdhci.h +++ b/drivers/mci/sdhci.h @@ -307,6 +307,7 @@ static inline void sdhci_write8(struct sdhci *host, int reg, u32 val) #define SDHCI_NO_DMA DMA_ERROR_CODE int sdhci_execute_tuning(struct sdhci *sdhci, u32 opcode); int sdhci_wait_idle(struct sdhci *host, struct mci_cmd *cmd); +int sdhci_wait_idle2(struct sdhci *host, struct mci_cmd *cmd, struct mci_data *data); int sdhci_wait_for_done(struct sdhci *host, u32 mask); void sdhci_read_response(struct sdhci *host, struct mci_cmd *cmd); void sdhci_set_cmd_xfer_mode(struct sdhci *host, struct mci_cmd *cmd, -- 2.40.1