summaryrefslogtreecommitdiffstats
path: root/drivers/mci/sdhci.c
diff options
context:
space:
mode:
authorSteffen Trumtrar <s.trumtrar@pengutronix.de>2024-03-18 11:18:29 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2024-03-18 13:17:07 +0100
commit6c809314ab8837a83bc2575b5698ce763a6d280f (patch)
tree108c049cd3442b7b380b909bd8a708d75e113f5c /drivers/mci/sdhci.c
parent94d79ed7b7814e1fc1c4ebe4678bbc73784b8046 (diff)
downloadbarebox-6c809314ab8837a83bc2575b5698ce763a6d280f.tar.gz
barebox-6c809314ab8837a83bc2575b5698ce763a6d280f.tar.xz
mci: sdhci: replace sdhci_wait_idle
Linux uses a different sdhci_wait_idle function than what barebox currently does. For HS200 support, the linux version needs to be used. As currently only arasan-sdhci is tested with HS200, keep the old sdhci_wait_idle as sdhci_wait_idle_data and convert all users of it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Diffstat (limited to 'drivers/mci/sdhci.c')
-rw-r--r--drivers/mci/sdhci.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index 7dedd5a7b2..8bba1e3bf9 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -788,7 +788,32 @@ void sdhci_enable_clk(struct sdhci *host, u16 clk)
sdhci_write16(host, SDHCI_CLOCK_CONTROL, clk);
}
-int sdhci_wait_idle(struct sdhci *host, struct mci_cmd *cmd)
+int sdhci_wait_idle(struct sdhci *host, struct mci_cmd *cmd, struct mci_data *data)
+{
+ u32 mask;
+ int ret;
+
+ mask = SDHCI_CMD_INHIBIT_CMD;
+
+ if (data || (cmd && (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_data(struct sdhci *host, struct mci_cmd *cmd)
{
u32 mask;
int ret;
@@ -820,7 +845,7 @@ void sdhci_set_clock(struct sdhci *host, unsigned int clock, unsigned int input_
sdhci_set_uhs_signaling(host, host->mci->timing);
- sdhci_wait_idle(host, NULL);
+ sdhci_wait_idle_data(host, NULL);
sdhci_write16(host, SDHCI_CLOCK_CONTROL, 0);