- addr[0x0555] = 0x00AA;
- addr[0x02AA] = 0x0055;
- addr[0x0555] = 0x0080;
- addr[0x0555] = 0x00AA;
- addr[0x02AA] = 0x0055;
-
- /* Start erase on unprotected sectors */
- for (sect = s_first; sect<=s_last; sect++) {
- if (info->protect[sect] == 0) { /* not protected */
- addr = (FPWV *)(info->start[sect]);
- addr[0] = 0x0030;
- l_sect = sect;
+ /*
+ * Start erase on unprotected sectors.
+ * Since the flash can erase multiple sectors with one command
+ * we take advantage of that by doing the erase in chunks of
+ * 3 sectors.
+ */
+ for (sect = s_first; sect <= s_last; ) {
+ l_sect = -1;
+
+ addr[FLASH_CYCLE1] = 0x00AA;
+ addr[FLASH_CYCLE2] = 0x0055;
+ addr[FLASH_CYCLE1] = 0x0080;
+ addr[FLASH_CYCLE1] = 0x00AA;
+ addr[FLASH_CYCLE2] = 0x0055;
+
+ /* do the erase in chunks of at most 3 sectors */
+ for (ssect = 0; ssect < 3; ssect++) {
+ if ((sect + ssect) > s_last)
+ break;
+ if (info->protect[sect + ssect] == 0) { /* not protected */
+ addr = (vu_short *)(info->start[sect + ssect]);
+ addr[0] = 0x0030;
+ l_sect = sect + ssect;
+ }