The following changes appear to fix the problems I have been experiencing. I think the basic issue is that I get timeouts even when the flag specifies completion. I also fixed a missing parenthesis that causes a test to always be false:

diff --git a/drivers/mfd/glamo/glamo-mci.c b/drivers/mfd/glamo/glamo-mci.c
index 789352d..76f1c7c 100644
--- a/drivers/mfd/glamo/glamo-mci.c
+++ b/drivers/mfd/glamo/glamo-mci.c
@@ -188,14 +188,14 @@ static void glamo_mci_irq(unsigned int irq, struct irq_desc *desc)
    writew(GLAMO_IRQ_MMC,
           glamo_mci_def_pdata.pglamo->base + GLAMO_REG_IRQ_CLEAR);

-    if (status & (GLAMO_STAT1_MMC_RTOUT |
-              GLAMO_STAT1_MMC_DTOUT))
+    if ((status & GLAMO_STAT1_MMC_DTOUT) &&
+        !(status & GLAMO_STAT1_MMC_RB_DRDY))
        cmd->error = -ETIMEDOUT;
    if (status & (GLAMO_STAT1_MMC_BWERR |
              GLAMO_STAT1_MMC_BRERR))
        cmd->error = -EILSEQ;
    if (cmd->error) {
-        dev_info(&host->pdev->dev, "Error after cmd: 0x%x\n", status);
+ dev_info(&host->pdev->dev, "Error in irq after cmd: 0x%x\n", status);
        goto done;
    }

@@ -227,7 +227,7 @@ static int glamo_mci_send_command(struct glamo_mci_host *host,

    /* if we can't do it, reject as busy */
    if (!(readw_dly(host->base + GLAMO_REG_MMC_RB_STAT1) &
-         GLAMO_STAT1_MMC_IDLE)) {
+         GLAMO_STAT1_MMC_IDLE)) {
        host->mrq = NULL;
        cmd->error = -EBUSY;
        mmc_request_done(host->mmc, cmd->mrq);
@@ -450,7 +450,9 @@ static void glamo_mci_send_request(struct mmc_host *mmc)
    do
        status = readw_dly(host->base + GLAMO_REG_MMC_RB_STAT1);
    while ((((status >> 15) & 1) != (host->ccnt & 1)) ||
-        (!(status & (GLAMO_STAT1_MMC_RB_RRDY |
+        (!(status & (GLAMO_STAT1_MMC_IDLE |
+                 GLAMO_STAT1_MMC_RB_RRDY |
+                 GLAMO_STAT1_MMC_RB_DRDY |
                 GLAMO_STAT1_MMC_RTOUT |
                 GLAMO_STAT1_MMC_DTOUT |
                 GLAMO_STAT1_MMC_BWERR |
@@ -468,20 +470,22 @@ static void glamo_mci_send_request(struct mmc_host *mmc)

    if (cmd->error) {
        dev_info(&host->pdev->dev, "Error after cmd: 0x%x\n", status);
-        goto done;
    }
-    /*
-     * mangle the response registers in two different exciting
-     * undocumented ways discovered by trial and error
-     */
-    if (mmc_resp_type(cmd) == MMC_RSP_R2)
-        /* grab the response */
-        for (n = 0; n < 8; n++) /* super mangle power 1 */
-            pu16[n ^ 6] = readw_dly(&reg_resp[n]);
-    else
-        for (n = 0; n < 3; n++) /* super mangle power 2 */
-            pu16[n] = (readw_dly(&reg_resp[n]) >> 8) |
-                  (readw_dly(&reg_resp[n + 1]) << 8);
+
+    if (status & GLAMO_STAT1_MMC_RB_RRDY) {
+        /*
+         * mangle the response registers in two different exciting
+         * undocumented ways discovered by trial and error
+         */
+        if (mmc_resp_type(cmd) == MMC_RSP_R2)
+            /* grab the response */
+            for (n = 0; n < 8; n++) /* super mangle power 1 */
+                pu16[n ^ 6] = readw_dly(&reg_resp[n]);
+        else
+            for (n = 0; n < 3; n++) /* super mangle power 2 */
+                pu16[n] = (readw_dly(&reg_resp[n]) >> 8) |
+                      (readw_dly(&reg_resp[n + 1]) << 8);
+    }
    /*
     * if we don't have bulk data to take care of, we're done
     */
diff --git a/drivers/mfd/glamo/glamo-mci.c b/drivers/mfd/glamo/glamo-mci.c
index 789352d..76f1c7c 100644
--- a/drivers/mfd/glamo/glamo-mci.c
+++ b/drivers/mfd/glamo/glamo-mci.c
@@ -188,14 +188,14 @@ static void glamo_mci_irq(unsigned int irq, struct irq_desc *desc)
 	writew(GLAMO_IRQ_MMC,
 	       glamo_mci_def_pdata.pglamo->base + GLAMO_REG_IRQ_CLEAR);
 
-	if (status & (GLAMO_STAT1_MMC_RTOUT |
-		      GLAMO_STAT1_MMC_DTOUT))
+	if ((status & GLAMO_STAT1_MMC_DTOUT) &&
+		!(status & GLAMO_STAT1_MMC_RB_DRDY))
 		cmd->error = -ETIMEDOUT;
 	if (status & (GLAMO_STAT1_MMC_BWERR |
 		      GLAMO_STAT1_MMC_BRERR))
 		cmd->error = -EILSEQ;
 	if (cmd->error) {
-		dev_info(&host->pdev->dev, "Error after cmd: 0x%x\n", status);
+		dev_info(&host->pdev->dev, "Error in irq after cmd: 0x%x\n", status);
 		goto done;
 	}
 
@@ -227,7 +227,7 @@ static int glamo_mci_send_command(struct glamo_mci_host *host,
 
 	/* if we can't do it, reject as busy */
 	if (!(readw_dly(host->base + GLAMO_REG_MMC_RB_STAT1) &
-	     GLAMO_STAT1_MMC_IDLE)) {
+		 GLAMO_STAT1_MMC_IDLE)) {
 		host->mrq = NULL;
 		cmd->error = -EBUSY;
 		mmc_request_done(host->mmc, cmd->mrq);
@@ -450,7 +450,9 @@ static void glamo_mci_send_request(struct mmc_host *mmc)
 	do
 		status = readw_dly(host->base + GLAMO_REG_MMC_RB_STAT1);
 	while ((((status >> 15) & 1) != (host->ccnt & 1)) ||
-		(!(status & (GLAMO_STAT1_MMC_RB_RRDY |
+		(!(status & (GLAMO_STAT1_MMC_IDLE |
+				 GLAMO_STAT1_MMC_RB_RRDY |
+				 GLAMO_STAT1_MMC_RB_DRDY |
 			     GLAMO_STAT1_MMC_RTOUT |
 			     GLAMO_STAT1_MMC_DTOUT |
 			     GLAMO_STAT1_MMC_BWERR |
@@ -468,20 +470,22 @@ static void glamo_mci_send_request(struct mmc_host *mmc)
 
 	if (cmd->error) {
 		dev_info(&host->pdev->dev, "Error after cmd: 0x%x\n", status);
-		goto done;
 	}
-	/*
-	 * mangle the response registers in two different exciting
-	 * undocumented ways discovered by trial and error
-	 */
-	if (mmc_resp_type(cmd) == MMC_RSP_R2)
-		/* grab the response */
-		for (n = 0; n < 8; n++) /* super mangle power 1 */
-			pu16[n ^ 6] = readw_dly(&reg_resp[n]);
-	else
-		for (n = 0; n < 3; n++) /* super mangle power 2 */
-			pu16[n] = (readw_dly(&reg_resp[n]) >> 8) |
-				  (readw_dly(&reg_resp[n + 1]) << 8);
+
+	if (status & GLAMO_STAT1_MMC_RB_RRDY) {
+		/*
+		 * mangle the response registers in two different exciting
+		 * undocumented ways discovered by trial and error
+		 */
+		if (mmc_resp_type(cmd) == MMC_RSP_R2)
+			/* grab the response */
+			for (n = 0; n < 8; n++) /* super mangle power 1 */
+				pu16[n ^ 6] = readw_dly(&reg_resp[n]);
+		else
+			for (n = 0; n < 3; n++) /* super mangle power 2 */
+				pu16[n] = (readw_dly(&reg_resp[n]) >> 8) |
+					  (readw_dly(&reg_resp[n + 1]) << 8);
+	}
 	/*
 	 * if we don't have bulk data to take care of, we're done
 	 */

Reply via email to