Mark Fujitsu MBM29F400BC write as broken (implicit eraseblock layout in write)

Use full-chip write function on Fujitsu MBM29F400TC and ST M29F400BT.
Add support for ST M29F400BB.

Corresponding to flashrom svn r1083.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
diff --git a/chipdrivers.h b/chipdrivers.h
index 3a9c611..9e7af2d 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -87,7 +87,6 @@
 int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
 int block_erase_chip_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
 int write_m29f400bt(struct flashchip *flash, uint8_t *buf);
-int write_coreboot_m29f400bt(struct flashchip *flash, uint8_t *buf);
 void protect_m29f400bt(chipaddr bios);
 void write_page_m29f400bt(chipaddr bios, uint8_t *src,
 			  chipaddr dst, int page_size);
diff --git a/flashchips.c b/flashchips.c
index 354bd95..4c4305a 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -2382,7 +2382,7 @@
 		.total_size	= 512,
 		.page_size	= 64 * 1024,
 		.feature_bits	= FEATURE_ADDR_SHIFTED | FEATURE_EITHER_RESET,
-		.tested		= TEST_UNTESTED,
+		.tested		= TEST_BAD_WRITE, /* Implicit eraseblock layout in write_m29f400bt is broken. */
 		.probe		= probe_m29f400bt,
 		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (m29f400bt.c) */
 		.block_erasers	=
@@ -2400,7 +2400,7 @@
 				.block_erase = block_erase_chip_m29f400bt,
 			},
 		},
-		.write		= write_coreboot_m29f400bt,
+		.write		= NULL,
 		.read		= read_memmapped,
 	},
 
@@ -2431,7 +2431,7 @@
 				.block_erase = block_erase_chip_m29f400bt,
 			},
 		},
-		.write		= write_coreboot_m29f400bt,
+		.write		= write_m29f400bt,
 		.read		= read_memmapped,
 	},
 
@@ -5278,7 +5278,7 @@
 		.feature_bits	= FEATURE_ADDR_2AA | FEATURE_EITHER_RESET,
 		.tested		= TEST_UNTESTED,
 		.probe		= probe_jedec,
-		.probe_timing	= TIMING_IGNORED, /* routine don't use probe_timing (am29f040b.c) */
+		.probe_timing	= TIMING_IGNORED, /* routine doesn't use probe_timing (am29f040b.c) */
 		.block_erasers	=
 		{
 			{
@@ -5296,6 +5296,37 @@
 	{
 		/* FIXME: this has WORD/BYTE sequences; 2AA for word, 555 for byte */
 		.vendor		= "ST",
+		.name		= "M29F400BB",
+		.bustype	= CHIP_BUSTYPE_PARALLEL,
+		.manufacture_id	= ST_ID,
+		.model_id	= ST_M29F400BB,
+		.total_size	= 512,
+		.page_size	= 64 * 1024,
+		.feature_bits	= FEATURE_ADDR_SHIFTED | FEATURE_EITHER_RESET,
+		.tested		= TEST_BAD_WRITE, /* Implicit eraseblock layout in write_m29f400bt is broken. */
+		.probe		= probe_m29f400bt,
+		.probe_timing	= TIMING_IGNORED, /* routine doesn't use probe_timing (m29f400bt.c) */
+		.block_erasers	=
+		{
+			{
+				.eraseblocks = {
+					{16 * 1024, 1},
+					{8 * 1024, 2},
+					{32 * 1024, 1},
+					{64 * 1024, 7},
+				},
+				.block_erase = block_erase_m29f400bt,
+			}, {
+				.eraseblocks = { {512 * 1024, 1} },
+				.block_erase = block_erase_chip_m29f400bt,
+			}
+		},
+		.write		= NULL,
+		.read		= read_memmapped,
+	},
+	{
+		/* FIXME: this has WORD/BYTE sequences; 2AA for word, 555 for byte */
+		.vendor		= "ST",
 		.name		= "M29F400BT",
 		.bustype	= CHIP_BUSTYPE_PARALLEL,
 		.manufacture_id	= ST_ID,
@@ -5321,7 +5352,7 @@
 				.block_erase = block_erase_chip_m29f400bt,
 			}
 		},
-		.write		= write_coreboot_m29f400bt,
+		.write		= write_m29f400bt,
 		.read		= read_memmapped,
 	},
 
diff --git a/m29f400bt.c b/m29f400bt.c
index c8ed5d8..2a770ba 100644
--- a/m29f400bt.c
+++ b/m29f400bt.c
@@ -204,56 +204,3 @@
 
 	return 0;
 }
-
-int write_coreboot_m29f400bt(struct flashchip *flash, uint8_t *buf)
-{
-	chipaddr bios = flash->virtual_memory;
-
-	msg_cinfo("Programming page:\n ");
-	/*********************************
-	*Pages for M29F400BT:
-	* 16	0x7c000		0x7ffff		TOP
-	*  8 	0x7a000		0x7bfff
-	*  8 	0x78000		0x79fff
-	* 32	0x70000		0x77fff
-	* 64	0x60000		0x6ffff
-	* 64	0x50000		0x5ffff
-	* 64	0x40000		0x4ffff
-	*---------------------------------
-	* 64	0x30000		0x3ffff
-	* 64	0x20000		0x2ffff
-	* 64	0x10000		0x1ffff
-	* 64	0x00000		0x0ffff		BOTTOM
-	*********************************/
-	msg_cinfo("%04d at address: 0x%08x\n", 7, 0x00000);
-	if (block_erase_m29f400bt(flash, 0x00000, 64 * 1024)) {
-		msg_cerr("ERASE FAILED!\n");
-		return -1;
-	}
-	write_page_m29f400bt(bios, buf + 0x00000, bios + 0x00000, 64 * 1024);
-
-	msg_cinfo("%04d at address: 0x%08x\n", 7, 0x10000);
-	if (block_erase_m29f400bt(flash, 0x10000, 64 * 1024)) {
-		msg_cerr("ERASE FAILED!\n");
-		return -1;
-	}
-	write_page_m29f400bt(bios, buf + 0x10000, bios + 0x10000, 64 * 1024);
-
-	msg_cinfo("%04d at address: 0x%08x\n", 7, 0x20000);
-	if (block_erase_m29f400bt(flash, 0x20000, 64 * 1024)) {
-		msg_cerr("ERASE FAILED!\n");
-		return -1;
-	}
-	write_page_m29f400bt(bios, buf + 0x20000, bios + 0x20000, 64 * 1024);
-
-	msg_cinfo("%04d at address: 0x%08x\n", 7, 0x30000);
-	if (block_erase_m29f400bt(flash, 0x30000, 64 * 1024)) {
-		msg_cerr("ERASE FAILED!\n");
-		return -1;
-	}
-	write_page_m29f400bt(bios, buf + 0x30000, bios + 0x30000, 64 * 1024);
-
-	msg_cinfo("\n");
-
-	return 0;
-}