diff options
author | Sean Nelson <audiohacked@gmail.com> | 2010-01-20 20:55:53 +0000 |
---|---|---|
committer | Sean Nelson <audiohacked@gmail.com> | 2010-01-20 20:55:53 +0000 |
commit | 51c83fb2b204a369e1b1825b66c56e5babcf8022 (patch) | |
tree | af901ed6d2a2214445035d483c29492217ee7727 /sst49lfxxxc.c | |
parent | 21f54963611aa0f3ee3ad16a45395d0cec8363f1 (diff) | |
download | ast2050-flashrom-51c83fb2b204a369e1b1825b66c56e5babcf8022.zip ast2050-flashrom-51c83fb2b204a369e1b1825b66c56e5babcf8022.tar.gz |
Convert various SST chips to use block_erasers
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"
Corresponding to flashrom svn r877.
Signed-off-by: Sean Nelson <audiohacked@gmail.com>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Diffstat (limited to 'sst49lfxxxc.c')
-rw-r--r-- | sst49lfxxxc.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/sst49lfxxxc.c b/sst49lfxxxc.c index a421acf..80e5520 100644 --- a/sst49lfxxxc.c +++ b/sst49lfxxxc.c @@ -3,6 +3,7 @@ * * Copyright (C) 2000 Silicon Integrated System Corporation * Copyright (C) 2005-2007 coresystems GmbH + * Copyright (C) 2009 Sean Nelson <audiohacked@gmail.com> * * 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 @@ -35,6 +36,15 @@ #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; @@ -72,7 +82,7 @@ static int write_lockbits_49lfxxxc(struct flashchip *flash, unsigned char bits) 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; @@ -97,6 +107,31 @@ static int erase_sector_49lfxxxc(struct flashchip *flash, unsigned long address, 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) { |