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"

Signed-off-by: Sean Nelson <[email protected]>

diff --git a/chipdrivers.h b/chipdrivers.h
index 6e2edc6..c5062ca 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -116,46 +116,51 @@ int write_29f002(struct flashchip *flash, uint8_t *buf);
 /* pm49fl00x.c */
 int probe_49fl00x(struct flashchip *flash);
 int erase_49fl00x(struct flashchip *flash);
 int write_49fl00x(struct flashchip *flash, uint8_t *buf);
 
 /* sharplhf00l04.c */
 int probe_lhf00l04(struct flashchip *flash);
 int erase_lhf00l04_block(struct flashchip *flash, unsigned int blockaddr, 
unsigned int blocklen);
 int write_lhf00l04(struct flashchip *flash, uint8_t *buf);
 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 */
 int probe_39sf020(struct flashchip *flash);
 int write_39sf020(struct flashchip *flash, uint8_t *buf);
 
 /* sst49lf040.c */
 int erase_49lf040(struct flashchip *flash);
 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 */
 int probe_w39v040c(struct flashchip *flash);
 int erase_w39v040c(struct flashchip *flash);
 int write_w39v040c(struct flashchip *flash, uint8_t *buf);
 
 /* w39V080fa.c */
 int probe_winbond_fwhub(struct flashchip *flash);
 int erase_winbond_fwhub(struct flashchip *flash);
 int write_winbond_fwhub(struct flashchip *flash, uint8_t *buf);
 
 /* w29ee011.c */
diff --git a/flashchips.c b/flashchips.c
index 32c3514..70954b8 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -3470,27 +3470,27 @@ struct flashchip flashchips[] = {
                .erase          = NULL,
                .block_erasers  =
                {
                        {
                                .eraseblocks = {
                                        {64 * 1024, 15},
                                        {8 * 1024, 8}
                                 },
                                .block_erase = erase_lhf00l04_block,
                        }, {
                                .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,
                .read           = read_memmapped,
        },
 
        {
                .vendor         = "Spansion",
                .name           = "S25FL008A",
                .bustype        = CHIP_BUSTYPE_SPI,
                .manufacture_id = SPANSION_ID,
                .model_id       = SPANSION_S25FL008A,
                .total_size     = 1024,
@@ -3744,253 +3744,400 @@ struct flashchip flashchips[] = {
        },
 
        {
                .vendor         = "SST",
                .name           = "SST28SF040A",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .model_id       = SST_28SF040,
                .total_size     = 512,
                .page_size      = 256,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST29EE010",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST29LE010",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .model_id       = SST_29LE010,
                .total_size     = 128,
                .page_size      = 128,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST29EE020A",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST29LE020",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .model_id       = SST_29LE020,
                .total_size     = 256,
                .page_size      = 128,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST39SF010A",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST39SF020A",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST39SF040",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST39VF512",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST39VF010",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST39VF020",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST39VF040",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .model_id       = SST_39VF040,
                .total_size     = 512,
                .page_size      = 4096,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST39VF080",
                .bustype        = CHIP_BUSTYPE_PARALLEL,
                .manufacture_id = SST_ID,
                .model_id       = SST_39VF080,
                .total_size     = 1024,
                .page_size      = 4096,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF002A/B",
                .bustype        = CHIP_BUSTYPE_FWH, /* A/A Mux */
                .manufacture_id = SST_ID,
                .model_id       = SST_49LF002A,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF003A/B",
                .bustype        = CHIP_BUSTYPE_FWH, /* A/A Mux */
                .manufacture_id = SST_ID,
                .model_id       = SST_49LF003A,
                .total_size     = 384,
                .page_size      = 64 * 1024,
                .feature_bits   = FEATURE_REGISTERMAP,
                .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,
        },
 
        {
                /* Contrary to the data sheet, TBL# on the SST49LF004B affects 
the top 128kB (instead of 64kB)
                 * and is only honored for 64k block erase, but not 4k sector 
erase.
                 */
                .vendor         = "SST",
                .name           = "SST49LF004A/B",
                .bustype        = CHIP_BUSTYPE_FWH, /* A/A Mux */
                .manufacture_id = SST_ID,
                .model_id       = SST_49LF004A,
@@ -4001,191 +4148,330 @@ struct flashchip flashchips[] = {
                .probe          = probe_sst_fwhub,
                .probe_timing   = 1,            /* 150 ns | routine is wrapper 
to probe_jedec (sst_fwhub.c) */
                .erase          = NULL,
                .block_erasers  =
                {
                        {
                                .eraseblocks = { {4 * 1024, 128} },
                                .block_erase = erase_sector_jedec, /* missing 
unlock */
                        }, {
                                .eraseblocks = { {64 * 1024, 8} },
                                .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,
                .read           = read_memmapped,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF004C",
                .bustype        = CHIP_BUSTYPE_FWH,
                .manufacture_id = SST_ID,
                .model_id       = SST_49LF004C,
                .total_size     = 512,
                .page_size      = 4 * 1024,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF008A",
                .bustype        = CHIP_BUSTYPE_FWH, /* A/A Mux */
                .manufacture_id = SST_ID,
                .model_id       = SST_49LF008A,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF008C",
                .bustype        = CHIP_BUSTYPE_FWH,
                .manufacture_id = SST_ID,
                .model_id       = SST_49LF008C,
                .total_size     = 1024,
                .page_size      = 4 * 1024,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF016C",
                .bustype        = CHIP_BUSTYPE_FWH,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF020",
                .bustype        = CHIP_BUSTYPE_LPC,
                .manufacture_id = SST_ID,
                .model_id       = SST_49LF020,
                .total_size     = 256,
                .page_size      = 16 * 1024,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF020A",
                .bustype        = CHIP_BUSTYPE_LPC,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF040",
                .bustype        = CHIP_BUSTYPE_LPC,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF040B",
                .bustype        = CHIP_BUSTYPE_LPC, /* A/A Mux */
                .manufacture_id = SST_ID,
                .model_id       = SST_49LF040B,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF080A",
                .bustype        = CHIP_BUSTYPE_LPC, /* A/A Mux */
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF160C",
                .bustype        = CHIP_BUSTYPE_LPC,
                .manufacture_id = SST_ID,
                .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,
        },
 
        {
                .vendor         = "ST",
                .name           = "M25P05-A",
                .bustype        = CHIP_BUSTYPE_SPI,
                .manufacture_id = ST_ID,
                .model_id       = ST_M25P05A,
                .total_size     = 64,
                .page_size      = 256,
                .tested         = TEST_UNTESTED,
diff --git a/sst28sf040.c b/sst28sf040.c
index 930ad5b..f253e39 100644
--- a/sst28sf040.c
+++ b/sst28sf040.c
@@ -1,18 +1,19 @@
 /*
  * This file is part of the flashrom project.
  *
  * Copyright (C) 2000 Silicon Integrated System Corporation
  * Copyright (C) 2005 coresystems GmbH <[email protected]>
+ * Copyright (C) 2009 Sean Nelson <[email protected]>
  *
  * 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
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
@@ -40,44 +41,44 @@ static void protect_28sf040(chipaddr bios)
 }
 
 static void unprotect_28sf040(chipaddr bios)
 {
        chip_readb(bios + 0x1823);
        chip_readb(bios + 0x1820);
        chip_readb(bios + 0x1822);
        chip_readb(bios + 0x0418);
        chip_readb(bios + 0x041B);
        chip_readb(bios + 0x0419);
        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;
 
        chip_writeb(AUTO_PG_ERASE1, bios);
        chip_writeb(AUTO_PG_ERASE2, bios + address);
 
        /* wait for Toggle bit ready         */
        toggle_ready_jedec(bios);
 
        if (check_erased_range(flash, address, sector_size)) {
                fprintf(stderr, "ERASE FAILED!\n");
                return -1;
        }
        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;
 
        for (i = 0; i < page_size; i++) {
                /* transfer data from source to destination */
                if (*src == 0xFF) {
                        dst++, src++;
                        /* If the data is 0xFF, don't program it */
                        continue;
                }
                /*issue AUTO PROGRAM command */
                chip_writeb(AUTO_PGRM, dst);
@@ -152,13 +153,23 @@ int write_28sf040(struct flashchip *flash, uint8_t *buf)
 
                /* write to the sector */
                printf("%04d at address: 0x%08x", i, i * page_size);
                write_sector_28sf040(bios, buf + i * page_size,
                                     bios + i * page_size, page_size);
                
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
        }
        printf("\n");
 
        protect_28sf040(bios);
 
        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..6866eb9 100644
--- a/sst49lfxxxc.c
+++ b/sst49lfxxxc.c
@@ -1,18 +1,19 @@
 /*
  * This file is part of the flashrom project.
  *
  * Copyright (C) 2000 Silicon Integrated System Corporation
  * Copyright (C) 2005-2007 coresystems GmbH
+ * Copyright (C) 2009 Sean Nelson <[email protected]>
  *
  * 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
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
@@ -25,26 +26,35 @@
 #define SECTOR_ERASE           0x30
 #define BLOCK_ERASE            0x20
 #define ERASE                  0xD0
 #define AUTO_PGRM              0x10
 #define RESET                  0xFF
 #define READ_ID                        0x90
 #define READ_STATUS            0x70
 #define CLEAR_STATUS           0x50
 
 #define STATUS_BPS             (1 << 1)
 #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;
        int i, left = flash->total_size * 1024;
        unsigned long address;
 
        printf_debug("\nbios=0x%08lx\n", registers);
        for (i = 0; left > 65536; i++, left -= 65536) {
                printf_debug("lockbits at address=0x%08lx is 0x%01x\n",
                             registers + (i * 65536) + 2,
                             chip_readb(registers + (i * 65536) + 2));
                chip_writeb(bits, registers + (i * 65536) + 2);
        }
@@ -62,51 +72,76 @@ static int write_lockbits_49lfxxxc(struct flashchip *flash, 
unsigned char bits)
        printf_debug("lockbits at address=0x%08lx is 0x%01x\n",
                     registers + address + 2,
                     chip_readb(registers + address + 2));
        chip_writeb(bits, registers + address + 2);
        address += 8192;
        printf_debug("lockbits at address=0x%08lx is 0x%01x\n",
                     registers + address + 2,
                     chip_readb(registers + address + 2));
        chip_writeb(bits, registers + address + 2);
 
        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;
 
        chip_writeb(SECTOR_ERASE, bios);
        chip_writeb(ERASE, bios + address);
 
        do {
                status = chip_readb(bios);
                if (status & (STATUS_ESS | STATUS_BPS)) {
                        printf("sector 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, sector_size)) {
                fprintf(stderr, "ERASE FAILED!\n");
                return -1;
        }
        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)
 {
        int i;
        unsigned char status;
 
        chip_writeb(CLEAR_STATUS, bios);
        for (i = 0; i < page_size; i++) {
                /* transfer data from source to destination */
                if (*src == 0xFF) {
                        dst++, src++;
                        /* If the data is 0xFF, don't program it */
                        continue;
diff --git a/sst_fwhub.c b/sst_fwhub.c
index b29722f..75d9e05 100644
--- a/sst_fwhub.c
+++ b/sst_fwhub.c
@@ -1,18 +1,19 @@
 /*
  * This file is part of the flashrom project.
  *
  * Copyright (C) 2000 Silicon Integrated System Corporation
  * Copyright (C) 2009 Kontron Modular Computers
+ * Copyright (C) 2009 Sean Nelson <[email protected]>
  *
  * 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
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
@@ -104,26 +105,45 @@ int erase_sst_fwhub_block(struct flashchip *flash, 
unsigned int offset, unsigned
                        "at 0x%06x\n", offset);
                return 1;
        }
 
        if (erase_block_jedec(flash, offset, page_size)) {
                fprintf(stderr, "ERASE FAILED!\n");
                return -1;
        }
        toggle_ready_jedec(flash->virtual_memory);
 
        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;
        unsigned int total_size = flash->total_size * 1024;
 
        for (i = 0; i < total_size; i += flash->page_size) {
                if (erase_sst_fwhub_block(flash, i, flash->page_size)) {
                        fprintf(stderr, "ERASE FAILED!\n");
                        return -1;
                }
        }
 
        return 0;
_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to