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 5/5] esdhc-xload: check for PRSSTAT_BREN only after each block
Date: Mon,  4 Mar 2019 14:18:53 +0100	[thread overview]
Message-ID: <20190304131853.30864-6-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20190304131853.30864-1-s.hauer@pengutronix.de>

The BREN bit tells us a watermark level sized buffer is ready for read.
Instead of testing it before each FIFO read we must only check it once
and then read a watermark level sized buffer. This is at least necessary
on Layerscape, otherwise timeouts occur while reading the buffer.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/imx-esdhc-pbl.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
index 33d78aad05..f77530d310 100644
--- a/drivers/mci/imx-esdhc-pbl.c
+++ b/drivers/mci/imx-esdhc-pbl.c
@@ -84,28 +84,33 @@ static int esdhc_do_data(struct esdhc *esdhc, struct mci_data *data)
 	u32 databuf;
 	u32 size;
 	u32 irqstat;
-	u32 timeout;
 	u32 present;
 
 	buffer = data->dest;
 
-	timeout = 1000000;
 	size = data->blocksize * data->blocks;
 	irqstat = esdhc_read32(esdhc, SDHCI_INT_STATUS);
 
 	while (size) {
-		present = esdhc_read32(esdhc, SDHCI_PRESENT_STATE) & PRSSTAT_BREN;
-		if (present) {
+		int i;
+		int timeout = 1000000;
+
+		while (1) {
+			present = esdhc_read32(esdhc, SDHCI_PRESENT_STATE) & PRSSTAT_BREN;
+			if (present)
+				break;
+			if (!--timeout) {
+				pr_err("read time out\n");
+				return -ETIMEDOUT;
+			}
+		}
+
+		for (i = 0; i < SECTOR_SIZE / sizeof(uint32_t); i++) {
 			databuf = esdhc_read32(esdhc, SDHCI_BUFFER);
 			*((u32 *)buffer) = databuf;
 			buffer += 4;
 			size -= 4;
 		}
-
-		if (!timeout--) {
-			pr_err("read time out\n");
-			return -ETIMEDOUT;
-		}
 	}
 
 	return 0;
@@ -205,6 +210,8 @@ static int esdhc_read_blocks(struct esdhc *esdhc, void *dst, size_t len)
 		      IRQSTATEN_DTOE | IRQSTATEN_DCE | IRQSTATEN_DEBE |
 		      IRQSTATEN_DINT);
 
+	esdhc_write32(esdhc, IMX_SDHCI_WML, 0x0);
+
 	val = esdhc_read32(esdhc, SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET);
 	val |= SYSCTL_HCKEN | SYSCTL_IPGEN;
 	esdhc_write32(esdhc, SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET, val);
-- 
2.20.1


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

      parent reply	other threads:[~2019-03-04 13:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04 13:18 [PATCH 0/5] ESDHC xload: Prepare for Layerscape support Sascha Hauer
2019-03-04 13:18 ` [PATCH 1/5] esdhc-xload: Move to drivers/mci Sascha Hauer
2019-03-04 13:18 ` [PATCH 2/5] esdhc-xload: move some register defines to header file Sascha Hauer
2019-03-04 13:18 ` [PATCH 3/5] esdhc-xload: Use static inline io wrappers Sascha Hauer
2019-03-04 13:18 ` [PATCH 4/5] esdhc-xload: Add bigendian support Sascha Hauer
2019-03-04 13:18 ` Sascha Hauer [this message]

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=20190304131853.30864-6-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