Signed-off-by: Zheng Bao zheng.bao@amd.com
-----Original Message----- From: coreboot-bounces+zheng.bao=amd.com@coreboot.org [mailto:coreboot-bounces+zheng.bao=amd.com@coreboot.org] On Behalf Of Bao, Zheng Sent: Monday, December 29, 2008 4:34 PM To: Coreboot Subject: [coreboot] [patch]:SB600 flashrom using virtual memory
The accessing is changed to reading and writing byte to virtual memory. Reading chip can be improved. Writing doesn't seem to get noticeable improvement.
The patch contains my previous patch which fixes hang and is not acked-by yet.
Zheng
diff -Nuar -x .svn -x flashrom -x '*.o' -x .dependencies flashrom-org/chipset_enable.c coreboot-v2-svn/util/flashrom/chipset_enable.c --- flashrom-org/chipset_enable.c 2008-12-22 14:12:08.000000000 +0800 +++ coreboot-v2-svn/util/flashrom/chipset_enable.c 2008-12-23 09:46:53.000000000 +0800 @@ -681,8 +681,16 @@ flashbus = BUS_TYPE_SB600_SPI;
/* Enable SPI ROM in SB600 PM register. */ + /* If we enable SPI ROM here, we have to disable it after we leave. + * But how can we know which ROM we are going to handle? So we have + * to trade off. We only access LPC ROM if we boot via LPC ROM. And + * only SPI ROM if we boot via SPI ROM. If you want to do it crossly, + * you have to use the code below. + */ + /* OUTB(0x8f, 0xcd6); OUTB(0x0e, 0xcd7); + */
return 0; } diff -Nuar -x .svn -x flashrom -x '*.o' -x .dependencies flashrom-org/sb600spi.c coreboot-v2-svn/util/flashrom/sb600spi.c --- flashrom-org/sb600spi.c 2008-11-29 15:07:14.000000000 +0800 +++ coreboot-v2-svn/util/flashrom/sb600spi.c 2008-12-29 16:17:09.000000000 +0800 @@ -44,13 +44,11 @@
int sb600_spi_read(struct flashchip *flash, uint8_t *buf) { - int rc = 0, i; + int rc = 0; int total_size = flash->total_size * 1024; - int page_size = 8;
- for (i = 0; i < total_size / page_size; i++) - spi_nbyte_read(i * page_size, (void *)(buf + i * page_size), - page_size); + memcpy(buf, (const char *)flash->virtual_memory, total_size); + return rc; }
@@ -68,17 +66,20 @@ { int rc = 0, i; int total_size = flash->total_size * 1024; + uint8_t *bios;
/* Erase first */ printf("Erasing flash before programming... "); flash->erase(flash); printf("done.\n");
+ spi_disable_blockprotect(); printf("Programming flash"); - for (i = 0; i < total_size; i++, buf++) { - spi_disable_blockprotect(); + for (i = 0, bios = (uint8_t *)flash->virtual_memory; + i < total_size; + i++, buf++, bios++) { spi_write_enable(); - spi_byte_program(i, *buf); + *bios = *buf; /* wait program complete. */ if (i % 0x8000 == 0) printf("."); @@ -97,12 +98,18 @@ printf("reset\n"); }
-void execute_command(void) +int execute_command(void) { + int timeout = 1000; + sb600_spibar[2] |= 1;
- while (sb600_spibar[2] & 1) - ; + while ((sb600_spibar[2] & 1) && timeout) + { + myusec_delay(1); + timeout --; + } + return timeout ? 1 : 0; }
int sb600_spi_command(unsigned int writecnt, unsigned int readcnt, @@ -150,7 +157,8 @@ */ reset_internal_fifo_pointer();
- execute_command(); + if (!execute_command()) + return 1;
/* * After the command executed, we should find out the index of the