[PATCH] mci: sdhci: arasan: fix probing eMMC without no-sd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Usual procedure when calling the detect callback of a MCI host driver is
to assume the connected card is a SD-Card and on timeout, treat it as
MMC instead. The Arasan driver failed to do this properly leading to the
need to specify no-sd to get eMMCs working. This is because the driver
only handled software timeouts gracefully: The MCI host itself may also
report timeout and it should not be treated as an error and instead
should be silently passed along as -ETIMEDOUT, so the MCI core can check
against it and fall back to eMMC after a failed probe for SD.

Reported-by: Michael Graichen <michael.graichen@xxxxxxxxxxx>
Reported-by: Steffen Trumtrar <s.trumtrar@xxxxxxxxxxxxxx>
Cc: Yann Sionneau <ysionneau@xxxxxxxxx>
Signed-off-by: Ahmad Fatoum <ahmad@xxxxxx>
---
 drivers/mci/arasan-sdhci.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/mci/arasan-sdhci.c b/drivers/mci/arasan-sdhci.c
index 22389503becf..00a8ceed6836 100644
--- a/drivers/mci/arasan-sdhci.c
+++ b/drivers/mci/arasan-sdhci.c
@@ -136,16 +136,17 @@ static void arasan_sdhci_set_ios(struct mci_host *mci, struct mci_ios *ios)
 static int arasan_sdhci_wait_for_done(struct arasan_sdhci_host *host, u32 mask)
 {
 	u64 start = get_time_ns();
-	u16 stat;
-	u16 error;
+	u32 stat;
 
 	do {
-		stat = sdhci_read16(&host->sdhci, SDHCI_INT_NORMAL_STATUS);
+		stat = sdhci_read32(&host->sdhci, SDHCI_INT_STATUS);
+
+		if (stat & SDHCI_INT_TIMEOUT)
+			return -ETIMEDOUT;
+
 		if (stat & SDHCI_INT_ERROR) {
-			error = sdhci_read16(&host->sdhci,
-					     SDHCI_INT_ERROR_STATUS);
 			dev_err(host->mci.hw_dev, "SDHCI_INT_ERROR: 0x%08x\n",
-				error);
+				stat);
 			return -EPERM;
 		}
 
@@ -159,8 +160,11 @@ static int arasan_sdhci_wait_for_done(struct arasan_sdhci_host *host, u32 mask)
 	return 0;
 }
 
-static void print_error(struct arasan_sdhci_host *host, int cmdidx)
+static void print_error(struct arasan_sdhci_host *host, int cmdidx, int ret)
 {
+	if (ret == -ETIMEDOUT)
+		return;
+
 	dev_err(host->mci.hw_dev,
 		"error while transferring data for command %d\n", cmdidx);
 	dev_err(host->mci.hw_dev, "state = 0x%08x , interrupt = 0x%08x\n",
@@ -210,10 +214,8 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 	sdhci_write16(&host->sdhci, SDHCI_COMMAND, command);
 
 	ret = arasan_sdhci_wait_for_done(host, mask);
-	if (ret == -EPERM)
+	if (ret)
 		goto error;
-	else if (ret)
-		return ret;
 
 	sdhci_read_response(&host->sdhci, cmd);
 	sdhci_write32(&host->sdhci, SDHCI_INT_STATUS, mask);
@@ -223,7 +225,7 @@ static int arasan_sdhci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 
 error:
 	if (ret) {
-		print_error(host, cmd->cmdidx);
+		print_error(host, cmd->cmdidx, ret);
 		arasan_sdhci_reset(host, BIT(1)); // SDHCI_RESET_CMD
 		arasan_sdhci_reset(host, BIT(2)); // SDHCI_RESET_DATA
 	}
-- 
2.38.1





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux