Simlifies ich_spi_write, and changes the naming of "page" to "block".
Only write operation is modified. If this is proved to be acceptable,
read operation will be modified in a same manner later. Impact of
modification have been made minimal, other parts of flashrom should
not be affected.
Not tested due to lack of facilities. Appreciated if anyone could help testing.
Signed-off-by: FENG yu ning <[EMAIL PROTECTED]>
Index: flashrom/ichspi.c
===================================================================
--- flashrom/ichspi.c (revision 3767)
+++ flashrom/ichspi.c (working copy)
@@ -510,22 +510,21 @@
return 0;
}
-static int ich_spi_write_page(struct flashchip *flash, uint8_t * bytes,
- int offset, int maxdata)
+static int ich_spi_write_block(struct flashchip *flash, uint8_t * bytes,
+ int offset, int block_size, int maxdata)
{
- int page_size = flash->page_size;
- uint32_t remaining = page_size;
+ uint32_t remaining = block_size;
int a;
- printf_debug("ich_spi_write_page: offset=%d, number=%d, buf=%p\n",
- offset, page_size, bytes);
+ printf_debug("ich_spi_write_block: offset=%d, block size=%d, buf=%p\n",
+ offset, block_size, bytes);
- for (a = 0; a < page_size; a += maxdata) {
+ for (a = 0; a < block_size; a += maxdata) {
if (remaining < maxdata) {
if (run_opcode
(curopcodes->opcode[0],
- offset + (page_size - remaining), remaining,
- &bytes[page_size - remaining]) != 0) {
+ offset + a, remaining,
+ &bytes[a]) != 0) {
printf_debug("Error writing");
return 1;
}
@@ -533,8 +532,8 @@
} else {
if (run_opcode
(curopcodes->opcode[0],
- offset + (page_size - remaining), maxdata,
- &bytes[page_size - remaining]) != 0) {
+ offset + a, maxdata,
+ &bytes[a]) != 0) {
printf_debug("Error writing");
return 1;
}
@@ -568,13 +567,12 @@
{
int i, j, rc = 0;
int total_size = flash->total_size * 1024;
- int page_size = flash->page_size;
int erase_size = 64 * 1024;
int maxdata = 64;
spi_disable_blockprotect();
- printf("Programming page: \n");
+ printf("Programming flashchip: \n");
for (i = 0; i < total_size / erase_size; i++) {
/* FIMXE: call the chip-specific spi_block_erase_XX instead.
@@ -590,11 +588,12 @@
if (flashbus == BUS_TYPE_VIA_SPI)
maxdata = 16;
- for (j = 0; j < erase_size / page_size; j++) {
- ich_spi_write_page(flash,
- (void *)(buf + (i * erase_size) + (j * page_size)),
- (i * erase_size) + (j * page_size), maxdata);
- }
+ ich_spi_write_block(flash,
+ (void *)(buf + (i * erase_size)),
+ i * erase_size,
+ erase_size,
+ maxdata);
+
}
printf("\n");
--
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot