summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Nelson <audiohacked@gmail.com>2010-01-20 20:55:53 +0000
committerSean Nelson <audiohacked@gmail.com>2010-01-20 20:55:53 +0000
commit51c83fb2b204a369e1b1825b66c56e5babcf8022 (patch)
treeaf901ed6d2a2214445035d483c29492217ee7727
parent21f54963611aa0f3ee3ad16a45395d0cec8363f1 (diff)
downloadast2050-flashrom-51c83fb2b204a369e1b1825b66c56e5babcf8022.zip
ast2050-flashrom-51c83fb2b204a369e1b1825b66c56e5babcf8022.tar.gz
Convert various SST chips to use block_erasers
Convert the following chips to block_erasers: SST28SF040A SST29EE010 SST29LE010 SST29EE020A SST29LE020 SST39SF010A SST39SF020A SST39SF040 SST39VF512 SST39VF010 SST39VF020 SST39VF040 SST39VF080 SST49LF002A/B SST49LF003A/B SST49LF004C SST49LF008A SST49LF008C SST49LF016C SST49LF020 SST49LF020A SST49LF040 SST49LF040B SST49LF080A SST49LF160C . Extend sst28sf040 to include chip and sector functions for block_eraser. Extend sst49lfxxxc to include chip, sector, block erasers functions for block_erasers. Extend sst_fwhub to include chip and sector functions for block_erasers. Add copyrights to changed files. Killed erase_sst_fwhub. Killed erase_49lfxxxc. NULL A/A mux mode full chip erasers. Ignore block locks in erase/write. Change comments from "PP mode" to "A/A mux mode" Corresponding to flashrom svn r877. Signed-off-by: Sean Nelson <audiohacked@gmail.com> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
-rw-r--r--chipdrivers.h7
-rw-r--r--flashchips.c374
-rw-r--r--sst28sf040.c15
-rw-r--r--sst49lfxxxc.c37
-rw-r--r--sst_fwhub.c20
5 files changed, 405 insertions, 48 deletions
diff --git a/chipdrivers.h b/chipdrivers.h
index 6e2edc6..c5062ca 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -126,7 +126,8 @@ void protect_lhf00l04(chipaddr bios);
/* sst28sf040.c */
int probe_28sf040(struct flashchip *flash);
-int erase_28sf040(struct flashchip *flash);
+int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
+int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size);
int write_28sf040(struct flashchip *flash, uint8_t *buf);
/* sst39sf020.c */
@@ -140,12 +141,16 @@ int write_49lf040(struct flashchip *flash, uint8_t *buf);
/* sst49lfxxxc.c */
int probe_49lfxxxc(struct flashchip *flash);
int erase_49lfxxxc(struct flashchip *flash);
+int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size);
+int erase_block_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size);
+int erase_chip_49lfxxxc(struct flashchip *flash, unsigned int addr, unsigned int blocksize);
int write_49lfxxxc(struct flashchip *flash, uint8_t *buf);
/* sst_fwhub.c */
int probe_sst_fwhub(struct flashchip *flash);
int erase_sst_fwhub(struct flashchip *flash);
int erase_sst_fwhub_block(struct flashchip *flash, unsigned int offset, unsigned int page_size);
+int erase_sst_fwhub_sector(struct flashchip *flash, unsigned int offset, unsigned int page_size);
int write_sst_fwhub(struct flashchip *flash, uint8_t *buf);
/* w39v040c.c */
diff --git a/flashchips.c b/flashchips.c
index 32c3514..70954b8 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -3480,7 +3480,7 @@ struct flashchip flashchips[] = {
.eraseblocks = {
{1024 * 1024, 1}
},
- .block_erase = NULL, /* 30 D0, only in PP mode */
+ .block_erase = NULL, /* 30 D0, only in A/A mux mode */
},
},
.write = write_lhf00l04,
@@ -3754,7 +3754,17 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_28sf040,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (sst28sf040.c) */
- .erase = erase_28sf040,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {128, 4096} },
+ .block_erase = erase_sector_28sf040,
+ }, {
+ .eraseblocks = { {512 * 1024, 1} },
+ .block_erase = erase_chip_28sf040,
+ }
+ },
.write = write_28sf040,
.read = read_memmapped,
},
@@ -3767,10 +3777,17 @@ struct flashchip flashchips[] = {
.model_id = SST_29EE010,
.total_size = 128,
.page_size = 128,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_jedec,
.probe_timing = 10,
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {128 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_jedec,
.read = read_memmapped,
},
@@ -3786,7 +3803,14 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_jedec,
.probe_timing = 10,
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {128 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_jedec,
.read = read_memmapped,
},
@@ -3799,10 +3823,17 @@ struct flashchip flashchips[] = {
.model_id = SST_29EE020A,
.total_size = 256,
.page_size = 128,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_jedec,
.probe_timing = 10,
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {256 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_jedec,
.read = read_memmapped,
},
@@ -3818,7 +3849,14 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_jedec,
.probe_timing = 10,
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {256 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_jedec,
.read = read_memmapped,
},
@@ -3831,10 +3869,20 @@ struct flashchip flashchips[] = {
.model_id = SST_39SF010,
.total_size = 128,
.page_size = 4096,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_jedec,
.probe_timing = 1, /* 150 ns */
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 32} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {128 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_49f002,
.read = read_memmapped,
},
@@ -3847,10 +3895,20 @@ struct flashchip flashchips[] = {
.model_id = SST_39SF020,
.total_size = 256,
.page_size = 4096,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_jedec,
.probe_timing = 1, /* 150 ns */
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 64} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {256 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_49f002,
.read = read_memmapped,
},
@@ -3863,10 +3921,20 @@ struct flashchip flashchips[] = {
.model_id = SST_39SF040,
.total_size = 512,
.page_size = 4096,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_jedec,
.probe_timing = 1, /* 150 ns */
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 128} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {512 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_49f002,
.read = read_memmapped,
},
@@ -3879,10 +3947,20 @@ struct flashchip flashchips[] = {
.model_id = SST_39VF512,
.total_size = 64,
.page_size = 4096,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_jedec,
.probe_timing = 1, /* 150 ns*/
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 16} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {64 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_49f002,
.read = read_memmapped,
},
@@ -3895,10 +3973,20 @@ struct flashchip flashchips[] = {
.model_id = SST_39VF010,
.total_size = 128,
.page_size = 4096,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_jedec,
.probe_timing = 1, /* 150 ns */
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 32} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {128 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_49f002,
.read = read_memmapped,
},
@@ -3911,10 +3999,20 @@ struct flashchip flashchips[] = {
.model_id = SST_39VF020,
.total_size = 256,
.page_size = 4096,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_jedec,
.probe_timing = 1, /* 150 ns */
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 64} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {256 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_49f002,
.read = read_memmapped,
},
@@ -3930,7 +4028,17 @@ struct flashchip flashchips[] = {
.tested = TEST_OK_PROBE,
.probe = probe_jedec,
.probe_timing = 1, /* 150 ns */
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 128} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {512 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_49f002,
.read = read_memmapped,
},
@@ -3946,7 +4054,20 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_jedec,
.probe_timing = 1, /* 150 ns */
- .erase = erase_chip_jedec,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 256} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {64 * 1024, 16} },
+ .block_erase = erase_block_jedec,
+ }, {
+ .eraseblocks = { {1024 * 1024, 1} },
+ .block_erase = erase_chip_block_jedec,
+ }
+ },
.write = write_49f002,
.read = read_memmapped,
},
@@ -3960,10 +4081,23 @@ struct flashchip flashchips[] = {
.total_size = 256,
.page_size = 16 * 1024,
.feature_bits = FEATURE_REGISTERMAP,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_sst_fwhub,
.probe_timing = 1, /* 150 ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
- .erase = erase_sst_fwhub,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 64} },
+ .block_erase = erase_sst_fwhub_sector,
+ }, {
+ .eraseblocks = { {16 * 1024, 16} },
+ .block_erase = erase_sst_fwhub_block,
+ }, {
+ .eraseblocks = { {256 * 1024, 1} },
+ .block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
+ }
+ },
.write = write_sst_fwhub,
.read = read_memmapped,
},
@@ -3980,7 +4114,20 @@ struct flashchip flashchips[] = {
.tested = TEST_OK_PR,
.probe = probe_sst_fwhub,
.probe_timing = 1, /* 150 ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
- .erase = erase_sst_fwhub,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 96} },
+ .block_erase = erase_sst_fwhub_sector,
+ }, {
+ .eraseblocks = { {64 * 1024, 6} },
+ .block_erase = erase_sst_fwhub_block,
+ }, {
+ .eraseblocks = { {384 * 1024, 1} },
+ .block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
+ }
+ },
.write = write_sst_fwhub,
.read = read_memmapped,
},
@@ -4011,7 +4158,7 @@ struct flashchip flashchips[] = {
.block_erase = erase_sst_fwhub_block, /* same as erase_block_jedec, but with unlock */
}, {
.eraseblocks = { {512 * 1024, 1} },
- .block_erase = NULL, /* AA 55 80 AA 55 10, only in PP mode */
+ .block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
},
},
.write = write_sst_fwhub,
@@ -4029,7 +4176,22 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_49lfxxxc,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (sst49lfxxxc.c) */
- .erase = erase_49lfxxxc,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 128} },
+ .block_erase = erase_sector_49lfxxxc,
+ }, {
+ .eraseblocks = {
+ {64 * 1024, 7},
+ {32 * 1024, 1},
+ {8 * 1024, 2},
+ {16 * 1024, 1},
+ },
+ .block_erase = erase_block_49lfxxxc,
+ }
+ },
.write = write_49lfxxxc,
.read = read_memmapped,
},
@@ -4043,10 +4205,23 @@ struct flashchip flashchips[] = {
.total_size = 1024,
.page_size = 64 * 1024,
.feature_bits = FEATURE_REGISTERMAP,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_sst_fwhub,
.probe_timing = 1, /* 150 ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
- .erase = erase_sst_fwhub,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 256} },
+ .block_erase = erase_sst_fwhub_sector,
+ }, {
+ .eraseblocks = { {64 * 1024, 16} },
+ .block_erase = erase_sst_fwhub_block,
+ }, {
+ .eraseblocks = { {1024 * 1024, 1} },
+ .block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
+ }
+ },
.write = write_sst_fwhub,
.read = read_memmapped,
},
@@ -4062,7 +4237,22 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_49lfxxxc,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (sst49lfxxxc.c) */
- .erase = erase_49lfxxxc,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 256} },
+ .block_erase = erase_sector_49lfxxxc,
+ }, {
+ .eraseblocks = {
+ {64 * 1024, 15},
+ {32 * 1024, 1},
+ {8 * 1024, 2},
+ {16 * 1024, 1},
+ },
+ .block_erase = erase_block_49lfxxxc,
+ }
+ },
.write = write_49lfxxxc,
.read = read_memmapped,
},
@@ -4075,10 +4265,25 @@ struct flashchip flashchips[] = {
.model_id = SST_49LF016C,
.total_size = 2048,
.page_size = 4 * 1024,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_49lfxxxc,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (sst49lfxxxc.c) */
- .erase = erase_49lfxxxc,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 512} },
+ .block_erase = erase_sector_49lfxxxc,
+ }, {
+ .eraseblocks = {
+ {64 * 1024, 31},
+ {32 * 1024, 1},
+ {8 * 1024, 2},
+ {16 * 1024, 1},
+ },
+ .block_erase = erase_block_49lfxxxc,
+ }
+ },
.write = write_49lfxxxc,
.read = read_memmapped,
},
@@ -4094,7 +4299,20 @@ struct flashchip flashchips[] = {
.tested = TEST_OK_PR,
.probe = probe_jedec,
.probe_timing = 1, /* 150 ns */
- .erase = erase_49lf040,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 64} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {16 * 1024, 16} },
+ .block_erase = erase_block_jedec,
+ }, {
+ .eraseblocks = { {256 * 1024, 1} },
+ .block_erase = NULL,
+ }
+ },
.write = write_49lf040,
.read = read_memmapped,
},
@@ -4107,10 +4325,23 @@ struct flashchip flashchips[] = {
.model_id = SST_49LF020A,
.total_size = 256,
.page_size = 4 * 1024,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_jedec,
.probe_timing = 1, /* 150 ns */
- .erase = erase_49lf040,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 64} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {16 * 1024, 16} },
+ .block_erase = erase_block_jedec,
+ }, {
+ .eraseblocks = { {256 * 1024, 1} },
+ .block_erase = NULL,
+ }
+ },
.write = write_49lf040,
.read = read_memmapped,
},
@@ -4123,10 +4354,23 @@ struct flashchip flashchips[] = {
.model_id = SST_49LF040,
.total_size = 512,
.page_size = 4096,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_jedec,
.probe_timing = 1, /* 150 ns */
- .erase = erase_49lf040,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 128} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {64 * 1024, 8} },
+ .block_erase = erase_block_jedec,
+ }, {
+ .eraseblocks = { {512 * 1024, 1} },
+ .block_erase = NULL,
+ }
+ },
.write = write_49lf040,
.read = read_memmapped,
},
@@ -4140,11 +4384,24 @@ struct flashchip flashchips[] = {
.total_size = 512,
.page_size = 64 * 1024,
.feature_bits = FEATURE_REGISTERMAP,
- .tested = TEST_OK_PREW,
- .probe = probe_sst_fwhub,
+ .tested = TEST_UNTESTED,
+ .probe = probe_jedec,
.probe_timing = 1, /* 150ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
- .erase = erase_sst_fwhub,
- .write = write_sst_fwhub,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 128} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {64 * 1024, 8} },
+ .block_erase = erase_block_jedec,
+ }, {
+ .eraseblocks = { {512 * 1024, 1} },
+ .block_erase = NULL,
+ }
+ },
+ .write = write_49lf040,
.read = read_memmapped,
},
@@ -4156,10 +4413,23 @@ struct flashchip flashchips[] = {
.model_id = SST_49LF080A,
.total_size = 1024,
.page_size = 4096,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_jedec,
.probe_timing = TIMING_FIXME,
- .erase = erase_49lf040,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 256} },
+ .block_erase = erase_sector_jedec,
+ }, {
+ .eraseblocks = { {64 * 1024, 16} },
+ .block_erase = erase_block_jedec,
+ }, {
+ .eraseblocks = { {1024 * 1024, 1} },
+ .block_erase = NULL,
+ }
+ },
.write = write_49lf040,
.read = read_memmapped,
},
@@ -4172,10 +4442,26 @@ struct flashchip flashchips[] = {
.model_id = SST_49LF160C,
.total_size = 2048,
.page_size = 4 * 1024,
- .tested = TEST_OK_PREW,
+ .tested = TEST_OK_PRW,
.probe = probe_49lfxxxc,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (sst49lfxxxc.c) */
.erase = erase_49lfxxxc,
+ .erase = NULL,
+ .block_erasers =
+ {
+ {
+ .eraseblocks = { {4 * 1024, 512} },
+ .block_erase = erase_sector_49lfxxxc,
+ }, {
+ .eraseblocks = {
+ {64 * 1024, 31},
+ {32 * 1024, 1},
+ {8 * 1024, 2},
+ {16 * 1024, 1},
+ },
+ .block_erase = erase_block_49lfxxxc,
+ }
+ },
.write = write_49lfxxxc,
.read = read_memmapped,
},
diff --git a/sst28sf040.c b/sst28sf040.c
index 930ad5b..f253e39 100644
--- a/sst28sf040.c
+++ b/sst28sf040.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2000 Silicon Integrated System Corporation
* Copyright (C) 2005 coresystems GmbH <stepan@openbios.org>
+ * Copyright (C) 2009 Sean Nelson <audiohacked@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -50,7 +51,7 @@ static void unprotect_28sf040(chipaddr bios)
chip_readb(bios + 0x041A);
}
-static int erase_sector_28sf040(struct flashchip *flash, unsigned long address, int sector_size)
+int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size)
{
chipaddr bios = flash->virtual_memory;
@@ -67,7 +68,7 @@ static int erase_sector_28sf040(struct flashchip *flash, unsigned long address,
return 0;
}
-static int write_sector_28sf040(chipaddr bios, uint8_t *src, chipaddr dst,
+int write_sector_28sf040(chipaddr bios, uint8_t *src, chipaddr dst,
unsigned int page_size)
{
int i;
@@ -162,3 +163,13 @@ int write_28sf040(struct flashchip *flash, uint8_t *buf)
return 0;
}
+
+int erase_chip_28sf040(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_28sf040(flash);
+}
diff --git a/sst49lfxxxc.c b/sst49lfxxxc.c
index a421acf..80e5520 100644
--- a/sst49lfxxxc.c
+++ b/sst49lfxxxc.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2000 Silicon Integrated System Corporation
* Copyright (C) 2005-2007 coresystems GmbH
+ * Copyright (C) 2009 Sean Nelson <audiohacked@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,6 +36,15 @@
#define STATUS_ESS (1 << 6)
#define STATUS_WSMS (1 << 7)
+int unlock_block_49lfxxxc(struct flashchip *flash, unsigned long address, unsigned char bits)
+{
+ unsigned long lock = flash->virtual_registers + address + 2;
+ printf_debug("lockbits at address=0x%08lx is 0x%01x\n", lock, chip_readb(lock));
+ chip_writeb(bits, lock);
+
+ return 0;
+}
+
static int write_lockbits_49lfxxxc(struct flashchip *flash, unsigned char bits)
{
chipaddr registers = flash->virtual_registers;
@@ -72,7 +82,7 @@ static int write_lockbits_49lfxxxc(struct flashchip *flash, unsigned char bits)
return 0;
}
-static int erase_sector_49lfxxxc(struct flashchip *flash, unsigned long address, int sector_size)
+int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size)
{
unsigned char status;
chipaddr bios = flash->virtual_memory;
@@ -97,6 +107,31 @@ static int erase_sector_49lfxxxc(struct flashchip *flash, unsigned long address,
return 0;
}
+int erase_block_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int block_size)
+{
+ unsigned char status;
+ chipaddr bios = flash->virtual_memory;
+
+ chip_writeb(BLOCK_ERASE, bios);
+ chip_writeb(ERASE, bios + address);
+
+ do {
+ status = chip_readb(bios);
+ if (status & (STATUS_ESS | STATUS_BPS)) {
+ printf("block erase FAILED at address=0x%08lx status=0x%01x\n", bios + address, status);
+ chip_writeb(CLEAR_STATUS, bios);
+ return (-1);
+ }
+ } while (!(status & STATUS_WSMS));
+ chip_writeb(RESET, bios);
+
+ if (check_erased_range(flash, address, block_size)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
+ return 0;
+}
+
static int write_sector_49lfxxxc(chipaddr bios, uint8_t *src, chipaddr dst,
unsigned int page_size)
{
diff --git a/sst_fwhub.c b/sst_fwhub.c
index b29722f..75d9e05 100644
--- a/sst_fwhub.c
+++ b/sst_fwhub.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2000 Silicon Integrated System Corporation
* Copyright (C) 2009 Kontron Modular Computers
+ * Copyright (C) 2009 Sean Nelson <audiohacked@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -114,6 +115,25 @@ int erase_sst_fwhub_block(struct flashchip *flash, unsigned int offset, unsigned
return 0;
}
+int erase_sst_fwhub_sector(struct flashchip *flash, unsigned int offset, unsigned int page_size)
+{
+ uint8_t blockstatus = clear_sst_fwhub_block_lock(flash, offset);
+
+ if (blockstatus) {
+ printf("Sector lock clearing failed, not erasing sector "
+ "at 0x%06x\n", offset);
+ return 1;
+ }
+
+ if (erase_sector_jedec(flash, offset, page_size)) {
+ fprintf(stderr, "ERASE FAILED!\n");
+ return -1;
+ }
+ toggle_ready_jedec(flash->virtual_memory);
+
+ return 0;
+}
+
int erase_sst_fwhub(struct flashchip *flash)
{
int i;
OpenPOWER on IntegriCloud