]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mtd/onenand/omap2.c
Merge branch 'for-2.6.28' of git://linux-nfs.org/~bfields/linux
[linux-2.6-omap-h63xx.git] / drivers / mtd / onenand / omap2.c
index 34b42533f4bbc9b3b809a622e3c89beebce911ce..e39b21d3e168e5bb3cabf1a076193bca3f33bcab 100644 (file)
@@ -38,7 +38,6 @@
 #include <asm/arch/gpmc.h>
 #include <asm/arch/onenand.h>
 #include <asm/arch/gpio.h>
-#include <asm/arch/gpmc.h>
 #include <asm/arch/pm.h>
 
 #include <linux/dma-mapping.h>
@@ -187,16 +186,36 @@ retry:
                        }
                }
        } else {
+               int retry_cnt = 0;
+
                /* Turn interrupts off */
                syscfg = read_reg(c, ONENAND_REG_SYS_CFG1);
                syscfg &= ~ONENAND_SYS_CFG1_IOBE;
                write_reg(c, syscfg, ONENAND_REG_SYS_CFG1);
 
                timeout = jiffies + msecs_to_jiffies(20);
-               while (time_before(jiffies, timeout)) {
-                       intr = read_reg(c, ONENAND_REG_INTERRUPT);
-                       if (intr & ONENAND_INT_MASTER)
+               while (1) {
+                       if (time_before(jiffies, timeout)) {
+                               intr = read_reg(c, ONENAND_REG_INTERRUPT);
+                               if (intr & ONENAND_INT_MASTER)
+                                       break;
+                       } else {
+                               /* Timeout after 20ms */
+                               ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
+                               if (ctrl & ONENAND_CTRL_ONGO) {
+                                       /*
+                                        * The operation seems to be still going
+                                        * so give it some more time.
+                                        */
+                                       retry_cnt += 1;
+                                       if (retry_cnt < 3) {
+                                               timeout = jiffies +
+                                                         msecs_to_jiffies(20);
+                                               continue;
+                                       }
+                               }
                                break;
+                       }
                }
        }