summaryrefslogtreecommitdiff
path: root/drivers/mtd/spi/spansion.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-01-10 02:20:12 -0500
committerWolfgang Denk <wd@denx.de>2011-04-11 21:00:53 +0200
commit6163045bcd276818d9ad6bdd1bf36ddcd60d014b (patch)
tree732ba3dd3b07977e38c773960dfb76c78ee4ab09 /drivers/mtd/spi/spansion.c
parent000044d8bfdc803a1a97e68ba95f289bfe5ad149 (diff)
downloadu-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/spansion.c')
-rw-r--r--drivers/mtd/spi/spansion.c41
1 files changed, 4 insertions, 37 deletions
diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c
index c0900f9..d0f03ff 100644
--- a/drivers/mtd/spi/spansion.c
+++ b/drivers/mtd/spi/spansion.c
@@ -54,8 +54,6 @@
#define SPSN_EXT_ID_S25FL128P_64KB 0x0301
#define SPSN_EXT_ID_S25FL032P 0x4d00
-#define SPANSION_SR_WIP (1 << 0) /* Write-in-Progress */
-
struct spansion_spi_flash_params {
u16 idcode1;
u16 idcode2;
@@ -135,32 +133,6 @@ static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
},
};
-static int spansion_wait_ready(struct spi_flash *flash, unsigned long timeout)
-{
- struct spi_slave *spi = flash->spi;
- unsigned long timebase;
- int ret;
- u8 status;
-
- timebase = get_timer(0);
- do {
- ret = spi_flash_cmd(spi, CMD_S25FLXX_RDSR, &status, sizeof(status));
- if (ret)
- return -1;
-
- if ((status & SPANSION_SR_WIP) == 0)
- break;
-
- } while (get_timer(timebase) < timeout);
-
-
- if ((status & SPANSION_SR_WIP) == 0)
- return 0;
-
- /* Timed out */
- return -1;
-}
-
static int spansion_read_fast(struct spi_flash *flash,
u32 offset, size_t len, void *buf)
{
@@ -233,11 +205,9 @@ static int spansion_write(struct spi_flash *flash,
break;
}
- ret = spansion_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
- if (ret < 0) {
- debug("SF: SPANSION page programming timed out\n");
+ ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PROG_TIMEOUT);
+ if (ret)
break;
- }
page_addr++;
byte_addr = 0;
@@ -297,12 +267,9 @@ int spansion_erase(struct spi_flash *flash, u32 offset, size_t len)
break;
}
- /* Up to 2 seconds */
- ret = spansion_wait_ready(flash, SPI_FLASH_PAGE_ERASE_TIMEOUT);
- if (ret < 0) {
- debug("SF: SPANSION page erase timed out\n");
+ ret = spi_flash_cmd_wait_ready(flash, SPI_FLASH_PAGE_ERASE_TIMEOUT);
+ if (ret)
break;
- }
}
debug("SF: SPANSION: Successfully erased %u bytes @ 0x%x\n",