mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 19/21] mci: imx-esdhci: Use generic PIO transfer function
Date: Tue, 19 Nov 2019 11:50:34 +0100	[thread overview]
Message-ID: <20191119105036.12300-20-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20191119105036.12300-1-s.hauer@pengutronix.de>

Use sdhci_transfer_data() in PIO mode to share mode code.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/imx-esdhc.c | 69 +----------------------------------------
 1 file changed, 1 insertion(+), 68 deletions(-)

diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 4d23788eec..bebc36d0b6 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -164,73 +164,6 @@ static inline void esdhc_setbits32(struct fsl_esdhc_host *host, unsigned int reg
 	esdhc_clrsetbits32(host, reg, 0, set);
 }
 
-/*
- * PIO Read/Write Mode reduce the performace as DMA is not used in this mode.
- */
-static int
-esdhc_pio_read_write(struct mci_host *mci, struct mci_data *data)
-{
-	struct fsl_esdhc_host *host = to_fsl_esdhc(mci);
-	u32 blocks;
-	char *buffer;
-	u32 databuf;
-	u32 size;
-	u32 irqstat;
-	u32 timeout;
-
-	if (data->flags & MMC_DATA_READ) {
-		blocks = data->blocks;
-		buffer = data->dest;
-		while (blocks) {
-			timeout = PIO_TIMEOUT;
-			size = data->blocksize;
-			irqstat = sdhci_read32(&host->sdhci, SDHCI_INT_STATUS);
-			while (!(sdhci_read32(&host->sdhci, SDHCI_PRESENT_STATE) &
-					SDHCI_BUFFER_READ_ENABLE)
-				&& --timeout);
-			if (timeout <= 0) {
-				dev_err(host->dev, "Data Read Failed\n");
-				return -ETIMEDOUT;
-			}
-			while (size && (!(irqstat & SDHCI_INT_XFER_COMPLETE))) {
-				udelay(100); /* Wait before last byte transfer complete */
-				irqstat = sdhci_read32(&host->sdhci, SDHCI_INT_STATUS);
-				databuf = sdhci_read32(&host->sdhci, SDHCI_BUFFER);
-				*((u32 *)buffer) = databuf;
-				buffer += 4;
-				size -= 4;
-			}
-			blocks--;
-		}
-	} else {
-		blocks = data->blocks;
-		buffer = (char *)data->src;
-		while (blocks) {
-			timeout = PIO_TIMEOUT;
-			size = data->blocksize;
-			irqstat = sdhci_read32(&host->sdhci, SDHCI_INT_STATUS);
-			while (!(sdhci_read32(&host->sdhci, SDHCI_PRESENT_STATE) &
-					SDHCI_BUFFER_WRITE_ENABLE)
-				&& --timeout);
-			if (timeout <= 0) {
-				dev_err(host->dev, "Data Write Failed\n");
-				return -ETIMEDOUT;
-			}
-			while (size && (!(irqstat & SDHCI_INT_XFER_COMPLETE))) {
-				udelay(100); /* Wait before last byte transfer complete */
-				databuf = *((u32 *)buffer);
-				buffer += 4;
-				size -= 4;
-				irqstat = sdhci_read32(&host->sdhci, SDHCI_INT_STATUS);
-				sdhci_write32(&host->sdhci, SDHCI_BUFFER, databuf);
-			}
-			blocks--;
-		}
-	}
-
-	return 0;
-}
-
 static int esdhc_setup_data(struct mci_host *mci, struct mci_data *data,
 			    dma_addr_t dma)
 {
@@ -266,7 +199,7 @@ static int esdhc_do_data(struct mci_host *mci, struct mci_data *data)
 	u32 irqstat;
 
 	if (IS_ENABLED(CONFIG_MCI_IMX_ESDHC_PIO))
-		return esdhc_pio_read_write(mci, data);
+		return sdhci_transfer_data(&host->sdhci, data);
 
 	do {
 		irqstat = sdhci_read32(&host->sdhci, SDHCI_INT_STATUS);
-- 
2.24.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-11-19 10:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19 10:50 [PATCH 00/21] mci: SDHCI helper functions and arasan driver Sascha Hauer
2019-11-19 10:50 ` [PATCH 01/21] mci: Add sdhci helper Sascha Hauer
2019-11-19 11:10   ` Ahmad Fatoum
2019-11-19 13:09     ` Sascha Hauer
2019-11-19 10:50 ` [PATCH 02/21] mci: sdhci: Add missing command type defines Sascha Hauer
2019-11-19 10:50 ` [PATCH 03/21] mci: imx-esdhc: use sdhci helpers Sascha Hauer
2019-11-19 10:50 ` [PATCH 04/21] mci: bcm2835: " Sascha Hauer
2019-11-19 10:50 ` [PATCH 05/21] mci: tegra: " Sascha Hauer
2019-11-19 10:50 ` [PATCH 06/21] mci: dove: " Sascha Hauer
2019-11-19 10:50 ` [PATCH 07/21] mci: imx-esdhc: Use 16bit register definitions Sascha Hauer
2019-11-19 10:50 ` [PATCH 08/21] mci: mci-bcm2835: " Sascha Hauer
2019-11-19 10:50 ` [PATCH 09/21] mci: tegra: " Sascha Hauer
2019-11-19 10:50 ` [PATCH 10/21] mci: imx-esdhc-pbl: " Sascha Hauer
2019-11-19 10:50 ` [PATCH 11/21] mci: sdhci: remove 32bit register defines Sascha Hauer
2019-11-19 10:50 ` [PATCH 12/21] mci: sdhci: remove duplicate transfer mode " Sascha Hauer
2019-11-19 10:50 ` [PATCH 13/21] mci: sdhci: remove duplicate register defines for interrupt bits Sascha Hauer
2019-11-19 10:50 ` [PATCH 14/21] mci: sdhci: remove duplicate register defines for prsstat bits Sascha Hauer
2019-11-19 10:50 ` [PATCH 15/21] mci: dove: Use sdhci_set_cmd_xfer_mode() Sascha Hauer
2019-11-19 10:50 ` [PATCH 16/21] mci: imx-esdhc: " Sascha Hauer
2019-11-19 10:50 ` [PATCH 17/21] mci: bcm2835: " Sascha Hauer
2019-11-19 10:50 ` [PATCH 18/21] mci: tegra: " Sascha Hauer
2019-11-19 10:50 ` Sascha Hauer [this message]
2019-11-19 10:50 ` [PATCH 20/21] mci: mci-bcm2835: Use generic PIO transfer function Sascha Hauer
2019-11-19 10:50 ` [PATCH 21/21] mci: add Arasan SDHCI controller driver Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191119105036.12300-20-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox