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.

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

diff --git a/chipdrivers.h b/chipdrivers.h
index e7261e0..e074217 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -121,34 +121,40 @@ int write_49fl00x(struct flashchip *flash, uint8_t *buf);
 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_chip(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);
 
diff --git a/flashchips.c b/flashchips.c
index 8e90d2a..b8fd16a 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -3536,31 +3536,48 @@ struct flashchip flashchips[] = {
                .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",
@@ -3568,31 +3585,45 @@ struct flashchip flashchips[] = {
                .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",
@@ -3600,111 +3631,178 @@ struct flashchip flashchips[] = {
                .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",
@@ -3712,15 +3810,25 @@ struct flashchip flashchips[] = {
                .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",
@@ -3728,32 +3836,58 @@ struct flashchip flashchips[] = {
                .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 = erase_sst_fwhub_chip,
+                       }
+               },
                .write          = write_sst_fwhub,
                .read           = read_memmapped,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF003A/B",
@@ -3762,15 +3896,28 @@ struct flashchip flashchips[] = {
                .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 = erase_sst_fwhub_chip,
+                       }
+               },
                .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.
@@ -3811,32 +3958,63 @@ struct flashchip flashchips[] = {
                .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,
+                       }, {
+                               .eraseblocks = { {512 * 1024, 1} },
+                               .block_erase = erase_chip_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 = erase_sst_fwhub_chip,
+                       }
+               },
                .write          = write_sst_fwhub,
                .read           = read_memmapped,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF008C",
@@ -3844,31 +4022,67 @@ struct flashchip flashchips[] = {
                .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,
+                       }, {
+                               .eraseblocks = { {1024 * 1024, 1} },
+                               .block_erase = erase_chip_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,
+                       }, {
+                               .eraseblocks = { {2 * 1024 * 1024, 1} },
+                               .block_erase = erase_chip_49lfxxxc,
+                       }
+               },
                .write          = write_49lfxxxc,
                .read           = read_memmapped,
        },
 
        {
                .vendor         = "SST",
                .name           = "SST49LF020",
@@ -3876,96 +4090,180 @@ struct flashchip flashchips[] = {
                .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 = erase_chip_block_jedec,
+                       }
+               },
                .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 = erase_chip_block_jedec,
+                       }
+               },
                .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 = erase_chip_block_jedec,
+                       }
+               },
                .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 = erase_chip_block_jedec,
+                       }
+               },
+               .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 = erase_chip_block_jedec,
+                       }
+               },
                .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,
+                       }, {
+                               .eraseblocks = { {2 * 1024 * 1024, 1} },
+                               .block_erase = erase_chip_49lfxxxc,
+                       }
+               },
                .write          = write_49lfxxxc,
                .read           = read_memmapped,
        },
 
        {
                .vendor         = "ST",
                .name           = "M25P05-A",
diff --git a/sst28sf040.c b/sst28sf040.c
index 930ad5b..f253e39 100644
--- a/sst28sf040.c
+++ b/sst28sf040.c
@@ -1,12 +1,13 @@
 /*
  * 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,
@@ -46,15 +47,15 @@ static void unprotect_28sf040(chipaddr bios)
        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         */
@@ -63,15 +64,15 @@ static int erase_sector_28sf040(struct flashchip *flash, 
unsigned long address,
        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) {
@@ -158,7 +159,17 @@ int write_28sf040(struct flashchip *flash, uint8_t *buf)
        }
        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..e7ee78c 100644
--- a/sst49lfxxxc.c
+++ b/sst49lfxxxc.c
@@ -1,12 +1,13 @@
 /*
  * 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,
@@ -68,15 +69,15 @@ static int write_lockbits_49lfxxxc(struct flashchip *flash, 
unsigned char bits)
                     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);
 
@@ -93,14 +94,39 @@ static int erase_sector_49lfxxxc(struct flashchip *flash, 
unsigned long address,
        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);
@@ -163,14 +189,24 @@ int erase_49lfxxxc(struct flashchip *flash)
                        return (-1);
 
        chip_writeb(RESET, bios);
 
        return 0;
 }
 
+int erase_chip_49lfxxxc(struct flashchip *flash, unsigned int addr, unsigned 
int blocksize)
+{
+       if ((addr != 0) || (blocksize != flash->total_size * 1024)) {
+               fprintf(stderr, "%s called with incorrect arguments\n",
+                       __func__);
+               return -1;
+       }
+       return erase_49lfxxxc(flash);
+}
+
 int write_49lfxxxc(struct flashchip *flash, uint8_t *buf)
 {
        int i;
        int total_size = flash->total_size * 1024;
        int page_size = flash->page_size;
        chipaddr bios = flash->virtual_memory;
 
diff --git a/sst_fwhub.c b/sst_fwhub.c
index b29722f..070557d 100644
--- a/sst_fwhub.c
+++ b/sst_fwhub.c
@@ -1,12 +1,13 @@
 /*
  * 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,
@@ -110,14 +111,33 @@ int erase_sst_fwhub_block(struct flashchip *flash, 
unsigned int offset, unsigned
                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)) {
@@ -125,14 +145,24 @@ int erase_sst_fwhub(struct flashchip *flash)
                        return -1;
                }
        }
 
        return 0;
 }
 
+int erase_sst_fwhub_chip(struct flashchip *flash, unsigned int addr, unsigned 
int blocksize)
+{
+       if ((addr != 0) || (blocksize != flash->total_size * 1024)) {
+               fprintf(stderr, "%s called with incorrect arguments\n",
+                       __func__);
+               return -1;
+       }
+       return erase_sst_fwhub(flash);
+}
+
 int write_sst_fwhub(struct flashchip *flash, uint8_t *buf)
 {
        int i, rc;
        int total_size = flash->total_size * 1024;
        int page_size = flash->page_size;
        chipaddr bios = flash->virtual_memory;
        uint8_t *readbuf = malloc(page_size);
_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to