Re: [PATCH] mmc:sdhci: Add Auto-CMD12 err detecting and handling routine

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

 



Hi, all

Expect your comments.


On 08/23/2013 07:04 PM, Haijun Zhang wrote:
When Auto-CMD12 is enabled, Auto-cmd12 error status and signal
bit should be set to reflect this behaviour in case error.

Signed-off-by: Haijun Zhang <haijun.zhang@xxxxxxxxxxxxx>
---
  drivers/mmc/host/sdhci.c | 32 +++++++++++++++++++++-----------
  1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index a78bd4f..db30b3e 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -238,16 +238,23 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);

  static void sdhci_init(struct sdhci_host *host, int soft)
  {
+	u32 init_irq;
+
  	if (soft)
  		sdhci_reset(host, SDHCI_RESET_CMD|SDHCI_RESET_DATA);
  	else
  		sdhci_reset(host, SDHCI_RESET_ALL);

-	sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK,
-		SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
-		SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_INDEX |
-		SDHCI_INT_END_BIT | SDHCI_INT_CRC | SDHCI_INT_TIMEOUT |
-		SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE);
+	init_irq = SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
+			SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT |
+			SDHCI_INT_INDEX | SDHCI_INT_END_BIT |
+			SDHCI_INT_CRC | SDHCI_INT_TIMEOUT |
+			SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE;
+
+	if (host->flags & SDHCI_AUTO_CMD12)
+		init_irq |= SDHCI_INT_ACMD12ERR;
+
+	sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, init_irq);

  	if (soft) {
  		/* force clock reconfiguration */
@@ -2238,7 +2245,7 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
  	if (intmask & SDHCI_INT_TIMEOUT)
  		host->cmd->error = -ETIMEDOUT;
  	else if (intmask & (SDHCI_INT_CRC | SDHCI_INT_END_BIT |
-			SDHCI_INT_INDEX))
+			SDHCI_INT_INDEX | SDHCI_INT_ACMD12ERR))
  		host->cmd->error = -EILSEQ;

  	if (host->cmd->error) {
@@ -2408,6 +2415,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
  	struct sdhci_host *host = dev_id;
  	u32 intmask, unexpected = 0;
  	int cardint = 0, max_loops = 16;
+	u32 cmd_mask = SDHCI_INT_CMD_MASK;

  	spin_lock(&host->lock);

@@ -2454,10 +2462,12 @@ again:
  		tasklet_schedule(&host->card_tasklet);
  	}

-	if (intmask & SDHCI_INT_CMD_MASK) {
-		sdhci_writel(host, intmask & SDHCI_INT_CMD_MASK,
-			SDHCI_INT_STATUS);
-		sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK);
+	if (host->flags & SDHCI_AUTO_CMD12)
+		cmd_mask |= SDHCI_INT_ACMD12ERR;
+
+	if (intmask & cmd_mask) {
+		sdhci_writel(host, intmask & cmd_mask, SDHCI_INT_STATUS);
+		sdhci_cmd_irq(host, intmask & cmd_mask);
  	}

  	if (intmask & SDHCI_INT_DATA_MASK) {
@@ -2466,7 +2476,7 @@ again:
  		sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK);
  	}

-	intmask &= ~(SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK);
+	intmask &= ~(cmd_mask | SDHCI_INT_DATA_MASK);

  	intmask &= ~SDHCI_INT_ERROR;




--
Thanks & Regards

Haijun

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux