]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
Flash Erase enhancement by Chris Hallinan, 5 Apr 2001 16:41:29
authorwdenk <wdenk>
Tue, 10 Apr 2001 15:50:57 +0000 (15:50 +0000)
committerwdenk <wdenk>
Tue, 10 Apr 2001 15:50:57 +0000 (15:50 +0000)
Fix initialization problem in bootp.

board/walnut405/flash.c
net/bootp.c

index 5501e916f7cc60d0e93868b7d37561503d4d2217..4f083ef2d1144654afb25b8faf290f0cb102def5 100644 (file)
  * MA 02111-1307 USA
  */
 
+/*
+ * Modified 4/5/2001
+ * Wait for completion of each sector erase command issued
+ * 4/5/2001
+ * Chris Hallinan - DS4.COM, Inc. - clh@net1plus.com
+ */
+
 #include <ppcboot.h>
 #include <ppc4xx.h>
 #include <asm/processor.h>
@@ -473,6 +480,26 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
        return (info->size);
 }
 
+int wait_for_DQ7(flash_info_t *info, int sect)
+{
+       ulong start, now, last;
+       volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[sect]);
+
+       start = get_timer (0);
+    last  = start;
+    while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) {
+        if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
+            printf ("Timeout\n");
+            return -1;
+        }
+        /* show that we're waiting */
+        if ((now - last) > 1000) {  /* every second */
+            putc ('.');
+            last = now;
+        }
+    }
+       return 0;
+}
 
 /*-----------------------------------------------------------------------
  */
@@ -482,8 +509,7 @@ void        flash_erase (flash_info_t *info, int s_first, int s_last)
        volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[0]);
        volatile FLASH_WORD_SIZE *addr2;
        int flag, prot, sect, l_sect;
-       ulong start, now, last;
-        int i;
+       int i;
 
        if ((s_first < 0) || (s_first > s_last)) {
                if (info->flash_id == FLASH_UNKNOWN) {
@@ -522,26 +548,34 @@ void      flash_erase (flash_info_t *info, int s_first, int s_last)
        for (sect = s_first; sect<=s_last; sect++) {
                if (info->protect[sect] == 0) { /* not protected */
                    addr2 = (FLASH_WORD_SIZE *)(info->start[sect]);
-                    if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) {
-                        addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
-                        addr[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
-                        addr[ADDR0] = (FLASH_WORD_SIZE)0x00800080;
-                        addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
-                        addr[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
-                        addr2[0] = (FLASH_WORD_SIZE)0x00500050;  /* block erase */
-                        for (i=0; i<50; i++)
-                          udelay(1000);  /* wait 1 ms */
-                    } else {
-   if (sect == s_first) {
-                        addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
-                        addr[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
-                        addr[ADDR0] = (FLASH_WORD_SIZE)0x00800080;
-                        addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
-                        addr[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
-   }
-                        addr2[0] = (FLASH_WORD_SIZE)0x00300030;  /* sector erase */
-                    }
+                   printf("Erasing sector %p\n", addr2);       // CLH
+
+                   if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) {
+                       addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
+                       addr[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
+                       addr[ADDR0] = (FLASH_WORD_SIZE)0x00800080;
+                       addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
+                       addr[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
+                       addr2[0] = (FLASH_WORD_SIZE)0x00500050;  /* block erase */
+                       for (i=0; i<50; i++)
+                               udelay(1000);  /* wait 1 ms */
+                   } else {
+                       addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
+                       addr[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
+                       addr[ADDR0] = (FLASH_WORD_SIZE)0x00800080;
+                       addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
+                       addr[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
+                       addr2[0] = (FLASH_WORD_SIZE)0x00300030;  /* sector erase */
+                   }
                    l_sect = sect;
+                   /*
+                    * Wait for each sector to complete, it's more 
+                    * reliable.  According to AMD Spec, you must 
+                    * issue all erase commands within a specified
+                    * timeout.  This has been seen to fail, especially
+                    * if printf()s are included (for debug)!!
+                    */
+                   wait_for_DQ7(info, sect);
                }
        }
 
@@ -552,28 +586,16 @@ void      flash_erase (flash_info_t *info, int s_first, int s_last)
        /* wait at least 80us - let's wait 1 ms */
        udelay (1000);
 
+#if 0
        /*
         * We wait for the last triggered sector
         */
        if (l_sect < 0)
                goto DONE;
-
-       start = get_timer (0);
-       last  = start;
-       addr = (FLASH_WORD_SIZE *)(info->start[l_sect]);
-       while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) {
-               if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
-                       printf ("Timeout\n");
-                       return;
-               }
-               /* show that we're waiting */
-               if ((now - last) > 1000) {      /* every second */
-                       putc ('.');
-                       last = now;
-               }
-       }
+       wait_for_DQ7(info, l_sect);
 
 DONE:
+#endif
        /* reset to read mode */
        addr = (FLASH_WORD_SIZE *)info->start[0];
        addr[0] = (FLASH_WORD_SIZE)0x00F000F0;  /* reset bank */
index 16ae6f4d3001142760bcd7a83a802b074a6455eb..cb9638629555924ca930b47a883d466ce5e36b48 100644 (file)
@@ -293,14 +293,14 @@ static int BootpExtended (u8 *e)
      e  +=  2;
 #endif
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
-    *e++ = 40;         /* NIS Domain name request */
+#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
+    *e++ = 17;         /* Boot path */
     *e++ = 32;
      e  += 32;
 #endif
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
-    *e++ = 17;         /* Boot path */
+#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
+    *e++ = 40;         /* NIS Domain name request */
     *e++ = 32;
      e  += 32;
 #endif
@@ -319,6 +319,7 @@ BootpRequest (void)
 
        printf("BOOTP broadcast %d\n", ++BootpTry);
        pkt = NetTxPacket;
+       memset ((void*)pkt, 0, PKTSIZE);
 
        NetSetEther(pkt, NetBcastAddr, PROT_IP);
        pkt += ETHER_HDR_SIZE;