Index: jedec.c
===================================================================
--- jedec.c	(revision 809)
+++ jedec.c	(working copy)
@@ -245,6 +245,16 @@
 	return 0;
 }
 
+int erase_all_blocks_jedec(struct flashchip *flash, unsigned int addr, unsigned int blocksize)
+{
+	if ((addr != 0) || (blocksize != flash->total_size * 1024)) {
+		fprintf(stderr, "%s called with incorrect arguments\n",
+			__func__);
+		return -1;
+	}
+	return erase_chip_jedec(flash);
+}
+
 int erase_chip_jedec(struct flashchip *flash)
 {
 	int total_size = flash->total_size * 1024;
Index: flashchips.c
===================================================================
--- flashchips.c	(revision 809)
+++ flashchips.c	(working copy)
@@ -61,10 +61,20 @@
 		.model_id	= AM_29F010B,	/* Same as Am29F010A */
 		.total_size	= 128,
 		.page_size	= 16 * 1024,
-		.tested		= TEST_OK_PREW,
+		.tested		= TEST_OK_PRW,
 		.probe		= probe_29f040b,
 		.probe_timing	= TIMING_ZERO,
-		.erase		= erase_29f040b,
+		.erase		= NULL,
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = { {16 * 1024, 8} },
+				.block_erase = erase_sector_29f040b,
+			}, {
+				.eraseblocks = { {128 * 1024, 1} },
+				.block_erase = erase_chip_29f040b,
+			},
+		},
 		.write		= write_pm29f002,
 		.read		= read_memmapped,
 	},
@@ -80,7 +90,22 @@
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_jedec,
 		.probe_timing	= TIMING_ZERO,
-		.erase		= erase_chip_jedec,
+		.erase		= NULL,
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = { 
+					{16 * 1024, 1},
+					{8 * 1024, 2},
+					{32 * 1024, 1},
+					{64 * 1024, 3},
+				},
+				.block_erase = erase_sector_jedec,
+			}, {
+				.eraseblocks = { {256 * 1024, 1} },
+				.block_erase = erase_all_blocks_jedec,
+			},
+		},
 		.write		= write_jedec_1,
 		.read		= read_memmapped,
 	},
@@ -93,10 +118,25 @@
 		.model_id	= AM_29F002BT,
 		.total_size	= 256,
 		.page_size	= 256,
-		.tested		= TEST_OK_PRE,
+		.tested		= TEST_OK_PR,
 		.probe		= probe_jedec,
 		.probe_timing	= TIMING_ZERO,
-		.erase		= erase_chip_jedec,
+		.erase		= NULL,
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = { 
+					{16 * 1024, 1},
+					{8 * 1024, 2},
+					{32 * 1024, 1},
+					{64 * 1024, 3},
+				},
+				.block_erase = erase_sector_jedec,
+			}, {
+				.eraseblocks = { {256 * 1024, 1} },
+				.block_erase = erase_all_blocks_jedec,
+			},
+		},
 		.write		= write_jedec_1,
 		.read		= read_memmapped,
 	},
@@ -107,12 +147,22 @@
 		.bustype	= CHIP_BUSTYPE_PARALLEL,
 		.manufacture_id	= AMD_ID,
 		.model_id	= AM_29F016D,
-		.total_size	= 2048,
+		.total_size	= 2 * 1024,
 		.page_size	= 64 * 1024,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_29f040b,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (am29f040b.c) */
-		.erase		= erase_29f040b,
+		.erase		= NULL,
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = { {64 * 1024, 32} },
+				.block_erase = erase_sector_29f040b,
+			}, {
+				.eraseblocks = { {2048 * 1024, 1} },
+				.block_erase = erase_chip_29f040b,
+			},
+		},
 		.write		= write_29f040b,
 		.read		= read_memmapped,
 	},
@@ -125,10 +175,20 @@
 		.model_id	= AM_29F040B,
 		.total_size	= 512,
 		.page_size	= 64 * 1024,
-		.tested		= TEST_OK_PREW,
+		.tested		= TEST_OK_PRW,
 		.probe		= probe_29f040b,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (am29f040b.c) */
-		.erase		= erase_29f040b,
+		.erase		= NULL,
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = { {64 * 1024, 8} },
+				.block_erase = erase_sector_29f040b,
+			}, {
+				.eraseblocks = { {512 * 1024, 1} },
+				.block_erase = erase_chip_29f040b,
+			},
+		},
 		.write		= write_29f040b,
 		.read		= read_memmapped,
 	},
@@ -144,7 +204,17 @@
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_jedec,
 		.probe_timing	= TIMING_ZERO,
-		.erase		= erase_29f040b,
+		.erase		= NULL,
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = { {64 * 1024, 16} },
+				.block_erase = erase_sector_29f040b,
+			}, {
+				.eraseblocks = { {1024 * 1024, 1} },
+				.block_erase = erase_chip_29f040b,
+			},
+		},
 		.write		= write_29f040b,
 		.read		= read_memmapped,
 	},
@@ -160,7 +230,17 @@
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_29f040b,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (am29f040b.c) */
-		.erase		= erase_29f040b,
+		.erase		= NULL,
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = { {64 * 1024, 8} },
+				.block_erase = erase_sector_29f040b,
+			}, {
+				.eraseblocks = { {512 * 1024, 1} },
+				.block_erase = erase_chip_29f040b,
+			},
+		},
 		.write		= write_29f040b,
 		.read		= read_memmapped,
 	},
@@ -176,7 +256,17 @@
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_29f040b,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (am29f040b.c) */
-		.erase		= erase_29f040b,
+		.erase		= NULL,
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = { {64 * 1024, 16} },
+				.block_erase = erase_sector_29f040b,
+			}, {
+				.eraseblocks = { {1024 * 1024, 1} },
+				.block_erase = erase_chip_29f040b,
+			},
+		},
 		.write		= write_29f040b,
 		.read		= read_memmapped,
 	},
@@ -770,7 +860,17 @@
 		.tested		= TEST_OK_PR,
 		.probe		= probe_29f040b,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (am29f040b.c) */
-		.erase		= erase_29f040b,
+		.erase		= NULL,
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = { {64 * 1024, 8} },
+				.block_erase = erase_sector_29f040b,
+			}, {
+				.eraseblocks = { {512 * 1024, 1} },
+				.block_erase = erase_chip_29f040b,
+			},
+		},
 		.write		= write_29f040b,
 		.read		= read_memmapped,
 	},
@@ -1768,32 +1868,62 @@
 
 	{
 		.vendor		= "PMC",
-		.name		= "Pm29F0002T",
+		.name		= "Pm29F002T",
 		.bustype	= CHIP_BUSTYPE_PARALLEL,
 		.manufacture_id	= PMC_ID_NOPREFIX,
 		.model_id	= PMC_29F002T,
 		.total_size	= 256,
-		.page_size	= 8192,
+		.page_size	= 8 * 1024,
 		.tested		= TEST_OK_PREW,
 		.probe		= probe_29f040b,
 		.probe_timing	= TIMING_FIXME, 
-		.erase		= erase_29f040b,
+		.erase		= NULL,
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = { 
+					{16 * 1024, 1}, 
+					{8 * 1024, 2}, 
+					{96 * 1024, 1}, 
+					{128 * 1024, 1}, 
+				},
+				.block_erase = erase_sector_29f040b,
+			}, {
+				.eraseblocks = { {256 * 1024, 1} },
+				.block_erase = erase_chip_29f040b,
+			},
+		},
 		.write		= write_pm29f002,
 		.read		= read_memmapped,
 	},
 
 	{
 		.vendor		= "PMC",
-		.name		= "Pm29F0002B",
+		.name		= "Pm29F002B",
 		.bustype	= CHIP_BUSTYPE_PARALLEL,
 		.manufacture_id	= PMC_ID_NOPREFIX,
 		.model_id	= PMC_29F002B,
 		.total_size	= 256,
-		.page_size	= 8192,
+		.page_size	= 8 * 1024,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_29f040b,
 		.probe_timing	= TIMING_FIXME, 
-		.erase		= erase_29f040b,
+		.erase		= NULL,
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = { 
+					{16 * 1024, 1}, 
+					{8 * 1024, 2}, 
+					{96 * 1024, 1}, 
+					{128 * 1024, 1}, 
+				},
+				.block_erase = erase_sector_29f040b,
+			}, {
+				.eraseblocks = { {256 * 1024, 1} },
+				.block_erase = erase_chip_29f040b,
+			},
+		},
 		.write		= write_pm29f002,
 		.read		= read_memmapped,
 	},
@@ -1949,7 +2079,7 @@
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_25VF040_REMS,
 		.total_size	= 512,
-		.page_size	= 64*1024,
+		.page_size	= 64 * 1024,
 		.tested		= TEST_OK_PR,
 		.probe		= probe_spi_rems,
 		.probe_timing	= TIMING_ZERO,
@@ -1965,7 +2095,7 @@
 		.manufacture_id	= SST_ID,
 		.model_id	= SST_25VF040B_REMS,
 		.total_size	= 512,
-		.page_size	= 64*1024,
+		.page_size	= 64 * 1024,
 		.tested		= TEST_OK_PR,
 		.probe		= probe_spi_rems,
 		.probe_timing	= TIMING_ZERO,
@@ -3139,7 +3269,7 @@
 		.manufacture_id	= WINBOND_ID,
 		.model_id	= W_39V040A,
 		.total_size	= 512,
-		.page_size	= 64*1024,
+		.page_size	= 64 * 1024,
 		.tested		= TEST_OK_PREW,
 		.probe		= probe_jedec,
 		.probe_timing	= 10, 
@@ -3155,7 +3285,7 @@
 		.manufacture_id	= WINBOND_ID,
 		.model_id	= W_39V040B,
 		.total_size	= 512,
-		.page_size	= 64*1024,
+		.page_size	= 64 * 1024,
 		.tested		= TEST_OK_PR | TEST_BAD_ERASE | TEST_BAD_WRITE,
 		.probe		= probe_jedec,
 		.probe_timing	= 10, 
@@ -3171,7 +3301,7 @@
 		.manufacture_id	= WINBOND_ID,
 		.model_id	= W_39V040C,
 		.total_size	= 512,
-		.page_size	= 64*1024,
+		.page_size	= 64 * 1024,
 		.tested		= TEST_OK_PREW,
 		.probe		= probe_w39v040c,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (w39v040c.c) */
@@ -3187,7 +3317,7 @@
 		.manufacture_id	= WINBOND_ID,
 		.model_id	= W_39V040FA,
 		.total_size	= 512,
-		.page_size	= 64*1024,
+		.page_size	= 64 * 1024,
 		.tested		= TEST_OK_PREW,
 		.probe		= probe_jedec,
 		.probe_timing	= 10, 
@@ -3203,7 +3333,7 @@
 		.manufacture_id	= WINBOND_ID,
 		.model_id	= W_39V080A,
 		.total_size	= 1024,
-		.page_size	= 64*1024,
+		.page_size	= 64 * 1024,
 		.tested		= TEST_OK_PREW,
 		.probe		= probe_jedec,
 		.probe_timing	= 10, 
@@ -3267,7 +3397,7 @@
 		.manufacture_id	= WINBOND_ID,
 		.model_id	= W_39V080FA,
 		.total_size	= 1024,
-		.page_size	= 64*1024,
+		.page_size	= 64 * 1024,
 		.tested		= TEST_OK_PREW,
 		.probe		= probe_winbond_fwhub,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (w39v080fa.c) */
@@ -3283,7 +3413,7 @@
 		.manufacture_id	= WINBOND_ID,
 		.model_id	= W_39V080FA_DM,
 		.total_size	= 512,
-		.page_size	= 64*1024,
+		.page_size	= 64 * 1024,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_winbond_fwhub,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (w39v080fa.c) */
Index: am29f040b.c
===================================================================
--- am29f040b.c	(revision 809)
+++ am29f040b.c	(working copy)
@@ -22,9 +22,9 @@
 
 /* FIMXE: check that the 2 second delay is really needed.
           Use erase_sector_jedec if not? */
-static int erase_sector_29f040b(struct flashchip *flash, unsigned long address)
+int erase_sector_29f040b(struct flashchip *flash, unsigned int address, unsigned int blocklen)
 {
-	int page_size = flash->page_size;
+	//int page_size = flash->page_size;
 	chipaddr bios = flash->virtual_memory;
 
 	chip_writeb(0xAA, bios + 0x555);
@@ -39,13 +39,24 @@
 	/* wait for Toggle bit ready         */
 	toggle_ready_jedec(bios + address);
 
-	if (check_erased_range(flash, address, page_size)) {
+	if (check_erased_range(flash, address, blocklen)) {
 		fprintf(stderr, "ERASE FAILED!\n");
 		return -1;
 	}
 	return 0;
 }
 
+/* erase chip with block_erase() prototype */
+int erase_chip_29f040b(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+{
+	if ((addr != 0) || (blocklen != flash->total_size * 1024)) {
+		fprintf(stderr, "%s called with incorrect arguments\n",
+			__func__);
+		return -1;
+	}
+	return erase_29f040b(flash);
+}
+
 /* FIXME: use write_sector_jedec? */
 static int write_sector_29f040b(chipaddr bios, uint8_t *src, chipaddr dst,
 				unsigned int page_size)
@@ -127,7 +138,7 @@
 	printf("Programming page ");
 	for (i = 0; i < total_size / page_size; i++) {
 		/* erase the page before programming */
-		if (erase_sector_29f040b(flash, i * page_size)) {
+		if (erase_sector_29f040b(flash, i * page_size, page_size)) {
 			fprintf(stderr, "ERASE FAILED!\n");
 			return -1;
 		}
Index: chipdrivers.h
===================================================================
--- chipdrivers.h	(revision 809)
+++ chipdrivers.h	(working copy)
@@ -60,6 +60,8 @@
 /* am29f040b.c */
 int probe_29f040b(struct flashchip *flash);
 int erase_29f040b(struct flashchip *flash);
+int erase_sector_29f040b(struct flashchip *flash, unsigned int blockaddr, unsigned int blocksize);
+int erase_chip_29f040b(struct flashchip *flash, unsigned int blockaddr, unsigned int blocksize);
 int write_29f040b(struct flashchip *flash, uint8_t *buf);
 
 /* pm29f002.c */
@@ -83,6 +85,7 @@
 int write_jedec_1(struct flashchip *flash, uint8_t *buf);
 int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int pagesize);
 int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
+int erase_all_blocks_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
 int write_sector_jedec(chipaddr bios, uint8_t *src,
 		       chipaddr dst, unsigned int page_size);
 
