summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-04-12 03:39:28 (GMT)
committerMike Frysinger <vapier@gentoo.org>2011-04-12 03:41:09 (GMT)
commitcdb6a00fb8f96b9259ed7d77a1eacbfa3777ddac (patch)
treed85d1da65a9ce3e93b180944a4fce15cc3a672c2
parent192b639ecce29caa954482dbcaa46ae4fc4df0e7 (diff)
downloadu-boot-cdb6a00fb8f96b9259ed7d77a1eacbfa3777ddac.tar.xz
sf: atmel: undo unification of status polling
The AT45 flashes are completely different (at the command set and status register level) from all other SPI flashes, so we can't unify their logic with common code. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--drivers/mtd/spi/atmel.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/drivers/mtd/spi/atmel.c b/drivers/mtd/spi/atmel.c
index a9910b1..10df387 100644
--- a/drivers/mtd/spi/atmel.c
+++ b/drivers/mtd/spi/atmel.c
@@ -113,8 +113,35 @@ static const struct atmel_spi_flash_params atmel_spi_flash_table[] = {
static int at45_wait_ready(struct spi_flash *flash, unsigned long timeout)
{
- return spi_flash_cmd_poll_bit(flash, timeout,
- CMD_AT45_READ_STATUS, AT45_STATUS_READY);
+ 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;
}
/*