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

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

Corresponding to flashrom svn r907.

Signed-off-by: Sean Nelson <audiohacked@gmail.com>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
This commit is contained in:
Sean Nelson 2010-02-19 00:52:10 +00:00
parent ce5fad038d
commit 6e0b912f46
8 changed files with 64 additions and 7 deletions

View File

@ -41,7 +41,7 @@ CPPFLAGS += -I/usr/local/include
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

View File

@ -117,6 +117,7 @@ int write_29f002(struct flashchip *flash, uint8_t *buf);
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_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigne
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 write_sst_fwhub(struct flashchip *flash, uint8_t *buf);
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);

View File

@ -206,6 +206,8 @@ struct flashchip {
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);

View File

@ -49,6 +49,8 @@ struct flashchip flashchips[] = {
* .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 @@ struct flashchip flashchips[] = {
.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 @@ struct flashchip flashchips[] = {
.block_erase = erase_chip_block_jedec,
}
},
.unlock = unlock_49fl00x,
.write = write_49fl00x,
.read = read_memmapped,
},
@ -3360,7 +3362,6 @@ struct flashchip flashchips[] = {
.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 @@ struct flashchip flashchips[] = {
.block_erase = erase_chip_block_jedec,
}
},
.unlock = unlock_49fl00x,
.write = write_49fl00x,
.read = read_memmapped,
},
@ -4406,7 +4408,6 @@ struct flashchip flashchips[] = {
.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 @@ struct flashchip flashchips[] = {
.block_erase = erase_block_49lfxxxc,
}
},
.unlock = unlock_49lfxxxc,
.write = write_49lfxxxc,
.read = read_memmapped,
},
@ -5740,7 +5742,6 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_jedec,
.probe_timing = TIMING_FIXME,
/* .erase = NULL, Was erase_w39v040c */
.block_erasers =
{
{
@ -5751,6 +5752,7 @@ struct flashchip flashchips[] = {
.block_erase = erase_chip_block_jedec,
}
},
.printlock = printlock_w39v040c,
.write = write_jedec_1,
.read = read_memmapped,
},
@ -5915,7 +5917,6 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_jedec,
.probe_timing = TIMING_FIXME,
/* .erase = NULL, Was erase_winbond_fwhub */
.block_erasers =
{
{
@ -5926,6 +5927,7 @@ struct flashchip flashchips[] = {
.block_erase = erase_chip_block_jedec,
}
},
.unlock = unlock_winbond_fwhub,
.write = write_jedec_1,
.read = read_memmapped,
},
@ -5942,7 +5944,6 @@ struct flashchip flashchips[] = {
.tested = TEST_UNTESTED,
.probe = probe_jedec,
.probe_timing = TIMING_FIXME,
/* .erase = NULL, Was erase_winbond_fwhub */
.block_erasers =
{
{
@ -5953,6 +5954,7 @@ struct flashchip flashchips[] = {
.block_erase = erase_chip_block_jedec,
}
},
.unlock = unlock_winbond_fwhub,
.write = write_jedec_1,
.read = read_memmapped,
},

View File

@ -838,6 +838,9 @@ notfound:
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 @@ int doit(struct flashchip *flash, int force, char *filename, int read_it, int wr
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 @@ int doit(struct flashchip *flash, int force, char *filename, int read_it, int wr
} 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. ");

View File

@ -36,6 +36,12 @@ void write_lockbits_49fl00x(chipaddr bios, int size,
}
}
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;

View File

@ -82,6 +82,11 @@ static int write_lockbits_49lfxxxc(struct flashchip *flash, unsigned char bits)
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;

View File

@ -50,6 +50,32 @@ int probe_w39v040c(struct flashchip *flash)
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;