Commit 6b11ad2f authored by Sean Nelson's avatar Sean Nelson
Browse files

Convert the following chips to use struct eraseblock


AMIC_A29002B
AMIC_A29002T
EN_29F002B
EN_29F002T
MBM29F004BC
MBM29F004TC
MBM29F400BC
MBM29F400TC
MX_25L3205
MX_25L6405
MX_29F002B
MX_29F002T

Add block erasers for m29f400bt and mx29f002.
Change programmer delays from 2 seconds to 10us in mx29f002 and am29f040b.

Corresponding to flashrom svn r819.
Signed-off-by: default avatarSean Nelson <audiohacked@gmail.com>
Acked-by: default avatarCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
parent bbfeb70f
......@@ -20,8 +20,7 @@
#include "flash.h"
/* FIMXE: check that the 2 second delay is really needed.
Use erase_sector_jedec if not? */
/* FIMXE: Use erase_sector_jedec if not? */
int erase_sector_29f040b(struct flashchip *flash, unsigned int address, unsigned int blocklen)
{
chipaddr bios = flash->virtual_memory;
......@@ -33,7 +32,7 @@ int erase_sector_29f040b(struct flashchip *flash, unsigned int address, unsigned
chip_writeb(0x55, bios + 0x2AA);
chip_writeb(0x30, bios + address);
programmer_delay(2 * 1000 * 1000);
programmer_delay(10);
/* wait for Toggle bit ready */
toggle_ready_jedec(bios + address);
......
......@@ -97,7 +97,8 @@ int write_m29f002b(struct flashchip *flash, uint8_t *buf);
/* m29f400bt.c */
int probe_m29f400bt(struct flashchip *flash);
int erase_m29f400bt(struct flashchip *flash);
int block_erase_m29f400bt(struct flashchip *flash, int start, int len);
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);
......@@ -107,6 +108,8 @@ void write_page_m29f400bt(chipaddr bios, uint8_t *src,
/* mx29f002.c */
int probe_29f002(struct flashchip *flash);
int erase_29f002(struct flashchip *flash);
int erase_chip_29f002(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
int erase_sector_29f002(struct flashchip *flash, unsigned int address, unsigned int blocklen);
int write_29f002(struct flashchip *flash, uint8_t *buf);
/* pm49fl00x.c */
......
......@@ -1166,7 +1166,22 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_29f002,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (mx29f002.c) */
.erase = erase_29f002,
.erase = NULL,
.block_erasers =
{
{
.eraseblocks = {
{16 * 1024, 1},
{8 * 1024, 2},
{32 * 1024, 1},
{64 * 1024, 3},
},
.block_erase = erase_sector_29f002,
}, {
.eraseblocks = { {256 * 1024, 1} },
.block_erase = erase_chip_29f002,
},
},
.write = write_jedec_1,
.read = read_memmapped,
},
......@@ -1179,10 +1194,25 @@ struct flashchip flashchips[] = {
.model_id = AMIC_A29002T,
.total_size = 256,
.page_size = 64 * 1024,
.tested = TEST_OK_PRE,
.tested = TEST_OK_PR,
.probe = probe_29f002,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (mx29f002.c) */
.erase = erase_29f002,
.erase = NULL,
.block_erasers =
{
{
.eraseblocks = {
{64 * 1024, 3},
{32 * 1024, 1},
{8 * 1024, 2},
{16 * 1024, 1},
},
.block_erase = erase_sector_29f002,
}, {
.eraseblocks = { {256 * 1024, 1} },
.block_erase = erase_chip_29f002,
},
},
.write = write_jedec_1,
.read = read_memmapped,
},
......@@ -1448,7 +1478,23 @@ struct flashchip flashchips[] = {
.tested = TEST_OK_PROBE,
.probe = probe_spi_rdid,
.probe_timing = TIMING_ZERO,
.erase = spi_chip_erase_60_c7,
.erase = NULL,
.block_erasers =
{
{
.eraseblocks = { {4 * 1024, 2048} },
.block_erase = spi_block_erase_20,
}, {
.eraseblocks = { {4 * 1024, 2048} },
.block_erase = spi_block_erase_d8,
}, {
.eraseblocks = { {8 * 1024 * 1024, 1} },
.block_erase = spi_block_erase_60,
}, {
.eraseblocks = { {8 * 1024 * 1024, 1} },
.block_erase = spi_block_erase_c7,
},
},
.write = spi_chip_write_256,
.read = spi_chip_read,
},
......@@ -1512,7 +1558,22 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_jedec,
.probe_timing = TIMING_ZERO, /* Datasheet has no timing info specified */
.erase = erase_chip_jedec,
.erase = NULL,
.block_erasers =
{
{
.eraseblocks = {
{64 * 1024, 3},
{32 * 1024, 1},
{8 * 1024, 2},
{16 * 1024, 1},
},
.block_erase = erase_sector_jedec,
}, {
.eraseblocks = { {256 * 1024, 1} },
.block_erase = erase_chip_block_jedec,
},
},
.write = write_jedec_1,
.read = read_memmapped,
},
......@@ -1525,10 +1586,25 @@ struct flashchip flashchips[] = {
.model_id = EN_29F002T,
.total_size = 256,
.page_size = 256,
.tested = TEST_OK_PRE,
.tested = TEST_OK_PR,
.probe = probe_jedec,
.probe_timing = TIMING_ZERO, /* Datasheet has no timing info specified */
.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_chip_block_jedec,
},
},
.write = write_jedec_1,
.read = read_memmapped,
},
......@@ -1545,6 +1621,21 @@ struct flashchip flashchips[] = {
.probe = probe_jedec,
.probe_timing = TIMING_ZERO, /* Datasheet has no timing info specified */
.erase = NULL,
.block_erasers =
{
{
.eraseblocks = {
{16 * 1024, 1},
{8 * 1024, 2},
{32 * 1024, 1},
{64 * 1024, 7},
},
.block_erase = erase_sector_29f040b,
}, {
.eraseblocks = { {512 * 1024, 1} },
.block_erase = erase_chip_29f040b,
},
},
.write = NULL,
.read = read_memmapped,
},
......@@ -1561,6 +1652,21 @@ struct flashchip flashchips[] = {
.probe = probe_jedec,
.probe_timing = TIMING_ZERO, /* Datasheet has no timing info specified */
.erase = NULL,
.block_erasers =
{
{
.eraseblocks = {
{64 * 1024, 7},
{32 * 1024, 1},
{8 * 1024, 2},
{16 * 1024, 1},
},
.block_erase = erase_sector_29f040b,
}, {
.eraseblocks = { {512 * 1024, 1} },
.block_erase = erase_chip_29f040b,
},
},
.write = NULL,
.read = read_memmapped,
},
......@@ -1576,7 +1682,22 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_m29f400bt,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (m29f400bt.c) */
.erase = erase_m29f400bt,
.erase = NULL,
.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 = write_coreboot_m29f400bt,
.read = read_memmapped,
},
......@@ -1592,7 +1713,22 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_m29f400bt,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (m29f400bt.c) */
.erase = erase_m29f400bt,
.erase = NULL,
.block_erasers =
{
{
.eraseblocks = {
{64 * 1024, 7},
{32 * 1024, 1},
{8 * 1024, 2},
{16 * 1024, 1},
},
.block_erase = block_erase_m29f400bt,
}, {
.eraseblocks = { {512 * 1024, 1} },
.block_erase = block_erase_chip_m29f400bt,
},
},
.write = write_coreboot_m29f400bt,
.read = read_memmapped,
},
......@@ -1892,10 +2028,26 @@ struct flashchip flashchips[] = {
.model_id = MX_25L3205,
.total_size = 4096,
.page_size = 256,
.tested = TEST_OK_PREW,
.tested = TEST_OK_PRW,
.probe = probe_spi_rdid,
.probe_timing = TIMING_ZERO,
.erase = spi_chip_erase_60_c7,
.erase = NULL,
.block_erasers =
{
{
.eraseblocks = { {4 * 1024, 1024} },
.block_erase = spi_block_erase_20,
}, {
.eraseblocks = { {4 * 1024, 1024} },
.block_erase = spi_block_erase_d8,
}, {
.eraseblocks = { {4 * 1024 * 1024, 1} },
.block_erase = spi_block_erase_60,
}, {
.eraseblocks = { {4 * 1024 * 1024, 1} },
.block_erase = spi_block_erase_c7,
},
},
.write = spi_chip_write_256,
.read = spi_chip_read,
},
......@@ -1991,7 +2143,22 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_29f002,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (mx29f002.c) */
.erase = erase_29f002,
.erase = NULL,
.block_erasers =
{
{
.eraseblocks = {
{16 * 1024, 1},
{8 * 1024, 2},
{32 * 1024, 1},
{64 * 1024, 3},
},
.block_erase = erase_sector_29f002, /* This erase function has 64k blocksize for eLiteFlash */
}, {
.eraseblocks = { {256 * 1024, 1} },
.block_erase = erase_chip_29f002,
},
},
.write = write_jedec_1,
.read = read_memmapped,
},
......@@ -2004,10 +2171,25 @@ struct flashchip flashchips[] = {
.model_id = MX_29F002T,
.total_size = 256,
.page_size = 64 * 1024,
.tested = TEST_OK_PRE,
.tested = TEST_OK_PR,
.probe = probe_29f002,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (mx29f002.c) */
.erase = erase_29f002,
.erase = NULL,
.block_erasers =
{
{
.eraseblocks = {
{64 * 1024, 3},
{32 * 1024, 1},
{8 * 1024, 2},
{16 * 1024, 1},
},
.block_erase = erase_sector_29f002, /* This erase function has 64k blocksize for eLiteFlash */
}, {
.eraseblocks = { {256 * 1024, 1} },
.block_erase = erase_chip_29f002,
},
},
.write = write_jedec_1,
.read = read_memmapped,
},
......
......@@ -102,7 +102,7 @@ int erase_m29f400bt(struct flashchip *flash)
return 0;
}
int block_erase_m29f400bt(struct flashchip *flash, int start, int len)
int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len)
{
chipaddr bios = flash->virtual_memory;
chipaddr dst = bios + start;
......@@ -126,6 +126,16 @@ int block_erase_m29f400bt(struct flashchip *flash, int start, int len)
return 0;
}
int block_erase_chip_m29f400bt(struct flashchip *flash, unsigned int address, unsigned int blocklen)
{
if ((address != 0) || (blocklen != flash->total_size * 1024)) {
fprintf(stderr, "%s called with incorrect arguments\n",
__func__);
return -1;
}
return erase_m29f400bt(flash);
}
int write_m29f400bt(struct flashchip *flash, uint8_t *buf)
{
int i;
......
......@@ -43,6 +43,39 @@ int probe_29f002(struct flashchip *flash)
return 0;
}
int erase_sector_29f002(struct flashchip *flash, unsigned int address, unsigned int blocklen)
{
chipaddr bios = flash->virtual_memory;
chip_writeb(0xAA, bios + 0x555);
chip_writeb(0x55, bios + 0x2AA);
chip_writeb(0x80, bios + 0x555);
chip_writeb(0xAA, bios + 0x555);
chip_writeb(0x55, bios + 0x2AA);
chip_writeb(0x30, bios + address);
programmer_delay(10);
/* wait for Toggle bit ready */
toggle_ready_jedec(bios + address);
if (check_erased_range(flash, address, blocklen)) {
fprintf(stderr, "ERASE FAILED!\n");
return -1;
}
return 0;
}
int erase_chip_29f002(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_29f002(flash);
}
/* FIXME: Use erase_chip_jedec?
* erase_29f002 uses shorter addresses, sends F0 (exit ID mode) and
* and has a bigger delay before polling the toggle bit */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment