Author: stefanct Date: Sun Jun 1 04:21:02 2014 New Revision: 1808 URL: http://flashrom.org/trac/flashrom/changeset/1808
Log: Combine block_erase*_en29lv640b and block_erase*_m29f400bt respectively.
This patch combines two identical block and chip erase functions respectively: - Merge block_erase_m29f400bt and block_erase_en29lv640b into erase_block_shifted_jedec. - Merge block_erase_chip_m29f400bt and block_erase_chip_en29lv640b into erase_chip_block_shifted_jedec.
Leave their implementations in en29lv640b.c for now.
Signed-off-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Modified: trunk/chipdrivers.h trunk/en29lv640b.c trunk/flashchips.c trunk/m29f400bt.c
Modified: trunk/chipdrivers.h ============================================================================== --- trunk/chipdrivers.h Sun Jun 1 04:13:23 2014 (r1807) +++ trunk/chipdrivers.h Sun Jun 1 04:21:02 2014 (r1808) @@ -147,8 +147,6 @@
/* m29f400bt.c */ int probe_m29f400bt(struct flashctx *flash); -int block_erase_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len); -int block_erase_chip_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len); int write_m29f400bt(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); void protect_m29f400bt(struct flashctx *flash, chipaddr bios);
@@ -199,8 +197,8 @@
/* en29lv640b.c */ int probe_en29lv640b(struct flashctx *flash); -int block_erase_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len); -int block_erase_chip_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len); +int erase_block_shifted_jedec(struct flashctx *flash, unsigned int start, unsigned int len); +int erase_chip_block_shifted_jedec(struct flashctx *flash, unsigned int start, unsigned int len); int write_en29lv640b(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
#endif /* !__CHIPDRIVERS_H__ */
Modified: trunk/en29lv640b.c ============================================================================== --- trunk/en29lv640b.c Sun Jun 1 04:13:23 2014 (r1807) +++ trunk/en29lv640b.c Sun Jun 1 04:21:02 2014 (r1808) @@ -86,7 +86,7 @@ return 0; }
-int erase_en29lv640b(struct flashctx *flash) +static int erase_chip_shifted_jedec(struct flashctx *flash) { chipaddr bios = flash->virtual_memory;
@@ -105,8 +105,7 @@ return 0; }
-int block_erase_en29lv640b(struct flashctx *flash, unsigned int start, - unsigned int len) +int erase_block_shifted_jedec(struct flashctx *flash, unsigned int start, unsigned int len) { chipaddr bios = flash->virtual_memory; chipaddr dst = bios + start; @@ -126,12 +125,11 @@ return 0; }
-int block_erase_chip_en29lv640b(struct flashctx *flash, unsigned int address, - unsigned int blocklen) +int erase_chip_block_shifted_jedec(struct flashctx *flash, unsigned int address, unsigned int blocklen) { if ((address != 0) || (blocklen != flash->chip->total_size * 1024)) { msg_cerr("%s called with incorrect arguments\n", __func__); return -1; } - return erase_en29lv640b(flash); + return erase_chip_shifted_jedec(flash); }
Modified: trunk/flashchips.c ============================================================================== --- trunk/flashchips.c Sun Jun 1 04:13:23 2014 (r1807) +++ trunk/flashchips.c Sun Jun 1 04:21:02 2014 (r1808) @@ -4730,10 +4730,10 @@ {8 * 1024, 8}, {64 * 1024, 127}, }, - .block_erase = block_erase_en29lv640b, + .block_erase = erase_block_shifted_jedec, }, { .eraseblocks = { {8 * 1024 * 1024, 1} }, - .block_erase = block_erase_chip_en29lv640b, + .block_erase = erase_chip_block_shifted_jedec, }, }, .write = write_en29lv640b, @@ -4827,10 +4827,10 @@ {32 * 1024, 1}, {64 * 1024, 7}, }, - .block_erase = block_erase_m29f400bt, + .block_erase = erase_block_shifted_jedec, }, { .eraseblocks = { {512 * 1024, 1} }, - .block_erase = block_erase_chip_m29f400bt, + .block_erase = erase_chip_block_shifted_jedec, }, }, .write = write_m29f400bt, @@ -4859,10 +4859,10 @@ {8 * 1024, 2}, {16 * 1024, 1}, }, - .block_erase = block_erase_m29f400bt, + .block_erase = erase_block_shifted_jedec, }, { .eraseblocks = { {512 * 1024, 1} }, - .block_erase = block_erase_chip_m29f400bt, + .block_erase = erase_chip_block_shifted_jedec, }, }, .write = write_m29f400bt, @@ -4891,10 +4891,10 @@ {32 * 1024, 1}, {64 * 1024, 31}, }, - .block_erase = block_erase_m29f400bt, + .block_erase = erase_block_shifted_jedec, }, { .eraseblocks = { {2048 * 1024, 1} }, - .block_erase = block_erase_chip_m29f400bt, + .block_erase = erase_chip_block_shifted_jedec, }, }, .write = write_m29f400bt, /* Supports a fast mode too */ @@ -4923,10 +4923,10 @@ {8 * 1024, 2}, {16 * 1024, 1}, }, - .block_erase = block_erase_m29f400bt, + .block_erase = erase_block_shifted_jedec, }, { .eraseblocks = { {2048 * 1024, 1} }, - .block_erase = block_erase_chip_m29f400bt, + .block_erase = erase_chip_block_shifted_jedec, }, }, .write = write_m29f400bt, /* Supports a fast mode too */ @@ -11292,10 +11292,10 @@ {32 * 1024, 1}, {64 * 1024, 7}, }, - .block_erase = block_erase_m29f400bt, + .block_erase = erase_block_shifted_jedec, }, { .eraseblocks = { {512 * 1024, 1} }, - .block_erase = block_erase_chip_m29f400bt, + .block_erase = erase_chip_block_shifted_jedec, } }, .write = write_m29f400bt, @@ -11324,10 +11324,10 @@ {8 * 1024, 2}, {16 * 1024, 1}, }, - .block_erase = block_erase_m29f400bt, + .block_erase = erase_block_shifted_jedec, }, { .eraseblocks = { {512 * 1024, 1} }, - .block_erase = block_erase_chip_m29f400bt, + .block_erase = erase_chip_block_shifted_jedec, } }, .write = write_m29f400bt,
Modified: trunk/m29f400bt.c ============================================================================== --- trunk/m29f400bt.c Sun Jun 1 04:13:23 2014 (r1807) +++ trunk/m29f400bt.c Sun Jun 1 04:21:02 2014 (r1808) @@ -85,54 +85,3 @@
return 0; } - -int erase_m29f400bt(struct flashctx *flash) -{ - chipaddr bios = flash->virtual_memory; - - chip_writeb(flash, 0xAA, bios + 0xAAA); - chip_writeb(flash, 0x55, bios + 0x555); - chip_writeb(flash, 0x80, bios + 0xAAA); - - chip_writeb(flash, 0xAA, bios + 0xAAA); - chip_writeb(flash, 0x55, bios + 0x555); - chip_writeb(flash, 0x10, bios + 0xAAA); - - programmer_delay(10); - toggle_ready_jedec(flash, bios); - - /* FIXME: Check the status register for errors. */ - return 0; -} - -int block_erase_m29f400bt(struct flashctx *flash, unsigned int start, - unsigned int len) -{ - chipaddr bios = flash->virtual_memory; - chipaddr dst = bios + start; - - chip_writeb(flash, 0xAA, bios + 0xAAA); - chip_writeb(flash, 0x55, bios + 0x555); - chip_writeb(flash, 0x80, bios + 0xAAA); - - chip_writeb(flash, 0xAA, bios + 0xAAA); - chip_writeb(flash, 0x55, bios + 0x555); - chip_writeb(flash, 0x30, dst); - - programmer_delay(10); - toggle_ready_jedec(flash, bios); - - /* FIXME: Check the status register for errors. */ - return 0; -} - -int block_erase_chip_m29f400bt(struct flashctx *flash, unsigned int address, - unsigned int blocklen) -{ - if ((address != 0) || (blocklen != flash->chip->total_size * 1024)) { - msg_cerr("%s called with incorrect arguments\n", - __func__); - return -1; - } - return erase_m29f400bt(flash); -}