mirror of
https://review.coreboot.org/flashrom.git
synced 2025-08-15 19:40:19 +02:00
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 <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> Tested-by: Maciej Pijanka <maciej.pijanka@gmail.com> Tested-by: Idwer Vollering <vidwer@gmail.com> Acked-by: Idwer Vollering <vidwer@gmail.com> Tested-by: Sean Nelson <audiohacked@gmail.com> Acked-by: Sean Nelson <audiohacked@gmail.com>
This commit is contained in:
20
sst28sf040.c
20
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)
|
||||
|
Reference in New Issue
Block a user