summaryrefslogtreecommitdiffstats
path: root/drivers/mci/imx-esdhc-pbl.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-12-02 07:19:53 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-12-04 08:37:12 +0100
commit8780906b36046b6aab9cfffdca3323b8a3916b25 (patch)
treeba40c61c8dd26fa390945a2cb20a4dc2a81f34a1 /drivers/mci/imx-esdhc-pbl.c
parente158af3ac254ffb56cccb2fd7b7da2e2d50710f3 (diff)
downloadbarebox-8780906b36046b6aab9cfffdca3323b8a3916b25.tar.gz
barebox-8780906b36046b6aab9cfffdca3323b8a3916b25.tar.xz
mci: imx-esdhc: Introduce esdhc_poll()
Replace all of the explcitly coded timeout loops with a shared subroutine that is used by both regular driver and PBL code. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci/imx-esdhc-pbl.c')
-rw-r--r--drivers/mci/imx-esdhc-pbl.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
index 21aa758f9b..d6c178651a 100644
--- a/drivers/mci/imx-esdhc-pbl.c
+++ b/drivers/mci/imx-esdhc-pbl.c
@@ -44,7 +44,6 @@ esdhc_send_cmd(struct fsl_esdhc_host *host, struct mci_cmd *cmd, struct mci_data
u32 xfertyp, mixctrl, command;
u32 irqstat;
int ret;
- int timeout;
sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, -1);
@@ -81,12 +80,11 @@ esdhc_send_cmd(struct fsl_esdhc_host *host, struct mci_cmd *cmd, struct mci_data
command << 16 | xfertyp);
/* Wait for the command to complete */
- timeout = 10000;
- while (!(sdhci_read32(&host->sdhci, SDHCI_INT_STATUS) & SDHCI_INT_CMD_COMPLETE)) {
- __udelay(1);
- if (!timeout--)
- return -ETIMEDOUT;
- }
+ ret = esdhc_poll(host, SDHCI_INT_STATUS,
+ SDHCI_INT_CMD_COMPLETE, SDHCI_INT_CMD_COMPLETE,
+ 100 * MSECOND);
+ if (ret)
+ return ret;
irqstat = sdhci_read32(&host->sdhci, SDHCI_INT_STATUS);
sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, irqstat);
@@ -110,13 +108,11 @@ esdhc_send_cmd(struct fsl_esdhc_host *host, struct mci_cmd *cmd, struct mci_data
sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, -1);
/* Wait for the bus to be idle */
- timeout = 10000;
- while (sdhci_read32(&host->sdhci, SDHCI_PRESENT_STATE) & (SDHCI_CMD_INHIBIT_CMD |
- SDHCI_CMD_INHIBIT_DATA | SDHCI_DATA_LINE_ACTIVE)) {
- __udelay(1);
- if (!timeout--)
- return -ETIMEDOUT;
- }
+ ret = esdhc_poll(host, SDHCI_PRESENT_STATE,
+ SDHCI_CMD_INHIBIT_CMD |
+ SDHCI_CMD_INHIBIT_DATA |
+ SDHCI_DATA_LINE_ACTIVE, 0,
+ 100 * MSECOND);
return 0;
}