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>
This commit is contained in:
committed by
Felix Held
parent
b10cbd0d08
commit
b90e251000
@@ -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;
|
const struct spi_slave *spi = &flash->spi;
|
||||||
int ret;
|
int ret;
|
||||||
|
int attempt = 0;
|
||||||
u8 status;
|
u8 status;
|
||||||
struct stopwatch sw;
|
struct stopwatch sw;
|
||||||
|
|
||||||
stopwatch_init_msecs_expire(&sw, timeout);
|
stopwatch_init_msecs_expire(&sw, timeout);
|
||||||
do {
|
do {
|
||||||
|
attempt++;
|
||||||
|
|
||||||
ret = do_spi_flash_cmd(spi, &cmd, 1, &status, 1);
|
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;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((status & poll_bit) == 0)
|
if ((status & poll_bit) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
} while (!stopwatch_expired(&sw));
|
} 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user