]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mtd/onenand/omap2.c
Merge current mainline tree into linux-omap tree
[linux-2.6-omap-h63xx.git] / drivers / mtd / onenand / omap2.c
index a9885d1e9322ea0d43986173e563b1538c85d192..28034ef08a82a4e83d8cbaaad0be3265de7b9806 100644 (file)
@@ -3,9 +3,9 @@
  *
  *  OneNAND driver for OMAP2 / OMAP3
  *
- *  Copyright (C) 2005-2006 Nokia Corporation
+ *  Copyright © 2005-2006 Nokia Corporation
  *
- *  Author: Jarkko Lavinen <jarkko.lavinen@nokia.com> and Juha Yrjola
+ *  Author: Jarkko Lavinen <jarkko.lavinen@nokia.com> and Juha Yrjölä
  *  IRQ and DMA support written by Timo Teras
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -186,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;
+                       }
                }
        }