Flashrom support for some Numonyx parts (M25PE)

Using block erase d8 as discussed with Peter Stuge

Corresponding to flashrom svn r333 and coreboot v2 svn r3707.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
diff --git a/flash.h b/flash.h
index bce4844..0812331 100644
--- a/flash.h
+++ b/flash.h
@@ -424,6 +424,7 @@
 void spi_write_enable();
 void spi_write_disable();
 int spi_chip_erase_c7(struct flashchip *flash);
+int spi_chip_erase_d8(struct flashchip *flash);
 int spi_chip_write(struct flashchip *flash, uint8_t *buf);
 int spi_chip_read(struct flashchip *flash, uint8_t *buf);
 uint8_t spi_read_status_register();
diff --git a/flashchips.c b/flashchips.c
index 3043caf..1115342 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -59,6 +59,11 @@
 	{"Macronix",	"MX25L1605",		MX_ID,		MX_25L1605,		2048,	256,		TEST_UNTESTED,	probe_spi_rdid,		spi_chip_erase_c7,	spi_chip_write,	spi_chip_read},
 	{"Macronix",	"MX25L3205",		MX_ID,		MX_25L3205,		4096,	256,		TEST_OK_PREW,	probe_spi_rdid,		spi_chip_erase_c7,	spi_chip_write,	spi_chip_read},
 	{"Macronix",	"MX29F002",		MX_ID,		MX_29F002,		256,	64 * 1024,	TEST_UNTESTED,	probe_29f002,		erase_29f002,			write_29f002},
+	{"Numonyx",	"M25PE10",		ST_ID,		0x8011,			128,	256,		TEST_UNTESTED,	probe_spi_rdid,		spi_chip_erase_d8,	spi_chip_write, spi_chip_read},
+	{"Numonyx",	"M25PE20",		ST_ID,		0x8012,			256,	256,		TEST_UNTESTED,	probe_spi_rdid,		spi_chip_erase_d8,	spi_chip_write, spi_chip_read},
+	{"Numonyx",	"M25PE40",		ST_ID,		0x8013,			256,	256,		TEST_UNTESTED,	probe_spi_rdid,		spi_chip_erase_d8,	spi_chip_write, spi_chip_read},
+	{"Numonyx",	"M25PE80",		ST_ID,		0x8014,			1024,	256,		TEST_OK_PREW,	probe_spi_rdid,		spi_chip_erase_d8,	spi_chip_write, spi_chip_read},
+	{"Numonyx",	"M25PE16",		ST_ID,		0x8015,			2048,	256,		TEST_UNTESTED,	probe_spi_rdid,		spi_chip_erase_d8,	spi_chip_write, spi_chip_read},
 	{"PMC",		"Pm25LV010",		PMC_ID,		PMC_25LV010,		128,	256,		TEST_UNTESTED,	probe_spi_rdid,		spi_chip_erase_c7,	spi_chip_write,	spi_chip_read},
 	{"PMC",		"Pm25LV016B",		PMC_ID,		PMC_25LV016B,		2048,	256,		TEST_UNTESTED,	probe_spi_rdid,		spi_chip_erase_c7,	spi_chip_write,	spi_chip_read},
 	{"PMC",		"Pm25LV020",		PMC_ID,		PMC_25LV020,		256,	256,		TEST_UNTESTED,	probe_spi_rdid,		spi_chip_erase_c7,	spi_chip_write,	spi_chip_read},
diff --git a/spi.c b/spi.c
index 0028b4c..83624fa 100644
--- a/spi.c
+++ b/spi.c
@@ -310,6 +310,29 @@
 	return 0;
 }
 
+int spi_chip_erase_d8(struct flashchip *flash)
+{
+	int i, rc = 0;
+	int total_size = flash->total_size * 1024;
+	int erase_size = 64 * 1024;
+
+	spi_disable_blockprotect();
+
+	printf("Erasing chip: \n");
+
+	for (i = 0; i < total_size / erase_size; i++) {
+		rc = spi_block_erase_d8(flash, i * erase_size);
+		if (rc) {
+			printf("Error erasing block at 0x%x\n", i);
+			break;
+		}
+	}
+
+	printf("\n");
+
+	return rc;
+}
+
 /* Sector size is usually 4k, though Macronix eliteflash has 64k */
 int spi_sector_erase(const struct flashchip *flash, unsigned long addr)
 {