From 79e6757d269b91ee759bd569df7093225f4f3715 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Wed, 13 Oct 2010 21:49:30 +0000 Subject: Refactor remaining write wrappers Kill duplicated code. Annotate write functions with their chunk size. Mark Fujitsu MBM29F400BC and ST M29F400BB as untested because their write code no longer uses a broken layout. Corresponding to flashrom svn r1210. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Uwe Hermann Tested-by: Maciej Pijanka Tested-by: Idwer Vollering Acked-by: Idwer Vollering Tested-by: Sean Nelson Acked-by: Sean Nelson --- sst28sf040.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'sst28sf040.c') diff --git a/sst28sf040.c b/sst28sf040.c index ba220939d..0c62fd6d2 100644 --- a/sst28sf040.c +++ b/sst28sf040.c @@ -30,7 +30,7 @@ #define RESET 0xFF #define READ_ID 0x90 -static void protect_28sf040(struct flashchip *flash) +int protect_28sf040(struct flashchip *flash) { chipaddr bios = flash->virtual_memory; @@ -41,9 +41,11 @@ static void protect_28sf040(struct flashchip *flash) chip_readb(bios + 0x041B); chip_readb(bios + 0x0419); chip_readb(bios + 0x040A); + + return 0; } -static void unprotect_28sf040(struct flashchip *flash) +int unprotect_28sf040(struct flashchip *flash) { chipaddr bios = flash->virtual_memory; @@ -54,12 +56,15 @@ static void unprotect_28sf040(struct flashchip *flash) chip_readb(bios + 0x041B); chip_readb(bios + 0x0419); chip_readb(bios + 0x041A); + + return 0; } int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size) { chipaddr bios = flash->virtual_memory; + /* This command sequence is very similar to erase_block_82802ab. */ chip_writeb(AUTO_PG_ERASE1, bios); chip_writeb(AUTO_PG_ERASE2, bios + address); @@ -101,10 +106,8 @@ static int erase_28sf040(struct flashchip *flash) { chipaddr bios = flash->virtual_memory; - unprotect_28sf040(flash); chip_writeb(CHIP_ERASE, bios); chip_writeb(CHIP_ERASE, bios); - protect_28sf040(flash); programmer_delay(10); toggle_ready_jedec(bios); @@ -116,15 +119,10 @@ static int erase_28sf040(struct flashchip *flash) return 0; } +/* chunksize is 1 */ int write_28sf040(struct flashchip *flash, uint8_t *buf) { - unprotect_28sf040(flash); - - write_sector_28sf040(flash, buf, 0, flash->total_size * 1024); - - protect_28sf040(flash); - - return 0; + return write_sector_28sf040(flash, buf, 0, flash->total_size * 1024); } int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int blocklen) -- cgit v1.2.3