mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-02 14:33:18 +02:00
Introduce a generic SPI read function: spi_write_chunked()
Every SPI programmer driver had its own completely different chip write implementation, and all of them were insufficiently commented. Create spi_write_chunked as a copy of spi_read_chunked and convert all SPI programmers to use it. No functional changes except: - Bus Pirate uses 12 Byte writes instead of 8 Byte writes - SB600 uses 5 Byte writes instead of 1 Byte writes Corresponding to flashrom svn r1005. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de> Acked-by: David Hendricks <dhendrix@google.com>
This commit is contained in:
16
sb600spi.c
16
sb600spi.c
@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2008 Wang Qingpei <Qingpei.Wang@amd.com>
|
||||
* Copyright (C) 2008 Joe Bao <Zheng.Bao@amd.com>
|
||||
* Copyright (C) 2008 Advanced Micro Devices, Inc.
|
||||
* Copyright (C) 2009, 2010 Carl-Daniel Hailfinger
|
||||
*
|
||||
* 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
|
||||
@ -49,7 +50,6 @@ int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
|
||||
/* FIXME: SB600 can write 5 bytes per transaction. */
|
||||
int sb600_spi_write_1(struct flashchip *flash, uint8_t *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size * 1024;
|
||||
int result = 0;
|
||||
|
||||
@ -63,19 +63,7 @@ int sb600_spi_write_1(struct flashchip *flash, uint8_t *buf)
|
||||
msg_pinfo("done.\n");
|
||||
|
||||
msg_pinfo("Programming flash");
|
||||
for (i = 0; i < total_size; i++, buf++) {
|
||||
result = spi_nbyte_program(i, buf, 1);
|
||||
if (result) {
|
||||
msg_perr("Write error!\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
/* wait program complete. */
|
||||
if (i % 0x8000 == 0)
|
||||
msg_pspew(".");
|
||||
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
|
||||
;
|
||||
}
|
||||
result = spi_write_chunked(flash, buf, 0, total_size, 5);
|
||||
msg_pinfo(" done.\n");
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user