1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 15:12:36 +02:00

Further cleanup after JEDEC refactorings

Convert _sst_fwhub functions to jedec.

Corresponding to flashrom svn r943.

kill unused sst_fwhub.c functions
make unlock_* check if unlock was successful and only return 0 when fully successful
Signed-off-by: Sean Nelson <audiohacked@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
This commit is contained in:
Sean Nelson 2010-03-16 03:09:10 +00:00
parent b3289c904c
commit ccf7a2a231
3 changed files with 30 additions and 110 deletions

View File

@ -111,11 +111,8 @@ int write_49lfxxxc(struct flashchip *flash, uint8_t *buf);
int unlock_49lfxxxc(struct flashchip *flash);
/* sst_fwhub.c */
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);
int printlock_sst_fwhub(struct flashchip *flash);
int unlock_sst_fwhub(struct flashchip *flash);
/* w39v040c.c */
int printlock_w39v040c(struct flashchip *flash);

View File

@ -4084,17 +4084,19 @@ struct flashchip flashchips[] = {
{
{
.eraseblocks = { {4 * 1024, 64} },
.block_erase = erase_sst_fwhub_sector,
.block_erase = erase_sector_jedec,
}, {
.eraseblocks = { {16 * 1024, 16} },
.block_erase = erase_sst_fwhub_block,
.block_erase = erase_block_jedec,
}, {
.eraseblocks = { {256 * 1024, 1} },
.block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
}
},
.printlock = printlock_sst_fwhub,
.write = write_sst_fwhub,
.printlock = printlock_sst_fwhub,
.unlock = unlock_sst_fwhub,
.write = write_jedec_1,
.read = read_memmapped,
},
@ -4114,17 +4116,19 @@ struct flashchip flashchips[] = {
{
{
.eraseblocks = { {4 * 1024, 96} },
.block_erase = erase_sst_fwhub_sector,
.block_erase = erase_sector_jedec,
}, {
.eraseblocks = { {64 * 1024, 6} },
.block_erase = erase_sst_fwhub_block,
.block_erase = erase_block_jedec,
}, {
.eraseblocks = { {384 * 1024, 1} },
.block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
}
},
.printlock = printlock_sst_fwhub,
.write = write_sst_fwhub,
.printlock = printlock_sst_fwhub,
.unlock = unlock_sst_fwhub,
.write = write_jedec_1,
.read = read_memmapped,
},
@ -4147,17 +4151,19 @@ struct flashchip flashchips[] = {
{
{
.eraseblocks = { {4 * 1024, 128} },
.block_erase = erase_sector_jedec, /* missing unlock */
.block_erase = erase_sector_jedec,
}, {
.eraseblocks = { {64 * 1024, 8} },
.block_erase = erase_sst_fwhub_block, /* same as erase_block_jedec, but with unlock */
.block_erase = erase_block_jedec,
}, {
.eraseblocks = { {512 * 1024, 1} },
.block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
},
},
.printlock = printlock_sst_fwhub,
.write = write_sst_fwhub,
.printlock = printlock_sst_fwhub,
.unlock = unlock_sst_fwhub,
.write = write_jedec_1,
.read = read_memmapped,
},
@ -4208,17 +4214,19 @@ struct flashchip flashchips[] = {
{
{
.eraseblocks = { {4 * 1024, 256} },
.block_erase = erase_sst_fwhub_sector,
.block_erase = erase_sector_jedec,
}, {
.eraseblocks = { {64 * 1024, 16} },
.block_erase = erase_sst_fwhub_block,
.block_erase = erase_block_jedec,
}, {
.eraseblocks = { {1024 * 1024, 1} },
.block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */
}
},
.printlock = printlock_sst_fwhub,
.write = write_sst_fwhub,
.printlock = printlock_sst_fwhub,
.unlock = unlock_sst_fwhub,
.write = write_jedec_1,
.read = read_memmapped,
},

View File

@ -27,18 +27,6 @@
#include "flash.h"
#include "chipdrivers.h"
// I need that Berkeley bit-map printer
void print_sst_fwhub_status(uint8_t status)
{
printf("%s", status & 0x80 ? "Ready:" : "Busy:");
printf("%s", status & 0x40 ? "BE SUSPEND:" : "BE RUN/FINISH:");
printf("%s", status & 0x20 ? "BE ERROR:" : "BE OK:");
printf("%s", status & 0x10 ? "PROG ERR:" : "PROG OK:");
printf("%s", status & 0x8 ? "VP ERR:" : "VPP OK:");
printf("%s", status & 0x4 ? "PROG SUSPEND:" : "PROG RUN/FINISH:");
printf("%s", status & 0x2 ? "WP|TBL#|WP#,ABORT:" : "UNLOCK:");
}
int check_sst_fwhub_block_lock(struct flashchip *flash, int offset)
{
chipaddr registers = flash->virtual_registers;
@ -93,91 +81,18 @@ int printlock_sst_fwhub(struct flashchip *flash)
return 0;
}
int erase_sst_fwhub_block(struct flashchip *flash, unsigned int offset, unsigned int page_size)
int unlock_sst_fwhub(struct flashchip *flash)
{
uint8_t blockstatus = clear_sst_fwhub_block_lock(flash, offset);
int i, ret=0;
if (blockstatus) {
printf("Block lock clearing failed, not erasing block "
"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;
for (i = 0; i < flash->total_size * 1024; i += flash->page_size)
{
if (clear_sst_fwhub_block_lock(flash, i))
{
msg_cdbg("Warning: Unlock Failed for block 0x%06x\n", i);
ret++;
}
}
return 0;
return ret;
}
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);
printf("Programming page: ");
for (i = 0; i < total_size / page_size; i++) {
printf("%04d at address: 0x%08x", i, i * page_size);
/* Auto Skip Blocks, which already contain the desired data:
* Faster, because we only write, what has changed
* More secure, because blocks, which are excluded
* (with the exclude or layout feature)
* are not erased and rewritten; data is retained also
* in sudden power off situations
*/
flash->read(flash, readbuf, i * page_size, page_size);
if (memcmp((void *)(buf + i * page_size),
(void *)(readbuf), page_size)) {
rc = erase_sst_fwhub_block(flash, i * page_size,
page_size);
if (rc)
return 1;
write_sector_jedec_common(flash, buf + i * page_size,
bios + i * page_size, page_size, 0xffff);
}
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");
return 0;
}