summaryrefslogtreecommitdiffstats
path: root/src/drivers/spi
diff options
context:
space:
mode:
authorRaul E Rangel <rrangel@chromium.org>2022-04-29 14:06:09 -0600
committerFelix Held <felix-coreboot@felixheld.de>2022-05-02 14:05:15 +0000
commitb90e2510001996ea9419fb482c9c7a97af21ec12 (patch)
treecb693126da3d582b957aafe02f02ca71b19e270b /src/drivers/spi
parentb10cbd0d085e6ab3127e5cae27494a9c69a89268 (diff)
downloadcoreboot-b90e2510001996ea9419fb482c9c7a97af21ec12.tar.gz
coreboot-b90e2510001996ea9419fb482c9c7a97af21ec12.tar.bz2
coreboot-b90e2510001996ea9419fb482c9c7a97af21ec12.zip
drivers/spi: Add better error reporting to spi_flash_cmd_poll_bit
It's useful to know how many attempts were made at polling the status bit. BUG=b:228289365 TEST=Boot guybrush Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: Ifcc79a339707fbaab33e128807d4c0b26aa90108 Reviewed-on: https://review.coreboot.org/c/coreboot/+/63959 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Rob Barnes <robbarnes@google.com>
Diffstat (limited to 'src/drivers/spi')
-rw-r--r--src/drivers/spi/spi_flash.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 0142fad44232..9934f55e49b9 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -192,19 +192,28 @@ int spi_flash_cmd_poll_bit(const struct spi_flash *flash, unsigned long timeout,
{
const struct spi_slave *spi = &flash->spi;
int ret;
+ int attempt = 0;
u8 status;
struct stopwatch sw;
stopwatch_init_msecs_expire(&sw, timeout);
do {
+ attempt++;
+
ret = do_spi_flash_cmd(spi, &cmd, 1, &status, 1);
- if (ret)
+ if (ret) {
+ printk(BIOS_WARNING,
+ "SF: SPI command failed on attempt %d with rc %d\n", attempt,
+ ret);
return -1;
+ }
+
if ((status & poll_bit) == 0)
return 0;
} while (!stopwatch_expired(&sw));
- printk(BIOS_WARNING, "SF: timeout at %ld msec\n", stopwatch_duration_msecs(&sw));
+ printk(BIOS_WARNING, "SF: timeout at %ld msec after %d attempts\n",
+ stopwatch_duration_msecs(&sw), attempt);
return -1;
}