mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 08/12] mci: imx-esdhc-pbl: Use sdhci_transfer_data()
Date: Mon,  2 Dec 2019 07:19:50 -0800	[thread overview]
Message-ID: <20191202151954.16032-9-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20191202151954.16032-1-andrew.smirnov@gmail.com>

Drop some extra code by converting esdhc_do_data() to use
sdhci_transfer_data().

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/mci/Kconfig         |  1 +
 drivers/mci/Makefile        |  2 +-
 drivers/mci/imx-esdhc-pbl.c | 35 +----------------------------------
 drivers/mci/sdhci.c         | 13 +++++++++++++
 4 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index c269b71e8..13fa58504 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -105,6 +105,7 @@ config MCI_IMX_ESDHC_PIO
 
 config MCI_IMX_ESDHC_PBL
 	bool
+        select MCI_SDHCI
 
 config MCI_OMAP_HSMMC
 	bool "OMAP HSMMC"
diff --git a/drivers/mci/Makefile b/drivers/mci/Makefile
index cfb84a899..54eb65978 100644
--- a/drivers/mci/Makefile
+++ b/drivers/mci/Makefile
@@ -16,4 +16,4 @@ obj-$(CONFIG_MCI_SPI)		+= mci_spi.o
 obj-$(CONFIG_MCI_DW)		+= dw_mmc.o
 obj-$(CONFIG_MCI_MMCI)		+= mmci.o
 obj-$(CONFIG_MCI_STM32_SDMMC2)	+= stm32_sdmmc2.o
-obj-$(CONFIG_MCI_SDHCI)		+= sdhci.o
+obj-pbl-$(CONFIG_MCI_SDHCI)	+= sdhci.o
diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
index 08f28471c..b61cba2ba 100644
--- a/drivers/mci/imx-esdhc-pbl.c
+++ b/drivers/mci/imx-esdhc-pbl.c
@@ -66,40 +66,7 @@ static u32 esdhc_xfertyp(struct mci_cmd *cmd, struct mci_data *data)
 
 static int esdhc_do_data(struct fsl_esdhc_host *host, struct mci_data *data)
 {
-	char *buffer;
-	u32 databuf;
-	u32 size;
-	u32 irqstat;
-	u32 present;
-
-	buffer = data->dest;
-
-	size = data->blocksize * data->blocks;
-	irqstat = sdhci_read32(&host->sdhci, SDHCI_INT_STATUS);
-
-	while (size) {
-		int i;
-		int timeout = 1000000;
-
-		while (1) {
-			present = sdhci_read32(&host->sdhci, SDHCI_PRESENT_STATE) & SDHCI_BUFFER_READ_ENABLE;
-			if (present)
-				break;
-			if (!--timeout) {
-				pr_err("read time out\n");
-				return -ETIMEDOUT;
-			}
-		}
-
-		for (i = 0; i < SECTOR_WML; i++) {
-			databuf = sdhci_read32(&host->sdhci, SDHCI_BUFFER);
-			*((u32 *)buffer) = databuf;
-			buffer += 4;
-			size -= 4;
-		}
-	}
-
-	return 0;
+	return sdhci_transfer_data(&host->sdhci, data);
 }
 
 static int
diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index 1ab1c0f23..172c8343a 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -88,6 +88,19 @@ static void sdhci_tx_pio(struct sdhci *sdhci, struct mci_data *data,
 		sdhci_write32(sdhci, SDHCI_BUFFER, buf[i]);
 }
 
+#ifdef __PBL__
+/*
+ * Stubs to make timeout logic below work in PBL
+ */
+
+#define get_time_ns()		0
+/*
+ * Use time in us as a busy counter timeout value
+ */
+#define is_timeout(s, t)	((s)++ > ((t) / 1000))
+
+#endif
+
 int sdhci_transfer_data(struct sdhci *sdhci, struct mci_data *data)
 {
 	unsigned int block = 0;
-- 
2.21.0


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

  parent reply	other threads:[~2019-12-02 15:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-02 15:19 [PATCH 00/12] Share i.MX ESDHC PBL and PIO code Andrey Smirnov
2019-12-02 15:19 ` [PATCH 01/12] mci: imx-esdhc: Drop unnecessary type conversion Andrey Smirnov
2019-12-02 15:19 ` [PATCH 02/12] mci: imx-esdhc: Drop unused type definition Andrey Smirnov
2019-12-02 15:19 ` [PATCH 03/12] mci: imx-esdhc: Drop extra helper varaible Andrey Smirnov
2019-12-02 15:19 ` [PATCH 04/12] mci: imx-esdhc-pbl: Don't setup DMA registers Andrey Smirnov
2019-12-02 15:19 ` [PATCH 05/12] mci: imx-esdhc-pbl: Share initialization code Andrey Smirnov
2019-12-02 15:19 ` [PATCH 06/12] mci: imx-esdhc-pbl: Drop 'wrap_wml' flag Andrey Smirnov
2019-12-02 15:19 ` [PATCH 07/12] mci: imx-esdhc-pbl: Share IO accessors with regular driver Andrey Smirnov
2019-12-02 15:19 ` Andrey Smirnov [this message]
2019-12-02 15:19 ` [PATCH 09/12] mci: imx-esdhc-pbl: Use sdhci_set_cmd_xfer_mode() Andrey Smirnov
2019-12-02 15:19 ` [PATCH 10/12] mci: imx-esdhc: Share code for esdhc_(setup|do)_data operations Andrey Smirnov
2019-12-02 15:19 ` [PATCH 11/12] mci: imx-esdhc: Introduce esdhc_poll() Andrey Smirnov
2019-12-02 15:19 ` [PATCH 12/12] mci: imx-esdhc: Share code for esdhc_send_cmd() Andrey Smirnov
2019-12-04  8:42 ` [PATCH 00/12] Share i.MX ESDHC PBL and PIO code 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=20191202151954.16032-9-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --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