the following patch was just integrated into master:
commit c50c0ab4566a031a0420d762f2403126635bba93
Author: Dave Frodin <dave.frodin(a)se-eng.com>
Date: Wed Jun 11 12:53:47 2014 -0600
drivers/spi: Reduce the per loop delay of spi_flash_cmd_poll_bit()
At the end of some SPI operations the SPI device needs to be polled
to determine if it is done with the operation. For SPI data writes
the predicted time of that operation could be less than 10us.
The current per loop delay of 500us is adding too much delay.
This change replaces the delay(x) in the do-while loop with a
timer so that the actual timeout value won't be lengthened by the
delay of reading the SPI device.
Change-Id: Ia8b00879135f926c402bbd9d08953c77a2dcc84e
Signed-off-by: Dave Frodin <dave.frodin(a)se-eng.com>
Reviewed-on: http://review.coreboot.org/5973
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix(a)chromium.org>
Reviewed-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Reviewed-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
See http://review.coreboot.org/5973 for details.
-gerrit
the following patch was just integrated into master:
commit ba92428514d8cac8045faa1dc573599424ef7231
Author: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Date: Fri Jun 27 12:13:30 2014 +1000
intel: Make monotonic timer a first class citizen
The monotonic time now needs to be a first class citizen in Coreboot as
it is a hard dependency of the drivers/spi flash command polling
function.
Change-Id: I4e43d2680bf84bc525138f71c2b813b0f6be5265
Signed-off-by: Edward O'Callaghan <eocallaghan(a)alterapraxis.com>
Reviewed-on: http://review.coreboot.org/6135
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix(a)chromium.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
See http://review.coreboot.org/6135 for details.
-gerrit
David Hendricks (dhendrix(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6177
-gerrit
commit ed5ebbbddb053837ba96bf4a40d62781d8373e9c
Author: Dave Frodin <dave.frodin(a)se-eng.com>
Date: Wed Jun 11 12:53:47 2014 -0600
drivers/spi: Reduce the per loop delay of spi_flash_cmd_poll_bit()
At the end of some SPI operations the SPI device needs to be polled
to determine if it is done with the operation. For SPI data writes
the predicted time of that operation could be less than 10us.
The current per loop delay of 500us is adding too much delay.
This change replaces the delay(x) in the do-while loop with a
timer so that the actual timeout value won't be lengthened by the
delay of reading the SPI device.
Change-Id: Icddb9953d7065d9ef789f941ea1a93ce9305a33a
Signed-off-by: Dave Frodin <dave.frodin(a)se-eng.com>
---
src/drivers/spi/spi_flash.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 33588d5..6d92836 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -16,6 +16,7 @@
#include <cpu/x86/smm.h>
#endif
#include "spi_flash_internal.h"
+#include <timer.h>
static void spi_flash_addr(u32 addr, u8 *cmd)
{
@@ -106,27 +107,24 @@ int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout,
u8 cmd, u8 poll_bit)
{
struct spi_slave *spi = flash->spi;
- unsigned long timebase;
int ret;
u8 status;
+ struct mono_time current, end;
+
+ timer_monotonic_get(¤t);
+ end = current;
+ mono_time_add_msecs(&end, timeout);
- timebase = timeout;
do {
ret = spi_flash_cmd_read(spi, &cmd, 1, &status, 1);
if (ret)
return -1;
-
if ((status & poll_bit) == 0)
- break;
-
- udelay(500);
- } while (timebase--);
-
- if ((status & poll_bit) == 0)
- return 0;
+ return 0;
+ timer_monotonic_get(¤t);
+ } while (!mono_time_after(¤t, &end));
- /* Timed out */
- printk(BIOS_DEBUG, "SF: time out!\n");
+ printk(BIOS_DEBUG, "SF: timeout at %ld msec\n",timeout);
return -1;
}