Author: snelson Date: Fri Feb 19 01:52:10 2010 New Revision: 907 URL: http://flashrom.org/trac/coreboot/changeset/907
Log: Here's a very quick patch to fix the missing unlock code. Fixes missing unlock for certain chips: * unlock_49lf00x * Pm49fl002 * Pm49fl004
* unlock_49flxxxc * SST49LF160C
* unlock_winbond_fwhub * W39V080FA * W39V080FA (dual mode)
Fixes missing printlock for certain chip: * printlock_w39v040c * W39V040C
Signed-off-by: Sean Nelson audiohacked@gmail.com Acked-by: Michael Karcher flashrom@mkarcher.dialup.fu-berlin.de
Modified: trunk/Makefile trunk/chipdrivers.h trunk/flash.h trunk/flashchips.c trunk/flashrom.c trunk/pm49fl00x.c trunk/sst49lfxxxc.c trunk/w39v040c.c
Modified: trunk/Makefile ============================================================================== --- trunk/Makefile Thu Feb 18 13:24:38 2010 (r906) +++ trunk/Makefile Fri Feb 19 01:52:10 2010 (r907) @@ -41,7 +41,7 @@ LDFLAGS += -L/usr/local/lib endif
-CHIP_OBJS = jedec.o stm50flw0x0x.o w39v080fa.o sharplhf00l04.o w29ee011.o \ +CHIP_OBJS = jedec.o stm50flw0x0x.o w39v040c.o w39v080fa.o sharplhf00l04.o w29ee011.o \ sst28sf040.o m29f400bt.o 82802ab.o pm49fl00x.o \ sst49lfxxxc.o sst_fwhub.o flashchips.o spi.o
Modified: trunk/chipdrivers.h ============================================================================== --- trunk/chipdrivers.h Thu Feb 18 13:24:38 2010 (r906) +++ trunk/chipdrivers.h Fri Feb 19 01:52:10 2010 (r907) @@ -117,6 +117,7 @@ int probe_49fl00x(struct flashchip *flash); int erase_49fl00x(struct flashchip *flash); int write_49fl00x(struct flashchip *flash, uint8_t *buf); +int unlock_49fl00x(struct flashchip *flash);
/* sharplhf00l04.c */ int probe_lhf00l04(struct flashchip *flash); @@ -145,6 +146,7 @@ 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); +int unlock_49lfxxxc(struct flashchip *flash);
/* sst_fwhub.c */ int probe_sst_fwhub(struct flashchip *flash); @@ -157,11 +159,13 @@ int probe_w39v040c(struct flashchip *flash); int erase_w39v040c(struct flashchip *flash); int write_w39v040c(struct flashchip *flash, uint8_t *buf); +int printlock_w39v040c(struct flashchip *flash);
/* 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); +int unlock_winbond_fwhub(struct flashchip *flash);
/* w29ee011.c */ int probe_w29ee011(struct flashchip *flash);
Modified: trunk/flash.h ============================================================================== --- trunk/flash.h Thu Feb 18 13:24:38 2010 (r906) +++ trunk/flash.h Fri Feb 19 01:52:10 2010 (r907) @@ -206,6 +206,8 @@ int (*block_erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen); } block_erasers[NUM_ERASEFUNCTIONS];
+ int (*printlock) (struct flashchip *flash); + int (*unlock) (struct flashchip *flash); int (*write) (struct flashchip *flash, uint8_t *buf); int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len);
Modified: trunk/flashchips.c ============================================================================== --- trunk/flashchips.c Thu Feb 18 13:24:38 2010 (r906) +++ trunk/flashchips.c Fri Feb 19 01:52:10 2010 (r907) @@ -49,6 +49,8 @@ * .eraseblocks[] = Array of { blocksize, blockcount } * .block_erase = Block erase function * } + * .printlock = Chip lock status function + * .unlock = Chip unlock function * .write = Chip write function * .read = Chip read function */ @@ -3330,7 +3332,6 @@ .tested = TEST_UNTESTED, .probe = probe_jedec, .probe_timing = TIMING_ZERO, /* routine is wrapper to probe_jedec (pm49fl00x.c) */ - /* .erase = NULL, Was: erase_49fl00x */ .block_erasers = { { @@ -3344,6 +3345,7 @@ .block_erase = erase_chip_block_jedec, } }, + .unlock = unlock_49fl00x, .write = write_49fl00x, .read = read_memmapped, }, @@ -3360,7 +3362,6 @@ .tested = TEST_UNTESTED, .probe = probe_jedec, .probe_timing = TIMING_ZERO, /* routine is wrapper to probe_jedec (pm49fl00x.c) */ - /* .erase = NULL, Was: erase_49fl00x */ .block_erasers = { { @@ -3374,6 +3375,7 @@ .block_erase = erase_chip_block_jedec, } }, + .unlock = unlock_49fl00x, .write = write_49fl00x, .read = read_memmapped, }, @@ -4406,7 +4408,6 @@ .tested = TEST_OK_PRW, .probe = probe_49lfxxxc, .probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (sst49lfxxxc.c) */ - /* .erase = NULL, Was: erase_49flxxxc */ .block_erasers = { { @@ -4422,6 +4423,7 @@ .block_erase = erase_block_49lfxxxc, } }, + .unlock = unlock_49lfxxxc, .write = write_49lfxxxc, .read = read_memmapped, }, @@ -5740,7 +5742,6 @@ .tested = TEST_UNTESTED, .probe = probe_jedec, .probe_timing = TIMING_FIXME, - /* .erase = NULL, Was erase_w39v040c */ .block_erasers = { { @@ -5751,6 +5752,7 @@ .block_erase = erase_chip_block_jedec, } }, + .printlock = printlock_w39v040c, .write = write_jedec_1, .read = read_memmapped, }, @@ -5915,7 +5917,6 @@ .tested = TEST_UNTESTED, .probe = probe_jedec, .probe_timing = TIMING_FIXME, - /* .erase = NULL, Was erase_winbond_fwhub */ .block_erasers = { { @@ -5926,6 +5927,7 @@ .block_erase = erase_chip_block_jedec, } }, + .unlock = unlock_winbond_fwhub, .write = write_jedec_1, .read = read_memmapped, }, @@ -5942,7 +5944,6 @@ .tested = TEST_UNTESTED, .probe = probe_jedec, .probe_timing = TIMING_FIXME, - /* .erase = NULL, Was erase_winbond_fwhub */ .block_erasers = { { @@ -5953,6 +5954,7 @@ .block_erase = erase_chip_block_jedec, } }, + .unlock = unlock_winbond_fwhub, .write = write_jedec_1, .read = read_memmapped, },
Modified: trunk/flashrom.c ============================================================================== --- trunk/flashrom.c Thu Feb 18 13:24:38 2010 (r906) +++ trunk/flashrom.c Fri Feb 19 01:52:10 2010 (r907) @@ -838,6 +838,9 @@ flash->vendor, flash->name, flash->total_size, flashbuses_to_text(flash->bustype), base);
+ if (flash->printlock) + flash->printlock(flash); + return flash; }
@@ -1147,12 +1150,18 @@ fprintf(stderr, "Continuing anyway.\n"); } } + if (flash->unlock) + flash->unlock(flash); + if (erase_flash(flash)) { emergency_help_message(); programmer_shutdown(); return 1; } } else if (read_it) { + if (flash->unlock) + flash->unlock(flash); + if (read_flash(flash, filename)) { programmer_shutdown(); return 1; @@ -1160,6 +1169,9 @@ } else { struct stat image_stat;
+ if (flash->unlock) + flash->unlock(flash); + if (flash->tested & TEST_BAD_ERASE) { fprintf(stderr, "Erase is not working on this chip " "and erase is needed for write. ");
Modified: trunk/pm49fl00x.c ============================================================================== --- trunk/pm49fl00x.c Thu Feb 18 13:24:38 2010 (r906) +++ trunk/pm49fl00x.c Fri Feb 19 01:52:10 2010 (r907) @@ -36,6 +36,12 @@ } }
+int unlock_49fl00x(struct flashchip *flash) +{ + write_lockbits_49fl00x(flash->virtual_registers, flash->total_size * 1024, 0, flash->page_size); + return 0; +} + int erase_49fl00x(struct flashchip *flash) { int i;
Modified: trunk/sst49lfxxxc.c ============================================================================== --- trunk/sst49lfxxxc.c Thu Feb 18 13:24:38 2010 (r906) +++ trunk/sst49lfxxxc.c Fri Feb 19 01:52:10 2010 (r907) @@ -82,6 +82,11 @@ return 0; }
+int unlock_49lfxxxc(struct flashchip *flash) +{ + return write_lockbits_49lfxxxc(flash, 0); +} + int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size) { unsigned char status;
Modified: trunk/w39v040c.c ============================================================================== --- trunk/w39v040c.c Thu Feb 18 13:24:38 2010 (r906) +++ trunk/w39v040c.c Fri Feb 19 01:52:10 2010 (r907) @@ -50,6 +50,32 @@ return 1; }
+int printlock_w39v040c(struct flashchip *flash) +{ + chipaddr bios = flash->virtual_memory; + uint8_t lock; + + chip_writeb(0xAA, bios + 0x5555); + programmer_delay(10); + chip_writeb(0x55, bios + 0x2AAA); + programmer_delay(10); + chip_writeb(0x90, bios + 0x5555); + programmer_delay(10); + + lock = chip_readb(bios + 0xfff2); + + chip_writeb(0xAA, bios + 0x5555); + programmer_delay(10); + chip_writeb(0x55, bios + 0x2AAA); + programmer_delay(10); + chip_writeb(0xF0, bios + 0x5555); + programmer_delay(40); + + printf("%s: Boot block #TBL is %slocked, rest of chip #WP is %slocked.\n", + __func__, lock & 0x4 ? "" : "un", lock & 0x8 ? "" : "un"); + return 0; +} + int erase_w39v040c(struct flashchip *flash) { int i;