diff options
author | Mike Frysinger <vapier@gentoo.org> | 2011-01-10 02:20:12 -0500 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2011-04-11 21:00:53 +0200 |
commit | 6163045bcd276818d9ad6bdd1bf36ddcd60d014b (patch) | |
tree | 732ba3dd3b07977e38c773960dfb76c78ee4ab09 /drivers/mtd/spi/atmel.c | |
parent | 000044d8bfdc803a1a97e68ba95f289bfe5ad149 (diff) | |
download | u-boot-imx-6163045bcd276818d9ad6bdd1bf36ddcd60d014b.zip u-boot-imx-6163045bcd276818d9ad6bdd1bf36ddcd60d014b.tar.gz u-boot-imx-6163045bcd276818d9ad6bdd1bf36ddcd60d014b.tar.bz2 |
sf: unify status polling for ready bit
All of the spi flash drivers implement the status register polling for
detecting the device ready state, so unify them all in a new helper
function -- spi_flash_wait_ready.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'drivers/mtd/spi/atmel.c')
-rw-r--r-- | drivers/mtd/spi/atmel.c | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/drivers/mtd/spi/atmel.c b/drivers/mtd/spi/atmel.c index 8d02169..7827b75 100644 --- a/drivers/mtd/spi/atmel.c +++ b/drivers/mtd/spi/atmel.c @@ -113,35 +113,8 @@ static const struct atmel_spi_flash_params atmel_spi_flash_table[] = { static int at45_wait_ready(struct spi_flash *flash, unsigned long timeout) { - struct spi_slave *spi = flash->spi; - unsigned long timebase; - int ret; - u8 cmd = CMD_AT45_READ_STATUS; - u8 status; - - timebase = get_timer(0); - - ret = spi_xfer(spi, 8, &cmd, NULL, SPI_XFER_BEGIN); - if (ret) - return -1; - - do { - ret = spi_xfer(spi, 8, NULL, &status, 0); - if (ret) - return -1; - - if (status & AT45_STATUS_READY) - break; - } while (get_timer(timebase) < timeout); - - /* Deactivate CS */ - spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END); - - if (status & AT45_STATUS_READY) - return 0; - - /* Timed out */ - return -1; + return spi_flash_cmd_poll_bit(flash, timeout, + CMD_AT45_READ_STATUS, AT45_STATUS_READY); } /* |