diff options
author | stefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2013-09-12 08:29:06 +0000 |
---|---|---|
committer | stefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2013-09-12 08:29:06 +0000 |
commit | a384fd1ea1c246e73a708e46b559680b5026aec3 (patch) | |
tree | 64161051da3569c3eff1d44fa0fbab934c5d2c36 /stm50.c | |
parent | 8524c271d09dfe27769a7f604cb5b6be1490dcad (diff) | |
download | flashrom-a384fd1ea1c246e73a708e46b559680b5026aec3.tar.gz |
Enable sector erase function for selected ST M50 chips.
Affected chips: M50FLW040A, M50FLW040B, M50FLW080A, M50FLW080B.
Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1738 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'stm50.c')
-rw-r--r-- | stm50.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -84,10 +84,9 @@ int unlock_stm50_uniform(struct flashctx *flash) return 0; } -/* This function is unused. */ -int erase_sector_stm50(struct flashctx *flash, unsigned int sector, unsigned int sectorsize) +static int stm50_erase_sector(struct flashctx *flash, unsigned int addr) { - chipaddr bios = flash->virtual_memory + sector; + chipaddr bios = flash->virtual_memory + addr; // clear status register chip_writeb(flash, 0x50, bios); @@ -96,8 +95,21 @@ int erase_sector_stm50(struct flashctx *flash, unsigned int sector, unsigned int chip_writeb(flash, 0xd0, bios); programmer_delay(10); - wait_82802ab(flash); + uint8_t status = wait_82802ab(flash); + print_status_82802ab(status); - /* FIXME: Check the status register for errors. */ - return 0; + return status == 0x80; +} + +/* Some ST M50* chips do support erasing of sectors. This function will derive the erase function to use from + * the length of the of the block. For calls that apparently do not address a sector (but a block) we just call + * the block erase function instead. FIXME: This duplicates the behavior of the remaining erasers for blocks and + * might be fixed when flashrom supports multiple functions per eraser or erasers that do erase parts of the + * chip only. */ +int erase_sector_stm50(struct flashctx *flash, unsigned int addr, unsigned int len) +{ + if (len == 4096) + return stm50_erase_sector(flash, addr); + else + return erase_block_82802ab(flash, addr, len); } |