From 21efd9ffe2bc51463bd4278def63e3c294907da2 Mon Sep 17 00:00:00 2001 From: Ronald Hoogenboom Date: Mon, 21 Jan 2008 23:55:08 +0000 Subject: [PATCH] Omitting the wait for SPI ready when there is no data to be read, e.g. readcnt==0 saves 10 seconds with the unconditional 10us delay, reducing programming time for SST25VF016B to 40-45 secs. Signed-off-by: Ronald Hoogenboom Acked-by: Carl-Daniel Hailfinger git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3068 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- util/flashrom/spi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/util/flashrom/spi.c b/util/flashrom/spi.c index 20e8828697..4c01b3104f 100644 --- a/util/flashrom/spi.c +++ b/util/flashrom/spi.c @@ -227,12 +227,15 @@ static int it8716f_spi_command(uint16_t port, unsigned int writecnt, unsigned in * We can't use writecnt directly, but have to use a strange encoding. */ outb(((0x4 + (fast_spi ? 1 : 0)) << 4) | ((readcnt & 0x3) << 2) | (writeenc), port); - do { - busy = inb(port) & 0x80; - } while (busy); - for (i = 0; i < readcnt; i++) { - readarr[i] = inb(port + 5 + i); + if (readcnt > 0) { + do { + busy = inb(port) & 0x80; + } while (busy); + + for (i = 0; i < readcnt; i++) { + readarr[i] = inb(port + 5 + i); + } } return 0;