
This prepares for final removal of reset_timer() from Nios2
Signed-off-by: Graeme Russ graeme.russ@gmail.com --- drivers/mtd/cfi_flash.c | 12 ++++++------ drivers/mtd/nand/nand_base.c | 17 +++++++++-------- drivers/mtd/spi/eeprom_m95xxx.c | 6 +++--- drivers/mtd/spi/spi_flash.c | 6 +++--- 4 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index 3ac6c80..dad80c5 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -563,7 +563,7 @@ static int flash_is_busy (flash_info_t * info, flash_sect_t sect) static int flash_status_check (flash_info_t * info, flash_sect_t sector, ulong tout, char *prompt) { - ulong start; + u32 start;
#if CONFIG_SYS_HZ != 1000 if ((ulong)CONFIG_SYS_HZ > 100000) @@ -576,9 +576,9 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector, #ifdef CONFIG_NIOS2 reset_timer(); #endif - start = get_timer (0); + start = time_now_ms(); while (flash_is_busy (info, sector)) { - if (get_timer (start) > tout) { + if (time_since_ms(start) > tout) { printf ("Flash %s timeout at address %lx data %lx\n", prompt, info->start[sector], flash_read_long (info, sector, 0)); @@ -653,7 +653,7 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst, ulong tout, char *prompt) { #ifdef CONFIG_SYS_CFI_FLASH_STATUS_POLL - ulong start; + u32 start; int ready;
#if CONFIG_SYS_HZ != 1000 @@ -667,7 +667,7 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst, #ifdef CONFIG_NIOS2 reset_timer(); #endif - start = get_timer(0); + start = time_now_ms(); while (1) { switch (info->portwidth) { case FLASH_CFI_8BIT: @@ -688,7 +688,7 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst, } if (ready) break; - if (get_timer(start) > tout) { + if (time_since_ms(start) > tout) { printf("Flash %s timeout at address %lx data %lx\n", prompt, (ulong)dst, (ulong)flash_read8(dst)); return ERR_TIMOUT; diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 52f8575..c838695 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -33,6 +33,7 @@ */
#include <common.h> +#include <time.h>
#define ENOTSUPP 524 /* Operation is not supported */
@@ -439,12 +440,12 @@ void nand_wait_ready(struct mtd_info *mtd) { struct nand_chip *chip = mtd->priv; u32 timeo = (CONFIG_SYS_HZ * 20) / 1000; - u32 time_start; + u32 start;
- time_start = get_timer(0); + start = time_now_ms();
/* wait until command is processed or timeout occures */ - while (get_timer(time_start) < timeo) { + while (time_since_ms(start) < timeo) { if (chip->dev_ready) if (chip->dev_ready(mtd)) break; @@ -705,7 +706,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this) { unsigned long timeo; int state = this->state; - u32 time_start; + u32 start;
if (state == FL_ERASING) timeo = (CONFIG_SYS_HZ * 400) / 1000; @@ -717,10 +718,10 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this) else this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
- time_start = get_timer(0); + start = time_now_ms();
while (1) { - if (get_timer(time_start) > timeo) { + if (time_since_ms(start) > timeo) { printf("Timeout!"); return 0x01; } @@ -734,8 +735,8 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this) } } #ifdef PPCHAMELON_NAND_TIMER_HACK - time_start = get_timer(0); - while (get_timer(time_start) < 10) + start = time_now_ms(); + while (time_since_ms(start) < 10) ; #endif /* PPCHAMELON_NAND_TIMER_HACK */
diff --git a/drivers/mtd/spi/eeprom_m95xxx.c b/drivers/mtd/spi/eeprom_m95xxx.c index ef8ed6f..16b194c 100644 --- a/drivers/mtd/spi/eeprom_m95xxx.c +++ b/drivers/mtd/spi/eeprom_m95xxx.c @@ -75,7 +75,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len) { struct spi_slave *slave; char buf[3]; - ulong start; + u32 start;
slave = spi_setup_slave(CONFIG_DEFAULT_SPI_BUS, 1, 1000000, CONFIG_DEFAULT_SPI_MODE); @@ -103,7 +103,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len) if(spi_xfer(slave, len * 8, buffer, NULL, SPI_XFER_END)) return -1;
- start = get_timer(0); + start = time_now_ms(); do { buf[0] = SPI_EEPROM_RDSR; buf[1] = 0; @@ -112,7 +112,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len) if (!(buf[1] & 1)) break;
- } while (get_timer(start) < CONFIG_SYS_SPI_WRITE_TOUT); + } while (time_since_ms(start) < CONFIG_SYS_SPI_WRITE_TOUT);
if (buf[1] & 1) printf ("*** spi_write: Time out while writing!\n"); diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 016b586..6e1054d 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -94,7 +94,7 @@ int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout, u8 cmd, u8 poll_bit) { struct spi_slave *spi = flash->spi; - unsigned long timebase; + u32 start; int ret; u8 status;
@@ -104,7 +104,7 @@ int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout, return ret; }
- timebase = get_timer(0); + start = time_now_ms(); do { WATCHDOG_RESET();
@@ -115,7 +115,7 @@ int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout, if ((status & poll_bit) == 0) break;
- } while (get_timer(timebase) < timeout); + } while (time_since_ms(start) < timeout);
spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END);