mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 25/30] mci: sdhci: fix sdhci_transfer_data MMC_SEND_TUNING compatibility
Date: Mon,  5 May 2025 14:06:28 +0200	[thread overview]
Message-ID: <20250505120633.3717186-26-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250505120633.3717186-1-a.fatoum@pengutronix.de>

Depending on whether we are executing a tuning sequence or not, we need
to poll for different status bits. Implement the logic in preparation
for adding HS200 support to the i.MX eSDHC driver.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/mci/sdhci.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index a4b56a6e9286..6308dc9d9140 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -291,8 +291,10 @@ void sdhci_set_cmd_xfer_mode(struct sdhci *host, struct mci_cmd *cmd,
 		if (data->flags & MMC_DATA_READ)
 			*xfer |= SDHCI_DATA_TO_HOST;
 
-		if (dma)
+		if (dma && !mmc_op_tuning(cmd->cmdidx))
 			*xfer |= SDHCI_DMA_EN;
+	} else if (mmc_op_tuning(cmd->cmdidx)) {
+		*command |= SDHCI_DATA_PRESENT;
 	}
 }
 
@@ -529,7 +531,7 @@ int sdhci_transfer_data_dma(struct sdhci *sdhci, struct mci_cmd *cmd,
 	struct device *dev = sdhci_dev(sdhci);
 	u64 start;
 	int nbytes;
-	u32 irqstat;
+	u32 irqcheck, irqstat;
 	int ret;
 
 	if (!data)
@@ -539,6 +541,10 @@ int sdhci_transfer_data_dma(struct sdhci *sdhci, struct mci_cmd *cmd,
 
 	start = get_time_ns();
 
+	irqcheck = SDHCI_INT_XFER_COMPLETE;
+	if (mmc_op_tuning(cmd->cmdidx))
+		irqcheck = SDHCI_INT_DATA_AVAIL;
+
 	do {
 		irqstat = sdhci_read32(sdhci, SDHCI_INT_STATUS);
 
@@ -575,7 +581,7 @@ int sdhci_transfer_data_dma(struct sdhci *sdhci, struct mci_cmd *cmd,
 			sdhci_set_sdma_addr(sdhci, ALIGN(dma, SDHCI_DEFAULT_BOUNDARY_SIZE));
 		}
 
-		if (irqstat & SDHCI_INT_XFER_COMPLETE)
+		if (irqstat & irqcheck)
 			break;
 
 		if (is_timeout(start, 10 * SECOND)) {
@@ -597,12 +603,16 @@ int sdhci_transfer_data_pio(struct sdhci *sdhci, struct mci_cmd *cmd,
 			    struct mci_data *data)
 {
 	unsigned int block = 0;
-	u32 stat, prs;
+	u32 stat, prs, irqcheck;
 	uint64_t start = get_time_ns();
 
 	if (!data)
 		return 0;
 
+	irqcheck = SDHCI_INT_XFER_COMPLETE;
+	if (mmc_op_tuning(cmd->cmdidx))
+		irqcheck = SDHCI_INT_DATA_AVAIL;
+
 	do {
 		stat = sdhci_read32(sdhci, SDHCI_INT_STATUS);
 		if (stat & SDHCI_INT_ERROR)
@@ -630,7 +640,7 @@ int sdhci_transfer_data_pio(struct sdhci *sdhci, struct mci_cmd *cmd,
 		if (is_timeout(start, 10 * SECOND))
 			return -ETIMEDOUT;
 
-	} while (!(stat & SDHCI_INT_XFER_COMPLETE));
+	} while (!(stat & irqcheck));
 
 	return 0;
 }
@@ -822,7 +832,8 @@ int sdhci_wait_idle(struct sdhci *host, struct mci_cmd *cmd, struct mci_data *da
 	if (data || (cmd && (cmd->resp_type & MMC_RSP_BUSY)))
 		mask |= SDHCI_CMD_INHIBIT_DATA;
 
-	if (cmd && cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
+	if (cmd && (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION ||
+		    mmc_op_tuning(cmd->cmdidx)))
 		mask &= ~SDHCI_CMD_INHIBIT_DATA;
 
 	if (data && data->timeout_ns != 0)
@@ -853,7 +864,8 @@ int sdhci_wait_idle_data(struct sdhci *host, struct mci_cmd *cmd)
 	mask = SDHCI_CMD_INHIBIT_CMD | SDHCI_CMD_INHIBIT_DATA;
 	timeout_ns = SDHCI_CMD_DEFAULT_BUSY_TIMEOUT_NS;
 
-	if (cmd && cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
+	if (cmd && (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION ||
+		    mmc_op_tuning(cmd->cmdidx)))
 		mask &= ~SDHCI_CMD_INHIBIT_DATA;
 
 	if (cmd && cmd->busy_timeout != 0)
-- 
2.39.5




  parent reply	other threads:[~2025-05-05 12:39 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-05 12:06 [PATCH 00/30] mci: imx-esdhc: add HS200 support Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 01/30] mci: sdhci: fix SDHCI_TRNS_AUTO_CMD12 definition Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 02/30] mci: move most recent I/O settings into mci_host::ios Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 03/30] mci: use struct mci_host::ios inside mci_set_ios Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 04/30] mci: tuning: fix fallback to DDR52 Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 05/30] mci: sdhci: unmap DMA buffers on timeout Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 06/30] mci: add MMC_CAP_UHS constants Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 07/30] mci: rename MMC_CAP_MMC_x_yV_DDR to MMC_CAP_x_yV_DDR as in Linux Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 08/30] mci: compare host and card caps for supported speeds Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 09/30] mci: print HS200 capabilities in devinfo Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 10/30] mci: respect no-1-8-v OF property Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 11/30] mci: sdhci: add support for struct mci_data::timeout_ns Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 12/30] mci: imx-esdhc: use unsigned types where appropriate Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 13/30] mci: imx-esdhc: implement esdhc_poll using sdhci_read32_poll_timeout Ahmad Fatoum
2025-05-06  6:25   ` Sascha Hauer
2025-05-05 12:06 ` [PATCH 14/30] mci: imx-esdhc: drop one extra read of SDHCI_INT_STATUS Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 15/30] mci: sdhci: add cmd parameter to sdhci_transfer_* Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 16/30] mci: arasan: introduce mmc_op_tuning helper Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 17/30] mci: imx-esdhc: flesh out register description Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 18/30] mci: imx-esdhc: add support for delay/tuning properties in DT Ahmad Fatoum
2025-05-06  6:37   ` Sascha Hauer
2025-05-05 12:06 ` [PATCH 19/30] mci: add mci_set_timing helper Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 20/30] mci: imx-esdhc: add support for setting drive strength Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 21/30] mci: sdhci: move SDHCI_MAKE_BLKSZ definition to header Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 22/30] mci: imx-esdhc: select different pinctrl state depending on frequency Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 23/30] mci: core: retry MMC_CMD_SET_BLOCKLEN up to 4 times Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 24/30] mci: imx-esdhc: don't reconfigure clock unless required Ahmad Fatoum
2025-05-05 12:06 ` Ahmad Fatoum [this message]
2025-05-05 12:06 ` [PATCH 26/30] mci: core: implement mmc_send_tuning Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 27/30] mci: imx-esdhc: set burst_length_enable Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 28/30] mci: imx-esdhc: fixup quirks in standard SDHCI registers Ahmad Fatoum
2025-05-06  7:11   ` Sascha Hauer
2025-05-05 12:06 ` [PATCH 29/30] mci: sdhci: support Linux SDHCI_QUIRK2_BROKEN_HS200 flag Ahmad Fatoum
2025-05-05 12:06 ` [PATCH 30/30] mci: imx-esdhc: implement HS200 support Ahmad Fatoum
2025-05-05 12:41   ` Ahmad Fatoum

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=20250505120633.3717186-26-a.fatoum@pengutronix.de \
    --to=a.fatoum@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