[U-Boot] [PATCH v1 (WIP) 00/16] [Timer]API Rewrite

The following series is a work-in-progress revamp of the timer API. The aim is to create a new userland API consisting of the following functions (along with a few arch level support functions):
u32 time_now_ms(void); u32 time_since_ms(u32 from, u32 to); u32 time_max_since_ms(u32 from, u32 to);
This current patch series migrates the users of the existing timer API consisting of get_timer() and reset_timer() to the new API while still retaining the arch specific framework in the background.
I feel that the arch level implementation should be left for a completely separate patch series. This will allow the migration to progress in a series of very neatly defined and distinct (and therefore easily bisectable) steps.
Note: I have included my SOB on each patch - I am marking this as the start of the official patch series to bring the following discussion threads to conclusion:
http://lists.denx.de/pipermail/u-boot/2011-May/093093.html http://lists.denx.de/pipermail/u-boot/2011-May/093141.html http://lists.denx.de/pipermail/u-boot/2011-May/093209.html http://lists.denx.de/pipermail/u-boot/2011-May/093404.html
And the Timer API Task on the wiki:
http://www.denx.de/wiki/U-Boot/TaskTimerAPI
There are 18 days left in the current merge window (and I am going on holidays for a week during that) so I kind of doubt that this will make 2011.09 - If it does not, However, I _really_ want to pound this out ready for 2011.12
Comments please
Graeme Russ (16): [Timer]Fix misuse of ARM *timer_masked() functions outside arch/arm [Timer]Remove calls to set_timer outside arch/ [Timer]Remove calls to set_timer in arch/ [Timer]Allow reset_timer() only for Nios2 [Timer]Remove reset_timer() for non-Nios2 arches [Timer]Fix at91rm9200/spi.c timer usage [Timer]Remove reset_timer_masked() [Timer]Create new userland timer API [Timer]Replace get_timer() usage in drivers/block/ [Timer]Replace get_timer() usage in driver/mtd and driver/block [Timer]Remove reset_timer() completely [Timer]Replace get_timer() usage in drivers/ [Timer]Replace get_timer() usage in net/ [Timer]Replace get_timer() usage in common/ [Timer]Replace get_timer() usage in board/ [Timer]Replace get_timer() usage in arch/
arch/arm/cpu/arm1136/mx31/timer.c | 17 -------- arch/arm/cpu/arm1136/mx35/timer.c | 9 ---- arch/arm/cpu/arm1136/omap24xx/timer.c | 24 +++-------- arch/arm/cpu/arm1176/s3c64xx/timer.c | 17 -------- arch/arm/cpu/arm1176/tnetv107x/timer.c | 14 ------- arch/arm/cpu/arm720t/interrupts.c | 17 -------- arch/arm/cpu/arm920t/a320/timer.c | 12 ------ arch/arm/cpu/arm920t/at91/timer.c | 19 --------- arch/arm/cpu/arm920t/at91rm9200/spi.c | 5 +- arch/arm/cpu/arm920t/at91rm9200/timer.c | 18 --------- arch/arm/cpu/arm920t/ep93xx/timer.c | 15 +------ arch/arm/cpu/arm920t/imx/timer.c | 21 +--------- arch/arm/cpu/arm920t/ks8695/timer.c | 25 ++---------- arch/arm/cpu/arm920t/s3c24x0/timer.c | 18 --------- arch/arm/cpu/arm925t/timer.c | 23 +---------- arch/arm/cpu/arm926ejs/armada100/timer.c | 20 +--------- arch/arm/cpu/arm926ejs/davinci/timer.c | 5 -- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 20 +--------- arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 19 +-------- arch/arm/cpu/arm926ejs/mx25/timer.c | 19 --------- arch/arm/cpu/arm926ejs/mx27/timer.c | 19 --------- arch/arm/cpu/arm926ejs/nomadik/timer.c | 12 ++--- arch/arm/cpu/arm926ejs/omap/timer.c | 11 ----- arch/arm/cpu/arm926ejs/orion5x/timer.c | 20 +--------- arch/arm/cpu/arm926ejs/pantheon/timer.c | 20 +--------- arch/arm/cpu/arm926ejs/spear/timer.c | 22 +--------- arch/arm/cpu/arm926ejs/versatile/timer.c | 11 ----- arch/arm/cpu/armv7/mx5/timer.c | 20 ++-------- arch/arm/cpu/armv7/omap-common/timer.c | 21 +--------- arch/arm/cpu/armv7/s5p-common/timer.c | 10 ----- arch/arm/cpu/armv7/tegra2/timer.c | 17 -------- arch/arm/cpu/ixp/timer.c | 13 ------ arch/arm/cpu/lh7a40x/timer.c | 11 ----- arch/arm/cpu/pxa/timer.c | 18 +-------- arch/arm/cpu/s3c44b0/timer.c | 18 --------- arch/arm/cpu/sa1100/timer.c | 16 -------- arch/avr32/cpu/interrupts.c | 23 ----------- arch/blackfin/cpu/interrupts.c | 5 -- arch/blackfin/cpu/jtag-console.c | 4 +- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 9 ---- arch/m68k/lib/board.c | 2 - arch/m68k/lib/time.c | 21 +--------- arch/microblaze/cpu/timer.c | 12 +----- arch/microblaze/lib/time.c | 4 +- arch/mips/cpu/mips32/time.c | 12 ------ arch/nios2/cpu/epcs.c | 12 +++--- arch/nios2/cpu/interrupts.c | 44 --------------------- arch/powerpc/cpu/mpc824x/drivers/i2c/i2c.c | 8 ++-- arch/powerpc/cpu/mpc8260/ether_fcc.c | 12 +++--- arch/powerpc/lib/board.c | 2 - arch/powerpc/lib/interrupts.c | 10 ----- arch/sh/lib/time.c | 12 ------ arch/sh/lib/time_sh2.c | 15 +------- arch/sparc/lib/board.c | 2 - arch/sparc/lib/interrupts.c | 12 +----- arch/x86/lib/board.c | 2 - arch/x86/lib/timer.c | 10 ----- board/BuS/EB+MCF-EV123/flash.c | 10 +++-- board/LEOX/elpt860/flash.c | 12 +++--- board/Marvell/common/flash.c | 16 ++++---- board/Marvell/common/intel_flash.c | 19 ++++----- board/RPXClassic/flash.c | 8 ++-- board/RPXlite/flash.c | 8 ++-- board/RPXlite_dw/flash.c | 8 ++-- board/RRvision/flash.c | 8 ++-- board/a3000/flash.c | 8 ++-- board/alaska/flash.c | 34 ++++++++-------- board/altera/common/AMDLV065D.c | 8 ++-- board/altera/common/flash.c | 10 ++-- board/amcc/common/flash.c | 16 ++++---- board/amcc/taihu/flash.c | 16 ++++---- board/amcc/yucca/flash.c | 16 ++++---- board/amirix/ap1000/flash.c | 4 +- board/armadillo/flash.c | 6 ++- board/armltd/integrator/timer.c | 24 ++---------- board/armltd/vexpress/ca9x4_ct_vxp.c | 5 -- board/astro/mcf5373l/mcf5373l.c | 4 +- board/atc/flash.c | 22 +++++----- board/atmel/at91rm9200dk/flash.c | 10 +++-- board/atmel/atstk1000/flash.c | 2 +- board/bmw/flash.c | 8 ++-- board/c2mon/flash.c | 8 ++-- board/cerf250/flash.c | 14 +++---- board/cm4008/flash.c | 10 +++-- board/cm41xx/flash.c | 10 +++-- board/cmc_pu2/flash.c | 11 +++-- board/cmi/flash.c | 12 +++--- board/cobra5272/flash.c | 10 +++-- board/cogent/flash.c | 14 +++--- board/cpc45/flash.c | 8 ++-- board/cpu86/flash.c | 16 ++++---- board/cpu87/flash.c | 16 ++++---- board/cradle/flash.c | 10 +++-- board/cray/L1/flash.c | 8 ++-- board/csb226/flash.c | 10 +++-- board/cu824/flash.c | 8 ++-- board/dave/common/flash.c | 8 ++-- board/dnp1110/flash.c | 14 +++---- board/earthlcd/favr-32-ezkit/flash.c | 2 +- board/eltec/bab7xx/flash.c | 8 ++-- board/eltec/elppc/flash.c | 8 ++-- board/eltec/mhpc/flash.c | 8 ++-- board/emk/common/flash.c | 18 ++++---- board/ep7312/flash.c | 10 +++-- board/ep8260/flash.c | 8 ++-- board/esd/common/flash.c | 8 ++-- board/esd/cpci5200/strataflash.c | 4 +- board/esd/pf5200/flash.c | 18 ++++---- board/esteem192e/flash.c | 18 ++++---- board/etin/debris/flash.c | 16 ++++---- board/etx094/flash.c | 12 +++--- board/evb4510/flash.c | 4 +- board/evb64260/flash.c | 8 ++-- board/evb64260/intel_flash.c | 18 ++++----- board/fads/flash.c | 8 ++-- board/flagadm/flash.c | 22 +++++----- board/freescale/m5253demo/flash.c | 14 +++--- board/freescale/mpc8260ads/flash.c | 12 +++--- board/freescale/mpc8266ads/flash.c | 12 +++--- board/funkwerk/vovpn-gw/flash.c | 16 ++++---- board/g2000/strataflash.c | 4 +- board/gcplus/flash.c | 14 +++---- board/gen860t/flash.c | 16 ++++---- board/genietv/flash.c | 8 ++-- board/gw8260/flash.c | 8 ++-- board/hermes/flash.c | 8 ++-- board/hidden_dragon/flash.c | 8 ++-- board/hymod/flash.c | 10 ++-- board/icecube/flash.c | 18 ++++---- board/icu862/flash.c | 8 ++-- board/idmr/flash.c | 10 +++-- board/impa7/flash.c | 10 +++-- board/incaip/flash.c | 22 +++++----- board/innokom/flash.c | 10 +++-- board/ip860/flash.c | 8 ++-- board/iphase4539/flash.c | 8 ++-- board/ivm/flash.c | 8 ++-- board/ixdp425/flash.c | 10 +++-- board/jse/flash.c | 8 ++-- board/kup/common/flash.c | 12 +++--- board/lantec/flash.c | 8 ++-- board/lart/flash.c | 10 +++-- board/linkstation/avr.c | 40 ++++++++++---------- board/lpd7a40x/flash.c | 10 +++-- board/lubbock/flash.c | 14 +++---- board/lwmon/flash.c | 10 ++-- board/mbx8xx/flash.c | 8 ++-- board/modnet50/flash.c | 14 ++++--- board/mpl/common/flash.c | 16 ++++---- board/mpl/mip405/mip405.c | 11 ++--- board/mpl/vcma9/flash.c | 10 +++-- board/musenki/flash.c | 8 ++-- board/mvblue/flash.c | 8 ++-- board/mx1ads/syncflash.c | 2 +- board/mx1fs2/flash.c | 16 ++++---- board/netphone/flash.c | 8 ++-- board/netta/flash.c | 8 ++-- board/netta2/flash.c | 8 ++-- board/netvia/flash.c | 8 ++-- board/ns9750dev/flash.c | 15 +++---- board/nvidia/common/board.c | 1 - board/nx823/flash.c | 8 ++-- board/o2dnt/flash.c | 26 ++++++------ board/oxc/flash.c | 8 ++-- board/pcippc2/flash.c | 8 ++-- board/pcs440ep/flash.c | 12 +++--- board/pleb2/flash.c | 18 ++++---- board/pm520/flash.c | 22 +++++----- board/pm826/flash.c | 8 ++-- board/pm828/flash.c | 8 ++-- board/ppmc7xx/flash.c | 8 ++-- board/ppmc8260/strataflash.c | 4 +- board/prodrive/common/flash.c | 12 +++--- board/psyent/common/AMDLV065D.c | 8 ++-- board/r360mpi/flash.c | 8 ++-- board/rbc823/flash.c | 8 ++-- board/rmu/flash.c | 8 ++-- board/rpxsuper/flash.c | 8 ++-- board/rsdproto/flash.c | 8 ++-- board/sacsng/flash.c | 8 ++-- board/samsung/smdk2400/flash.c | 10 +++-- board/sandburst/common/flash.c | 8 ++-- board/sandpoint/flash.c | 8 ++-- board/sbc2410x/flash.c | 10 +++-- board/sbc405/strataflash.c | 4 +- board/sbc8240/flash.c | 8 ++-- board/sbc8260/flash.c | 8 ++-- board/scb9328/flash.c | 5 +- board/shannon/flash.c | 10 +++-- board/siemens/IAD210/flash.c | 8 ++-- board/siemens/SCM/flash.c | 8 ++-- board/siemens/SMN42/flash.c | 8 ++-- board/sixnet/flash.c | 12 +++--- board/snmc/qs850/flash.c | 8 ++-- board/snmc/qs860t/flash.c | 18 ++++---- board/stx/stxgp3/flash.c | 12 +++--- board/svm_sc8xx/flash.c | 16 ++++---- board/tb0229/flash.c | 18 ++++---- board/ti/omap1610inn/flash.c | 15 +++---- board/ti/omap730p2/flash.c | 15 +++---- board/tqc/tqm5200/cam5200_flash.c | 16 ++++---- board/trab/cmd_trab.c | 6 +- board/trab/flash.c | 10 +++-- board/utx8245/flash.c | 8 ++-- board/v37/flash.c | 12 +++--- board/w7o/flash.c | 20 +++++----- board/w7o/fpga.c | 10 ++-- board/westel/amx860/flash.c | 8 ++-- board/xaeniax/flash.c | 14 +++---- board/xm250/flash.c | 23 +++++------ board/zeus/zeus.c | 4 +- board/zylonite/flash.c | 14 +++---- common/cmd_misc.c | 4 +- drivers/block/mg_disk.c | 10 ++--- drivers/fpga/ACEX1K.c | 5 +- drivers/fpga/cyclon2.c | 5 +- drivers/fpga/spartan2.c | 30 +++++++++------ drivers/fpga/spartan3.c | 32 ++++++++++------ drivers/fpga/virtex2.c | 20 ++++++---- drivers/i2c/bfin-twi_i2c.c | 6 +- drivers/i2c/spr_i2c.c | 28 ++++++++------ drivers/i2c/u8500_i2c.c | 8 ++-- drivers/input/ps2mult.c | 6 +- drivers/mmc/omap_hsmmc.c | 57 +++++++++++++++------------- drivers/mtd/cfi_flash.c | 14 +++---- drivers/mtd/nand/nand_base.c | 17 ++++---- drivers/mtd/spi/atmel.c | 4 +- drivers/mtd/spi/eeprom_m95xxx.c | 5 +- drivers/mtd/spi/spi_flash.c | 6 +- drivers/net/4xx_enet.c | 8 +-- drivers/net/bcm570x.c | 2 +- drivers/net/cs8900.c | 17 ++++---- drivers/net/dm9000x.c | 6 +- drivers/net/ethoc.c | 6 +- drivers/net/fec_mxc.c | 18 ++++---- drivers/net/ftgmac100.c | 6 +- drivers/net/ftmac100.c | 6 +- drivers/net/greth.c | 16 ++++---- drivers/net/lan91c96.c | 5 +- drivers/net/ne2000_base.c | 6 +- drivers/net/netarm_eth.c | 14 ++++-- drivers/net/ns7520_eth.c | 5 +- drivers/net/ns9750_eth.c | 4 +- drivers/net/rtl8139.c | 6 +- drivers/net/rtl8169.c | 26 ++++++------- drivers/net/smc91111.c | 4 +- drivers/serial/serial_clps7111.c | 6 +- drivers/serial/serial_netarm.c | 4 +- drivers/spi/atmel_dataflash_spi.c | 8 +-- drivers/usb/gadget/ether.c | 25 ++++++------ drivers/usb/host/ehci-hcd.c | 8 ++-- drivers/usb/host/sl811-hcd.c | 5 +- include/common.h | 37 ++++++++++-------- lib/time.c | 26 +++++++++++++ net/bootp.c | 6 +- net/net.c | 18 +++----- net/sntp.c | 2 +- net/tftp.c | 4 +- 258 files changed, 1238 insertions(+), 1866 deletions(-)
-- 1.7.5.2.317.g391b14

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- board/armadillo/flash.c | 6 ++++-- board/atmel/at91rm9200dk/flash.c | 10 ++++++---- board/cerf250/flash.c | 14 ++++++-------- board/cm4008/flash.c | 10 ++++++---- board/cm41xx/flash.c | 10 ++++++---- board/cmc_pu2/flash.c | 11 ++++++----- board/cradle/flash.c | 10 ++++++---- board/csb226/flash.c | 10 ++++++---- board/dnp1110/flash.c | 14 ++++++-------- board/ep7312/flash.c | 10 ++++++---- board/gcplus/flash.c | 14 ++++++-------- board/impa7/flash.c | 10 ++++++---- board/innokom/flash.c | 10 ++++++---- board/ixdp425/flash.c | 10 ++++++---- board/lart/flash.c | 10 ++++++---- board/lpd7a40x/flash.c | 10 ++++++---- board/lubbock/flash.c | 14 ++++++-------- board/modnet50/flash.c | 14 ++++++++------ board/mpl/vcma9/flash.c | 10 ++++++---- board/mx1ads/syncflash.c | 2 +- board/ns9750dev/flash.c | 15 ++++++--------- board/pleb2/flash.c | 18 +++++++++--------- board/samsung/smdk2400/flash.c | 10 ++++++---- board/sbc2410x/flash.c | 10 ++++++---- board/scb9328/flash.c | 5 +++-- board/shannon/flash.c | 10 ++++++---- board/ti/omap1610inn/flash.c | 15 ++++++--------- board/ti/omap730p2/flash.c | 15 ++++++--------- board/trab/cmd_trab.c | 6 +++--- board/trab/flash.c | 10 ++++++---- board/xaeniax/flash.c | 14 ++++++-------- board/xm250/flash.c | 23 +++++++++++------------ board/zylonite/flash.c | 14 ++++++-------- drivers/mtd/spi/eeprom_m95xxx.c | 5 +++-- drivers/net/fec_mxc.c | 6 +++--- drivers/net/netarm_eth.c | 12 +++++++----- 36 files changed, 208 insertions(+), 189 deletions(-)
diff --git a/board/armadillo/flash.c b/board/armadillo/flash.c index cdbbfd0..cf7d7f6 100644 --- a/board/armadillo/flash.c +++ b/board/armadillo/flash.c @@ -162,6 +162,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int rc = ERR_OK; unsigned long base; unsigned long addr; + ulong start;
if ((info->flash_id & FLASH_VENDMASK) != (FUJ_MANUFACT & FLASH_VENDMASK)) { @@ -192,7 +193,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last && !ctrlc (); sect++) { /* ARM simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */
@@ -232,6 +233,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) { int flag; unsigned long base; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -250,7 +252,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) flag = disable_interrupts ();
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
base = dest & 0xF0000000; FL_WORD (base + (0x555 << 1)) = 0xAA; diff --git a/board/atmel/at91rm9200dk/flash.c b/board/atmel/at91rm9200dk/flash.c index 902c3c4..be22743 100644 --- a/board/atmel/at91rm9200dk/flash.c +++ b/board/atmel/at91rm9200dk/flash.c @@ -285,6 +285,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip1; + ulong start;
/* first look for protection bits */
@@ -325,7 +326,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = (volatile u16 *) (info->start[sect]); @@ -345,7 +346,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -400,6 +401,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) int rc = ERR_OK; int cflag, iflag; int chip1; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -425,7 +427,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait until flash is ready */ chip1 = 0; @@ -433,7 +435,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; } diff --git a/board/cerf250/flash.c b/board/cerf250/flash.c index a4b201e..e1e7807 100644 --- a/board/cerf250/flash.c +++ b/board/cerf250/flash.c @@ -221,7 +221,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -254,9 +254,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -269,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -393,6 +390,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -406,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/cm4008/flash.c b/board/cm4008/flash.c index 2e66872..d6fd519 100644 --- a/board/cm4008/flash.c +++ b/board/cm4008/flash.c @@ -209,6 +209,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int flag, prot, sect; ulong type; int rcode = 0; + ulong start;
if ((s_first < 0) || (s_first > s_last)) { if (info->flash_id == FLASH_UNKNOWN) { @@ -250,7 +251,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
addr = (volatile unsigned char *) (info->start[sect]); *addr = 0x50; /* clear status register */ @@ -258,7 +259,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0xB0; /* suspend erase */ @@ -370,6 +371,7 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) volatile unsigned char *addr = (volatile unsigned char *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -384,11 +386,11 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0xFF; /* restore read mode */ return (1); } diff --git a/board/cm41xx/flash.c b/board/cm41xx/flash.c index 2e66872..d6fd519 100644 --- a/board/cm41xx/flash.c +++ b/board/cm41xx/flash.c @@ -209,6 +209,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int flag, prot, sect; ulong type; int rcode = 0; + ulong start;
if ((s_first < 0) || (s_first > s_last)) { if (info->flash_id == FLASH_UNKNOWN) { @@ -250,7 +251,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
addr = (volatile unsigned char *) (info->start[sect]); *addr = 0x50; /* clear status register */ @@ -258,7 +259,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0xB0; /* suspend erase */ @@ -370,6 +371,7 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) volatile unsigned char *addr = (volatile unsigned char *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -384,11 +386,11 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0xFF; /* restore read mode */ return (1); } diff --git a/board/cmc_pu2/flash.c b/board/cmc_pu2/flash.c index d832e62..d10faab 100644 --- a/board/cmc_pu2/flash.c +++ b/board/cmc_pu2/flash.c @@ -264,7 +264,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) { vu_short *addr = (vu_short *)(info->start[0]); int flag, prot, sect, ssect, l_sect; - ulong now, last; + ulong now, last, start;
debug ("flash_erase: first: %d last: %d\n", s_first, s_last);
@@ -335,11 +335,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- reset_timer_masked (); + start = get_timer(0); last = 0; addr = (vu_short *)(info->start[l_sect]); while ((addr[0] & 0x0080) != 0x0080) { - if ((now = get_timer_masked ()) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -434,6 +434,7 @@ static int write_word_amd (flash_info_t *info, vu_short *dest, ushort data) { int flag; vu_short *base; /* first address in flash bank */ + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*dest & data) != data) { @@ -455,11 +456,11 @@ static int write_word_amd (flash_info_t *info, vu_short *dest, ushort data) if (flag) enable_interrupts();
- reset_timer_masked (); + start = get_timer(0);
/* data polling for D7 */ while ((*dest & 0x0080) != (data & 0x0080)) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = 0x00F0; /* reset bank */ return (1); } diff --git a/board/cradle/flash.c b/board/cradle/flash.c index b5635fb..1601782 100644 --- a/board/cradle/flash.c +++ b/board/cradle/flash.c @@ -136,6 +136,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -173,7 +174,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -182,7 +183,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while ((*addr & 0x80) != 0x80) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0xB0; /* suspend erase */ *addr = 0xFF; /* reset to read mode */ @@ -221,6 +222,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) vu_short *addr = (vu_short *) dest, val; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -246,11 +248,11 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((val = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0xB0; diff --git a/board/csb226/flash.c b/board/csb226/flash.c index 02ded1c..e103470 100644 --- a/board/csb226/flash.c +++ b/board/csb226/flash.c @@ -141,6 +141,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -175,7 +176,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ u32 * volatile addr = (u32 * volatile)(info->start[sect]); @@ -189,7 +190,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) *addr = 0x00D000D0; /* erase confirm */
while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B000B0; /* suspend erase*/ *addr = 0x00FF00FF; /* read mode */ rc = ERR_TIMOUT; @@ -221,6 +222,7 @@ static int write_long (flash_info_t *info, ulong dest, ulong data) u32 * volatile addr = (u32 * volatile)dest, val; int rc = ERR_OK; int flag; + ulong start;
/* read array command - just for the case... */ *addr = 0x00FF00FF; @@ -247,11 +249,11 @@ static int write_long (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while(((val = *addr) & 0x00800080) != 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0x00B000B0; diff --git a/board/dnp1110/flash.c b/board/dnp1110/flash.c index c81abc5..53f89ee 100644 --- a/board/dnp1110/flash.c +++ b/board/dnp1110/flash.c @@ -212,7 +212,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -245,9 +245,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts();
@@ -260,14 +257,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
*addr = (FPW)0x00500050; /* clear status register */ *addr = (FPW)0x00200020; /* erase setup */ *addr = (FPW)0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW)0x00B000B0; /* suspend erase */ *addr = (FPW)0x00FF00FF; /* reset to read mode */ @@ -385,6 +382,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *)dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -398,11 +396,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (start = get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW)0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/ep7312/flash.c b/board/ep7312/flash.c index 0c2b3ae..2ed9c9a 100644 --- a/board/ep7312/flash.c +++ b/board/ep7312/flash.c @@ -119,6 +119,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -156,7 +157,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -165,7 +166,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while ((*addr & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0xB0; /* suspend erase */ *addr = 0xFF; /* reset to read mode */ rc = ERR_TIMOUT; @@ -203,6 +204,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) vu_short *addr = (vu_short *) dest, val; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -228,11 +230,11 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((val = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0xB0; diff --git a/board/gcplus/flash.c b/board/gcplus/flash.c index 8511582..ab567e8 100644 --- a/board/gcplus/flash.c +++ b/board/gcplus/flash.c @@ -225,7 +225,7 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -258,9 +258,6 @@ flash_erase(flash_info_t * info, int s_first, int s_last) printf("\n"); }
- start = get_timer(0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts();
@@ -273,7 +270,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ @@ -282,7 +279,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -401,6 +398,7 @@ write_data(flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -414,11 +412,11 @@ write_data(flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/impa7/flash.c b/board/impa7/flash.c index d0c5880..6eae428 100644 --- a/board/impa7/flash.c +++ b/board/impa7/flash.c @@ -128,6 +128,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -165,7 +166,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -174,7 +175,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0x00D000D0; /* erase confirm */
while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B000B0; /* suspend erase */ *addr = 0x00FF00FF; /* reset to read mode */ @@ -211,6 +212,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) ulong barf; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -236,14 +238,14 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* read status register command */ *addr = 0x00700070;
/* wait while polling the status register */ while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0x00B000B0; diff --git a/board/innokom/flash.c b/board/innokom/flash.c index 8c95341..ed4b987 100644 --- a/board/innokom/flash.c +++ b/board/innokom/flash.c @@ -182,6 +182,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -218,7 +219,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) PRINTK("\n");
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ u16 * volatile addr = (u16 * volatile)(info->start[sect]); @@ -235,7 +236,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
while ((*addr & 0x0080) != 0x0080) { PRINTK("."); - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B0; /* suspend erase*/ *addr = 0x00FF; /* read mode */ rc = ERR_TIMOUT; @@ -279,6 +280,7 @@ static int write_word (flash_info_t *info, ulong dest, ushort data) volatile u16 *addr = (u16 *)dest, val; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) return ERR_NOT_ERASED; @@ -302,11 +304,11 @@ static int write_word (flash_info_t *info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while(((val = *addr) & 0x80) != 0x80) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; *addr = 0xB0; /* suspend program command */ goto outahere; diff --git a/board/ixdp425/flash.c b/board/ixdp425/flash.c index f1d9190..5e4e0e7 100644 --- a/board/ixdp425/flash.c +++ b/board/ixdp425/flash.c @@ -218,6 +218,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int flag, prot, sect; ulong type; int rcode = 0; + ulong start;
if ((s_first < 0) || (s_first > s_last)) { if (info->flash_id == FLASH_UNKNOWN) { @@ -260,7 +261,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(start);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ @@ -269,7 +270,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ @@ -388,6 +389,7 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -402,11 +404,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/lart/flash.c b/board/lart/flash.c index 29a331e..408c884 100644 --- a/board/lart/flash.c +++ b/board/lart/flash.c @@ -250,6 +250,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) ulong result; int iflag, cflag, prot, sect; int rc = ERR_OK; + ulong start;
/* first look for protection bits */
@@ -291,7 +292,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ @@ -305,7 +306,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) do { /* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = PUZZLE_TO_FLASH(CMD_SUSPEND); result = BIT_TIMEOUT; @@ -354,6 +355,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) ulong result; int rc = ERR_OK; int cflag, iflag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -377,13 +379,13 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = PUZZLE_TO_FLASH(CMD_SUSPEND); result = BIT_TIMEOUT; diff --git a/board/lpd7a40x/flash.c b/board/lpd7a40x/flash.c index a3ba75b..f5c0713 100644 --- a/board/lpd7a40x/flash.c +++ b/board/lpd7a40x/flash.c @@ -229,6 +229,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) ulong result, result1; int iflag, prot, sect; int rc = ERR_OK; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -284,7 +285,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) sect, info->start[sect]);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -297,7 +298,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_STATUS_RESET; result = BIT_TIMEOUT; break; @@ -357,6 +358,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) ulong result; int rc = ERR_OK; int iflag; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -387,12 +389,12 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_SUSPEND; result = BIT_TIMEOUT; break; diff --git a/board/lubbock/flash.c b/board/lubbock/flash.c index a4b201e..1ea2893 100644 --- a/board/lubbock/flash.c +++ b/board/lubbock/flash.c @@ -221,7 +221,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -254,9 +254,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -269,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -393,6 +390,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -406,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start)) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/modnet50/flash.c b/board/modnet50/flash.c index 4c31143..4834e21 100644 --- a/board/modnet50/flash.c +++ b/board/modnet50/flash.c @@ -291,6 +291,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, sect, setup_offset = 0; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) { printf ("- missing\n"); @@ -338,14 +339,14 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) (__u16) SECERASE_CMD;
/* wait some time */ - reset_timer_masked (); - while (get_timer_masked () < 1000) { + start = get_timer(0); + while (get_timer(start) < 1000) { }
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0); while (flash_check_erase_amd (info->start[sect])) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("timeout!\n"); /* OOPS: reach timeout, * try to reset chip @@ -411,6 +412,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) { int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*(__u16 *) (dest) & data) != data) @@ -446,10 +448,10 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) }
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
while (flash_check_write_amd (dest)) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { printf ("timeout! @ %08lX\n", dest); /* OOPS: reach timeout, * try to reset chip */ diff --git a/board/mpl/vcma9/flash.c b/board/mpl/vcma9/flash.c index 7abf9cf..5d49204 100644 --- a/board/mpl/vcma9/flash.c +++ b/board/mpl/vcma9/flash.c @@ -175,6 +175,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip; + ulong start;
/* first look for protection bits */
@@ -215,7 +216,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -235,7 +236,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip = TMO; @@ -297,6 +298,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) int rc = ERR_OK; int cflag, iflag; int chip; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -323,7 +325,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait until flash is ready */ chip = 0; @@ -331,7 +333,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip = ERR | TMO; break; } diff --git a/board/mx1ads/syncflash.c b/board/mx1ads/syncflash.c index 47f613c..7331efa 100644 --- a/board/mx1ads/syncflash.c +++ b/board/mx1ads/syncflash.c @@ -276,7 +276,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) {
/* arm simple, non interrupt dependent timer */
- reset_timer_masked(); + get_timer(0);
SF_NvmodeErase(); SF_NvmodeWrite(); diff --git a/board/ns9750dev/flash.c b/board/ns9750dev/flash.c index 5b56b98..185bc2d 100644 --- a/board/ns9750dev/flash.c +++ b/board/ns9750dev/flash.c @@ -261,7 +261,7 @@ void flash_unprotect_sectors (FPWV * addr) int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -294,10 +294,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- - start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -312,7 +308,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -321,7 +317,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -441,6 +437,7 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -454,11 +451,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/pleb2/flash.c b/board/pleb2/flash.c index a8897dc..2406c5f 100644 --- a/board/pleb2/flash.c +++ b/board/pleb2/flash.c @@ -472,7 +472,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) FPWV *addr; int flag, prot, sect; int intel = (info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL; - ulong now, last; + ulong start, now, last; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -516,8 +516,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- reset_timer_masked (); - /* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last && rcode == 0; sect++) {
@@ -527,7 +525,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
- reset_timer_masked (); + start = get_timer(0); last = 0;
addr = (FPWV *) (info->start[sect]); @@ -559,7 +557,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
while ((*addr & (FPW) 0x00800080) != (FPW) 0x00800080) { if ((now = - get_timer_masked ()) > CONFIG_SYS_FLASH_ERASE_TOUT) { + get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n");
if (intel) { @@ -661,6 +659,7 @@ static int write_word_amd (flash_info_t * info, FPWV * dest, FPW data) int flag; int res = 0; /* result, assume success */ FPWV *base; /* first address in flash bank */ + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*dest & data) != data) { @@ -683,12 +682,12 @@ static int write_word_amd (flash_info_t * info, FPWV * dest, FPW data) if (flag) enable_interrupts ();
- reset_timer_masked (); + start = get_timer(0);
/* data polling for D7 */ while (res == 0 && (*dest & (FPW) 0x00800080) != (data & (FPW) 0x00800080)) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00F000F0; /* reset bank */ res = 1; } @@ -711,6 +710,7 @@ static int write_word_intel (flash_info_t * info, FPWV * dest, FPW data) { int flag; int res = 0; /* result, assume success */ + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*dest & data) != data) { @@ -730,10 +730,10 @@ static int write_word_intel (flash_info_t * info, FPWV * dest, FPW data) if (flag) enable_interrupts ();
- reset_timer_masked (); + start = get_timer(0);
while (res == 0 && (*dest & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00B000B0; /* Suspend program */ res = 1; } diff --git a/board/samsung/smdk2400/flash.c b/board/samsung/smdk2400/flash.c index fb69c21..47382fe 100644 --- a/board/samsung/smdk2400/flash.c +++ b/board/samsung/smdk2400/flash.c @@ -231,6 +231,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) ulong result, result1; int iflag, prot, sect; int rc = ERR_OK; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -286,7 +287,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) sect, info->start[sect]);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -299,7 +300,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_STATUS_RESET; result = BIT_TIMEOUT; break; @@ -359,6 +360,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) ulong result; int rc = ERR_OK; int iflag; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -389,12 +391,12 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_SUSPEND; result = BIT_TIMEOUT; break; diff --git a/board/sbc2410x/flash.c b/board/sbc2410x/flash.c index abb0935..d209a6f 100644 --- a/board/sbc2410x/flash.c +++ b/board/sbc2410x/flash.c @@ -173,6 +173,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip; + ulong start;
/* first look for protection bits */
@@ -213,7 +214,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -233,7 +234,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip = TMO; @@ -295,6 +296,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) int rc = ERR_OK; int cflag, iflag; int chip; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -322,7 +324,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + get_timer(start);
/* wait until flash is ready */ chip = 0; @@ -330,7 +332,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip = ERR | TMO; break; } diff --git a/board/scb9328/flash.c b/board/scb9328/flash.c index c6f94ae..00c660a 100644 --- a/board/scb9328/flash.c +++ b/board/scb9328/flash.c @@ -97,11 +97,12 @@ static FLASH_BUS_RET flash_status_reg (void) static int flash_ready (ulong timeout) { int ok = 1; + ulong start;
- reset_timer_masked (); + start = get_timer(0); while ((flash_status_reg () & FLASH_CMD (CFI_INTEL_SR_READY)) != FLASH_CMD (CFI_INTEL_SR_READY)) { - if (get_timer_masked () > timeout && timeout != 0) { + if (get_timer(start) > timeout && timeout != 0) { ok = 0; break; } diff --git a/board/shannon/flash.c b/board/shannon/flash.c index 0455afa..179ec5f 100644 --- a/board/shannon/flash.c +++ b/board/shannon/flash.c @@ -190,6 +190,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip1, chip2; + ulong start;
/* first look for protection bits */
@@ -231,7 +232,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ @@ -253,7 +254,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; @@ -322,6 +323,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) int rc = ERR_OK; int cflag, iflag; int chip1, chip2; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -349,7 +351,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait until flash is ready */ chip1 = chip2 = 0; @@ -358,7 +360,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; diff --git a/board/ti/omap1610inn/flash.c b/board/ti/omap1610inn/flash.c index 36200ad..1b67d08 100644 --- a/board/ti/omap1610inn/flash.c +++ b/board/ti/omap1610inn/flash.c @@ -278,7 +278,7 @@ void flash_unprotect_sectors (FPWV * addr) int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -311,10 +311,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- - start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -329,7 +325,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -338,7 +334,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -458,6 +454,7 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -470,11 +467,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/ti/omap730p2/flash.c b/board/ti/omap730p2/flash.c index 5b56b98..185bc2d 100644 --- a/board/ti/omap730p2/flash.c +++ b/board/ti/omap730p2/flash.c @@ -261,7 +261,7 @@ void flash_unprotect_sectors (FPWV * addr) int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -294,10 +294,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- - start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -312,7 +308,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -321,7 +317,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -441,6 +437,7 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -454,11 +451,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/trab/cmd_trab.c b/board/trab/cmd_trab.c index dec3c61..17890d9 100644 --- a/board/trab/cmd_trab.c +++ b/board/trab/cmd_trab.c @@ -201,7 +201,7 @@ int do_burn_in (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * avoid timestamp overflow problem after about 68 minutes of * udelay() time. */ - reset_timer_masked (); + get_timer(0); for (i = 0; i < BIF_MAX; i++) {
/* call test function */ @@ -715,7 +715,7 @@ static void led_blink (void)
/* blink LED. This function does not return! */ while (1) { - reset_timer_masked (); + get_timer(0); led_set (1); udelay (1000000 / LED_BLINK_FREQ / 2); led_set (0); @@ -860,7 +860,7 @@ int do_temp_log (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * reset timer to avoid timestamp overflow problem * after about 68 minutes of udelay() time. */ - reset_timer_masked (); + get_timer(0); sdelay (delay); }
diff --git a/board/trab/flash.c b/board/trab/flash.c index 4e89c41..bde1f77 100644 --- a/board/trab/flash.c +++ b/board/trab/flash.c @@ -182,6 +182,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, prot, sect; int rc = ERR_OK; int chip1, chip2; + ulong start;
debug ("flash_erase: s_first %d s_last %d\n", s_first, s_last);
@@ -237,7 +238,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) sect, info->start[sect]);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -257,7 +258,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -315,6 +316,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) vu_long *addr = (vu_long *) dest; ulong result; int rc = ERR_OK; + ulong start;
#if 0 int cflag; @@ -348,7 +350,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start= get_timer(0);
/* wait until flash is ready */ chip1 = chip2 = 0; @@ -356,7 +358,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { chip1 = ERR | TMO; break; } diff --git a/board/xaeniax/flash.c b/board/xaeniax/flash.c index b051c89..6cb0aca 100644 --- a/board/xaeniax/flash.c +++ b/board/xaeniax/flash.c @@ -221,7 +221,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -254,9 +254,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -269,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -393,6 +390,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -406,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/xm250/flash.c b/board/xm250/flash.c index b02149c..e825aba 100644 --- a/board/xm250/flash.c +++ b/board/xm250/flash.c @@ -250,7 +250,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -283,9 +283,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -298,14 +295,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -422,6 +419,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -435,11 +433,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } @@ -470,6 +468,7 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) int rc = 0; vu_long *addr = (vu_long *)(info->start[sector]); int flag = disable_interrupts(); + ulong start;
*addr = INTEL_CLEAR; /* Clear status register */ if (prot) { /* Set sector lock bit */ @@ -481,10 +480,10 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) *addr = INTEL_CONFIRM; /* clear */ }
- reset_timer_masked (); + start = get_timer(0);
while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer_masked () > CONFIG_SYS_FLASH_UNLOCK_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf("Flash lock bit operation timed out\n"); rc = 1; break; @@ -510,13 +509,13 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) { if (info->protect[i]) { - reset_timer_masked (); + start = get_timer(0); addr = (vu_long *)(info->start[i]); *addr = INTEL_LOCKBIT; /* Sector lock bit */ *addr = INTEL_PROTECT; /* set */ while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer_masked () > CONFIG_SYS_FLASH_UNLOCK_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf("Flash lock bit operation timed out\n"); rc = 1; diff --git a/board/zylonite/flash.c b/board/zylonite/flash.c index 5ba84c6..3ee0ab8 100644 --- a/board/zylonite/flash.c +++ b/board/zylonite/flash.c @@ -224,7 +224,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -257,9 +257,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -272,14 +269,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -396,6 +393,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -409,11 +407,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/drivers/mtd/spi/eeprom_m95xxx.c b/drivers/mtd/spi/eeprom_m95xxx.c index 632db4e..ef8ed6f 100644 --- a/drivers/mtd/spi/eeprom_m95xxx.c +++ b/drivers/mtd/spi/eeprom_m95xxx.c @@ -75,6 +75,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len) { struct spi_slave *slave; char buf[3]; + ulong start;
slave = spi_setup_slave(CONFIG_DEFAULT_SPI_BUS, 1, 1000000, CONFIG_DEFAULT_SPI_MODE); @@ -102,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;
- reset_timer_masked(); + start = get_timer(0); do { buf[0] = SPI_EEPROM_RDSR; buf[1] = 0; @@ -111,7 +112,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len) if (!(buf[1] & 1)) break;
- } while (get_timer_masked() < CONFIG_SYS_SPI_WRITE_TOUT); + } while (get_timer(start) < CONFIG_SYS_SPI_WRITE_TOUT);
if (buf[1] & 1) printf ("*** spi_write: Time out while writing!\n"); diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 4e4cd27..ab90afa 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -86,7 +86,7 @@ static int fec_miiphy_read(const char *dev, uint8_t phyAddr, uint8_t regAddr, /* * wait for the related interrupt */ - start = get_timer_masked(); + start = get_timer(0); while (!(readl(&fec->eth->ievent) & FEC_IEVENT_MII)) { if (get_timer(start) > (CONFIG_SYS_HZ / 1000)) { printf("Read MDIO failed...\n"); @@ -138,7 +138,7 @@ static int fec_miiphy_write(const char *dev, uint8_t phyAddr, uint8_t regAddr, /* * wait for the MII interrupt */ - start = get_timer_masked(); + start = get_timer(0); while (!(readl(&fec->eth->ievent) & FEC_IEVENT_MII)) { if (get_timer(start) > (CONFIG_SYS_HZ / 1000)) { printf("Write MDIO failed...\n"); @@ -189,7 +189,7 @@ static int miiphy_wait_aneg(struct eth_device *dev) /* * Wait for AN completion */ - start = get_timer_masked(); + start = get_timer(0); do { if (get_timer(start) > (CONFIG_SYS_HZ * 5)) { printf("%s: Autonegotiation timeout\n", dev->name); diff --git a/drivers/net/netarm_eth.c b/drivers/net/netarm_eth.c index c9e324e..f54817e 100644 --- a/drivers/net/netarm_eth.c +++ b/drivers/net/netarm_eth.c @@ -81,9 +81,10 @@ static unsigned int na_mii_read (int reg)
static int na_mii_poll_busy (void) { + ulong start; /* arm simple, non interrupt dependent timer */ - reset_timer_masked (); - while (get_timer_masked () < NA_MII_POLL_BUSY_DELAY) { + start = get_timer(0)); + while (get_timer(start) < NA_MII_POLL_BUSY_DELAY) { if (!(GET_EADDR (NETARM_ETH_MII_IND) & NETARM_ETH_MIII_BUSY)) { return 1; } @@ -164,19 +165,20 @@ static unsigned int na_mii_check_speed (void) static int reset_eth (void) { int pt; + ulong start;
na_get_mac_addr (); pt = na_mii_identify_phy ();
/* reset the phy */ na_mii_write (MII_PHY_CONTROL, 0x8000); - reset_timer_masked (); - while (get_timer_masked () < NA_MII_NEGOTIATE_DELAY) { + start = get_timer(0); + while (get_timer(start) < NA_MII_NEGOTIATE_DELAY) { if ((na_mii_read (MII_PHY_STATUS) & 0x8000) == 0) { break; } } - if (get_timer_masked () >= NA_MII_NEGOTIATE_DELAY) + if (get_timer(start) >= NA_MII_NEGOTIATE_DELAY) printf ("phy reset timeout\n");
/* set the PCS reg */ -- 1.7.5.2.317.g391b14

Dear Graeme Russ,
Am 28.06.2011 13:40, schrieb Graeme Russ:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
..
board/atmel/at91rm9200dk/flash.c | 10 ++++++----
don't mind at91rm9200dk, it uses deprecated arm920t/at91rm9200 api and will therefore removed in this merge window.
regards
Andreas Bießmann

Dear Graeme Russ,
In message 1309261269-4363-2-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
I consider this a bug fix, independent from the other dicussion. This should be applied in any case.
Acked-by: Wolfgang Denk wd@denx.de
Best regards,
Wolfgang Denk

Hi Wolfgang,
Le 11/07/2011 23:57, Wolfgang Denk a écrit :
Dear Graeme Russ,
In message1309261269-4363-2-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russgraeme.russ@gmail.com
I consider this a bug fix, independent from the other dicussion. This should be applied in any case.
Acked-by: Wolfgang Denkwd@denx.de
Best regards,
Wolfgang Denk
Patch applies on u-boot-arm/master except for 4 files which are not found:
board/ixdp425/flash.c, removed by commit 973af335e61eede3578371330abd3971805887f5, "update/fix IXDP425 / IXDPG425 boards"
board/mpl/vcma9/flash.c: removed by commit 6d754843ff62312999a265162c67588913cab991, "VCMA9: use CFI driver (and remove the old one)"
board/trab/cmd_trab.c and board/trab/flash.c: removed by commit 566e5cf451ae7e33e31bb62ae5b9b258e33f8609, "ARM: drop unsupported 'trab' board"
If this is fine with everyone, I can pull this patch in u-boot-arm/master despite the four errors.
Amicalement,

Dear Albert ARIBAUD,
In message 4E1F2100.2030401@aribaud.net you wrote:
Patch applies on u-boot-arm/master except for 4 files which are not found:
board/ixdp425/flash.c, removed by commit 973af335e61eede3578371330abd3971805887f5, "update/fix IXDP425 / IXDPG425 boards"
board/mpl/vcma9/flash.c: removed by commit 6d754843ff62312999a265162c67588913cab991, "VCMA9: use CFI driver (and remove the old one)"
board/trab/cmd_trab.c and board/trab/flash.c: removed by commit 566e5cf451ae7e33e31bb62ae5b9b258e33f8609, "ARM: drop unsupported 'trab' board"
If this is fine with everyone, I can pull this patch in u-boot-arm/master despite the four errors.
Please do. These files were all correctly removed recently.
Best regards,
Wolfgang Denk

Hi Wolfgang,
On 15/07/11 05:50, Wolfgang Denk wrote:
Dear Albert ARIBAUD,
In message 4E1F2100.2030401@aribaud.net you wrote:
Patch applies on u-boot-arm/master except for 4 files which are not found:
board/ixdp425/flash.c, removed by commit 973af335e61eede3578371330abd3971805887f5, "update/fix IXDP425 / IXDPG425 boards"
board/mpl/vcma9/flash.c: removed by commit 6d754843ff62312999a265162c67588913cab991, "VCMA9: use CFI driver (and remove the old one)"
board/trab/cmd_trab.c and board/trab/flash.c: removed by commit 566e5cf451ae7e33e31bb62ae5b9b258e33f8609, "ARM: drop unsupported 'trab' board"
If this is fine with everyone, I can pull this patch in u-boot-arm/master despite the four errors.
Please do. These files were all correctly removed recently.
I'm OK with this, but I'm about to rebase - After that, I will rename the series, truncate it to only include the ack'd patches, rev them to V2, set their respective in-reply-to to the WIP patches and set the remainder to RFC in patchwork
So I could either: - Send a revised version as a separate patch for ARM and remove it from the series - Include it in the truncated series - Remove it from the series and let Albert process it as is
Which do you prefer?
Regards,
Graeme

Dear Graeme Russ,
In message 4E1F7AC5.2080300@gmail.com you wrote:
So I could either:
- Send a revised version as a separate patch for ARM and remove it from
the series
- Include it in the truncated series
- Remove it from the series and let Albert process it as is
Which do you prefer?
I'm fine with each of these - I just like to see this go in :-)
Best regards,
Wolfgang Denk

Hi Wolfgang,
On 15/07/11 16:31, Wolfgang Denk wrote:
Dear Graeme Russ,
In message 4E1F7AC5.2080300@gmail.com you wrote:
So I could either:
- Send a revised version as a separate patch for ARM and remove it from
the series
- Include it in the truncated series
- Remove it from the series and let Albert process it as is
Which do you prefer?
I'm fine with each of these - I just like to see this go in :-)
OK, I'll go with option #2 and rename the series 'Simplify Timer API'. I'll post this in the next day or two (hopefully tonight)
This will get the existing Timer API into a state where I can proceed with the outcome of our latest round of discussion.
Regards,
Graeme

--- Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
board/armadillo/flash.c | 6 ++++-- board/atmel/at91rm9200dk/flash.c | 10 ++++++---- board/cerf250/flash.c | 14 ++++++-------- board/cm4008/flash.c | 10 ++++++---- board/cm41xx/flash.c | 10 ++++++---- board/cmc_pu2/flash.c | 11 ++++++----- board/cradle/flash.c | 10 ++++++---- board/csb226/flash.c | 10 ++++++---- board/dnp1110/flash.c | 14 ++++++-------- board/ep7312/flash.c | 10 ++++++---- board/gcplus/flash.c | 14 ++++++-------- board/impa7/flash.c | 10 ++++++---- board/innokom/flash.c | 10 ++++++---- board/lart/flash.c | 10 ++++++---- board/lpd7a40x/flash.c | 10 ++++++---- board/lubbock/flash.c | 14 ++++++-------- board/modnet50/flash.c | 14 ++++++++------ board/mx1ads/syncflash.c | 2 +- board/ns9750dev/flash.c | 15 ++++++--------- board/pleb2/flash.c | 18 +++++++++--------- board/samsung/smdk2400/flash.c | 10 ++++++---- board/sbc2410x/flash.c | 10 ++++++---- board/scb9328/flash.c | 5 +++-- board/shannon/flash.c | 10 ++++++---- board/ti/omap1610inn/flash.c | 15 ++++++--------- board/ti/omap730p2/flash.c | 15 ++++++--------- board/xaeniax/flash.c | 14 ++++++-------- board/xm250/flash.c | 23 +++++++++++------------ board/zylonite/flash.c | 14 ++++++-------- drivers/mtd/spi/eeprom_m95xxx.c | 5 +++-- drivers/net/fec_mxc.c | 6 +++--- drivers/net/netarm_eth.c | 12 +++++++----- 32 files changed, 187 insertions(+), 174 deletions(-)
diff --git a/board/armadillo/flash.c b/board/armadillo/flash.c index cdbbfd0..cf7d7f6 100644 --- a/board/armadillo/flash.c +++ b/board/armadillo/flash.c @@ -162,6 +162,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int rc = ERR_OK; unsigned long base; unsigned long addr; + ulong start;
if ((info->flash_id & FLASH_VENDMASK) != (FUJ_MANUFACT & FLASH_VENDMASK)) { @@ -192,7 +193,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last && !ctrlc (); sect++) { /* ARM simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */
@@ -232,6 +233,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) { int flag; unsigned long base; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -250,7 +252,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) flag = disable_interrupts ();
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
base = dest & 0xF0000000; FL_WORD (base + (0x555 << 1)) = 0xAA; diff --git a/board/atmel/at91rm9200dk/flash.c b/board/atmel/at91rm9200dk/flash.c index 902c3c4..be22743 100644 --- a/board/atmel/at91rm9200dk/flash.c +++ b/board/atmel/at91rm9200dk/flash.c @@ -285,6 +285,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip1; + ulong start;
/* first look for protection bits */
@@ -325,7 +326,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = (volatile u16 *) (info->start[sect]); @@ -345,7 +346,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -400,6 +401,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) int rc = ERR_OK; int cflag, iflag; int chip1; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -425,7 +427,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait until flash is ready */ chip1 = 0; @@ -433,7 +435,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; } diff --git a/board/cerf250/flash.c b/board/cerf250/flash.c index a4b201e..e1e7807 100644 --- a/board/cerf250/flash.c +++ b/board/cerf250/flash.c @@ -221,7 +221,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -254,9 +254,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -269,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -393,6 +390,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -406,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/cm4008/flash.c b/board/cm4008/flash.c index 2e66872..d6fd519 100644 --- a/board/cm4008/flash.c +++ b/board/cm4008/flash.c @@ -209,6 +209,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int flag, prot, sect; ulong type; int rcode = 0; + ulong start;
if ((s_first < 0) || (s_first > s_last)) { if (info->flash_id == FLASH_UNKNOWN) { @@ -250,7 +251,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
addr = (volatile unsigned char *) (info->start[sect]); *addr = 0x50; /* clear status register */ @@ -258,7 +259,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0xB0; /* suspend erase */ @@ -370,6 +371,7 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) volatile unsigned char *addr = (volatile unsigned char *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -384,11 +386,11 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0xFF; /* restore read mode */ return (1); } diff --git a/board/cm41xx/flash.c b/board/cm41xx/flash.c index 2e66872..d6fd519 100644 --- a/board/cm41xx/flash.c +++ b/board/cm41xx/flash.c @@ -209,6 +209,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int flag, prot, sect; ulong type; int rcode = 0; + ulong start;
if ((s_first < 0) || (s_first > s_last)) { if (info->flash_id == FLASH_UNKNOWN) { @@ -250,7 +251,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
addr = (volatile unsigned char *) (info->start[sect]); *addr = 0x50; /* clear status register */ @@ -258,7 +259,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0xB0; /* suspend erase */ @@ -370,6 +371,7 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) volatile unsigned char *addr = (volatile unsigned char *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -384,11 +386,11 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0xFF; /* restore read mode */ return (1); } diff --git a/board/cmc_pu2/flash.c b/board/cmc_pu2/flash.c index d832e62..d10faab 100644 --- a/board/cmc_pu2/flash.c +++ b/board/cmc_pu2/flash.c @@ -264,7 +264,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) { vu_short *addr = (vu_short *)(info->start[0]); int flag, prot, sect, ssect, l_sect; - ulong now, last; + ulong now, last, start;
debug ("flash_erase: first: %d last: %d\n", s_first, s_last);
@@ -335,11 +335,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- reset_timer_masked (); + start = get_timer(0); last = 0; addr = (vu_short *)(info->start[l_sect]); while ((addr[0] & 0x0080) != 0x0080) { - if ((now = get_timer_masked ()) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -434,6 +434,7 @@ static int write_word_amd (flash_info_t *info, vu_short *dest, ushort data) { int flag; vu_short *base; /* first address in flash bank */ + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*dest & data) != data) { @@ -455,11 +456,11 @@ static int write_word_amd (flash_info_t *info, vu_short *dest, ushort data) if (flag) enable_interrupts();
- reset_timer_masked (); + start = get_timer(0);
/* data polling for D7 */ while ((*dest & 0x0080) != (data & 0x0080)) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = 0x00F0; /* reset bank */ return (1); } diff --git a/board/cradle/flash.c b/board/cradle/flash.c index b5635fb..1601782 100644 --- a/board/cradle/flash.c +++ b/board/cradle/flash.c @@ -136,6 +136,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -173,7 +174,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -182,7 +183,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while ((*addr & 0x80) != 0x80) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0xB0; /* suspend erase */ *addr = 0xFF; /* reset to read mode */ @@ -221,6 +222,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) vu_short *addr = (vu_short *) dest, val; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -246,11 +248,11 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((val = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0xB0; diff --git a/board/csb226/flash.c b/board/csb226/flash.c index 02ded1c..e103470 100644 --- a/board/csb226/flash.c +++ b/board/csb226/flash.c @@ -141,6 +141,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -175,7 +176,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ u32 * volatile addr = (u32 * volatile)(info->start[sect]); @@ -189,7 +190,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) *addr = 0x00D000D0; /* erase confirm */
while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B000B0; /* suspend erase*/ *addr = 0x00FF00FF; /* read mode */ rc = ERR_TIMOUT; @@ -221,6 +222,7 @@ static int write_long (flash_info_t *info, ulong dest, ulong data) u32 * volatile addr = (u32 * volatile)dest, val; int rc = ERR_OK; int flag; + ulong start;
/* read array command - just for the case... */ *addr = 0x00FF00FF; @@ -247,11 +249,11 @@ static int write_long (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while(((val = *addr) & 0x00800080) != 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0x00B000B0; diff --git a/board/dnp1110/flash.c b/board/dnp1110/flash.c index c81abc5..53f89ee 100644 --- a/board/dnp1110/flash.c +++ b/board/dnp1110/flash.c @@ -212,7 +212,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -245,9 +245,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts();
@@ -260,14 +257,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
*addr = (FPW)0x00500050; /* clear status register */ *addr = (FPW)0x00200020; /* erase setup */ *addr = (FPW)0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW)0x00B000B0; /* suspend erase */ *addr = (FPW)0x00FF00FF; /* reset to read mode */ @@ -385,6 +382,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *)dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -398,11 +396,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (start = get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW)0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/ep7312/flash.c b/board/ep7312/flash.c index 0c2b3ae..2ed9c9a 100644 --- a/board/ep7312/flash.c +++ b/board/ep7312/flash.c @@ -119,6 +119,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -156,7 +157,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -165,7 +166,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while ((*addr & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0xB0; /* suspend erase */ *addr = 0xFF; /* reset to read mode */ rc = ERR_TIMOUT; @@ -203,6 +204,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) vu_short *addr = (vu_short *) dest, val; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -228,11 +230,11 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((val = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0xB0; diff --git a/board/gcplus/flash.c b/board/gcplus/flash.c index 8511582..ab567e8 100644 --- a/board/gcplus/flash.c +++ b/board/gcplus/flash.c @@ -225,7 +225,7 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -258,9 +258,6 @@ flash_erase(flash_info_t * info, int s_first, int s_last) printf("\n"); }
- start = get_timer(0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts();
@@ -273,7 +270,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ @@ -282,7 +279,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -401,6 +398,7 @@ write_data(flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -414,11 +412,11 @@ write_data(flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/impa7/flash.c b/board/impa7/flash.c index d0c5880..6eae428 100644 --- a/board/impa7/flash.c +++ b/board/impa7/flash.c @@ -128,6 +128,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -165,7 +166,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -174,7 +175,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0x00D000D0; /* erase confirm */
while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B000B0; /* suspend erase */ *addr = 0x00FF00FF; /* reset to read mode */ @@ -211,6 +212,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) ulong barf; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -236,14 +238,14 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* read status register command */ *addr = 0x00700070;
/* wait while polling the status register */ while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0x00B000B0; diff --git a/board/innokom/flash.c b/board/innokom/flash.c index 8c95341..ed4b987 100644 --- a/board/innokom/flash.c +++ b/board/innokom/flash.c @@ -182,6 +182,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -218,7 +219,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) PRINTK("\n");
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ u16 * volatile addr = (u16 * volatile)(info->start[sect]); @@ -235,7 +236,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
while ((*addr & 0x0080) != 0x0080) { PRINTK("."); - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B0; /* suspend erase*/ *addr = 0x00FF; /* read mode */ rc = ERR_TIMOUT; @@ -279,6 +280,7 @@ static int write_word (flash_info_t *info, ulong dest, ushort data) volatile u16 *addr = (u16 *)dest, val; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) return ERR_NOT_ERASED; @@ -302,11 +304,11 @@ static int write_word (flash_info_t *info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while(((val = *addr) & 0x80) != 0x80) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; *addr = 0xB0; /* suspend program command */ goto outahere; diff --git a/board/lart/flash.c b/board/lart/flash.c index 29a331e..408c884 100644 --- a/board/lart/flash.c +++ b/board/lart/flash.c @@ -250,6 +250,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) ulong result; int iflag, cflag, prot, sect; int rc = ERR_OK; + ulong start;
/* first look for protection bits */
@@ -291,7 +292,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ @@ -305,7 +306,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) do { /* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = PUZZLE_TO_FLASH(CMD_SUSPEND); result = BIT_TIMEOUT; @@ -354,6 +355,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) ulong result; int rc = ERR_OK; int cflag, iflag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -377,13 +379,13 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = PUZZLE_TO_FLASH(CMD_SUSPEND); result = BIT_TIMEOUT; diff --git a/board/lpd7a40x/flash.c b/board/lpd7a40x/flash.c index a3ba75b..f5c0713 100644 --- a/board/lpd7a40x/flash.c +++ b/board/lpd7a40x/flash.c @@ -229,6 +229,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) ulong result, result1; int iflag, prot, sect; int rc = ERR_OK; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -284,7 +285,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) sect, info->start[sect]);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -297,7 +298,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_STATUS_RESET; result = BIT_TIMEOUT; break; @@ -357,6 +358,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) ulong result; int rc = ERR_OK; int iflag; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -387,12 +389,12 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_SUSPEND; result = BIT_TIMEOUT; break; diff --git a/board/lubbock/flash.c b/board/lubbock/flash.c index a4b201e..1ea2893 100644 --- a/board/lubbock/flash.c +++ b/board/lubbock/flash.c @@ -221,7 +221,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -254,9 +254,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -269,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -393,6 +390,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -406,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start)) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/modnet50/flash.c b/board/modnet50/flash.c index 4c31143..4834e21 100644 --- a/board/modnet50/flash.c +++ b/board/modnet50/flash.c @@ -291,6 +291,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, sect, setup_offset = 0; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) { printf ("- missing\n"); @@ -338,14 +339,14 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) (__u16) SECERASE_CMD;
/* wait some time */ - reset_timer_masked (); - while (get_timer_masked () < 1000) { + start = get_timer(0); + while (get_timer(start) < 1000) { }
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0); while (flash_check_erase_amd (info->start[sect])) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("timeout!\n"); /* OOPS: reach timeout, * try to reset chip @@ -411,6 +412,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) { int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*(__u16 *) (dest) & data) != data) @@ -446,10 +448,10 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) }
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
while (flash_check_write_amd (dest)) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { printf ("timeout! @ %08lX\n", dest); /* OOPS: reach timeout, * try to reset chip */ diff --git a/board/mx1ads/syncflash.c b/board/mx1ads/syncflash.c index 47f613c..7331efa 100644 --- a/board/mx1ads/syncflash.c +++ b/board/mx1ads/syncflash.c @@ -276,7 +276,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) {
/* arm simple, non interrupt dependent timer */
- reset_timer_masked(); + get_timer(0);
SF_NvmodeErase(); SF_NvmodeWrite(); diff --git a/board/ns9750dev/flash.c b/board/ns9750dev/flash.c index 5b56b98..185bc2d 100644 --- a/board/ns9750dev/flash.c +++ b/board/ns9750dev/flash.c @@ -261,7 +261,7 @@ void flash_unprotect_sectors (FPWV * addr) int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -294,10 +294,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- - start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -312,7 +308,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -321,7 +317,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -441,6 +437,7 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -454,11 +451,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/pleb2/flash.c b/board/pleb2/flash.c index a8897dc..2406c5f 100644 --- a/board/pleb2/flash.c +++ b/board/pleb2/flash.c @@ -472,7 +472,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) FPWV *addr; int flag, prot, sect; int intel = (info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL; - ulong now, last; + ulong start, now, last; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -516,8 +516,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- reset_timer_masked (); - /* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last && rcode == 0; sect++) {
@@ -527,7 +525,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
- reset_timer_masked (); + start = get_timer(0); last = 0;
addr = (FPWV *) (info->start[sect]); @@ -559,7 +557,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
while ((*addr & (FPW) 0x00800080) != (FPW) 0x00800080) { if ((now = - get_timer_masked ()) > CONFIG_SYS_FLASH_ERASE_TOUT) { + get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n");
if (intel) { @@ -661,6 +659,7 @@ static int write_word_amd (flash_info_t * info, FPWV * dest, FPW data) int flag; int res = 0; /* result, assume success */ FPWV *base; /* first address in flash bank */ + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*dest & data) != data) { @@ -683,12 +682,12 @@ static int write_word_amd (flash_info_t * info, FPWV * dest, FPW data) if (flag) enable_interrupts ();
- reset_timer_masked (); + start = get_timer(0);
/* data polling for D7 */ while (res == 0 && (*dest & (FPW) 0x00800080) != (data & (FPW) 0x00800080)) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00F000F0; /* reset bank */ res = 1; } @@ -711,6 +710,7 @@ static int write_word_intel (flash_info_t * info, FPWV * dest, FPW data) { int flag; int res = 0; /* result, assume success */ + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*dest & data) != data) { @@ -730,10 +730,10 @@ static int write_word_intel (flash_info_t * info, FPWV * dest, FPW data) if (flag) enable_interrupts ();
- reset_timer_masked (); + start = get_timer(0);
while (res == 0 && (*dest & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00B000B0; /* Suspend program */ res = 1; } diff --git a/board/samsung/smdk2400/flash.c b/board/samsung/smdk2400/flash.c index fb69c21..47382fe 100644 --- a/board/samsung/smdk2400/flash.c +++ b/board/samsung/smdk2400/flash.c @@ -231,6 +231,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) ulong result, result1; int iflag, prot, sect; int rc = ERR_OK; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -286,7 +287,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) sect, info->start[sect]);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -299,7 +300,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_STATUS_RESET; result = BIT_TIMEOUT; break; @@ -359,6 +360,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) ulong result; int rc = ERR_OK; int iflag; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -389,12 +391,12 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_SUSPEND; result = BIT_TIMEOUT; break; diff --git a/board/sbc2410x/flash.c b/board/sbc2410x/flash.c index abb0935..d209a6f 100644 --- a/board/sbc2410x/flash.c +++ b/board/sbc2410x/flash.c @@ -173,6 +173,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip; + ulong start;
/* first look for protection bits */
@@ -213,7 +214,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -233,7 +234,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip = TMO; @@ -295,6 +296,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) int rc = ERR_OK; int cflag, iflag; int chip; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -322,7 +324,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + get_timer(start);
/* wait until flash is ready */ chip = 0; @@ -330,7 +332,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip = ERR | TMO; break; } diff --git a/board/scb9328/flash.c b/board/scb9328/flash.c index c6f94ae..00c660a 100644 --- a/board/scb9328/flash.c +++ b/board/scb9328/flash.c @@ -97,11 +97,12 @@ static FLASH_BUS_RET flash_status_reg (void) static int flash_ready (ulong timeout) { int ok = 1; + ulong start;
- reset_timer_masked (); + start = get_timer(0); while ((flash_status_reg () & FLASH_CMD (CFI_INTEL_SR_READY)) != FLASH_CMD (CFI_INTEL_SR_READY)) { - if (get_timer_masked () > timeout && timeout != 0) { + if (get_timer(start) > timeout && timeout != 0) { ok = 0; break; } diff --git a/board/shannon/flash.c b/board/shannon/flash.c index 0455afa..179ec5f 100644 --- a/board/shannon/flash.c +++ b/board/shannon/flash.c @@ -190,6 +190,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip1, chip2; + ulong start;
/* first look for protection bits */
@@ -231,7 +232,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ @@ -253,7 +254,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; @@ -322,6 +323,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) int rc = ERR_OK; int cflag, iflag; int chip1, chip2; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -349,7 +351,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait until flash is ready */ chip1 = chip2 = 0; @@ -358,7 +360,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; diff --git a/board/ti/omap1610inn/flash.c b/board/ti/omap1610inn/flash.c index 36200ad..1b67d08 100644 --- a/board/ti/omap1610inn/flash.c +++ b/board/ti/omap1610inn/flash.c @@ -278,7 +278,7 @@ void flash_unprotect_sectors (FPWV * addr) int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -311,10 +311,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- - start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -329,7 +325,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -338,7 +334,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -458,6 +454,7 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -470,11 +467,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/ti/omap730p2/flash.c b/board/ti/omap730p2/flash.c index 5b56b98..185bc2d 100644 --- a/board/ti/omap730p2/flash.c +++ b/board/ti/omap730p2/flash.c @@ -261,7 +261,7 @@ void flash_unprotect_sectors (FPWV * addr) int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -294,10 +294,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- - start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -312,7 +308,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -321,7 +317,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -441,6 +437,7 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -454,11 +451,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/xaeniax/flash.c b/board/xaeniax/flash.c index b051c89..6cb0aca 100644 --- a/board/xaeniax/flash.c +++ b/board/xaeniax/flash.c @@ -221,7 +221,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -254,9 +254,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -269,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -393,6 +390,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -406,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/xm250/flash.c b/board/xm250/flash.c index b02149c..e825aba 100644 --- a/board/xm250/flash.c +++ b/board/xm250/flash.c @@ -250,7 +250,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -283,9 +283,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -298,14 +295,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -422,6 +419,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -435,11 +433,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } @@ -470,6 +468,7 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) int rc = 0; vu_long *addr = (vu_long *)(info->start[sector]); int flag = disable_interrupts(); + ulong start;
*addr = INTEL_CLEAR; /* Clear status register */ if (prot) { /* Set sector lock bit */ @@ -481,10 +480,10 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) *addr = INTEL_CONFIRM; /* clear */ }
- reset_timer_masked (); + start = get_timer(0);
while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer_masked () > CONFIG_SYS_FLASH_UNLOCK_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf("Flash lock bit operation timed out\n"); rc = 1; break; @@ -510,13 +509,13 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) { if (info->protect[i]) { - reset_timer_masked (); + start = get_timer(0); addr = (vu_long *)(info->start[i]); *addr = INTEL_LOCKBIT; /* Sector lock bit */ *addr = INTEL_PROTECT; /* set */ while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer_masked () > CONFIG_SYS_FLASH_UNLOCK_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf("Flash lock bit operation timed out\n"); rc = 1; diff --git a/board/zylonite/flash.c b/board/zylonite/flash.c index 5ba84c6..3ee0ab8 100644 --- a/board/zylonite/flash.c +++ b/board/zylonite/flash.c @@ -224,7 +224,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -257,9 +257,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -272,14 +269,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -396,6 +393,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -409,11 +407,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/drivers/mtd/spi/eeprom_m95xxx.c b/drivers/mtd/spi/eeprom_m95xxx.c index 632db4e..ef8ed6f 100644 --- a/drivers/mtd/spi/eeprom_m95xxx.c +++ b/drivers/mtd/spi/eeprom_m95xxx.c @@ -75,6 +75,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len) { struct spi_slave *slave; char buf[3]; + ulong start;
slave = spi_setup_slave(CONFIG_DEFAULT_SPI_BUS, 1, 1000000, CONFIG_DEFAULT_SPI_MODE); @@ -102,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;
- reset_timer_masked(); + start = get_timer(0); do { buf[0] = SPI_EEPROM_RDSR; buf[1] = 0; @@ -111,7 +112,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len) if (!(buf[1] & 1)) break;
- } while (get_timer_masked() < CONFIG_SYS_SPI_WRITE_TOUT); + } while (get_timer(start) < CONFIG_SYS_SPI_WRITE_TOUT);
if (buf[1] & 1) printf ("*** spi_write: Time out while writing!\n"); diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 4e4cd27..ab90afa 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -86,7 +86,7 @@ static int fec_miiphy_read(const char *dev, uint8_t phyAddr, uint8_t regAddr, /* * wait for the related interrupt */ - start = get_timer_masked(); + start = get_timer(0); while (!(readl(&fec->eth->ievent) & FEC_IEVENT_MII)) { if (get_timer(start) > (CONFIG_SYS_HZ / 1000)) { printf("Read MDIO failed...\n"); @@ -138,7 +138,7 @@ static int fec_miiphy_write(const char *dev, uint8_t phyAddr, uint8_t regAddr, /* * wait for the MII interrupt */ - start = get_timer_masked(); + start = get_timer(0); while (!(readl(&fec->eth->ievent) & FEC_IEVENT_MII)) { if (get_timer(start) > (CONFIG_SYS_HZ / 1000)) { printf("Write MDIO failed...\n"); @@ -189,7 +189,7 @@ static int miiphy_wait_aneg(struct eth_device *dev) /* * Wait for AN completion */ - start = get_timer_masked(); + start = get_timer(0); do { if (get_timer(start) > (CONFIG_SYS_HZ * 5)) { printf("%s: Autonegotiation timeout\n", dev->name); diff --git a/drivers/net/netarm_eth.c b/drivers/net/netarm_eth.c index c9e324e..f54817e 100644 --- a/drivers/net/netarm_eth.c +++ b/drivers/net/netarm_eth.c @@ -81,9 +81,10 @@ static unsigned int na_mii_read (int reg)
static int na_mii_poll_busy (void) { + ulong start; /* arm simple, non interrupt dependent timer */ - reset_timer_masked (); - while (get_timer_masked () < NA_MII_POLL_BUSY_DELAY) { + start = get_timer(0)); + while (get_timer(start) < NA_MII_POLL_BUSY_DELAY) { if (!(GET_EADDR (NETARM_ETH_MII_IND) & NETARM_ETH_MIII_BUSY)) { return 1; } @@ -164,19 +165,20 @@ static unsigned int na_mii_check_speed (void) static int reset_eth (void) { int pt; + ulong start;
na_get_mac_addr (); pt = na_mii_identify_phy ();
/* reset the phy */ na_mii_write (MII_PHY_CONTROL, 0x8000); - reset_timer_masked (); - while (get_timer_masked () < NA_MII_NEGOTIATE_DELAY) { + start = get_timer(0); + while (get_timer(start) < NA_MII_NEGOTIATE_DELAY) { if ((na_mii_read (MII_PHY_STATUS) & 0x8000) == 0) { break; } } - if (get_timer_masked () >= NA_MII_NEGOTIATE_DELAY) + if (get_timer(start) >= NA_MII_NEGOTIATE_DELAY) printf ("phy reset timeout\n");
/* set the PCS reg */ -- 1.7.5.2.317.g391b14

Hi Greame,
Le 15/07/2011 14:16, Graeme Russ a écrit :
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
Applied to u-boot-arm/master, thanks!
Amicalement,

On 16/07/11 18:40, Albert ARIBAUD wrote:
Hi Greame,
Le 15/07/2011 14:16, Graeme Russ a écrit :
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
Applied to u-boot-arm/master, thanks!
Oops, I forgot my SoB - I was going to repost this series with correct SoB
Regards,
Graeme

Le 16/07/2011 10:59, Graeme Russ a écrit :
On 16/07/11 18:40, Albert ARIBAUD wrote:
Hi Greame,
Le 15/07/2011 14:16, Graeme Russ a écrit :
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
Applied to u-boot-arm/master, thanks!
Oops, I forgot my SoB - I was going to repost this series with correct SoB
Regards,
Graeme
Oops, forgot to check this... Will fix and push -f once you're done.
Amicalement,

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- Changes since v2: - Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
board/armadillo/flash.c | 6 ++++-- board/atmel/at91rm9200dk/flash.c | 10 ++++++---- board/cerf250/flash.c | 14 ++++++-------- board/cm4008/flash.c | 10 ++++++---- board/cm41xx/flash.c | 10 ++++++---- board/cmc_pu2/flash.c | 11 ++++++----- board/cradle/flash.c | 10 ++++++---- board/csb226/flash.c | 10 ++++++---- board/dnp1110/flash.c | 14 ++++++-------- board/ep7312/flash.c | 10 ++++++---- board/gcplus/flash.c | 14 ++++++-------- board/impa7/flash.c | 10 ++++++---- board/innokom/flash.c | 10 ++++++---- board/lart/flash.c | 10 ++++++---- board/lpd7a40x/flash.c | 10 ++++++---- board/lubbock/flash.c | 14 ++++++-------- board/modnet50/flash.c | 14 ++++++++------ board/mx1ads/syncflash.c | 2 +- board/ns9750dev/flash.c | 15 ++++++--------- board/pleb2/flash.c | 18 +++++++++--------- board/samsung/smdk2400/flash.c | 10 ++++++---- board/sbc2410x/flash.c | 10 ++++++---- board/scb9328/flash.c | 5 +++-- board/shannon/flash.c | 10 ++++++---- board/ti/omap1610inn/flash.c | 15 ++++++--------- board/ti/omap730p2/flash.c | 15 ++++++--------- board/xaeniax/flash.c | 14 ++++++-------- board/xm250/flash.c | 23 +++++++++++------------ board/zylonite/flash.c | 14 ++++++-------- drivers/mtd/spi/eeprom_m95xxx.c | 5 +++-- drivers/net/fec_mxc.c | 6 +++--- drivers/net/netarm_eth.c | 12 +++++++----- 32 files changed, 187 insertions(+), 174 deletions(-)
diff --git a/board/armadillo/flash.c b/board/armadillo/flash.c index cdbbfd0..cf7d7f6 100644 --- a/board/armadillo/flash.c +++ b/board/armadillo/flash.c @@ -162,6 +162,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int rc = ERR_OK; unsigned long base; unsigned long addr; + ulong start;
if ((info->flash_id & FLASH_VENDMASK) != (FUJ_MANUFACT & FLASH_VENDMASK)) { @@ -192,7 +193,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last && !ctrlc (); sect++) { /* ARM simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */
@@ -232,6 +233,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) { int flag; unsigned long base; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -250,7 +252,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) flag = disable_interrupts ();
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
base = dest & 0xF0000000; FL_WORD (base + (0x555 << 1)) = 0xAA; diff --git a/board/atmel/at91rm9200dk/flash.c b/board/atmel/at91rm9200dk/flash.c index 902c3c4..be22743 100644 --- a/board/atmel/at91rm9200dk/flash.c +++ b/board/atmel/at91rm9200dk/flash.c @@ -285,6 +285,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip1; + ulong start;
/* first look for protection bits */
@@ -325,7 +326,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = (volatile u16 *) (info->start[sect]); @@ -345,7 +346,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -400,6 +401,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) int rc = ERR_OK; int cflag, iflag; int chip1; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -425,7 +427,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait until flash is ready */ chip1 = 0; @@ -433,7 +435,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; } diff --git a/board/cerf250/flash.c b/board/cerf250/flash.c index a4b201e..e1e7807 100644 --- a/board/cerf250/flash.c +++ b/board/cerf250/flash.c @@ -221,7 +221,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -254,9 +254,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -269,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -393,6 +390,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -406,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/cm4008/flash.c b/board/cm4008/flash.c index 2e66872..d6fd519 100644 --- a/board/cm4008/flash.c +++ b/board/cm4008/flash.c @@ -209,6 +209,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int flag, prot, sect; ulong type; int rcode = 0; + ulong start;
if ((s_first < 0) || (s_first > s_last)) { if (info->flash_id == FLASH_UNKNOWN) { @@ -250,7 +251,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
addr = (volatile unsigned char *) (info->start[sect]); *addr = 0x50; /* clear status register */ @@ -258,7 +259,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0xB0; /* suspend erase */ @@ -370,6 +371,7 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) volatile unsigned char *addr = (volatile unsigned char *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -384,11 +386,11 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0xFF; /* restore read mode */ return (1); } diff --git a/board/cm41xx/flash.c b/board/cm41xx/flash.c index 2e66872..d6fd519 100644 --- a/board/cm41xx/flash.c +++ b/board/cm41xx/flash.c @@ -209,6 +209,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int flag, prot, sect; ulong type; int rcode = 0; + ulong start;
if ((s_first < 0) || (s_first > s_last)) { if (info->flash_id == FLASH_UNKNOWN) { @@ -250,7 +251,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
addr = (volatile unsigned char *) (info->start[sect]); *addr = 0x50; /* clear status register */ @@ -258,7 +259,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0xB0; /* suspend erase */ @@ -370,6 +371,7 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) volatile unsigned char *addr = (volatile unsigned char *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -384,11 +386,11 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0xFF; /* restore read mode */ return (1); } diff --git a/board/cmc_pu2/flash.c b/board/cmc_pu2/flash.c index d832e62..d10faab 100644 --- a/board/cmc_pu2/flash.c +++ b/board/cmc_pu2/flash.c @@ -264,7 +264,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) { vu_short *addr = (vu_short *)(info->start[0]); int flag, prot, sect, ssect, l_sect; - ulong now, last; + ulong now, last, start;
debug ("flash_erase: first: %d last: %d\n", s_first, s_last);
@@ -335,11 +335,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- reset_timer_masked (); + start = get_timer(0); last = 0; addr = (vu_short *)(info->start[l_sect]); while ((addr[0] & 0x0080) != 0x0080) { - if ((now = get_timer_masked ()) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -434,6 +434,7 @@ static int write_word_amd (flash_info_t *info, vu_short *dest, ushort data) { int flag; vu_short *base; /* first address in flash bank */ + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*dest & data) != data) { @@ -455,11 +456,11 @@ static int write_word_amd (flash_info_t *info, vu_short *dest, ushort data) if (flag) enable_interrupts();
- reset_timer_masked (); + start = get_timer(0);
/* data polling for D7 */ while ((*dest & 0x0080) != (data & 0x0080)) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = 0x00F0; /* reset bank */ return (1); } diff --git a/board/cradle/flash.c b/board/cradle/flash.c index b5635fb..1601782 100644 --- a/board/cradle/flash.c +++ b/board/cradle/flash.c @@ -136,6 +136,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -173,7 +174,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -182,7 +183,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while ((*addr & 0x80) != 0x80) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0xB0; /* suspend erase */ *addr = 0xFF; /* reset to read mode */ @@ -221,6 +222,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) vu_short *addr = (vu_short *) dest, val; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -246,11 +248,11 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((val = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0xB0; diff --git a/board/csb226/flash.c b/board/csb226/flash.c index 02ded1c..e103470 100644 --- a/board/csb226/flash.c +++ b/board/csb226/flash.c @@ -141,6 +141,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -175,7 +176,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ u32 * volatile addr = (u32 * volatile)(info->start[sect]); @@ -189,7 +190,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) *addr = 0x00D000D0; /* erase confirm */
while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B000B0; /* suspend erase*/ *addr = 0x00FF00FF; /* read mode */ rc = ERR_TIMOUT; @@ -221,6 +222,7 @@ static int write_long (flash_info_t *info, ulong dest, ulong data) u32 * volatile addr = (u32 * volatile)dest, val; int rc = ERR_OK; int flag; + ulong start;
/* read array command - just for the case... */ *addr = 0x00FF00FF; @@ -247,11 +249,11 @@ static int write_long (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while(((val = *addr) & 0x00800080) != 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0x00B000B0; diff --git a/board/dnp1110/flash.c b/board/dnp1110/flash.c index c81abc5..53f89ee 100644 --- a/board/dnp1110/flash.c +++ b/board/dnp1110/flash.c @@ -212,7 +212,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -245,9 +245,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts();
@@ -260,14 +257,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
*addr = (FPW)0x00500050; /* clear status register */ *addr = (FPW)0x00200020; /* erase setup */ *addr = (FPW)0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW)0x00B000B0; /* suspend erase */ *addr = (FPW)0x00FF00FF; /* reset to read mode */ @@ -385,6 +382,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *)dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -398,11 +396,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (start = get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW)0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/ep7312/flash.c b/board/ep7312/flash.c index 0c2b3ae..2ed9c9a 100644 --- a/board/ep7312/flash.c +++ b/board/ep7312/flash.c @@ -119,6 +119,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -156,7 +157,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -165,7 +166,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while ((*addr & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0xB0; /* suspend erase */ *addr = 0xFF; /* reset to read mode */ rc = ERR_TIMOUT; @@ -203,6 +204,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) vu_short *addr = (vu_short *) dest, val; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -228,11 +230,11 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((val = *addr) & 0x80) != 0x80) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0xB0; diff --git a/board/gcplus/flash.c b/board/gcplus/flash.c index 8511582..ab567e8 100644 --- a/board/gcplus/flash.c +++ b/board/gcplus/flash.c @@ -225,7 +225,7 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -258,9 +258,6 @@ flash_erase(flash_info_t * info, int s_first, int s_last) printf("\n"); }
- start = get_timer(0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts();
@@ -273,7 +270,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ @@ -282,7 +279,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -401,6 +398,7 @@ write_data(flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -414,11 +412,11 @@ write_data(flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/impa7/flash.c b/board/impa7/flash.c index d0c5880..6eae428 100644 --- a/board/impa7/flash.c +++ b/board/impa7/flash.c @@ -128,6 +128,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -165,7 +166,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -174,7 +175,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0x00D000D0; /* erase confirm */
while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B000B0; /* suspend erase */ *addr = 0x00FF00FF; /* reset to read mode */ @@ -211,6 +212,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) ulong barf; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -236,14 +238,14 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* read status register command */ *addr = 0x00700070;
/* wait while polling the status register */ while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0x00B000B0; diff --git a/board/innokom/flash.c b/board/innokom/flash.c index 8c95341..ed4b987 100644 --- a/board/innokom/flash.c +++ b/board/innokom/flash.c @@ -182,6 +182,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) return ERR_UNKNOWN_FLASH_TYPE; @@ -218,7 +219,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) PRINTK("\n");
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ u16 * volatile addr = (u16 * volatile)(info->start[sect]); @@ -235,7 +236,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
while ((*addr & 0x0080) != 0x0080) { PRINTK("."); - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B0; /* suspend erase*/ *addr = 0x00FF; /* read mode */ rc = ERR_TIMOUT; @@ -279,6 +280,7 @@ static int write_word (flash_info_t *info, ulong dest, ushort data) volatile u16 *addr = (u16 *)dest, val; int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) return ERR_NOT_ERASED; @@ -302,11 +304,11 @@ static int write_word (flash_info_t *info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait while polling the status register */ while(((val = *addr) & 0x80) != 0x80) { - if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; *addr = 0xB0; /* suspend program command */ goto outahere; diff --git a/board/lart/flash.c b/board/lart/flash.c index 29a331e..408c884 100644 --- a/board/lart/flash.c +++ b/board/lart/flash.c @@ -250,6 +250,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) ulong result; int iflag, cflag, prot, sect; int rc = ERR_OK; + ulong start;
/* first look for protection bits */
@@ -291,7 +292,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ @@ -305,7 +306,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) do { /* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = PUZZLE_TO_FLASH(CMD_SUSPEND); result = BIT_TIMEOUT; @@ -354,6 +355,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) ulong result; int rc = ERR_OK; int cflag, iflag; + ulong start;
/* Check if Flash is (sufficiently) erased */ @@ -377,13 +379,13 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = PUZZLE_TO_FLASH(CMD_SUSPEND); result = BIT_TIMEOUT; diff --git a/board/lpd7a40x/flash.c b/board/lpd7a40x/flash.c index a3ba75b..f5c0713 100644 --- a/board/lpd7a40x/flash.c +++ b/board/lpd7a40x/flash.c @@ -229,6 +229,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) ulong result, result1; int iflag, prot, sect; int rc = ERR_OK; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -284,7 +285,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) sect, info->start[sect]);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -297,7 +298,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_STATUS_RESET; result = BIT_TIMEOUT; break; @@ -357,6 +358,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) ulong result; int rc = ERR_OK; int iflag; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -387,12 +389,12 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_SUSPEND; result = BIT_TIMEOUT; break; diff --git a/board/lubbock/flash.c b/board/lubbock/flash.c index a4b201e..1ea2893 100644 --- a/board/lubbock/flash.c +++ b/board/lubbock/flash.c @@ -221,7 +221,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -254,9 +254,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -269,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -393,6 +390,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -406,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start)) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/modnet50/flash.c b/board/modnet50/flash.c index 4c31143..4834e21 100644 --- a/board/modnet50/flash.c +++ b/board/modnet50/flash.c @@ -291,6 +291,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, sect, setup_offset = 0; int rc = ERR_OK; + ulong start;
if (info->flash_id == FLASH_UNKNOWN) { printf ("- missing\n"); @@ -338,14 +339,14 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) (__u16) SECERASE_CMD;
/* wait some time */ - reset_timer_masked (); - while (get_timer_masked () < 1000) { + start = get_timer(0); + while (get_timer(start) < 1000) { }
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0); while (flash_check_erase_amd (info->start[sect])) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("timeout!\n"); /* OOPS: reach timeout, * try to reset chip @@ -411,6 +412,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) { int rc = ERR_OK; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*(__u16 *) (dest) & data) != data) @@ -446,10 +448,10 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) }
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
while (flash_check_write_amd (dest)) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { printf ("timeout! @ %08lX\n", dest); /* OOPS: reach timeout, * try to reset chip */ diff --git a/board/mx1ads/syncflash.c b/board/mx1ads/syncflash.c index 47f613c..7331efa 100644 --- a/board/mx1ads/syncflash.c +++ b/board/mx1ads/syncflash.c @@ -276,7 +276,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) {
/* arm simple, non interrupt dependent timer */
- reset_timer_masked(); + get_timer(0);
SF_NvmodeErase(); SF_NvmodeWrite(); diff --git a/board/ns9750dev/flash.c b/board/ns9750dev/flash.c index 5b56b98..185bc2d 100644 --- a/board/ns9750dev/flash.c +++ b/board/ns9750dev/flash.c @@ -261,7 +261,7 @@ void flash_unprotect_sectors (FPWV * addr) int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -294,10 +294,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- - start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -312,7 +308,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -321,7 +317,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -441,6 +437,7 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -454,11 +451,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/pleb2/flash.c b/board/pleb2/flash.c index a8897dc..2406c5f 100644 --- a/board/pleb2/flash.c +++ b/board/pleb2/flash.c @@ -472,7 +472,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) FPWV *addr; int flag, prot, sect; int intel = (info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL; - ulong now, last; + ulong start, now, last; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -516,8 +516,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- reset_timer_masked (); - /* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last && rcode == 0; sect++) {
@@ -527,7 +525,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
- reset_timer_masked (); + start = get_timer(0); last = 0;
addr = (FPWV *) (info->start[sect]); @@ -559,7 +557,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
while ((*addr & (FPW) 0x00800080) != (FPW) 0x00800080) { if ((now = - get_timer_masked ()) > CONFIG_SYS_FLASH_ERASE_TOUT) { + get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n");
if (intel) { @@ -661,6 +659,7 @@ static int write_word_amd (flash_info_t * info, FPWV * dest, FPW data) int flag; int res = 0; /* result, assume success */ FPWV *base; /* first address in flash bank */ + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*dest & data) != data) { @@ -683,12 +682,12 @@ static int write_word_amd (flash_info_t * info, FPWV * dest, FPW data) if (flag) enable_interrupts ();
- reset_timer_masked (); + start = get_timer(0);
/* data polling for D7 */ while (res == 0 && (*dest & (FPW) 0x00800080) != (data & (FPW) 0x00800080)) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00F000F0; /* reset bank */ res = 1; } @@ -711,6 +710,7 @@ static int write_word_intel (flash_info_t * info, FPWV * dest, FPW data) { int flag; int res = 0; /* result, assume success */ + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*dest & data) != data) { @@ -730,10 +730,10 @@ static int write_word_intel (flash_info_t * info, FPWV * dest, FPW data) if (flag) enable_interrupts ();
- reset_timer_masked (); + start = get_timer(0);
while (res == 0 && (*dest & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00B000B0; /* Suspend program */ res = 1; } diff --git a/board/samsung/smdk2400/flash.c b/board/samsung/smdk2400/flash.c index fb69c21..47382fe 100644 --- a/board/samsung/smdk2400/flash.c +++ b/board/samsung/smdk2400/flash.c @@ -231,6 +231,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) ulong result, result1; int iflag, prot, sect; int rc = ERR_OK; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -286,7 +287,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) sect, info->start[sect]);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -299,7 +300,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_STATUS_RESET; result = BIT_TIMEOUT; break; @@ -359,6 +360,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) ulong result; int rc = ERR_OK; int iflag; + ulong start;
#ifdef USE_920T_MMU int cflag; @@ -389,12 +391,12 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_SUSPEND; result = BIT_TIMEOUT; break; diff --git a/board/sbc2410x/flash.c b/board/sbc2410x/flash.c index abb0935..d209a6f 100644 --- a/board/sbc2410x/flash.c +++ b/board/sbc2410x/flash.c @@ -173,6 +173,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip; + ulong start;
/* first look for protection bits */
@@ -213,7 +214,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -233,7 +234,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip = TMO; @@ -295,6 +296,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) int rc = ERR_OK; int cflag, iflag; int chip; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -322,7 +324,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + get_timer(start);
/* wait until flash is ready */ chip = 0; @@ -330,7 +332,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) result = *addr;
/* check timeout */ - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip = ERR | TMO; break; } diff --git a/board/scb9328/flash.c b/board/scb9328/flash.c index c6f94ae..00c660a 100644 --- a/board/scb9328/flash.c +++ b/board/scb9328/flash.c @@ -97,11 +97,12 @@ static FLASH_BUS_RET flash_status_reg (void) static int flash_ready (ulong timeout) { int ok = 1; + ulong start;
- reset_timer_masked (); + start = get_timer(0); while ((flash_status_reg () & FLASH_CMD (CFI_INTEL_SR_READY)) != FLASH_CMD (CFI_INTEL_SR_READY)) { - if (get_timer_masked () > timeout && timeout != 0) { + if (get_timer(start) > timeout && timeout != 0) { ok = 0; break; } diff --git a/board/shannon/flash.c b/board/shannon/flash.c index 0455afa..179ec5f 100644 --- a/board/shannon/flash.c +++ b/board/shannon/flash.c @@ -190,6 +190,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip1, chip2; + ulong start;
/* first look for protection bits */
@@ -231,7 +232,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ @@ -253,7 +254,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; @@ -322,6 +323,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) int rc = ERR_OK; int cflag, iflag; int chip1, chip2; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -349,7 +351,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0);
/* wait until flash is ready */ chip1 = chip2 = 0; @@ -358,7 +360,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer_masked() > CONFIG_SYS_FLASH_ERASE_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; diff --git a/board/ti/omap1610inn/flash.c b/board/ti/omap1610inn/flash.c index 36200ad..1b67d08 100644 --- a/board/ti/omap1610inn/flash.c +++ b/board/ti/omap1610inn/flash.c @@ -278,7 +278,7 @@ void flash_unprotect_sectors (FPWV * addr) int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -311,10 +311,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- - start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -329,7 +325,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -338,7 +334,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -458,6 +454,7 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -470,11 +467,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/ti/omap730p2/flash.c b/board/ti/omap730p2/flash.c index 5b56b98..185bc2d 100644 --- a/board/ti/omap730p2/flash.c +++ b/board/ti/omap730p2/flash.c @@ -261,7 +261,7 @@ void flash_unprotect_sectors (FPWV * addr) int flash_erase (flash_info_t * info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -294,10 +294,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- - start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -312,7 +308,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -321,7 +317,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -441,6 +437,7 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -454,11 +451,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/xaeniax/flash.c b/board/xaeniax/flash.c index b051c89..6cb0aca 100644 --- a/board/xaeniax/flash.c +++ b/board/xaeniax/flash.c @@ -221,7 +221,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -254,9 +254,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -269,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -393,6 +390,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -406,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/xm250/flash.c b/board/xm250/flash.c index b02149c..e825aba 100644 --- a/board/xm250/flash.c +++ b/board/xm250/flash.c @@ -250,7 +250,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -283,9 +283,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -298,14 +295,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -422,6 +419,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -435,11 +433,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } @@ -470,6 +468,7 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) int rc = 0; vu_long *addr = (vu_long *)(info->start[sector]); int flag = disable_interrupts(); + ulong start;
*addr = INTEL_CLEAR; /* Clear status register */ if (prot) { /* Set sector lock bit */ @@ -481,10 +480,10 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) *addr = INTEL_CONFIRM; /* clear */ }
- reset_timer_masked (); + start = get_timer(0);
while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer_masked () > CONFIG_SYS_FLASH_UNLOCK_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf("Flash lock bit operation timed out\n"); rc = 1; break; @@ -510,13 +509,13 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) { if (info->protect[i]) { - reset_timer_masked (); + start = get_timer(0); addr = (vu_long *)(info->start[i]); *addr = INTEL_LOCKBIT; /* Sector lock bit */ *addr = INTEL_PROTECT; /* set */ while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer_masked () > CONFIG_SYS_FLASH_UNLOCK_TOUT) + if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf("Flash lock bit operation timed out\n"); rc = 1; diff --git a/board/zylonite/flash.c b/board/zylonite/flash.c index 5ba84c6..3ee0ab8 100644 --- a/board/zylonite/flash.c +++ b/board/zylonite/flash.c @@ -224,7 +224,7 @@ static ulong flash_get_size (FPW *addr, flash_info_t *info) int flash_erase (flash_info_t *info, int s_first, int s_last) { int flag, prot, sect; - ulong type, start, last; + ulong type, start; int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) { @@ -257,9 +257,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); - last = start; - /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
@@ -272,14 +269,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -396,6 +393,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) FPWV *addr = (FPWV *) dest; ulong status; int flag; + ulong start;
/* Check if Flash is (sufficiently) erased */ if ((*addr & data) != data) { @@ -409,11 +407,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - reset_timer_masked (); + start = get_timer(0);
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer_masked () > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/drivers/mtd/spi/eeprom_m95xxx.c b/drivers/mtd/spi/eeprom_m95xxx.c index 632db4e..ef8ed6f 100644 --- a/drivers/mtd/spi/eeprom_m95xxx.c +++ b/drivers/mtd/spi/eeprom_m95xxx.c @@ -75,6 +75,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len) { struct spi_slave *slave; char buf[3]; + ulong start;
slave = spi_setup_slave(CONFIG_DEFAULT_SPI_BUS, 1, 1000000, CONFIG_DEFAULT_SPI_MODE); @@ -102,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;
- reset_timer_masked(); + start = get_timer(0); do { buf[0] = SPI_EEPROM_RDSR; buf[1] = 0; @@ -111,7 +112,7 @@ ssize_t spi_write (uchar *addr, int alen, uchar *buffer, int len) if (!(buf[1] & 1)) break;
- } while (get_timer_masked() < CONFIG_SYS_SPI_WRITE_TOUT); + } while (get_timer(start) < CONFIG_SYS_SPI_WRITE_TOUT);
if (buf[1] & 1) printf ("*** spi_write: Time out while writing!\n"); diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 4e4cd27..ab90afa 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -86,7 +86,7 @@ static int fec_miiphy_read(const char *dev, uint8_t phyAddr, uint8_t regAddr, /* * wait for the related interrupt */ - start = get_timer_masked(); + start = get_timer(0); while (!(readl(&fec->eth->ievent) & FEC_IEVENT_MII)) { if (get_timer(start) > (CONFIG_SYS_HZ / 1000)) { printf("Read MDIO failed...\n"); @@ -138,7 +138,7 @@ static int fec_miiphy_write(const char *dev, uint8_t phyAddr, uint8_t regAddr, /* * wait for the MII interrupt */ - start = get_timer_masked(); + start = get_timer(0); while (!(readl(&fec->eth->ievent) & FEC_IEVENT_MII)) { if (get_timer(start) > (CONFIG_SYS_HZ / 1000)) { printf("Write MDIO failed...\n"); @@ -189,7 +189,7 @@ static int miiphy_wait_aneg(struct eth_device *dev) /* * Wait for AN completion */ - start = get_timer_masked(); + start = get_timer(0); do { if (get_timer(start) > (CONFIG_SYS_HZ * 5)) { printf("%s: Autonegotiation timeout\n", dev->name); diff --git a/drivers/net/netarm_eth.c b/drivers/net/netarm_eth.c index c9e324e..f54817e 100644 --- a/drivers/net/netarm_eth.c +++ b/drivers/net/netarm_eth.c @@ -81,9 +81,10 @@ static unsigned int na_mii_read (int reg)
static int na_mii_poll_busy (void) { + ulong start; /* arm simple, non interrupt dependent timer */ - reset_timer_masked (); - while (get_timer_masked () < NA_MII_POLL_BUSY_DELAY) { + start = get_timer(0)); + while (get_timer(start) < NA_MII_POLL_BUSY_DELAY) { if (!(GET_EADDR (NETARM_ETH_MII_IND) & NETARM_ETH_MIII_BUSY)) { return 1; } @@ -164,19 +165,20 @@ static unsigned int na_mii_check_speed (void) static int reset_eth (void) { int pt; + ulong start;
na_get_mac_addr (); pt = na_mii_identify_phy ();
/* reset the phy */ na_mii_write (MII_PHY_CONTROL, 0x8000); - reset_timer_masked (); - while (get_timer_masked () < NA_MII_NEGOTIATE_DELAY) { + start = get_timer(0); + while (get_timer(start) < NA_MII_NEGOTIATE_DELAY) { if ((na_mii_read (MII_PHY_STATUS) & 0x8000) == 0) { break; } } - if (get_timer_masked () >= NA_MII_NEGOTIATE_DELAY) + if (get_timer(start) >= NA_MII_NEGOTIATE_DELAY) printf ("phy reset timeout\n");
/* set the PCS reg */ -- 1.7.5.2.317.g391b14

Hi Greame,
Le 16/07/2011 11:31, Graeme Russ a écrit :
Signed-off-by: Graeme Russgraeme.russ@gmail.com
Changes since v2:
- Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
Applied tu u-boot-arm/master (forced push), thanks!
Amicalement,

There is no need to use set_timer(). Replace with appropriate use of get_timer()
Signed-off-by: Graeme Russ graeme.russ@gmail.com
--- board/BuS/EB+MCF-EV123/flash.c | 10 ++++++---- board/cobra5272/flash.c | 10 ++++++---- board/idmr/flash.c | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/board/BuS/EB+MCF-EV123/flash.c b/board/BuS/EB+MCF-EV123/flash.c index 3c36367..8b7f957 100644 --- a/board/BuS/EB+MCF-EV123/flash.c +++ b/board/BuS/EB+MCF-EV123/flash.c @@ -157,6 +157,7 @@ int amd_flash_erase_sector(flash_info_t * info, int sector) { int state; ulong result; + ulong start;
volatile u16 *addr = (volatile u16 *) (info->start[sector]); @@ -171,13 +172,13 @@ int amd_flash_erase_sector(flash_info_t * info, int sector)
/* wait until flash is ready */ state = 0; - set_timer (0); + start = get_timer(0);
do { result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; state = ERR_TIMOUT; } @@ -267,6 +268,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) ulong result; int cflag, iflag; int state; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -295,7 +297,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) *addr = data;
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
/* wait until flash is ready */ state = 0; @@ -303,7 +305,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { state = ERR_TIMOUT; } if (!state && ((result & BIT_RDY_MASK) == (data & BIT_RDY_MASK))) diff --git a/board/cobra5272/flash.c b/board/cobra5272/flash.c index 33c9361..e8f02eb 100644 --- a/board/cobra5272/flash.c +++ b/board/cobra5272/flash.c @@ -147,6 +147,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip1; + ulong start;
/* first look for protection bits */
@@ -190,7 +191,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = @@ -211,7 +212,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -264,6 +265,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) int rc = ERR_OK; int cflag, iflag; int chip1; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -291,7 +293,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
/* wait until flash is ready */ chip1 = 0; @@ -299,7 +301,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; } diff --git a/board/idmr/flash.c b/board/idmr/flash.c index 57c9948..9f4ff2b 100644 --- a/board/idmr/flash.c +++ b/board/idmr/flash.c @@ -130,6 +130,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, prot, sect; int rc = ERR_OK; int chip1; + ulong start;
/* first look for protection bits */
@@ -170,7 +171,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = @@ -191,7 +192,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -248,6 +249,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) int rc = ERR_OK; int iflag; int chip1; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -272,7 +274,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
/* wait until flash is ready */ chip1 = 0; @@ -280,7 +282,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { chip1 = ERR | TMO; break; } -- 1.7.5.2.317.g391b14

Dear Graeme Russ,
In message 1309261269-4363-3-git-send-email-graeme.russ@gmail.com you wrote:
There is no need to use set_timer(). Replace with appropriate use of get_timer()
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Acked-by: Wolfgang Denk wd@denx.de
Best regards,
Wolfgang Denk

There is no need to use set_timer(). Replace with appropriate use of get_timer()
Signed-off-by: Graeme Russ graeme.russ@gmail.com
--- Sorry Wolfgang, but this patch has been through a few versions before it got integrated into the larger Timer API hence the v1->v2->v1 debacle.
checkpatch complains about long lines and brace usage in the board specific flash.c files - They are deprecated and not worth fixing for style
Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
Changes since V1: - Fix typo in commit message - Add reset_timer() to Nios2 get_timer(0)
Changes since V2 - No longer remove reset_timer() --- board/BuS/EB+MCF-EV123/flash.c | 10 ++++++---- board/cobra5272/flash.c | 10 ++++++---- board/idmr/flash.c | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/board/BuS/EB+MCF-EV123/flash.c b/board/BuS/EB+MCF-EV123/flash.c index 3c36367..8b7f957 100644 --- a/board/BuS/EB+MCF-EV123/flash.c +++ b/board/BuS/EB+MCF-EV123/flash.c @@ -157,6 +157,7 @@ int amd_flash_erase_sector(flash_info_t * info, int sector) { int state; ulong result; + ulong start;
volatile u16 *addr = (volatile u16 *) (info->start[sector]); @@ -171,13 +172,13 @@ int amd_flash_erase_sector(flash_info_t * info, int sector)
/* wait until flash is ready */ state = 0; - set_timer (0); + start = get_timer(0);
do { result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; state = ERR_TIMOUT; } @@ -267,6 +268,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) ulong result; int cflag, iflag; int state; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -295,7 +297,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) *addr = data;
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
/* wait until flash is ready */ state = 0; @@ -303,7 +305,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { state = ERR_TIMOUT; } if (!state && ((result & BIT_RDY_MASK) == (data & BIT_RDY_MASK))) diff --git a/board/cobra5272/flash.c b/board/cobra5272/flash.c index 33c9361..e8f02eb 100644 --- a/board/cobra5272/flash.c +++ b/board/cobra5272/flash.c @@ -147,6 +147,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip1; + ulong start;
/* first look for protection bits */
@@ -190,7 +191,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = @@ -211,7 +212,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -264,6 +265,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) int rc = ERR_OK; int cflag, iflag; int chip1; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -291,7 +293,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
/* wait until flash is ready */ chip1 = 0; @@ -299,7 +301,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; } diff --git a/board/idmr/flash.c b/board/idmr/flash.c index 57c9948..9f4ff2b 100644 --- a/board/idmr/flash.c +++ b/board/idmr/flash.c @@ -130,6 +130,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, prot, sect; int rc = ERR_OK; int chip1; + ulong start;
/* first look for protection bits */
@@ -170,7 +171,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = @@ -191,7 +192,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -248,6 +249,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) int rc = ERR_OK; int iflag; int chip1; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -272,7 +274,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
/* wait until flash is ready */ chip1 = 0; @@ -280,7 +282,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { chip1 = ERR | TMO; break; } -- 1.7.5.2.317.g391b14

There is no need to use set_timer(). Replace with appropriate use of get_timer()
Signed-off-by: Graeme Russ graeme.russ@gmail.com --- Sorry Wolfgang, but this patch has been through a few versions before it got integrated into the larger Timer API hence the v1->v2->v1 debacle.
checkpatch complains about long lines and brace usage in the board specific flash.c files - They are deprecated and not worth fixing for style
Changes since v2: - None - Revised to v3 with other patches in series
Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
Changes since V1: - Fix typo in commit message - Add reset_timer() to Nios2 get_timer(0)
Changes since V2 - No longer remove reset_timer() --- board/BuS/EB+MCF-EV123/flash.c | 10 ++++++---- board/cobra5272/flash.c | 10 ++++++---- board/idmr/flash.c | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/board/BuS/EB+MCF-EV123/flash.c b/board/BuS/EB+MCF-EV123/flash.c index 3c36367..8b7f957 100644 --- a/board/BuS/EB+MCF-EV123/flash.c +++ b/board/BuS/EB+MCF-EV123/flash.c @@ -157,6 +157,7 @@ int amd_flash_erase_sector(flash_info_t * info, int sector) { int state; ulong result; + ulong start;
volatile u16 *addr = (volatile u16 *) (info->start[sector]); @@ -171,13 +172,13 @@ int amd_flash_erase_sector(flash_info_t * info, int sector)
/* wait until flash is ready */ state = 0; - set_timer (0); + start = get_timer(0);
do { result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; state = ERR_TIMOUT; } @@ -267,6 +268,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) ulong result; int cflag, iflag; int state; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -295,7 +297,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) *addr = data;
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
/* wait until flash is ready */ state = 0; @@ -303,7 +305,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { state = ERR_TIMOUT; } if (!state && ((result & BIT_RDY_MASK) == (data & BIT_RDY_MASK))) diff --git a/board/cobra5272/flash.c b/board/cobra5272/flash.c index 33c9361..e8f02eb 100644 --- a/board/cobra5272/flash.c +++ b/board/cobra5272/flash.c @@ -147,6 +147,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, cflag, prot, sect; int rc = ERR_OK; int chip1; + ulong start;
/* first look for protection bits */
@@ -190,7 +191,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = @@ -211,7 +212,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -264,6 +265,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) int rc = ERR_OK; int cflag, iflag; int chip1; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -291,7 +293,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
/* wait until flash is ready */ chip1 = 0; @@ -299,7 +301,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; } diff --git a/board/idmr/flash.c b/board/idmr/flash.c index 57c9948..9f4ff2b 100644 --- a/board/idmr/flash.c +++ b/board/idmr/flash.c @@ -130,6 +130,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) int iflag, prot, sect; int rc = ERR_OK; int chip1; + ulong start;
/* first look for protection bits */
@@ -170,7 +171,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = @@ -191,7 +192,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -248,6 +249,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) int rc = ERR_OK; int iflag; int chip1; + ulong start;
/* * Check if Flash is (sufficiently) erased @@ -272,7 +274,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - set_timer (0); + start = get_timer(0);
/* wait until flash is ready */ chip1 = 0; @@ -280,7 +282,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer (0) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { + if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { chip1 = ERR | TMO; break; } -- 1.7.5.2.317.g391b14

Dear Graeme Russ,
In message 1310808837-3286-1-git-send-email-graeme.russ@gmail.com you wrote:
There is no need to use set_timer(). Replace with appropriate use of get_timer()
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Sorry Wolfgang, but this patch has been through a few versions before it got integrated into the larger Timer API hence the v1->v2->v1 debacle.
checkpatch complains about long lines and brace usage in the board specific flash.c files - They are deprecated and not worth fixing for style
Changes since v2:
- None - Revised to v3 with other patches in series
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
Changes since V1:
- Fix typo in commit message
- Add reset_timer() to Nios2 get_timer(0)
Changes since V2
- No longer remove reset_timer()
board/BuS/EB+MCF-EV123/flash.c | 10 ++++++---- board/cobra5272/flash.c | 10 ++++++---- board/idmr/flash.c | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- arch/arm/cpu/arm1136/mx31/timer.c | 5 ----- arch/arm/cpu/arm1136/mx35/timer.c | 4 ---- arch/arm/cpu/arm1136/omap24xx/timer.c | 5 ----- arch/arm/cpu/arm1176/s3c64xx/timer.c | 5 ----- arch/arm/cpu/arm1176/tnetv107x/timer.c | 5 ----- arch/arm/cpu/arm720t/interrupts.c | 5 ----- arch/arm/cpu/arm920t/a320/timer.c | 6 ------ arch/arm/cpu/arm920t/at91/timer.c | 5 ----- arch/arm/cpu/arm920t/at91rm9200/timer.c | 5 ----- arch/arm/cpu/arm920t/imx/timer.c | 5 ----- arch/arm/cpu/arm920t/ks8695/timer.c | 5 ----- arch/arm/cpu/arm920t/s3c24x0/timer.c | 5 ----- arch/arm/cpu/arm925t/timer.c | 5 ----- arch/arm/cpu/arm926ejs/armada100/timer.c | 5 ----- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx25/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx27/timer.c | 5 ----- arch/arm/cpu/arm926ejs/omap/timer.c | 5 ----- arch/arm/cpu/arm926ejs/orion5x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/pantheon/timer.c | 5 ----- arch/arm/cpu/arm926ejs/spear/timer.c | 5 ----- arch/arm/cpu/arm926ejs/versatile/timer.c | 5 ----- arch/arm/cpu/armv7/mx5/timer.c | 5 ----- arch/arm/cpu/armv7/omap-common/timer.c | 5 ----- arch/arm/cpu/armv7/s5p-common/timer.c | 5 ----- arch/arm/cpu/armv7/tegra2/timer.c | 5 ----- arch/arm/cpu/lh7a40x/timer.c | 5 ----- arch/arm/cpu/pxa/timer.c | 5 ----- arch/arm/cpu/s3c44b0/timer.c | 5 ----- arch/arm/cpu/sa1100/timer.c | 5 ----- arch/avr32/cpu/interrupts.c | 16 ---------------- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 4 ---- arch/m68k/lib/board.c | 2 -- arch/m68k/lib/time.c | 16 ++-------------- arch/microblaze/cpu/timer.c | 5 ----- arch/mips/cpu/mips32/time.c | 6 ------ arch/nios2/cpu/interrupts.c | 6 ------ arch/powerpc/lib/board.c | 2 -- arch/powerpc/lib/interrupts.c | 5 ----- arch/sh/lib/time.c | 7 +------ arch/sh/lib/time_sh2.c | 9 ++------- arch/sparc/lib/board.c | 2 -- arch/sparc/lib/interrupts.c | 5 ----- arch/x86/lib/board.c | 2 -- arch/x86/lib/timer.c | 5 ----- board/armltd/integrator/timer.c | 6 ------ include/common.h | 1 - 47 files changed, 5 insertions(+), 244 deletions(-)
diff --git a/arch/arm/cpu/arm1136/mx31/timer.c b/arch/arm/cpu/arm1136/mx31/timer.c index c4bc3b3..d51acbb 100644 --- a/arch/arm/cpu/arm1136/mx31/timer.c +++ b/arch/arm/cpu/arm1136/mx31/timer.c @@ -147,11 +147,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - gd->tbl = time_to_tick(t); -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm1136/mx35/timer.c b/arch/arm/cpu/arm1136/mx35/timer.c index db1e2c9..6dfb63a 100644 --- a/arch/arm/cpu/arm1136/mx35/timer.c +++ b/arch/arm/cpu/arm1136/mx35/timer.c @@ -92,10 +92,6 @@ ulong get_timer(ulong base) return (tmp / 1000) - base; }
-void set_timer(ulong t) -{ -} - /* * delay x useconds AND preserve advance timstamp value * GPTCNT is now supposed to tick 1 by 1 us. diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c index 228ceba..d6267ba 100644 --- a/arch/arm/cpu/arm1136/omap24xx/timer.c +++ b/arch/arm/cpu/arm1136/omap24xx/timer.c @@ -67,11 +67,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - gd->tbl = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm1176/s3c64xx/timer.c b/arch/arm/cpu/arm1176/s3c64xx/timer.c index 9768319..8e54060 100644 --- a/arch/arm/cpu/arm1176/s3c64xx/timer.c +++ b/arch/arm/cpu/arm1176/s3c64xx/timer.c @@ -159,11 +159,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t * (timer_load_val / (100 * CONFIG_SYS_HZ)); -} - void __udelay(unsigned long usec) { unsigned long long tmp; diff --git a/arch/arm/cpu/arm1176/tnetv107x/timer.c b/arch/arm/cpu/arm1176/tnetv107x/timer.c index a7a400d..c27375c 100644 --- a/arch/arm/cpu/arm1176/tnetv107x/timer.c +++ b/arch/arm/cpu/arm1176/tnetv107x/timer.c @@ -88,11 +88,6 @@ ulong get_timer(ulong base) return (get_timer_raw() / (TIMER_LOAD_VAL / TIM_CLK_DIV)) - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - unsigned long long get_ticks(void) { return get_timer(0); diff --git a/arch/arm/cpu/arm720t/interrupts.c b/arch/arm/cpu/arm720t/interrupts.c index eb8d425..164ca5d 100644 --- a/arch/arm/cpu/arm720t/interrupts.c +++ b/arch/arm/cpu/arm720t/interrupts.c @@ -219,11 +219,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/arm920t/a320/timer.c b/arch/arm/cpu/arm920t/a320/timer.c index 95cb8fd..b9c83c0 100644 --- a/arch/arm/cpu/arm920t/a320/timer.c +++ b/arch/arm/cpu/arm920t/a320/timer.c @@ -132,12 +132,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - debug("%s(%lx)\n", __func__, t); - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/arm920t/at91/timer.c b/arch/arm/cpu/arm920t/at91/timer.c index f0ad7d6..a69de57 100644 --- a/arch/arm/cpu/arm920t/at91/timer.c +++ b/arch/arm/cpu/arm920t/at91/timer.c @@ -83,11 +83,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->tbl = t; -} - void __udelay(unsigned long usec) { udelay_masked(usec); diff --git a/arch/arm/cpu/arm920t/at91rm9200/timer.c b/arch/arm/cpu/arm920t/at91rm9200/timer.c index 9c54bbe..0bcb775 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/timer.c +++ b/arch/arm/cpu/arm920t/at91rm9200/timer.c @@ -82,11 +82,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { udelay_masked(usec); diff --git a/arch/arm/cpu/arm920t/imx/timer.c b/arch/arm/cpu/arm920t/imx/timer.c index b06b518..ff85a41 100644 --- a/arch/arm/cpu/arm920t/imx/timer.c +++ b/arch/arm/cpu/arm920t/imx/timer.c @@ -62,11 +62,6 @@ ulong get_timer (ulong base) return get_timer_masked() - base; }
-void set_timer (ulong t) -{ - /* nop */ -} - void reset_timer_masked (void) { TCTL1 &= ~TCTL_TEN; diff --git a/arch/arm/cpu/arm920t/ks8695/timer.c b/arch/arm/cpu/arm920t/ks8695/timer.c index 886e370..8e14109 100644 --- a/arch/arm/cpu/arm920t/ks8695/timer.c +++ b/arch/arm/cpu/arm920t/ks8695/timer.c @@ -76,11 +76,6 @@ ulong get_timer(ulong base) return (get_timer_masked() - base); }
-void set_timer(ulong t) -{ - timer_ticks = t; -} - void __udelay(ulong usec) { ulong start = get_timer_masked(); diff --git a/arch/arm/cpu/arm920t/s3c24x0/timer.c b/arch/arm/cpu/arm920t/s3c24x0/timer.c index 8cf9ff6..22767c5 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/timer.c +++ b/arch/arm/cpu/arm920t/s3c24x0/timer.c @@ -94,11 +94,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/arm925t/timer.c b/arch/arm/cpu/arm925t/timer.c index 7dfe2b5..fdaeda5 100644 --- a/arch/arm/cpu/arm925t/timer.c +++ b/arch/arm/cpu/arm925t/timer.c @@ -75,11 +75,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/armada100/timer.c b/arch/arm/cpu/arm926ejs/armada100/timer.c index 5d911c5..eb49234 100644 --- a/arch/arm/cpu/arm926ejs/armada100/timer.c +++ b/arch/arm/cpu/arm926ejs/armada100/timer.c @@ -111,11 +111,6 @@ ulong get_timer(ulong base) base); }
-void set_timer(ulong t) -{ - gd->tbu = t; -} - void __udelay(unsigned long usec) { ulong delayticks; diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c index 3e80329..e890edb 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c @@ -122,11 +122,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - void __udelay(unsigned long usec) { uint current; diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c index 14f0c2d..af26b4c 100644 --- a/arch/arm/cpu/arm926ejs/mx25/timer.c +++ b/arch/arm/cpu/arm926ejs/mx25/timer.c @@ -170,11 +170,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = time_to_tick(t); -} - /* delay x useconds AND preserve advance timstamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c index 5c1cf01..127e670 100644 --- a/arch/arm/cpu/arm926ejs/mx27/timer.c +++ b/arch/arm/cpu/arm926ejs/mx27/timer.c @@ -173,11 +173,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = time_to_tick(t); -} - /* delay x useconds AND preserve advance timstamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c index 88a0ee6..f2e4deb 100644 --- a/arch/arm/cpu/arm926ejs/omap/timer.c +++ b/arch/arm/cpu/arm926ejs/omap/timer.c @@ -76,11 +76,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c index 9d45260..f691c99 100644 --- a/arch/arm/cpu/arm926ejs/orion5x/timer.c +++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c @@ -129,11 +129,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - static inline ulong uboot_cntr_val(void) { return readl(CNTMR_VAL_REG(UBOOT_CNTR)); diff --git a/arch/arm/cpu/arm926ejs/pantheon/timer.c b/arch/arm/cpu/arm926ejs/pantheon/timer.c index ca7f7f0..b487416 100644 --- a/arch/arm/cpu/arm926ejs/pantheon/timer.c +++ b/arch/arm/cpu/arm926ejs/pantheon/timer.c @@ -119,11 +119,6 @@ ulong get_timer(ulong base) base); }
-void set_timer(ulong t) -{ - gd->tbu = t; -} - void __udelay(unsigned long usec) { ulong delayticks; diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c index 66cf4de..7305abd 100644 --- a/arch/arm/cpu/arm926ejs/spear/timer.c +++ b/arch/arm/cpu/arm926ejs/spear/timer.c @@ -87,11 +87,6 @@ ulong get_timer(ulong base) return (get_timer_masked() / GPT_RESOLUTION) - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - void __udelay(unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/arm926ejs/versatile/timer.c b/arch/arm/cpu/arm926ejs/versatile/timer.c index 2e243b1..0e51a63 100644 --- a/arch/arm/cpu/arm926ejs/versatile/timer.c +++ b/arch/arm/cpu/arm926ejs/versatile/timer.c @@ -105,11 +105,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/armv7/mx5/timer.c b/arch/arm/cpu/armv7/mx5/timer.c index 1972f64..40ee0be 100644 --- a/arch/arm/cpu/armv7/mx5/timer.c +++ b/arch/arm/cpu/armv7/mx5/timer.c @@ -99,11 +99,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/armv7/omap-common/timer.c b/arch/arm/cpu/armv7/omap-common/timer.c index 9beebb1..5dcd044 100644 --- a/arch/arm/cpu/armv7/omap-common/timer.c +++ b/arch/arm/cpu/armv7/omap-common/timer.c @@ -72,11 +72,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->tbl = t; -} - /* delay x useconds */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/armv7/s5p-common/timer.c b/arch/arm/cpu/armv7/s5p-common/timer.c index b750d16..0b69f06 100644 --- a/arch/arm/cpu/armv7/s5p-common/timer.c +++ b/arch/arm/cpu/armv7/s5p-common/timer.c @@ -60,11 +60,6 @@ unsigned long get_timer(unsigned long base) return get_timer_masked() - base; }
-void set_timer(unsigned long t) -{ - gd->tbl = t; -} - /* delay x useconds */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/armv7/tegra2/timer.c b/arch/arm/cpu/armv7/tegra2/timer.c index fb061d0..4458de9 100644 --- a/arch/arm/cpu/armv7/tegra2/timer.c +++ b/arch/arm/cpu/armv7/tegra2/timer.c @@ -58,11 +58,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->tbl = t; -} - /* delay x useconds */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/lh7a40x/timer.c b/arch/arm/cpu/lh7a40x/timer.c index 2691315..6c6277d 100644 --- a/arch/arm/cpu/lh7a40x/timer.c +++ b/arch/arm/cpu/lh7a40x/timer.c @@ -85,11 +85,6 @@ ulong get_timer (ulong base) return (get_timer_masked() - base); }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo,tmp; diff --git a/arch/arm/cpu/pxa/timer.c b/arch/arm/cpu/pxa/timer.c index ec950c7..8900a70 100644 --- a/arch/arm/cpu/pxa/timer.c +++ b/arch/arm/cpu/pxa/timer.c @@ -74,11 +74,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - /* nop */ -} - void __udelay (unsigned long usec) { udelay_masked (usec); diff --git a/arch/arm/cpu/s3c44b0/timer.c b/arch/arm/cpu/s3c44b0/timer.c index 6f1d8f6..d30e1aa 100644 --- a/arch/arm/cpu/s3c44b0/timer.c +++ b/arch/arm/cpu/s3c44b0/timer.c @@ -70,11 +70,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/sa1100/timer.c b/arch/arm/cpu/sa1100/timer.c index 0207501..10ad964 100644 --- a/arch/arm/cpu/sa1100/timer.c +++ b/arch/arm/cpu/sa1100/timer.c @@ -44,11 +44,6 @@ ulong get_timer (ulong base) return get_timer_masked (); }
-void set_timer (ulong t) -{ - /* nop */ -} - void __udelay (unsigned long usec) { udelay_masked (usec); diff --git a/arch/avr32/cpu/interrupts.c b/arch/avr32/cpu/interrupts.c index c6ea435..8406f91 100644 --- a/arch/avr32/cpu/interrupts.c +++ b/arch/avr32/cpu/interrupts.c @@ -77,22 +77,6 @@ unsigned long get_timer(unsigned long base) return (unsigned long)(now >> 32) - base; }
-void set_timer(unsigned long t) -{ - unsigned long long ticks = t; - unsigned long lo, hi, hi_new; - - ticks = (ticks * get_tbclk()) / CONFIG_SYS_HZ; - hi = ticks >> 32; - lo = ticks & 0xffffffffUL; - - do { - timer_overflow = hi; - sysreg_write(COUNT, lo); - hi_new = timer_overflow; - } while (hi_new != hi); -} - /* * For short delays only. It will overflow after a few seconds. */ diff --git a/arch/m68k/cpu/mcf547x_8x/slicetimer.c b/arch/m68k/cpu/mcf547x_8x/slicetimer.c index 8dc010a..49dba6a 100644 --- a/arch/m68k/cpu/mcf547x_8x/slicetimer.c +++ b/arch/m68k/cpu/mcf547x_8x/slicetimer.c @@ -105,8 +105,4 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; -} #endif /* CONFIG_SLTTMR */ diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c index 6a892db..945ab66 100644 --- a/arch/m68k/lib/board.c +++ b/arch/m68k/lib/board.c @@ -574,8 +574,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
udelay (20);
- set_timer (0); - /* Insert function pointers now that we have relocated the code */
/* Initialize from environment */ diff --git a/arch/m68k/lib/time.c b/arch/m68k/lib/time.c index 7eaea5e..d10bcc7 100644 --- a/arch/m68k/lib/time.c +++ b/arch/m68k/lib/time.c @@ -126,10 +126,6 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; -} #endif /* CONFIG_MCFTMR */
#if defined(CONFIG_MCFPIT) @@ -173,14 +169,6 @@ void timer_init(void) timerp->pcsr |= PIT_PCSR_PRE(CONFIG_SYS_PIT_PRESCALE) | PIT_PCSR_EN; }
-void set_timer(ulong t) -{ - volatile pit_t *timerp = (pit_t *) (CONFIG_SYS_PIT_BASE); - - timestamp = 0; - timerp->pmr = lastinc = 0; -} - ulong get_timer(ulong base) { unsigned short now, diff; @@ -196,8 +184,8 @@ ulong get_timer(ulong base)
void wait_ticks(unsigned long ticks) { - set_timer(0); - while (get_timer(0) < ticks) ; + u32 start = get_timer(0); + while (get_timer(start) < ticks) ; } #endif /* CONFIG_MCFPIT */
diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index 4936c62..59ed126 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -45,11 +45,6 @@ ulong get_timer (ulong base) } #endif
-void set_timer (ulong t) -{ - timestamp = t; -} - #ifdef CONFIG_SYS_INTC_0 #ifdef CONFIG_SYS_TIMER_0 microblaze_timer_t *tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR); diff --git a/arch/mips/cpu/mips32/time.c b/arch/mips/cpu/mips32/time.c index 0e66441..b0a9c1f 100644 --- a/arch/mips/cpu/mips32/time.c +++ b/arch/mips/cpu/mips32/time.c @@ -64,12 +64,6 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; - write_c0_compare(read_c0_count() + CYCLES_PER_JIFFY); -} - void __udelay(unsigned long usec) { unsigned int tmo; diff --git a/arch/nios2/cpu/interrupts.c b/arch/nios2/cpu/interrupts.c index 63acfa9..0a97fa6 100644 --- a/arch/nios2/cpu/interrupts.c +++ b/arch/nios2/cpu/interrupts.c @@ -98,12 +98,6 @@ ulong get_timer (ulong base) return (timestamp - base); }
-void set_timer (ulong t) -{ - timestamp = t; -} - - /* The board must handle this interrupt if a timer is not * provided. */ diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c index aaa5add..22bbc52 100644 --- a/arch/powerpc/lib/board.c +++ b/arch/powerpc/lib/board.c @@ -932,8 +932,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
udelay (20);
- set_timer (0); - /* Initialize from environment */ if ((s = getenv ("loadaddr")) != NULL) { load_addr = simple_strtoul (s, NULL, 16); diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c index f603170..847ad37 100644 --- a/arch/powerpc/lib/interrupts.c +++ b/arch/powerpc/lib/interrupts.c @@ -146,8 +146,3 @@ ulong get_timer (ulong base) { return (timestamp - base); } - -void set_timer (ulong t) -{ - timestamp = t; -} diff --git a/arch/sh/lib/time.c b/arch/sh/lib/time.c index bc1656f..c4bfc86 100644 --- a/arch/sh/lib/time.c +++ b/arch/sh/lib/time.c @@ -139,15 +139,10 @@ unsigned long get_timer (unsigned long base) return tick_to_time(get_ticks()) - base; }
-void set_timer (unsigned long t) -{ - writel((0 - t), TCNT0); -} - void reset_timer (void) { tmu_timer_stop(0); - set_timer (0); + writel(0, TCNT0); tmu_timer_start(0); }
diff --git a/arch/sh/lib/time_sh2.c b/arch/sh/lib/time_sh2.c index 789b46f..a5c838b 100644 --- a/arch/sh/lib/time_sh2.c +++ b/arch/sh/lib/time_sh2.c @@ -54,7 +54,7 @@ int timer_init(void)
/* User Device 0 only */ cmt_timer_stop(0); - set_timer(CMT_TIMER_RESET); + writew(CMT_TIMER_RESET, CMCOR_0); cmt_timer_start(0);
return 0; @@ -90,15 +90,10 @@ ulong get_timer(ulong base) return (get_usec() / 1000) - base; }
-void set_timer(ulong t) -{ - writew((u16) t, CMCOR_0); -} - void reset_timer(void) { cmt_timer_stop(0); - set_timer(CMT_TIMER_RESET); + writew(CMT_TIMER_RESET, CMCOR_0); cmt0_timer = 0; cmt_timer_start(0); } diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c index 386cd04..6b705e5 100644 --- a/arch/sparc/lib/board.c +++ b/arch/sparc/lib/board.c @@ -365,8 +365,6 @@ void board_init_f(ulong bootflag)
udelay(20);
- set_timer(0); - /* Initialize from environment */ if ((s = getenv("loadaddr")) != NULL) { load_addr = simple_strtoul(s, NULL, 16); diff --git a/arch/sparc/lib/interrupts.c b/arch/sparc/lib/interrupts.c index 4c73b82..5274311 100644 --- a/arch/sparc/lib/interrupts.c +++ b/arch/sparc/lib/interrupts.c @@ -100,11 +100,6 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; -} - void timer_interrupt_init(void) { int irq; diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index df54222..c92291b 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -363,8 +363,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
udelay(20);
- set_timer (0); - /* Initialize from environment */ if ((s = getenv ("loadaddr")) != NULL) { load_addr = simple_strtoul (s, NULL, 16); diff --git a/arch/x86/lib/timer.c b/arch/x86/lib/timer.c index 8fc68cd..199ca8e 100644 --- a/arch/x86/lib/timer.c +++ b/arch/x86/lib/timer.c @@ -103,8 +103,3 @@ ulong get_timer (ulong base) { return (system_ticks - base); } - -void set_timer (ulong t) -{ - system_ticks = t; -} diff --git a/board/armltd/integrator/timer.c b/board/armltd/integrator/timer.c index 7562ffa..5406066 100644 --- a/board/armltd/integrator/timer.c +++ b/board/armltd/integrator/timer.c @@ -117,12 +117,6 @@ ulong get_timer (ulong base_ticks) return get_timer_masked () - base_ticks; }
-void set_timer (ulong ticks) -{ - timestamp = ticks; - total_count = ticks * div_timer; -} - /* delay usec useconds */ void __udelay (unsigned long usec) { diff --git a/include/common.h b/include/common.h index 1e4a6a5..340e585 100644 --- a/include/common.h +++ b/include/common.h @@ -586,7 +586,6 @@ void irq_install_handler(int, interrupt_handler_t *, void *); void irq_free_handler (int); void reset_timer (void); ulong get_timer (ulong base); -void set_timer (ulong t); void enable_interrupts (void); int disable_interrupts (void);

Dear Graeme Russ,
In message 1309261269-4363-4-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
The description is not quite correct, as you not only remove the calls to that function, but also it's implementation itself.
Otherwise:
Acked-by: Wolfgang Denk wd@denx.de
Best regards,
Wolfgang Denk

--- Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6 - Updated description
arch/arm/cpu/arm1136/mx31/timer.c | 5 ----- arch/arm/cpu/arm1136/mx35/timer.c | 4 ---- arch/arm/cpu/arm1136/omap24xx/timer.c | 5 ----- arch/arm/cpu/arm1176/s3c64xx/timer.c | 5 ----- arch/arm/cpu/arm1176/tnetv107x/timer.c | 5 ----- arch/arm/cpu/arm720t/interrupts.c | 5 ----- arch/arm/cpu/arm920t/a320/timer.c | 6 ------ arch/arm/cpu/arm920t/at91/timer.c | 5 ----- arch/arm/cpu/arm920t/at91rm9200/timer.c | 5 ----- arch/arm/cpu/arm920t/imx/timer.c | 5 ----- arch/arm/cpu/arm920t/ks8695/timer.c | 5 ----- arch/arm/cpu/arm920t/s3c24x0/timer.c | 5 ----- arch/arm/cpu/arm925t/timer.c | 5 ----- arch/arm/cpu/arm926ejs/armada100/timer.c | 5 ----- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx25/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx27/timer.c | 5 ----- arch/arm/cpu/arm926ejs/omap/timer.c | 5 ----- arch/arm/cpu/arm926ejs/orion5x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/pantheon/timer.c | 5 ----- arch/arm/cpu/arm926ejs/spear/timer.c | 5 ----- arch/arm/cpu/arm926ejs/versatile/timer.c | 5 ----- arch/arm/cpu/armv7/mx5/timer.c | 5 ----- arch/arm/cpu/armv7/omap-common/timer.c | 5 ----- arch/arm/cpu/armv7/s5p-common/timer.c | 5 ----- arch/arm/cpu/armv7/tegra2/timer.c | 5 ----- arch/arm/cpu/armv7/u8500/timer.c | 5 ----- arch/arm/cpu/ixp/timer.c | 5 ----- arch/arm/cpu/lh7a40x/timer.c | 5 ----- arch/arm/cpu/pxa/timer.c | 5 ----- arch/arm/cpu/s3c44b0/timer.c | 5 ----- arch/arm/cpu/sa1100/timer.c | 5 ----- arch/avr32/cpu/interrupts.c | 16 ---------------- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 4 ---- arch/m68k/lib/board.c | 2 -- arch/m68k/lib/time.c | 16 ++-------------- arch/microblaze/cpu/timer.c | 5 ----- arch/mips/cpu/mips32/time.c | 6 ------ arch/nios2/cpu/interrupts.c | 6 ------ arch/powerpc/lib/board.c | 2 -- arch/powerpc/lib/interrupts.c | 5 ----- arch/sh/lib/time.c | 7 +------ arch/sh/lib/time_sh2.c | 9 ++------- arch/sparc/lib/board.c | 2 -- arch/sparc/lib/interrupts.c | 5 ----- arch/x86/lib/board.c | 2 -- arch/x86/lib/timer.c | 5 ----- board/armltd/integrator/timer.c | 6 ------ include/common.h | 1 - 49 files changed, 5 insertions(+), 254 deletions(-)
diff --git a/arch/arm/cpu/arm1136/mx31/timer.c b/arch/arm/cpu/arm1136/mx31/timer.c index c4bc3b3..d51acbb 100644 --- a/arch/arm/cpu/arm1136/mx31/timer.c +++ b/arch/arm/cpu/arm1136/mx31/timer.c @@ -147,11 +147,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - gd->tbl = time_to_tick(t); -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm1136/mx35/timer.c b/arch/arm/cpu/arm1136/mx35/timer.c index db1e2c9..6dfb63a 100644 --- a/arch/arm/cpu/arm1136/mx35/timer.c +++ b/arch/arm/cpu/arm1136/mx35/timer.c @@ -92,10 +92,6 @@ ulong get_timer(ulong base) return (tmp / 1000) - base; }
-void set_timer(ulong t) -{ -} - /* * delay x useconds AND preserve advance timstamp value * GPTCNT is now supposed to tick 1 by 1 us. diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c index 228ceba..d6267ba 100644 --- a/arch/arm/cpu/arm1136/omap24xx/timer.c +++ b/arch/arm/cpu/arm1136/omap24xx/timer.c @@ -67,11 +67,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - gd->tbl = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm1176/s3c64xx/timer.c b/arch/arm/cpu/arm1176/s3c64xx/timer.c index 9768319..8e54060 100644 --- a/arch/arm/cpu/arm1176/s3c64xx/timer.c +++ b/arch/arm/cpu/arm1176/s3c64xx/timer.c @@ -159,11 +159,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t * (timer_load_val / (100 * CONFIG_SYS_HZ)); -} - void __udelay(unsigned long usec) { unsigned long long tmp; diff --git a/arch/arm/cpu/arm1176/tnetv107x/timer.c b/arch/arm/cpu/arm1176/tnetv107x/timer.c index a7a400d..c27375c 100644 --- a/arch/arm/cpu/arm1176/tnetv107x/timer.c +++ b/arch/arm/cpu/arm1176/tnetv107x/timer.c @@ -88,11 +88,6 @@ ulong get_timer(ulong base) return (get_timer_raw() / (TIMER_LOAD_VAL / TIM_CLK_DIV)) - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - unsigned long long get_ticks(void) { return get_timer(0); diff --git a/arch/arm/cpu/arm720t/interrupts.c b/arch/arm/cpu/arm720t/interrupts.c index eb8d425..164ca5d 100644 --- a/arch/arm/cpu/arm720t/interrupts.c +++ b/arch/arm/cpu/arm720t/interrupts.c @@ -219,11 +219,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/arm920t/a320/timer.c b/arch/arm/cpu/arm920t/a320/timer.c index 95cb8fd..b9c83c0 100644 --- a/arch/arm/cpu/arm920t/a320/timer.c +++ b/arch/arm/cpu/arm920t/a320/timer.c @@ -132,12 +132,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - debug("%s(%lx)\n", __func__, t); - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/arm920t/at91/timer.c b/arch/arm/cpu/arm920t/at91/timer.c index f0ad7d6..a69de57 100644 --- a/arch/arm/cpu/arm920t/at91/timer.c +++ b/arch/arm/cpu/arm920t/at91/timer.c @@ -83,11 +83,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->tbl = t; -} - void __udelay(unsigned long usec) { udelay_masked(usec); diff --git a/arch/arm/cpu/arm920t/at91rm9200/timer.c b/arch/arm/cpu/arm920t/at91rm9200/timer.c index 9c54bbe..0bcb775 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/timer.c +++ b/arch/arm/cpu/arm920t/at91rm9200/timer.c @@ -82,11 +82,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { udelay_masked(usec); diff --git a/arch/arm/cpu/arm920t/imx/timer.c b/arch/arm/cpu/arm920t/imx/timer.c index b06b518..ff85a41 100644 --- a/arch/arm/cpu/arm920t/imx/timer.c +++ b/arch/arm/cpu/arm920t/imx/timer.c @@ -62,11 +62,6 @@ ulong get_timer (ulong base) return get_timer_masked() - base; }
-void set_timer (ulong t) -{ - /* nop */ -} - void reset_timer_masked (void) { TCTL1 &= ~TCTL_TEN; diff --git a/arch/arm/cpu/arm920t/ks8695/timer.c b/arch/arm/cpu/arm920t/ks8695/timer.c index 886e370..8e14109 100644 --- a/arch/arm/cpu/arm920t/ks8695/timer.c +++ b/arch/arm/cpu/arm920t/ks8695/timer.c @@ -76,11 +76,6 @@ ulong get_timer(ulong base) return (get_timer_masked() - base); }
-void set_timer(ulong t) -{ - timer_ticks = t; -} - void __udelay(ulong usec) { ulong start = get_timer_masked(); diff --git a/arch/arm/cpu/arm920t/s3c24x0/timer.c b/arch/arm/cpu/arm920t/s3c24x0/timer.c index f17b7ea..bba06d5 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/timer.c +++ b/arch/arm/cpu/arm920t/s3c24x0/timer.c @@ -94,11 +94,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/arm925t/timer.c b/arch/arm/cpu/arm925t/timer.c index 7dfe2b5..fdaeda5 100644 --- a/arch/arm/cpu/arm925t/timer.c +++ b/arch/arm/cpu/arm925t/timer.c @@ -75,11 +75,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/armada100/timer.c b/arch/arm/cpu/arm926ejs/armada100/timer.c index 5d911c5..eb49234 100644 --- a/arch/arm/cpu/arm926ejs/armada100/timer.c +++ b/arch/arm/cpu/arm926ejs/armada100/timer.c @@ -111,11 +111,6 @@ ulong get_timer(ulong base) base); }
-void set_timer(ulong t) -{ - gd->tbu = t; -} - void __udelay(unsigned long usec) { ulong delayticks; diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c index 3e80329..e890edb 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c @@ -122,11 +122,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - void __udelay(unsigned long usec) { uint current; diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c index 14f0c2d..af26b4c 100644 --- a/arch/arm/cpu/arm926ejs/mx25/timer.c +++ b/arch/arm/cpu/arm926ejs/mx25/timer.c @@ -170,11 +170,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = time_to_tick(t); -} - /* delay x useconds AND preserve advance timstamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c index 5c1cf01..127e670 100644 --- a/arch/arm/cpu/arm926ejs/mx27/timer.c +++ b/arch/arm/cpu/arm926ejs/mx27/timer.c @@ -173,11 +173,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = time_to_tick(t); -} - /* delay x useconds AND preserve advance timstamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c index 88a0ee6..f2e4deb 100644 --- a/arch/arm/cpu/arm926ejs/omap/timer.c +++ b/arch/arm/cpu/arm926ejs/omap/timer.c @@ -76,11 +76,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c index 9d45260..f691c99 100644 --- a/arch/arm/cpu/arm926ejs/orion5x/timer.c +++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c @@ -129,11 +129,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - static inline ulong uboot_cntr_val(void) { return readl(CNTMR_VAL_REG(UBOOT_CNTR)); diff --git a/arch/arm/cpu/arm926ejs/pantheon/timer.c b/arch/arm/cpu/arm926ejs/pantheon/timer.c index ca7f7f0..b487416 100644 --- a/arch/arm/cpu/arm926ejs/pantheon/timer.c +++ b/arch/arm/cpu/arm926ejs/pantheon/timer.c @@ -119,11 +119,6 @@ ulong get_timer(ulong base) base); }
-void set_timer(ulong t) -{ - gd->tbu = t; -} - void __udelay(unsigned long usec) { ulong delayticks; diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c index 66cf4de..7305abd 100644 --- a/arch/arm/cpu/arm926ejs/spear/timer.c +++ b/arch/arm/cpu/arm926ejs/spear/timer.c @@ -87,11 +87,6 @@ ulong get_timer(ulong base) return (get_timer_masked() / GPT_RESOLUTION) - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - void __udelay(unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/arm926ejs/versatile/timer.c b/arch/arm/cpu/arm926ejs/versatile/timer.c index 2e243b1..0e51a63 100644 --- a/arch/arm/cpu/arm926ejs/versatile/timer.c +++ b/arch/arm/cpu/arm926ejs/versatile/timer.c @@ -105,11 +105,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/armv7/mx5/timer.c b/arch/arm/cpu/armv7/mx5/timer.c index 1972f64..40ee0be 100644 --- a/arch/arm/cpu/armv7/mx5/timer.c +++ b/arch/arm/cpu/armv7/mx5/timer.c @@ -99,11 +99,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/armv7/omap-common/timer.c b/arch/arm/cpu/armv7/omap-common/timer.c index 59bbca8..a0f6b7c 100644 --- a/arch/arm/cpu/armv7/omap-common/timer.c +++ b/arch/arm/cpu/armv7/omap-common/timer.c @@ -73,11 +73,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->tbl = t; -} - /* delay x useconds */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/armv7/s5p-common/timer.c b/arch/arm/cpu/armv7/s5p-common/timer.c index b750d16..0b69f06 100644 --- a/arch/arm/cpu/armv7/s5p-common/timer.c +++ b/arch/arm/cpu/armv7/s5p-common/timer.c @@ -60,11 +60,6 @@ unsigned long get_timer(unsigned long base) return get_timer_masked() - base; }
-void set_timer(unsigned long t) -{ - gd->tbl = t; -} - /* delay x useconds */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/armv7/tegra2/timer.c b/arch/arm/cpu/armv7/tegra2/timer.c index fb061d0..4458de9 100644 --- a/arch/arm/cpu/armv7/tegra2/timer.c +++ b/arch/arm/cpu/armv7/tegra2/timer.c @@ -58,11 +58,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->tbl = t; -} - /* delay x useconds */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/armv7/u8500/timer.c b/arch/arm/cpu/armv7/u8500/timer.c index 8e96eaa..79aad99 100644 --- a/arch/arm/cpu/armv7/u8500/timer.c +++ b/arch/arm/cpu/armv7/u8500/timer.c @@ -129,11 +129,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->tbl = t; -} - /* * Emulation of Power architecture long long timebase. * diff --git a/arch/arm/cpu/ixp/timer.c b/arch/arm/cpu/ixp/timer.c index 9f3ea42..c25e72f 100644 --- a/arch/arm/cpu/ixp/timer.c +++ b/arch/arm/cpu/ixp/timer.c @@ -104,11 +104,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->timestamp = time_to_tick(t); -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/lh7a40x/timer.c b/arch/arm/cpu/lh7a40x/timer.c index 2691315..6c6277d 100644 --- a/arch/arm/cpu/lh7a40x/timer.c +++ b/arch/arm/cpu/lh7a40x/timer.c @@ -85,11 +85,6 @@ ulong get_timer (ulong base) return (get_timer_masked() - base); }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo,tmp; diff --git a/arch/arm/cpu/pxa/timer.c b/arch/arm/cpu/pxa/timer.c index ec950c7..8900a70 100644 --- a/arch/arm/cpu/pxa/timer.c +++ b/arch/arm/cpu/pxa/timer.c @@ -74,11 +74,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - /* nop */ -} - void __udelay (unsigned long usec) { udelay_masked (usec); diff --git a/arch/arm/cpu/s3c44b0/timer.c b/arch/arm/cpu/s3c44b0/timer.c index 6f1d8f6..d30e1aa 100644 --- a/arch/arm/cpu/s3c44b0/timer.c +++ b/arch/arm/cpu/s3c44b0/timer.c @@ -70,11 +70,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/sa1100/timer.c b/arch/arm/cpu/sa1100/timer.c index 0207501..10ad964 100644 --- a/arch/arm/cpu/sa1100/timer.c +++ b/arch/arm/cpu/sa1100/timer.c @@ -44,11 +44,6 @@ ulong get_timer (ulong base) return get_timer_masked (); }
-void set_timer (ulong t) -{ - /* nop */ -} - void __udelay (unsigned long usec) { udelay_masked (usec); diff --git a/arch/avr32/cpu/interrupts.c b/arch/avr32/cpu/interrupts.c index c6ea435..8406f91 100644 --- a/arch/avr32/cpu/interrupts.c +++ b/arch/avr32/cpu/interrupts.c @@ -77,22 +77,6 @@ unsigned long get_timer(unsigned long base) return (unsigned long)(now >> 32) - base; }
-void set_timer(unsigned long t) -{ - unsigned long long ticks = t; - unsigned long lo, hi, hi_new; - - ticks = (ticks * get_tbclk()) / CONFIG_SYS_HZ; - hi = ticks >> 32; - lo = ticks & 0xffffffffUL; - - do { - timer_overflow = hi; - sysreg_write(COUNT, lo); - hi_new = timer_overflow; - } while (hi_new != hi); -} - /* * For short delays only. It will overflow after a few seconds. */ diff --git a/arch/m68k/cpu/mcf547x_8x/slicetimer.c b/arch/m68k/cpu/mcf547x_8x/slicetimer.c index 8dc010a..49dba6a 100644 --- a/arch/m68k/cpu/mcf547x_8x/slicetimer.c +++ b/arch/m68k/cpu/mcf547x_8x/slicetimer.c @@ -105,8 +105,4 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; -} #endif /* CONFIG_SLTTMR */ diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c index 6a892db..945ab66 100644 --- a/arch/m68k/lib/board.c +++ b/arch/m68k/lib/board.c @@ -574,8 +574,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
udelay (20);
- set_timer (0); - /* Insert function pointers now that we have relocated the code */
/* Initialize from environment */ diff --git a/arch/m68k/lib/time.c b/arch/m68k/lib/time.c index 7eaea5e..d10bcc7 100644 --- a/arch/m68k/lib/time.c +++ b/arch/m68k/lib/time.c @@ -126,10 +126,6 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; -} #endif /* CONFIG_MCFTMR */
#if defined(CONFIG_MCFPIT) @@ -173,14 +169,6 @@ void timer_init(void) timerp->pcsr |= PIT_PCSR_PRE(CONFIG_SYS_PIT_PRESCALE) | PIT_PCSR_EN; }
-void set_timer(ulong t) -{ - volatile pit_t *timerp = (pit_t *) (CONFIG_SYS_PIT_BASE); - - timestamp = 0; - timerp->pmr = lastinc = 0; -} - ulong get_timer(ulong base) { unsigned short now, diff; @@ -196,8 +184,8 @@ ulong get_timer(ulong base)
void wait_ticks(unsigned long ticks) { - set_timer(0); - while (get_timer(0) < ticks) ; + u32 start = get_timer(0); + while (get_timer(start) < ticks) ; } #endif /* CONFIG_MCFPIT */
diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index 4936c62..59ed126 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -45,11 +45,6 @@ ulong get_timer (ulong base) } #endif
-void set_timer (ulong t) -{ - timestamp = t; -} - #ifdef CONFIG_SYS_INTC_0 #ifdef CONFIG_SYS_TIMER_0 microblaze_timer_t *tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR); diff --git a/arch/mips/cpu/mips32/time.c b/arch/mips/cpu/mips32/time.c index 0e66441..b0a9c1f 100644 --- a/arch/mips/cpu/mips32/time.c +++ b/arch/mips/cpu/mips32/time.c @@ -64,12 +64,6 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; - write_c0_compare(read_c0_count() + CYCLES_PER_JIFFY); -} - void __udelay(unsigned long usec) { unsigned int tmo; diff --git a/arch/nios2/cpu/interrupts.c b/arch/nios2/cpu/interrupts.c index 63acfa9..0a97fa6 100644 --- a/arch/nios2/cpu/interrupts.c +++ b/arch/nios2/cpu/interrupts.c @@ -98,12 +98,6 @@ ulong get_timer (ulong base) return (timestamp - base); }
-void set_timer (ulong t) -{ - timestamp = t; -} - - /* The board must handle this interrupt if a timer is not * provided. */ diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c index aaa5add..22bbc52 100644 --- a/arch/powerpc/lib/board.c +++ b/arch/powerpc/lib/board.c @@ -932,8 +932,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
udelay (20);
- set_timer (0); - /* Initialize from environment */ if ((s = getenv ("loadaddr")) != NULL) { load_addr = simple_strtoul (s, NULL, 16); diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c index f603170..847ad37 100644 --- a/arch/powerpc/lib/interrupts.c +++ b/arch/powerpc/lib/interrupts.c @@ -146,8 +146,3 @@ ulong get_timer (ulong base) { return (timestamp - base); } - -void set_timer (ulong t) -{ - timestamp = t; -} diff --git a/arch/sh/lib/time.c b/arch/sh/lib/time.c index bc1656f..c4bfc86 100644 --- a/arch/sh/lib/time.c +++ b/arch/sh/lib/time.c @@ -139,15 +139,10 @@ unsigned long get_timer (unsigned long base) return tick_to_time(get_ticks()) - base; }
-void set_timer (unsigned long t) -{ - writel((0 - t), TCNT0); -} - void reset_timer (void) { tmu_timer_stop(0); - set_timer (0); + writel(0, TCNT0); tmu_timer_start(0); }
diff --git a/arch/sh/lib/time_sh2.c b/arch/sh/lib/time_sh2.c index 789b46f..a5c838b 100644 --- a/arch/sh/lib/time_sh2.c +++ b/arch/sh/lib/time_sh2.c @@ -54,7 +54,7 @@ int timer_init(void)
/* User Device 0 only */ cmt_timer_stop(0); - set_timer(CMT_TIMER_RESET); + writew(CMT_TIMER_RESET, CMCOR_0); cmt_timer_start(0);
return 0; @@ -90,15 +90,10 @@ ulong get_timer(ulong base) return (get_usec() / 1000) - base; }
-void set_timer(ulong t) -{ - writew((u16) t, CMCOR_0); -} - void reset_timer(void) { cmt_timer_stop(0); - set_timer(CMT_TIMER_RESET); + writew(CMT_TIMER_RESET, CMCOR_0); cmt0_timer = 0; cmt_timer_start(0); } diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c index 386cd04..6b705e5 100644 --- a/arch/sparc/lib/board.c +++ b/arch/sparc/lib/board.c @@ -365,8 +365,6 @@ void board_init_f(ulong bootflag)
udelay(20);
- set_timer(0); - /* Initialize from environment */ if ((s = getenv("loadaddr")) != NULL) { load_addr = simple_strtoul(s, NULL, 16); diff --git a/arch/sparc/lib/interrupts.c b/arch/sparc/lib/interrupts.c index 4c73b82..5274311 100644 --- a/arch/sparc/lib/interrupts.c +++ b/arch/sparc/lib/interrupts.c @@ -100,11 +100,6 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; -} - void timer_interrupt_init(void) { int irq; diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index df54222..c92291b 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -363,8 +363,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
udelay(20);
- set_timer (0); - /* Initialize from environment */ if ((s = getenv ("loadaddr")) != NULL) { load_addr = simple_strtoul (s, NULL, 16); diff --git a/arch/x86/lib/timer.c b/arch/x86/lib/timer.c index 8fc68cd..199ca8e 100644 --- a/arch/x86/lib/timer.c +++ b/arch/x86/lib/timer.c @@ -103,8 +103,3 @@ ulong get_timer (ulong base) { return (system_ticks - base); } - -void set_timer (ulong t) -{ - system_ticks = t; -} diff --git a/board/armltd/integrator/timer.c b/board/armltd/integrator/timer.c index 7562ffa..5406066 100644 --- a/board/armltd/integrator/timer.c +++ b/board/armltd/integrator/timer.c @@ -117,12 +117,6 @@ ulong get_timer (ulong base_ticks) return get_timer_masked () - base_ticks; }
-void set_timer (ulong ticks) -{ - timestamp = ticks; - total_count = ticks * div_timer; -} - /* delay usec useconds */ void __udelay (unsigned long usec) { diff --git a/include/common.h b/include/common.h index 2c8513a..1f5c8fa 100644 --- a/include/common.h +++ b/include/common.h @@ -587,7 +587,6 @@ void irq_install_handler(int, interrupt_handler_t *, void *); void irq_free_handler (int); void reset_timer (void); ulong get_timer (ulong base); -void set_timer (ulong t); void enable_interrupts (void); int disable_interrupts (void);
-- 1.7.5.2.317.g391b14

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- Changes since v2: - Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6 - Updated description
arch/arm/cpu/arm1136/mx31/timer.c | 5 ----- arch/arm/cpu/arm1136/mx35/timer.c | 4 ---- arch/arm/cpu/arm1136/omap24xx/timer.c | 5 ----- arch/arm/cpu/arm1176/s3c64xx/timer.c | 5 ----- arch/arm/cpu/arm1176/tnetv107x/timer.c | 5 ----- arch/arm/cpu/arm720t/interrupts.c | 5 ----- arch/arm/cpu/arm920t/a320/timer.c | 6 ------ arch/arm/cpu/arm920t/at91/timer.c | 5 ----- arch/arm/cpu/arm920t/at91rm9200/timer.c | 5 ----- arch/arm/cpu/arm920t/imx/timer.c | 5 ----- arch/arm/cpu/arm920t/ks8695/timer.c | 5 ----- arch/arm/cpu/arm920t/s3c24x0/timer.c | 5 ----- arch/arm/cpu/arm925t/timer.c | 5 ----- arch/arm/cpu/arm926ejs/armada100/timer.c | 5 ----- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx25/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx27/timer.c | 5 ----- arch/arm/cpu/arm926ejs/omap/timer.c | 5 ----- arch/arm/cpu/arm926ejs/orion5x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/pantheon/timer.c | 5 ----- arch/arm/cpu/arm926ejs/spear/timer.c | 5 ----- arch/arm/cpu/arm926ejs/versatile/timer.c | 5 ----- arch/arm/cpu/armv7/mx5/timer.c | 5 ----- arch/arm/cpu/armv7/omap-common/timer.c | 5 ----- arch/arm/cpu/armv7/s5p-common/timer.c | 5 ----- arch/arm/cpu/armv7/tegra2/timer.c | 5 ----- arch/arm/cpu/armv7/u8500/timer.c | 5 ----- arch/arm/cpu/ixp/timer.c | 5 ----- arch/arm/cpu/lh7a40x/timer.c | 5 ----- arch/arm/cpu/pxa/timer.c | 5 ----- arch/arm/cpu/s3c44b0/timer.c | 5 ----- arch/arm/cpu/sa1100/timer.c | 5 ----- arch/avr32/cpu/interrupts.c | 16 ---------------- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 4 ---- arch/m68k/lib/board.c | 2 -- arch/m68k/lib/time.c | 16 ++-------------- arch/microblaze/cpu/timer.c | 5 ----- arch/mips/cpu/mips32/time.c | 6 ------ arch/nios2/cpu/interrupts.c | 6 ------ arch/powerpc/lib/board.c | 2 -- arch/powerpc/lib/interrupts.c | 5 ----- arch/sh/lib/time.c | 7 +------ arch/sh/lib/time_sh2.c | 9 ++------- arch/sparc/lib/board.c | 2 -- arch/sparc/lib/interrupts.c | 5 ----- arch/x86/lib/board.c | 2 -- arch/x86/lib/timer.c | 5 ----- board/armltd/integrator/timer.c | 6 ------ include/common.h | 1 - 49 files changed, 5 insertions(+), 254 deletions(-)
diff --git a/arch/arm/cpu/arm1136/mx31/timer.c b/arch/arm/cpu/arm1136/mx31/timer.c index c4bc3b3..d51acbb 100644 --- a/arch/arm/cpu/arm1136/mx31/timer.c +++ b/arch/arm/cpu/arm1136/mx31/timer.c @@ -147,11 +147,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - gd->tbl = time_to_tick(t); -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm1136/mx35/timer.c b/arch/arm/cpu/arm1136/mx35/timer.c index db1e2c9..6dfb63a 100644 --- a/arch/arm/cpu/arm1136/mx35/timer.c +++ b/arch/arm/cpu/arm1136/mx35/timer.c @@ -92,10 +92,6 @@ ulong get_timer(ulong base) return (tmp / 1000) - base; }
-void set_timer(ulong t) -{ -} - /* * delay x useconds AND preserve advance timstamp value * GPTCNT is now supposed to tick 1 by 1 us. diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c index 228ceba..d6267ba 100644 --- a/arch/arm/cpu/arm1136/omap24xx/timer.c +++ b/arch/arm/cpu/arm1136/omap24xx/timer.c @@ -67,11 +67,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - gd->tbl = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm1176/s3c64xx/timer.c b/arch/arm/cpu/arm1176/s3c64xx/timer.c index 9768319..8e54060 100644 --- a/arch/arm/cpu/arm1176/s3c64xx/timer.c +++ b/arch/arm/cpu/arm1176/s3c64xx/timer.c @@ -159,11 +159,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t * (timer_load_val / (100 * CONFIG_SYS_HZ)); -} - void __udelay(unsigned long usec) { unsigned long long tmp; diff --git a/arch/arm/cpu/arm1176/tnetv107x/timer.c b/arch/arm/cpu/arm1176/tnetv107x/timer.c index a7a400d..c27375c 100644 --- a/arch/arm/cpu/arm1176/tnetv107x/timer.c +++ b/arch/arm/cpu/arm1176/tnetv107x/timer.c @@ -88,11 +88,6 @@ ulong get_timer(ulong base) return (get_timer_raw() / (TIMER_LOAD_VAL / TIM_CLK_DIV)) - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - unsigned long long get_ticks(void) { return get_timer(0); diff --git a/arch/arm/cpu/arm720t/interrupts.c b/arch/arm/cpu/arm720t/interrupts.c index eb8d425..164ca5d 100644 --- a/arch/arm/cpu/arm720t/interrupts.c +++ b/arch/arm/cpu/arm720t/interrupts.c @@ -219,11 +219,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/arm920t/a320/timer.c b/arch/arm/cpu/arm920t/a320/timer.c index 95cb8fd..b9c83c0 100644 --- a/arch/arm/cpu/arm920t/a320/timer.c +++ b/arch/arm/cpu/arm920t/a320/timer.c @@ -132,12 +132,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - debug("%s(%lx)\n", __func__, t); - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/arm920t/at91/timer.c b/arch/arm/cpu/arm920t/at91/timer.c index f0ad7d6..a69de57 100644 --- a/arch/arm/cpu/arm920t/at91/timer.c +++ b/arch/arm/cpu/arm920t/at91/timer.c @@ -83,11 +83,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->tbl = t; -} - void __udelay(unsigned long usec) { udelay_masked(usec); diff --git a/arch/arm/cpu/arm920t/at91rm9200/timer.c b/arch/arm/cpu/arm920t/at91rm9200/timer.c index 9c54bbe..0bcb775 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/timer.c +++ b/arch/arm/cpu/arm920t/at91rm9200/timer.c @@ -82,11 +82,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { udelay_masked(usec); diff --git a/arch/arm/cpu/arm920t/imx/timer.c b/arch/arm/cpu/arm920t/imx/timer.c index b06b518..ff85a41 100644 --- a/arch/arm/cpu/arm920t/imx/timer.c +++ b/arch/arm/cpu/arm920t/imx/timer.c @@ -62,11 +62,6 @@ ulong get_timer (ulong base) return get_timer_masked() - base; }
-void set_timer (ulong t) -{ - /* nop */ -} - void reset_timer_masked (void) { TCTL1 &= ~TCTL_TEN; diff --git a/arch/arm/cpu/arm920t/ks8695/timer.c b/arch/arm/cpu/arm920t/ks8695/timer.c index 886e370..8e14109 100644 --- a/arch/arm/cpu/arm920t/ks8695/timer.c +++ b/arch/arm/cpu/arm920t/ks8695/timer.c @@ -76,11 +76,6 @@ ulong get_timer(ulong base) return (get_timer_masked() - base); }
-void set_timer(ulong t) -{ - timer_ticks = t; -} - void __udelay(ulong usec) { ulong start = get_timer_masked(); diff --git a/arch/arm/cpu/arm920t/s3c24x0/timer.c b/arch/arm/cpu/arm920t/s3c24x0/timer.c index f17b7ea..bba06d5 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/timer.c +++ b/arch/arm/cpu/arm920t/s3c24x0/timer.c @@ -94,11 +94,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/arm925t/timer.c b/arch/arm/cpu/arm925t/timer.c index 7dfe2b5..fdaeda5 100644 --- a/arch/arm/cpu/arm925t/timer.c +++ b/arch/arm/cpu/arm925t/timer.c @@ -75,11 +75,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/armada100/timer.c b/arch/arm/cpu/arm926ejs/armada100/timer.c index 5d911c5..eb49234 100644 --- a/arch/arm/cpu/arm926ejs/armada100/timer.c +++ b/arch/arm/cpu/arm926ejs/armada100/timer.c @@ -111,11 +111,6 @@ ulong get_timer(ulong base) base); }
-void set_timer(ulong t) -{ - gd->tbu = t; -} - void __udelay(unsigned long usec) { ulong delayticks; diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c index 3e80329..e890edb 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c @@ -122,11 +122,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - void __udelay(unsigned long usec) { uint current; diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c index 14f0c2d..af26b4c 100644 --- a/arch/arm/cpu/arm926ejs/mx25/timer.c +++ b/arch/arm/cpu/arm926ejs/mx25/timer.c @@ -170,11 +170,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = time_to_tick(t); -} - /* delay x useconds AND preserve advance timstamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c index 5c1cf01..127e670 100644 --- a/arch/arm/cpu/arm926ejs/mx27/timer.c +++ b/arch/arm/cpu/arm926ejs/mx27/timer.c @@ -173,11 +173,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = time_to_tick(t); -} - /* delay x useconds AND preserve advance timstamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c index 88a0ee6..f2e4deb 100644 --- a/arch/arm/cpu/arm926ejs/omap/timer.c +++ b/arch/arm/cpu/arm926ejs/omap/timer.c @@ -76,11 +76,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c index 9d45260..f691c99 100644 --- a/arch/arm/cpu/arm926ejs/orion5x/timer.c +++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c @@ -129,11 +129,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - static inline ulong uboot_cntr_val(void) { return readl(CNTMR_VAL_REG(UBOOT_CNTR)); diff --git a/arch/arm/cpu/arm926ejs/pantheon/timer.c b/arch/arm/cpu/arm926ejs/pantheon/timer.c index ca7f7f0..b487416 100644 --- a/arch/arm/cpu/arm926ejs/pantheon/timer.c +++ b/arch/arm/cpu/arm926ejs/pantheon/timer.c @@ -119,11 +119,6 @@ ulong get_timer(ulong base) base); }
-void set_timer(ulong t) -{ - gd->tbu = t; -} - void __udelay(unsigned long usec) { ulong delayticks; diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c index 66cf4de..7305abd 100644 --- a/arch/arm/cpu/arm926ejs/spear/timer.c +++ b/arch/arm/cpu/arm926ejs/spear/timer.c @@ -87,11 +87,6 @@ ulong get_timer(ulong base) return (get_timer_masked() / GPT_RESOLUTION) - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - void __udelay(unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/arm926ejs/versatile/timer.c b/arch/arm/cpu/arm926ejs/versatile/timer.c index 2e243b1..0e51a63 100644 --- a/arch/arm/cpu/arm926ejs/versatile/timer.c +++ b/arch/arm/cpu/arm926ejs/versatile/timer.c @@ -105,11 +105,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay (unsigned long usec) { diff --git a/arch/arm/cpu/armv7/mx5/timer.c b/arch/arm/cpu/armv7/mx5/timer.c index 1972f64..40ee0be 100644 --- a/arch/arm/cpu/armv7/mx5/timer.c +++ b/arch/arm/cpu/armv7/mx5/timer.c @@ -99,11 +99,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - timestamp = t; -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/armv7/omap-common/timer.c b/arch/arm/cpu/armv7/omap-common/timer.c index 59bbca8..a0f6b7c 100644 --- a/arch/arm/cpu/armv7/omap-common/timer.c +++ b/arch/arm/cpu/armv7/omap-common/timer.c @@ -73,11 +73,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->tbl = t; -} - /* delay x useconds */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/armv7/s5p-common/timer.c b/arch/arm/cpu/armv7/s5p-common/timer.c index b750d16..0b69f06 100644 --- a/arch/arm/cpu/armv7/s5p-common/timer.c +++ b/arch/arm/cpu/armv7/s5p-common/timer.c @@ -60,11 +60,6 @@ unsigned long get_timer(unsigned long base) return get_timer_masked() - base; }
-void set_timer(unsigned long t) -{ - gd->tbl = t; -} - /* delay x useconds */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/armv7/tegra2/timer.c b/arch/arm/cpu/armv7/tegra2/timer.c index fb061d0..4458de9 100644 --- a/arch/arm/cpu/armv7/tegra2/timer.c +++ b/arch/arm/cpu/armv7/tegra2/timer.c @@ -58,11 +58,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->tbl = t; -} - /* delay x useconds */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/armv7/u8500/timer.c b/arch/arm/cpu/armv7/u8500/timer.c index 8e96eaa..79aad99 100644 --- a/arch/arm/cpu/armv7/u8500/timer.c +++ b/arch/arm/cpu/armv7/u8500/timer.c @@ -129,11 +129,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->tbl = t; -} - /* * Emulation of Power architecture long long timebase. * diff --git a/arch/arm/cpu/ixp/timer.c b/arch/arm/cpu/ixp/timer.c index 9f3ea42..c25e72f 100644 --- a/arch/arm/cpu/ixp/timer.c +++ b/arch/arm/cpu/ixp/timer.c @@ -104,11 +104,6 @@ ulong get_timer(ulong base) return get_timer_masked() - base; }
-void set_timer(ulong t) -{ - gd->timestamp = time_to_tick(t); -} - /* delay x useconds AND preserve advance timestamp value */ void __udelay(unsigned long usec) { diff --git a/arch/arm/cpu/lh7a40x/timer.c b/arch/arm/cpu/lh7a40x/timer.c index 2691315..6c6277d 100644 --- a/arch/arm/cpu/lh7a40x/timer.c +++ b/arch/arm/cpu/lh7a40x/timer.c @@ -85,11 +85,6 @@ ulong get_timer (ulong base) return (get_timer_masked() - base); }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo,tmp; diff --git a/arch/arm/cpu/pxa/timer.c b/arch/arm/cpu/pxa/timer.c index ec950c7..8900a70 100644 --- a/arch/arm/cpu/pxa/timer.c +++ b/arch/arm/cpu/pxa/timer.c @@ -74,11 +74,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - /* nop */ -} - void __udelay (unsigned long usec) { udelay_masked (usec); diff --git a/arch/arm/cpu/s3c44b0/timer.c b/arch/arm/cpu/s3c44b0/timer.c index 6f1d8f6..d30e1aa 100644 --- a/arch/arm/cpu/s3c44b0/timer.c +++ b/arch/arm/cpu/s3c44b0/timer.c @@ -70,11 +70,6 @@ ulong get_timer (ulong base) return get_timer_masked () - base; }
-void set_timer (ulong t) -{ - timestamp = t; -} - void __udelay (unsigned long usec) { ulong tmo; diff --git a/arch/arm/cpu/sa1100/timer.c b/arch/arm/cpu/sa1100/timer.c index 0207501..10ad964 100644 --- a/arch/arm/cpu/sa1100/timer.c +++ b/arch/arm/cpu/sa1100/timer.c @@ -44,11 +44,6 @@ ulong get_timer (ulong base) return get_timer_masked (); }
-void set_timer (ulong t) -{ - /* nop */ -} - void __udelay (unsigned long usec) { udelay_masked (usec); diff --git a/arch/avr32/cpu/interrupts.c b/arch/avr32/cpu/interrupts.c index c6ea435..8406f91 100644 --- a/arch/avr32/cpu/interrupts.c +++ b/arch/avr32/cpu/interrupts.c @@ -77,22 +77,6 @@ unsigned long get_timer(unsigned long base) return (unsigned long)(now >> 32) - base; }
-void set_timer(unsigned long t) -{ - unsigned long long ticks = t; - unsigned long lo, hi, hi_new; - - ticks = (ticks * get_tbclk()) / CONFIG_SYS_HZ; - hi = ticks >> 32; - lo = ticks & 0xffffffffUL; - - do { - timer_overflow = hi; - sysreg_write(COUNT, lo); - hi_new = timer_overflow; - } while (hi_new != hi); -} - /* * For short delays only. It will overflow after a few seconds. */ diff --git a/arch/m68k/cpu/mcf547x_8x/slicetimer.c b/arch/m68k/cpu/mcf547x_8x/slicetimer.c index 8dc010a..49dba6a 100644 --- a/arch/m68k/cpu/mcf547x_8x/slicetimer.c +++ b/arch/m68k/cpu/mcf547x_8x/slicetimer.c @@ -105,8 +105,4 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; -} #endif /* CONFIG_SLTTMR */ diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c index 6a892db..945ab66 100644 --- a/arch/m68k/lib/board.c +++ b/arch/m68k/lib/board.c @@ -574,8 +574,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
udelay (20);
- set_timer (0); - /* Insert function pointers now that we have relocated the code */
/* Initialize from environment */ diff --git a/arch/m68k/lib/time.c b/arch/m68k/lib/time.c index 7eaea5e..d10bcc7 100644 --- a/arch/m68k/lib/time.c +++ b/arch/m68k/lib/time.c @@ -126,10 +126,6 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; -} #endif /* CONFIG_MCFTMR */
#if defined(CONFIG_MCFPIT) @@ -173,14 +169,6 @@ void timer_init(void) timerp->pcsr |= PIT_PCSR_PRE(CONFIG_SYS_PIT_PRESCALE) | PIT_PCSR_EN; }
-void set_timer(ulong t) -{ - volatile pit_t *timerp = (pit_t *) (CONFIG_SYS_PIT_BASE); - - timestamp = 0; - timerp->pmr = lastinc = 0; -} - ulong get_timer(ulong base) { unsigned short now, diff; @@ -196,8 +184,8 @@ ulong get_timer(ulong base)
void wait_ticks(unsigned long ticks) { - set_timer(0); - while (get_timer(0) < ticks) ; + u32 start = get_timer(0); + while (get_timer(start) < ticks) ; } #endif /* CONFIG_MCFPIT */
diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index 4936c62..59ed126 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -45,11 +45,6 @@ ulong get_timer (ulong base) } #endif
-void set_timer (ulong t) -{ - timestamp = t; -} - #ifdef CONFIG_SYS_INTC_0 #ifdef CONFIG_SYS_TIMER_0 microblaze_timer_t *tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR); diff --git a/arch/mips/cpu/mips32/time.c b/arch/mips/cpu/mips32/time.c index 0e66441..b0a9c1f 100644 --- a/arch/mips/cpu/mips32/time.c +++ b/arch/mips/cpu/mips32/time.c @@ -64,12 +64,6 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; - write_c0_compare(read_c0_count() + CYCLES_PER_JIFFY); -} - void __udelay(unsigned long usec) { unsigned int tmo; diff --git a/arch/nios2/cpu/interrupts.c b/arch/nios2/cpu/interrupts.c index 63acfa9..0a97fa6 100644 --- a/arch/nios2/cpu/interrupts.c +++ b/arch/nios2/cpu/interrupts.c @@ -98,12 +98,6 @@ ulong get_timer (ulong base) return (timestamp - base); }
-void set_timer (ulong t) -{ - timestamp = t; -} - - /* The board must handle this interrupt if a timer is not * provided. */ diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c index aaa5add..22bbc52 100644 --- a/arch/powerpc/lib/board.c +++ b/arch/powerpc/lib/board.c @@ -932,8 +932,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
udelay (20);
- set_timer (0); - /* Initialize from environment */ if ((s = getenv ("loadaddr")) != NULL) { load_addr = simple_strtoul (s, NULL, 16); diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c index f603170..847ad37 100644 --- a/arch/powerpc/lib/interrupts.c +++ b/arch/powerpc/lib/interrupts.c @@ -146,8 +146,3 @@ ulong get_timer (ulong base) { return (timestamp - base); } - -void set_timer (ulong t) -{ - timestamp = t; -} diff --git a/arch/sh/lib/time.c b/arch/sh/lib/time.c index bc1656f..c4bfc86 100644 --- a/arch/sh/lib/time.c +++ b/arch/sh/lib/time.c @@ -139,15 +139,10 @@ unsigned long get_timer (unsigned long base) return tick_to_time(get_ticks()) - base; }
-void set_timer (unsigned long t) -{ - writel((0 - t), TCNT0); -} - void reset_timer (void) { tmu_timer_stop(0); - set_timer (0); + writel(0, TCNT0); tmu_timer_start(0); }
diff --git a/arch/sh/lib/time_sh2.c b/arch/sh/lib/time_sh2.c index 789b46f..a5c838b 100644 --- a/arch/sh/lib/time_sh2.c +++ b/arch/sh/lib/time_sh2.c @@ -54,7 +54,7 @@ int timer_init(void)
/* User Device 0 only */ cmt_timer_stop(0); - set_timer(CMT_TIMER_RESET); + writew(CMT_TIMER_RESET, CMCOR_0); cmt_timer_start(0);
return 0; @@ -90,15 +90,10 @@ ulong get_timer(ulong base) return (get_usec() / 1000) - base; }
-void set_timer(ulong t) -{ - writew((u16) t, CMCOR_0); -} - void reset_timer(void) { cmt_timer_stop(0); - set_timer(CMT_TIMER_RESET); + writew(CMT_TIMER_RESET, CMCOR_0); cmt0_timer = 0; cmt_timer_start(0); } diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c index 386cd04..6b705e5 100644 --- a/arch/sparc/lib/board.c +++ b/arch/sparc/lib/board.c @@ -365,8 +365,6 @@ void board_init_f(ulong bootflag)
udelay(20);
- set_timer(0); - /* Initialize from environment */ if ((s = getenv("loadaddr")) != NULL) { load_addr = simple_strtoul(s, NULL, 16); diff --git a/arch/sparc/lib/interrupts.c b/arch/sparc/lib/interrupts.c index 4c73b82..5274311 100644 --- a/arch/sparc/lib/interrupts.c +++ b/arch/sparc/lib/interrupts.c @@ -100,11 +100,6 @@ ulong get_timer(ulong base) return (timestamp - base); }
-void set_timer(ulong t) -{ - timestamp = t; -} - void timer_interrupt_init(void) { int irq; diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index df54222..c92291b 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -363,8 +363,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
udelay(20);
- set_timer (0); - /* Initialize from environment */ if ((s = getenv ("loadaddr")) != NULL) { load_addr = simple_strtoul (s, NULL, 16); diff --git a/arch/x86/lib/timer.c b/arch/x86/lib/timer.c index 8fc68cd..199ca8e 100644 --- a/arch/x86/lib/timer.c +++ b/arch/x86/lib/timer.c @@ -103,8 +103,3 @@ ulong get_timer (ulong base) { return (system_ticks - base); } - -void set_timer (ulong t) -{ - system_ticks = t; -} diff --git a/board/armltd/integrator/timer.c b/board/armltd/integrator/timer.c index 7562ffa..5406066 100644 --- a/board/armltd/integrator/timer.c +++ b/board/armltd/integrator/timer.c @@ -117,12 +117,6 @@ ulong get_timer (ulong base_ticks) return get_timer_masked () - base_ticks; }
-void set_timer (ulong ticks) -{ - timestamp = ticks; - total_count = ticks * div_timer; -} - /* delay usec useconds */ void __udelay (unsigned long usec) { diff --git a/include/common.h b/include/common.h index 2c8513a..1f5c8fa 100644 --- a/include/common.h +++ b/include/common.h @@ -587,7 +587,6 @@ void irq_install_handler(int, interrupt_handler_t *, void *); void irq_free_handler (int); void reset_timer (void); ulong get_timer (ulong base); -void set_timer (ulong t); void enable_interrupts (void); int disable_interrupts (void);
-- 1.7.5.2.317.g391b14

Dear Graeme Russ,
In message 1310808899-3325-1-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Changes since v2:
- Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
- Updated description
arch/arm/cpu/arm1136/mx31/timer.c | 5 ----- arch/arm/cpu/arm1136/mx35/timer.c | 4 ---- arch/arm/cpu/arm1136/omap24xx/timer.c | 5 ----- arch/arm/cpu/arm1176/s3c64xx/timer.c | 5 ----- arch/arm/cpu/arm1176/tnetv107x/timer.c | 5 ----- arch/arm/cpu/arm720t/interrupts.c | 5 ----- arch/arm/cpu/arm920t/a320/timer.c | 6 ------ arch/arm/cpu/arm920t/at91/timer.c | 5 ----- arch/arm/cpu/arm920t/at91rm9200/timer.c | 5 ----- arch/arm/cpu/arm920t/imx/timer.c | 5 ----- arch/arm/cpu/arm920t/ks8695/timer.c | 5 ----- arch/arm/cpu/arm920t/s3c24x0/timer.c | 5 ----- arch/arm/cpu/arm925t/timer.c | 5 ----- arch/arm/cpu/arm926ejs/armada100/timer.c | 5 ----- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx25/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx27/timer.c | 5 ----- arch/arm/cpu/arm926ejs/omap/timer.c | 5 ----- arch/arm/cpu/arm926ejs/orion5x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/pantheon/timer.c | 5 ----- arch/arm/cpu/arm926ejs/spear/timer.c | 5 ----- arch/arm/cpu/arm926ejs/versatile/timer.c | 5 ----- arch/arm/cpu/armv7/mx5/timer.c | 5 ----- arch/arm/cpu/armv7/omap-common/timer.c | 5 ----- arch/arm/cpu/armv7/s5p-common/timer.c | 5 ----- arch/arm/cpu/armv7/tegra2/timer.c | 5 ----- arch/arm/cpu/armv7/u8500/timer.c | 5 ----- arch/arm/cpu/ixp/timer.c | 5 ----- arch/arm/cpu/lh7a40x/timer.c | 5 ----- arch/arm/cpu/pxa/timer.c | 5 ----- arch/arm/cpu/s3c44b0/timer.c | 5 ----- arch/arm/cpu/sa1100/timer.c | 5 ----- arch/avr32/cpu/interrupts.c | 16 ---------------- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 4 ---- arch/m68k/lib/board.c | 2 -- arch/m68k/lib/time.c | 16 ++-------------- arch/microblaze/cpu/timer.c | 5 ----- arch/mips/cpu/mips32/time.c | 6 ------ arch/nios2/cpu/interrupts.c | 6 ------ arch/powerpc/lib/board.c | 2 -- arch/powerpc/lib/interrupts.c | 5 ----- arch/sh/lib/time.c | 7 +------ arch/sh/lib/time_sh2.c | 9 ++------- arch/sparc/lib/board.c | 2 -- arch/sparc/lib/interrupts.c | 5 ----- arch/x86/lib/board.c | 2 -- arch/x86/lib/timer.c | 5 ----- board/armltd/integrator/timer.c | 6 ------ include/common.h | 1 - 49 files changed, 5 insertions(+), 254 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- drivers/block/mg_disk.c | 2 ++ drivers/mtd/cfi_flash.c | 4 ++++ 2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index b74307a..2198017 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -91,7 +91,9 @@ static unsigned int mg_wait (u32 expect, u32 msec) u32 from, cur, err;
err = MG_ERR_NONE; +#ifdef CONFIG_NIOS2 reset_timer(); +#endif from = get_timer(0);
status = readb(mg_base() + MG_REG_STATUS); diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index 6039e1f..3ac6c80 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -573,7 +573,9 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector, #endif
/* Wait for command completion */ +#ifdef CONFIG_NIOS2 reset_timer(); +#endif start = get_timer (0); while (flash_is_busy (info, sector)) { if (get_timer (start) > tout) { @@ -662,7 +664,9 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst, #endif
/* Wait for command completion */ +#ifdef CONFIG_NIOS2 reset_timer(); +#endif start = get_timer(0); while (1) { switch (info->portwidth) {

Dear Graeme Russ,
In message 1309261269-4363-5-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
drivers/block/mg_disk.c | 2 ++ drivers/mtd/cfi_flash.c | 4 ++++ 2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index b74307a..2198017 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -91,7 +91,9 @@ static unsigned int mg_wait (u32 expect, u32 msec) u32 from, cur, err;
err = MG_ERR_NONE; +#ifdef CONFIG_NIOS2 reset_timer(); +#endif
I don't think this is a good idea. Instead of making this depend on a specific architecture, we should make it depend on some feature.
I. e. please change "#ifdef CONFIG_NIOS2" into some "#ifdef CONFIG_BROKEN_TIMERS" or CONFIG_TERRIBLY_SLOW_CLOCK or the like.
Best regards,
Wolfgang Denk

--- Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6 - Introduce new #define CONFIG_SYS_LOW_RES_TIMER
drivers/block/mg_disk.c | 2 ++ drivers/mtd/cfi_flash.c | 4 ++++ include/configs/PCI5441.h | 1 + include/configs/PK1C20.h | 1 + include/configs/nios2-generic.h | 1 + 5 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index b74307a..921bce9 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -91,7 +91,9 @@ static unsigned int mg_wait (u32 expect, u32 msec) u32 from, cur, err;
err = MG_ERR_NONE; +#ifdef CONFIG_SYS_LOW_RES_TIMER reset_timer(); +#endif from = get_timer(0);
status = readb(mg_base() + MG_REG_STATUS); diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index 929f9a9..ac91dfd 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -573,7 +573,9 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector, #endif
/* Wait for command completion */ +#ifdef CONFIG_SYS_LOW_RES_TIMER reset_timer(); +#endif start = get_timer (0); while (flash_is_busy (info, sector)) { if (get_timer (start) > tout) { @@ -662,7 +664,9 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst, #endif
/* Wait for command completion */ +#ifdef CONFIG_SYS_LOW_RES_TIMER reset_timer(); +#endif start = get_timer(0); while (1) { switch (info->portwidth) { diff --git a/include/configs/PCI5441.h b/include/configs/PCI5441.h index 70775e7..ae5bc2e 100644 --- a/include/configs/PCI5441.h +++ b/include/configs/PCI5441.h @@ -118,6 +118,7 @@ * TMRMS represents the desired mecs per tick (msecs per interrupt). *----------------------------------------------------------------------*/ #define CONFIG_SYS_HZ 1000 /* Always 1000 */ +#define CONFIG_SYS_LOW_RES_TIMER #define CONFIG_SYS_NIOS_TMRBASE 0x00920860 /* Tick timer base addr */ #define CONFIG_SYS_NIOS_TMRIRQ 3 /* Timer IRQ num */ #define CONFIG_SYS_NIOS_TMRMS 10 /* Desired period (msec)*/ diff --git a/include/configs/PK1C20.h b/include/configs/PK1C20.h index b466c4b..95c30cc 100644 --- a/include/configs/PK1C20.h +++ b/include/configs/PK1C20.h @@ -128,6 +128,7 @@ * TMRMS represents the desired mecs per tick (msecs per interrupt). *----------------------------------------------------------------------*/ #define CONFIG_SYS_HZ 1000 /* Always 1000 */ +#define CONFIG_SYS_LOW_RES_TIMER #define CONFIG_SYS_NIOS_TMRBASE 0x02120820 /* Tick timer base addr */ #define CONFIG_SYS_NIOS_TMRIRQ 3 /* Timer IRQ num */ #define CONFIG_SYS_NIOS_TMRMS 10 /* Desired period */ diff --git a/include/configs/nios2-generic.h b/include/configs/nios2-generic.h index 53f2084..d57d53c 100644 --- a/include/configs/nios2-generic.h +++ b/include/configs/nios2-generic.h @@ -52,6 +52,7 @@ /* * TIMER */ +#define CONFIG_SYS_LOW_RES_TIMER #define CONFIG_SYS_NIOS_TMRBASE CONFIG_SYS_TIMER_BASE #define CONFIG_SYS_NIOS_TMRIRQ CONFIG_SYS_TIMER_IRQ #define CONFIG_SYS_HZ 1000 /* Always 1000 */ -- 1.7.5.2.317.g391b14

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- Changes since v2: - Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6 - Introduce new #define CONFIG_SYS_LOW_RES_TIMER
drivers/block/mg_disk.c | 2 ++ drivers/mtd/cfi_flash.c | 4 ++++ include/configs/PCI5441.h | 1 + include/configs/PK1C20.h | 1 + include/configs/nios2-generic.h | 1 + 5 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index b74307a..921bce9 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -91,7 +91,9 @@ static unsigned int mg_wait (u32 expect, u32 msec) u32 from, cur, err;
err = MG_ERR_NONE; +#ifdef CONFIG_SYS_LOW_RES_TIMER reset_timer(); +#endif from = get_timer(0);
status = readb(mg_base() + MG_REG_STATUS); diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index 929f9a9..ac91dfd 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -573,7 +573,9 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector, #endif
/* Wait for command completion */ +#ifdef CONFIG_SYS_LOW_RES_TIMER reset_timer(); +#endif start = get_timer (0); while (flash_is_busy (info, sector)) { if (get_timer (start) > tout) { @@ -662,7 +664,9 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst, #endif
/* Wait for command completion */ +#ifdef CONFIG_SYS_LOW_RES_TIMER reset_timer(); +#endif start = get_timer(0); while (1) { switch (info->portwidth) { diff --git a/include/configs/PCI5441.h b/include/configs/PCI5441.h index 70775e7..ae5bc2e 100644 --- a/include/configs/PCI5441.h +++ b/include/configs/PCI5441.h @@ -118,6 +118,7 @@ * TMRMS represents the desired mecs per tick (msecs per interrupt). *----------------------------------------------------------------------*/ #define CONFIG_SYS_HZ 1000 /* Always 1000 */ +#define CONFIG_SYS_LOW_RES_TIMER #define CONFIG_SYS_NIOS_TMRBASE 0x00920860 /* Tick timer base addr */ #define CONFIG_SYS_NIOS_TMRIRQ 3 /* Timer IRQ num */ #define CONFIG_SYS_NIOS_TMRMS 10 /* Desired period (msec)*/ diff --git a/include/configs/PK1C20.h b/include/configs/PK1C20.h index b466c4b..95c30cc 100644 --- a/include/configs/PK1C20.h +++ b/include/configs/PK1C20.h @@ -128,6 +128,7 @@ * TMRMS represents the desired mecs per tick (msecs per interrupt). *----------------------------------------------------------------------*/ #define CONFIG_SYS_HZ 1000 /* Always 1000 */ +#define CONFIG_SYS_LOW_RES_TIMER #define CONFIG_SYS_NIOS_TMRBASE 0x02120820 /* Tick timer base addr */ #define CONFIG_SYS_NIOS_TMRIRQ 3 /* Timer IRQ num */ #define CONFIG_SYS_NIOS_TMRMS 10 /* Desired period */ diff --git a/include/configs/nios2-generic.h b/include/configs/nios2-generic.h index 53f2084..d57d53c 100644 --- a/include/configs/nios2-generic.h +++ b/include/configs/nios2-generic.h @@ -52,6 +52,7 @@ /* * TIMER */ +#define CONFIG_SYS_LOW_RES_TIMER #define CONFIG_SYS_NIOS_TMRBASE CONFIG_SYS_TIMER_BASE #define CONFIG_SYS_NIOS_TMRIRQ CONFIG_SYS_TIMER_IRQ #define CONFIG_SYS_HZ 1000 /* Always 1000 */ -- 1.7.5.2.317.g391b14

Dear Graeme Russ,
In message 1310808956-3364-1-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Changes since v2:
- Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
- Introduce new #define CONFIG_SYS_LOW_RES_TIMER
drivers/block/mg_disk.c | 2 ++ drivers/mtd/cfi_flash.c | 4 ++++ include/configs/PCI5441.h | 1 + include/configs/PK1C20.h | 1 + include/configs/nios2-generic.h | 1 + 5 files changed, 9 insertions(+), 0 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- arch/arm/cpu/arm1136/mx31/timer.c | 5 ----- arch/arm/cpu/arm1136/mx35/timer.c | 5 ----- arch/arm/cpu/arm1136/omap24xx/timer.c | 5 ----- arch/arm/cpu/arm1176/s3c64xx/timer.c | 5 ----- arch/arm/cpu/arm1176/tnetv107x/timer.c | 9 --------- arch/arm/cpu/arm720t/interrupts.c | 5 ----- arch/arm/cpu/arm920t/a320/timer.c | 6 ------ arch/arm/cpu/arm920t/at91/timer.c | 6 ------ arch/arm/cpu/arm920t/at91rm9200/timer.c | 6 ------ arch/arm/cpu/arm920t/ep93xx/timer.c | 5 ----- arch/arm/cpu/arm920t/imx/timer.c | 6 ------ arch/arm/cpu/arm920t/ks8695/timer.c | 7 +------ arch/arm/cpu/arm920t/s3c24x0/timer.c | 6 ------ arch/arm/cpu/arm925t/timer.c | 6 ------ arch/arm/cpu/arm926ejs/armada100/timer.c | 5 ----- arch/arm/cpu/arm926ejs/davinci/timer.c | 5 ----- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx25/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx27/timer.c | 5 ----- arch/arm/cpu/arm926ejs/nomadik/timer.c | 12 +++++------- arch/arm/cpu/arm926ejs/omap/timer.c | 6 ------ arch/arm/cpu/arm926ejs/orion5x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/pantheon/timer.c | 5 ----- arch/arm/cpu/arm926ejs/spear/timer.c | 6 ------ arch/arm/cpu/arm926ejs/versatile/timer.c | 6 ------ arch/arm/cpu/armv7/mx5/timer.c | 5 ----- arch/arm/cpu/armv7/omap-common/timer.c | 5 ----- arch/arm/cpu/armv7/s5p-common/timer.c | 5 ----- arch/arm/cpu/armv7/tegra2/timer.c | 5 ----- arch/arm/cpu/ixp/timer.c | 5 ----- arch/arm/cpu/lh7a40x/timer.c | 6 ------ arch/arm/cpu/pxa/timer.c | 7 +------ arch/arm/cpu/s3c44b0/timer.c | 6 ------ arch/arm/cpu/sa1100/timer.c | 5 ----- arch/avr32/cpu/interrupts.c | 7 ------- arch/blackfin/cpu/interrupts.c | 5 ----- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 5 ----- arch/m68k/lib/time.c | 5 ----- arch/microblaze/cpu/timer.c | 7 +------ arch/mips/cpu/mips32/time.c | 6 ------ arch/powerpc/lib/interrupts.c | 5 ----- arch/sh/lib/time.c | 7 ------- arch/sh/lib/time_sh2.c | 8 -------- arch/sparc/lib/interrupts.c | 7 +------ arch/x86/lib/timer.c | 5 ----- board/armltd/integrator/timer.c | 5 ----- board/armltd/vexpress/ca9x4_ct_vxp.c | 5 ----- board/nvidia/common/board.c | 1 - 49 files changed, 9 insertions(+), 270 deletions(-)
diff --git a/arch/arm/cpu/arm1136/mx31/timer.c b/arch/arm/cpu/arm1136/mx31/timer.c index d51acbb..eac4ffb 100644 --- a/arch/arm/cpu/arm1136/mx31/timer.c +++ b/arch/arm/cpu/arm1136/mx31/timer.c @@ -113,11 +113,6 @@ void reset_timer_masked (void) gd->tbl = 0; /* start "advancing" time stamp from 0 */ }
-void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long long get_ticks (void) { ulong now = GPTCNT; /* current tick value */ diff --git a/arch/arm/cpu/arm1136/mx35/timer.c b/arch/arm/cpu/arm1136/mx35/timer.c index 6dfb63a..80c0675 100644 --- a/arch/arm/cpu/arm1136/mx35/timer.c +++ b/arch/arm/cpu/arm1136/mx35/timer.c @@ -73,11 +73,6 @@ inline ulong get_timer_masked(void) return val; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { ulong tmp; diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c index d6267ba..6f1ebbf 100644 --- a/arch/arm/cpu/arm1136/omap24xx/timer.c +++ b/arch/arm/cpu/arm1136/omap24xx/timer.c @@ -57,11 +57,6 @@ int timer_init (void) /* * timer without interrupts */ -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm1176/s3c64xx/timer.c b/arch/arm/cpu/arm1176/s3c64xx/timer.c index 8e54060..bc21f86 100644 --- a/arch/arm/cpu/arm1176/s3c64xx/timer.c +++ b/arch/arm/cpu/arm1176/s3c64xx/timer.c @@ -142,11 +142,6 @@ void reset_timer_masked(void) timestamp = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer_masked(void) { unsigned long long res = get_ticks(); diff --git a/arch/arm/cpu/arm1176/tnetv107x/timer.c b/arch/arm/cpu/arm1176/tnetv107x/timer.c index c27375c..b3123c5 100644 --- a/arch/arm/cpu/arm1176/tnetv107x/timer.c +++ b/arch/arm/cpu/arm1176/tnetv107x/timer.c @@ -60,15 +60,6 @@ int timer_init(void) return 0; }
-void reset_timer(void) -{ - lastinc = timestamp = 0; - - __raw_writel(0, ®s->tcr); - __raw_writel(0, ®s->tim34); - __raw_writel(2 << 22, ®s->tcr); -} - static ulong get_timer_raw(void) { ulong now = __raw_readl(®s->tim34); diff --git a/arch/arm/cpu/arm720t/interrupts.c b/arch/arm/cpu/arm720t/interrupts.c index 164ca5d..9cd7fee 100644 --- a/arch/arm/cpu/arm720t/interrupts.c +++ b/arch/arm/cpu/arm720t/interrupts.c @@ -209,11 +209,6 @@ int timer_init (void)
#if defined(CONFIG_IMPA7) || defined(CONFIG_EP7312) || defined(CONFIG_NETARM) || defined(CONFIG_ARMADILLO) || defined(CONFIG_LPC2292)
-void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm920t/a320/timer.c b/arch/arm/cpu/arm920t/a320/timer.c index b9c83c0..443d31d 100644 --- a/arch/arm/cpu/arm920t/a320/timer.c +++ b/arch/arm/cpu/arm920t/a320/timer.c @@ -81,12 +81,6 @@ void reset_timer_masked(void) debug("%s(): lastdec = %lx\n", __func__, lastdec); }
-void reset_timer(void) -{ - debug("%s()\n", __func__); - reset_timer_masked(); -} - /* * return timer ticks */ diff --git a/arch/arm/cpu/arm920t/at91/timer.c b/arch/arm/cpu/arm920t/at91/timer.c index a69de57..374cc25 100644 --- a/arch/arm/cpu/arm920t/at91/timer.c +++ b/arch/arm/cpu/arm920t/at91/timer.c @@ -72,12 +72,6 @@ int timer_init(void) /* * timer without interrupts */ - -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm920t/at91rm9200/timer.c b/arch/arm/cpu/arm920t/at91rm9200/timer.c index 0bcb775..9a1ae85 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/timer.c +++ b/arch/arm/cpu/arm920t/at91rm9200/timer.c @@ -71,12 +71,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm920t/ep93xx/timer.c b/arch/arm/cpu/arm920t/ep93xx/timer.c index 4a0ce4d..f19ec61 100644 --- a/arch/arm/cpu/arm920t/ep93xx/timer.c +++ b/arch/arm/cpu/arm920t/ep93xx/timer.c @@ -97,11 +97,6 @@ void reset_timer_masked(void) timer.ticks = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - void __udelay(unsigned long usec) { unsigned long long target; diff --git a/arch/arm/cpu/arm920t/imx/timer.c b/arch/arm/cpu/arm920t/imx/timer.c index ff85a41..cdb2148 100644 --- a/arch/arm/cpu/arm920t/imx/timer.c +++ b/arch/arm/cpu/arm920t/imx/timer.c @@ -51,12 +51,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm920t/ks8695/timer.c b/arch/arm/cpu/arm920t/ks8695/timer.c index 8e14109..c78fd90 100644 --- a/arch/arm/cpu/arm920t/ks8695/timer.c +++ b/arch/arm/cpu/arm920t/ks8695/timer.c @@ -33,7 +33,7 @@ ulong timer_ticks;
int timer_init (void) { - reset_timer(); + reset_timer_masked();
return 0; } @@ -55,11 +55,6 @@ void reset_timer_masked(void) timer_ticks = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer_masked(void) { /* Check for timer wrap */ diff --git a/arch/arm/cpu/arm920t/s3c24x0/timer.c b/arch/arm/cpu/arm920t/s3c24x0/timer.c index 22767c5..4e50291 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/timer.c +++ b/arch/arm/cpu/arm920t/s3c24x0/timer.c @@ -83,12 +83,6 @@ int timer_init(void) /* * timer without interrupts */ - -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm925t/timer.c b/arch/arm/cpu/arm925t/timer.c index fdaeda5..9c965e0 100644 --- a/arch/arm/cpu/arm925t/timer.c +++ b/arch/arm/cpu/arm925t/timer.c @@ -64,12 +64,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm926ejs/armada100/timer.c b/arch/arm/cpu/arm926ejs/armada100/timer.c index eb49234..86da0ce 100644 --- a/arch/arm/cpu/arm926ejs/armada100/timer.c +++ b/arch/arm/cpu/arm926ejs/armada100/timer.c @@ -100,11 +100,6 @@ ulong get_timer_masked(void) return gd->tbu; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return ((get_timer_masked() / (CONFIG_SYS_HZ_CLOCK / 1000)) - diff --git a/arch/arm/cpu/arm926ejs/davinci/timer.c b/arch/arm/cpu/arm926ejs/davinci/timer.c index 1c6fa4a..8b1734c 100644 --- a/arch/arm/cpu/arm926ejs/davinci/timer.c +++ b/arch/arm/cpu/arm926ejs/davinci/timer.c @@ -78,11 +78,6 @@ int timer_init(void) return(0); }
-void reset_timer(void) -{ - gd->timer_reset_value = get_ticks(); -} - /* * Get the current 64 bit timer tick count */ diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c index e890edb..5beb3f5 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c @@ -112,11 +112,6 @@ ulong get_timer_masked(void) return timestamp; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c index 6966b0d..5f54085 100644 --- a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c +++ b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c @@ -121,11 +121,6 @@ void __udelay(unsigned long usec) /*NOP*/; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c index af26b4c..9a84b50 100644 --- a/arch/arm/cpu/arm926ejs/mx25/timer.c +++ b/arch/arm/cpu/arm926ejs/mx25/timer.c @@ -130,11 +130,6 @@ void reset_timer_masked(void) timestamp = 0; /* start "advancing" time stamp from 0 */ }
-void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long long get_ticks (void) { struct gpt_regs *gpt = (struct gpt_regs *)IMX_GPT1_BASE; diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c index 127e670..058dbee 100644 --- a/arch/arm/cpu/arm926ejs/mx27/timer.c +++ b/arch/arm/cpu/arm926ejs/mx27/timer.c @@ -133,11 +133,6 @@ void reset_timer_masked(void) timestamp = 0; /* start "advancing" time stamp from 0 */ }
-void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long long get_ticks (void) { struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE; diff --git a/arch/arm/cpu/arm926ejs/nomadik/timer.c b/arch/arm/cpu/arm926ejs/nomadik/timer.c index 1d98ef3..1cd0e1f 100644 --- a/arch/arm/cpu/arm926ejs/nomadik/timer.c +++ b/arch/arm/cpu/arm926ejs/nomadik/timer.c @@ -40,16 +40,12 @@ /* Configure a free-running, auto-wrap counter with no prescaler */ int timer_init(void) { + ulong val; + writel(MTU_CRn_ENA | MTU_CRn_PRESCALE_1 | MTU_CRn_32BITS, CONFIG_SYS_TIMERBASE + MTU_CR(0)); - reset_timer(); - return 0; -}
-/* Restart counting from 0 */ -void reset_timer(void) -{ - ulong val; + /* Reset the timer */ writel(0, CONFIG_SYS_TIMERBASE + MTU_LR(0)); /* * The load-register isn't really immediate: it changes on clock @@ -59,6 +55,8 @@ void reset_timer(void) val = READ_TIMER(); while (READ_TIMER() == val) ; + + return 0; }
/* Return how many HZ passed since "base" */ diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c index f2e4deb..390c9c8 100644 --- a/arch/arm/cpu/arm926ejs/omap/timer.c +++ b/arch/arm/cpu/arm926ejs/omap/timer.c @@ -65,12 +65,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c index f691c99..5bc43c8 100644 --- a/arch/arm/cpu/arm926ejs/orion5x/timer.c +++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c @@ -119,11 +119,6 @@ ulong get_timer_masked(void) return timestamp; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm926ejs/pantheon/timer.c b/arch/arm/cpu/arm926ejs/pantheon/timer.c index b487416..2727adc 100644 --- a/arch/arm/cpu/arm926ejs/pantheon/timer.c +++ b/arch/arm/cpu/arm926ejs/pantheon/timer.c @@ -108,11 +108,6 @@ ulong get_timer_masked(void) return gd->tbu; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return ((get_timer_masked() / (CONFIG_SYS_HZ_CLOCK / 1000)) - diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c index 7305abd..cbef34f 100644 --- a/arch/arm/cpu/arm926ejs/spear/timer.c +++ b/arch/arm/cpu/arm926ejs/spear/timer.c @@ -76,12 +76,6 @@ int timer_init(void) /* * timer without interrupts */ - -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return (get_timer_masked() / GPT_RESOLUTION) - base; diff --git a/arch/arm/cpu/arm926ejs/versatile/timer.c b/arch/arm/cpu/arm926ejs/versatile/timer.c index 0e51a63..f58e151 100644 --- a/arch/arm/cpu/arm926ejs/versatile/timer.c +++ b/arch/arm/cpu/arm926ejs/versatile/timer.c @@ -94,12 +94,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/armv7/mx5/timer.c b/arch/arm/cpu/armv7/mx5/timer.c index 40ee0be..4525beb 100644 --- a/arch/arm/cpu/armv7/mx5/timer.c +++ b/arch/arm/cpu/armv7/mx5/timer.c @@ -69,11 +69,6 @@ int timer_init(void) return 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - void reset_timer_masked(void) { ulong val = __raw_readl(&cur_gpt->counter); diff --git a/arch/arm/cpu/armv7/omap-common/timer.c b/arch/arm/cpu/armv7/omap-common/timer.c index 5dcd044..24ab853 100644 --- a/arch/arm/cpu/armv7/omap-common/timer.c +++ b/arch/arm/cpu/armv7/omap-common/timer.c @@ -62,11 +62,6 @@ int timer_init(void) /* * timer without interrupts */ -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/armv7/s5p-common/timer.c b/arch/arm/cpu/armv7/s5p-common/timer.c index 0b69f06..359c21f 100644 --- a/arch/arm/cpu/armv7/s5p-common/timer.c +++ b/arch/arm/cpu/armv7/s5p-common/timer.c @@ -50,11 +50,6 @@ int timer_init(void) /* * timer without interrupts */ -void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long get_timer(unsigned long base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/armv7/tegra2/timer.c b/arch/arm/cpu/armv7/tegra2/timer.c index 4458de9..2761c12 100644 --- a/arch/arm/cpu/armv7/tegra2/timer.c +++ b/arch/arm/cpu/armv7/tegra2/timer.c @@ -48,11 +48,6 @@ struct timerus *timer_base = (struct timerus *)NV_PA_TMRUS_BASE; #define TIMER_LOAD_VAL 0xffffffff
/* timer without interrupts */ -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/ixp/timer.c b/arch/arm/cpu/ixp/timer.c index edf341f..1ab8cd3 100644 --- a/arch/arm/cpu/ixp/timer.c +++ b/arch/arm/cpu/ixp/timer.c @@ -61,11 +61,6 @@ ulong get_timer (ulong base) return timestamp - base; }
-void reset_timer (void) -{ - timestamp = 0; -} - int timer_init (void) { /* install interrupt handler for timer */ diff --git a/arch/arm/cpu/lh7a40x/timer.c b/arch/arm/cpu/lh7a40x/timer.c index 6c6277d..58b35b1 100644 --- a/arch/arm/cpu/lh7a40x/timer.c +++ b/arch/arm/cpu/lh7a40x/timer.c @@ -74,12 +74,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return (get_timer_masked() - base); diff --git a/arch/arm/cpu/pxa/timer.c b/arch/arm/cpu/pxa/timer.c index 8900a70..44dae9a 100644 --- a/arch/arm/cpu/pxa/timer.c +++ b/arch/arm/cpu/pxa/timer.c @@ -59,16 +59,11 @@ static inline unsigned long long us_to_tick(unsigned long long us)
int timer_init (void) { - reset_timer(); + reset_timer_masked();
return 0; }
-void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/s3c44b0/timer.c b/arch/arm/cpu/s3c44b0/timer.c index d30e1aa..ce48952 100644 --- a/arch/arm/cpu/s3c44b0/timer.c +++ b/arch/arm/cpu/s3c44b0/timer.c @@ -59,12 +59,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/sa1100/timer.c b/arch/arm/cpu/sa1100/timer.c index 10ad964..694c03a 100644 --- a/arch/arm/cpu/sa1100/timer.c +++ b/arch/arm/cpu/sa1100/timer.c @@ -34,11 +34,6 @@ int timer_init (void) return 0; }
-void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked (); diff --git a/arch/avr32/cpu/interrupts.c b/arch/avr32/cpu/interrupts.c index 8406f91..6681e13 100644 --- a/arch/avr32/cpu/interrupts.c +++ b/arch/avr32/cpu/interrupts.c @@ -62,13 +62,6 @@ unsigned long long get_ticks(void) return ((unsigned long long)hi_now << 32) | lo; }
-void reset_timer(void) -{ - sysreg_write(COUNT, 0); - cpu_sync_pipeline(); /* process any pending interrupts */ - timer_overflow = 0; -} - unsigned long get_timer(unsigned long base) { u64 now = get_ticks(); diff --git a/arch/blackfin/cpu/interrupts.c b/arch/blackfin/cpu/interrupts.c index 54a67b4..9189816 100644 --- a/arch/blackfin/cpu/interrupts.c +++ b/arch/blackfin/cpu/interrupts.c @@ -152,8 +152,3 @@ ulong get_timer(ulong base)
return (milisec - base); } - -void reset_timer(void) -{ - timer_init(); -} diff --git a/arch/m68k/cpu/mcf547x_8x/slicetimer.c b/arch/m68k/cpu/mcf547x_8x/slicetimer.c index 49dba6a..467a807 100644 --- a/arch/m68k/cpu/mcf547x_8x/slicetimer.c +++ b/arch/m68k/cpu/mcf547x_8x/slicetimer.c @@ -95,11 +95,6 @@ void timer_init(void) timerp->cr = SLT_CR_RUN | SLT_CR_IEN | SLT_CR_TEN; }
-void reset_timer(void) -{ - timestamp = 0; -} - ulong get_timer(ulong base) { return (timestamp - base); diff --git a/arch/m68k/lib/time.c b/arch/m68k/lib/time.c index d10bcc7..a316cdf 100644 --- a/arch/m68k/lib/time.c +++ b/arch/m68k/lib/time.c @@ -116,11 +116,6 @@ void timer_init(void) DTIM_DTMR_FRR | DTIM_DTMR_ORRI | DTIM_DTMR_RST_EN; }
-void reset_timer(void) -{ - timestamp = 0; -} - ulong get_timer(ulong base) { return (timestamp - base); diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index 59ed126..a167755 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -28,11 +28,6 @@
volatile int timestamp = 0;
-void reset_timer (void) -{ - timestamp = 0; -} - #ifdef CONFIG_SYS_TIMER_0 ulong get_timer (ulong base) { @@ -61,7 +56,7 @@ int timer_init (void) tmr->control = TIMER_INTERRUPT | TIMER_RESET; tmr->control = TIMER_ENABLE | TIMER_ENABLE_INTR | TIMER_RELOAD | TIMER_DOWN_COUNT; - reset_timer (); + timestamp = 0; install_interrupt_handler (CONFIG_SYS_TIMER_0_IRQ, timer_isr, (void *)tmr); return 0; } diff --git a/arch/mips/cpu/mips32/time.c b/arch/mips/cpu/mips32/time.c index b0a9c1f..350896a 100644 --- a/arch/mips/cpu/mips32/time.c +++ b/arch/mips/cpu/mips32/time.c @@ -42,12 +42,6 @@ int timer_init(void) return 0; }
-void reset_timer(void) -{ - timestamp = 0; - write_c0_compare(read_c0_count() + CYCLES_PER_JIFFY); -} - ulong get_timer(ulong base) { unsigned int count; diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c index 847ad37..aeae413 100644 --- a/arch/powerpc/lib/interrupts.c +++ b/arch/powerpc/lib/interrupts.c @@ -137,11 +137,6 @@ void timer_interrupt (struct pt_regs *regs) #endif /* CONFIG_SHOW_ACTIVITY */ }
-void reset_timer (void) -{ - timestamp = 0; -} - ulong get_timer (ulong base) { return (timestamp - base); diff --git a/arch/sh/lib/time.c b/arch/sh/lib/time.c index c4bfc86..c70baed 100644 --- a/arch/sh/lib/time.c +++ b/arch/sh/lib/time.c @@ -139,13 +139,6 @@ unsigned long get_timer (unsigned long base) return tick_to_time(get_ticks()) - base; }
-void reset_timer (void) -{ - tmu_timer_stop(0); - writel(0, TCNT0); - tmu_timer_start(0); -} - unsigned long get_tbclk (void) { return timer_freq; diff --git a/arch/sh/lib/time_sh2.c b/arch/sh/lib/time_sh2.c index a5c838b..5827118 100644 --- a/arch/sh/lib/time_sh2.c +++ b/arch/sh/lib/time_sh2.c @@ -90,14 +90,6 @@ ulong get_timer(ulong base) return (get_usec() / 1000) - base; }
-void reset_timer(void) -{ - cmt_timer_stop(0); - writew(CMT_TIMER_RESET, CMCOR_0); - cmt0_timer = 0; - cmt_timer_start(0); -} - void __udelay(unsigned long usec) { unsigned long end = get_usec() + usec; diff --git a/arch/sparc/lib/interrupts.c b/arch/sparc/lib/interrupts.c index 5274311..61ee90b 100644 --- a/arch/sparc/lib/interrupts.c +++ b/arch/sparc/lib/interrupts.c @@ -90,11 +90,6 @@ void timer_interrupt(struct pt_regs *regs) timestamp++; }
-void reset_timer(void) -{ - timestamp = 0; -} - ulong get_timer(ulong base) { return (timestamp - base); @@ -104,7 +99,7 @@ void timer_interrupt_init(void) { int irq;
- reset_timer(); + timestamp = 0;
irq = timer_interrupt_init_cpu();
diff --git a/arch/x86/lib/timer.c b/arch/x86/lib/timer.c index 199ca8e..a822d66 100644 --- a/arch/x86/lib/timer.c +++ b/arch/x86/lib/timer.c @@ -94,11 +94,6 @@ void timer_isr(void *unused) } }
-void reset_timer (void) -{ - system_ticks = 0; -} - ulong get_timer (ulong base) { return (system_ticks - base); diff --git a/board/armltd/integrator/timer.c b/board/armltd/integrator/timer.c index 5406066..6734e8d 100644 --- a/board/armltd/integrator/timer.c +++ b/board/armltd/integrator/timer.c @@ -107,11 +107,6 @@ int timer_init (void) /* * timer without interrupts */ -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base_ticks) { return get_timer_masked () - base_ticks; diff --git a/board/armltd/vexpress/ca9x4_ct_vxp.c b/board/armltd/vexpress/ca9x4_ct_vxp.c index 6e5884b..da6f14d 100644 --- a/board/armltd/vexpress/ca9x4_ct_vxp.c +++ b/board/armltd/vexpress/ca9x4_ct_vxp.c @@ -199,11 +199,6 @@ void reset_timer_masked(void) timestamp = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer_masked(void) { ulong now = readl(&systimer_base->timer0value) / 1000; diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c index 3d6c248..c48c7ef 100644 --- a/board/nvidia/common/board.c +++ b/board/nvidia/common/board.c @@ -62,7 +62,6 @@ int board_early_init_f(void) */ int timer_init(void) { - reset_timer(); return 0; }

Dear Graeme Russ,
In message 1309261269-4363-6-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Seems this patch conflicts with 03/16, which apparently already removed the same code, at least in some places?
Best regards,
Wolfgang Denk

On 12/07/11 08:02, Wolfgang Denk wrote:
Dear Graeme Russ,
In message 1309261269-4363-6-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Seems this patch conflicts with 03/16, which apparently already removed the same code, at least in some places?
The conflict was due to a recent patch submitted outside this series - Fixed during rebase
Regards,
Graeme

--- Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
arch/arm/cpu/arm1136/mx31/timer.c | 5 ----- arch/arm/cpu/arm1136/mx35/timer.c | 5 ----- arch/arm/cpu/arm1136/omap24xx/timer.c | 5 ----- arch/arm/cpu/arm1176/s3c64xx/timer.c | 5 ----- arch/arm/cpu/arm1176/tnetv107x/timer.c | 9 --------- arch/arm/cpu/arm720t/interrupts.c | 5 ----- arch/arm/cpu/arm920t/a320/timer.c | 6 ------ arch/arm/cpu/arm920t/at91/timer.c | 6 ------ arch/arm/cpu/arm920t/at91rm9200/timer.c | 6 ------ arch/arm/cpu/arm920t/ep93xx/timer.c | 5 ----- arch/arm/cpu/arm920t/imx/timer.c | 6 ------ arch/arm/cpu/arm920t/ks8695/timer.c | 7 +------ arch/arm/cpu/arm920t/s3c24x0/timer.c | 6 ------ arch/arm/cpu/arm925t/timer.c | 6 ------ arch/arm/cpu/arm926ejs/armada100/timer.c | 5 ----- arch/arm/cpu/arm926ejs/davinci/timer.c | 5 ----- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx25/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx27/timer.c | 5 ----- arch/arm/cpu/arm926ejs/nomadik/timer.c | 12 +++++------- arch/arm/cpu/arm926ejs/omap/timer.c | 6 ------ arch/arm/cpu/arm926ejs/orion5x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/pantheon/timer.c | 5 ----- arch/arm/cpu/arm926ejs/spear/timer.c | 6 ------ arch/arm/cpu/arm926ejs/versatile/timer.c | 6 ------ arch/arm/cpu/armv7/mx5/timer.c | 5 ----- arch/arm/cpu/armv7/omap-common/timer.c | 5 ----- arch/arm/cpu/armv7/s5p-common/timer.c | 5 ----- arch/arm/cpu/armv7/tegra2/timer.c | 5 ----- arch/arm/cpu/ixp/timer.c | 5 ----- arch/arm/cpu/lh7a40x/timer.c | 6 ------ arch/arm/cpu/pxa/timer.c | 7 +------ arch/arm/cpu/s3c44b0/timer.c | 6 ------ arch/arm/cpu/sa1100/timer.c | 5 ----- arch/avr32/cpu/interrupts.c | 7 ------- arch/blackfin/cpu/interrupts.c | 5 ----- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 5 ----- arch/m68k/lib/time.c | 5 ----- arch/microblaze/cpu/timer.c | 7 +------ arch/mips/cpu/mips32/time.c | 6 ------ arch/powerpc/lib/interrupts.c | 5 ----- arch/sh/lib/time.c | 7 ------- arch/sh/lib/time_sh2.c | 8 -------- arch/sparc/lib/interrupts.c | 7 +------ arch/x86/lib/timer.c | 5 ----- board/armltd/integrator/timer.c | 5 ----- board/armltd/vexpress/ca9x4_ct_vxp.c | 5 ----- board/nvidia/common/board.c | 1 - 49 files changed, 9 insertions(+), 270 deletions(-)
diff --git a/arch/arm/cpu/arm1136/mx31/timer.c b/arch/arm/cpu/arm1136/mx31/timer.c index d51acbb..eac4ffb 100644 --- a/arch/arm/cpu/arm1136/mx31/timer.c +++ b/arch/arm/cpu/arm1136/mx31/timer.c @@ -113,11 +113,6 @@ void reset_timer_masked (void) gd->tbl = 0; /* start "advancing" time stamp from 0 */ }
-void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long long get_ticks (void) { ulong now = GPTCNT; /* current tick value */ diff --git a/arch/arm/cpu/arm1136/mx35/timer.c b/arch/arm/cpu/arm1136/mx35/timer.c index 6dfb63a..80c0675 100644 --- a/arch/arm/cpu/arm1136/mx35/timer.c +++ b/arch/arm/cpu/arm1136/mx35/timer.c @@ -73,11 +73,6 @@ inline ulong get_timer_masked(void) return val; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { ulong tmp; diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c index d6267ba..6f1ebbf 100644 --- a/arch/arm/cpu/arm1136/omap24xx/timer.c +++ b/arch/arm/cpu/arm1136/omap24xx/timer.c @@ -57,11 +57,6 @@ int timer_init (void) /* * timer without interrupts */ -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm1176/s3c64xx/timer.c b/arch/arm/cpu/arm1176/s3c64xx/timer.c index 8e54060..bc21f86 100644 --- a/arch/arm/cpu/arm1176/s3c64xx/timer.c +++ b/arch/arm/cpu/arm1176/s3c64xx/timer.c @@ -142,11 +142,6 @@ void reset_timer_masked(void) timestamp = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer_masked(void) { unsigned long long res = get_ticks(); diff --git a/arch/arm/cpu/arm1176/tnetv107x/timer.c b/arch/arm/cpu/arm1176/tnetv107x/timer.c index c27375c..b3123c5 100644 --- a/arch/arm/cpu/arm1176/tnetv107x/timer.c +++ b/arch/arm/cpu/arm1176/tnetv107x/timer.c @@ -60,15 +60,6 @@ int timer_init(void) return 0; }
-void reset_timer(void) -{ - lastinc = timestamp = 0; - - __raw_writel(0, ®s->tcr); - __raw_writel(0, ®s->tim34); - __raw_writel(2 << 22, ®s->tcr); -} - static ulong get_timer_raw(void) { ulong now = __raw_readl(®s->tim34); diff --git a/arch/arm/cpu/arm720t/interrupts.c b/arch/arm/cpu/arm720t/interrupts.c index 164ca5d..9cd7fee 100644 --- a/arch/arm/cpu/arm720t/interrupts.c +++ b/arch/arm/cpu/arm720t/interrupts.c @@ -209,11 +209,6 @@ int timer_init (void)
#if defined(CONFIG_IMPA7) || defined(CONFIG_EP7312) || defined(CONFIG_NETARM) || defined(CONFIG_ARMADILLO) || defined(CONFIG_LPC2292)
-void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm920t/a320/timer.c b/arch/arm/cpu/arm920t/a320/timer.c index b9c83c0..443d31d 100644 --- a/arch/arm/cpu/arm920t/a320/timer.c +++ b/arch/arm/cpu/arm920t/a320/timer.c @@ -81,12 +81,6 @@ void reset_timer_masked(void) debug("%s(): lastdec = %lx\n", __func__, lastdec); }
-void reset_timer(void) -{ - debug("%s()\n", __func__); - reset_timer_masked(); -} - /* * return timer ticks */ diff --git a/arch/arm/cpu/arm920t/at91/timer.c b/arch/arm/cpu/arm920t/at91/timer.c index a69de57..374cc25 100644 --- a/arch/arm/cpu/arm920t/at91/timer.c +++ b/arch/arm/cpu/arm920t/at91/timer.c @@ -72,12 +72,6 @@ int timer_init(void) /* * timer without interrupts */ - -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm920t/at91rm9200/timer.c b/arch/arm/cpu/arm920t/at91rm9200/timer.c index 0bcb775..9a1ae85 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/timer.c +++ b/arch/arm/cpu/arm920t/at91rm9200/timer.c @@ -71,12 +71,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm920t/ep93xx/timer.c b/arch/arm/cpu/arm920t/ep93xx/timer.c index 4a0ce4d..f19ec61 100644 --- a/arch/arm/cpu/arm920t/ep93xx/timer.c +++ b/arch/arm/cpu/arm920t/ep93xx/timer.c @@ -97,11 +97,6 @@ void reset_timer_masked(void) timer.ticks = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - void __udelay(unsigned long usec) { unsigned long long target; diff --git a/arch/arm/cpu/arm920t/imx/timer.c b/arch/arm/cpu/arm920t/imx/timer.c index ff85a41..cdb2148 100644 --- a/arch/arm/cpu/arm920t/imx/timer.c +++ b/arch/arm/cpu/arm920t/imx/timer.c @@ -51,12 +51,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm920t/ks8695/timer.c b/arch/arm/cpu/arm920t/ks8695/timer.c index 8e14109..c78fd90 100644 --- a/arch/arm/cpu/arm920t/ks8695/timer.c +++ b/arch/arm/cpu/arm920t/ks8695/timer.c @@ -33,7 +33,7 @@ ulong timer_ticks;
int timer_init (void) { - reset_timer(); + reset_timer_masked();
return 0; } @@ -55,11 +55,6 @@ void reset_timer_masked(void) timer_ticks = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer_masked(void) { /* Check for timer wrap */ diff --git a/arch/arm/cpu/arm920t/s3c24x0/timer.c b/arch/arm/cpu/arm920t/s3c24x0/timer.c index bba06d5..9c71b80 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/timer.c +++ b/arch/arm/cpu/arm920t/s3c24x0/timer.c @@ -83,12 +83,6 @@ int timer_init(void) /* * timer without interrupts */ - -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm925t/timer.c b/arch/arm/cpu/arm925t/timer.c index fdaeda5..9c965e0 100644 --- a/arch/arm/cpu/arm925t/timer.c +++ b/arch/arm/cpu/arm925t/timer.c @@ -64,12 +64,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm926ejs/armada100/timer.c b/arch/arm/cpu/arm926ejs/armada100/timer.c index eb49234..86da0ce 100644 --- a/arch/arm/cpu/arm926ejs/armada100/timer.c +++ b/arch/arm/cpu/arm926ejs/armada100/timer.c @@ -100,11 +100,6 @@ ulong get_timer_masked(void) return gd->tbu; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return ((get_timer_masked() / (CONFIG_SYS_HZ_CLOCK / 1000)) - diff --git a/arch/arm/cpu/arm926ejs/davinci/timer.c b/arch/arm/cpu/arm926ejs/davinci/timer.c index 1c6fa4a..8b1734c 100644 --- a/arch/arm/cpu/arm926ejs/davinci/timer.c +++ b/arch/arm/cpu/arm926ejs/davinci/timer.c @@ -78,11 +78,6 @@ int timer_init(void) return(0); }
-void reset_timer(void) -{ - gd->timer_reset_value = get_ticks(); -} - /* * Get the current 64 bit timer tick count */ diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c index e890edb..5beb3f5 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c @@ -112,11 +112,6 @@ ulong get_timer_masked(void) return timestamp; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c index 6966b0d..5f54085 100644 --- a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c +++ b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c @@ -121,11 +121,6 @@ void __udelay(unsigned long usec) /*NOP*/; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c index af26b4c..9a84b50 100644 --- a/arch/arm/cpu/arm926ejs/mx25/timer.c +++ b/arch/arm/cpu/arm926ejs/mx25/timer.c @@ -130,11 +130,6 @@ void reset_timer_masked(void) timestamp = 0; /* start "advancing" time stamp from 0 */ }
-void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long long get_ticks (void) { struct gpt_regs *gpt = (struct gpt_regs *)IMX_GPT1_BASE; diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c index 127e670..058dbee 100644 --- a/arch/arm/cpu/arm926ejs/mx27/timer.c +++ b/arch/arm/cpu/arm926ejs/mx27/timer.c @@ -133,11 +133,6 @@ void reset_timer_masked(void) timestamp = 0; /* start "advancing" time stamp from 0 */ }
-void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long long get_ticks (void) { struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE; diff --git a/arch/arm/cpu/arm926ejs/nomadik/timer.c b/arch/arm/cpu/arm926ejs/nomadik/timer.c index 1d98ef3..1cd0e1f 100644 --- a/arch/arm/cpu/arm926ejs/nomadik/timer.c +++ b/arch/arm/cpu/arm926ejs/nomadik/timer.c @@ -40,16 +40,12 @@ /* Configure a free-running, auto-wrap counter with no prescaler */ int timer_init(void) { + ulong val; + writel(MTU_CRn_ENA | MTU_CRn_PRESCALE_1 | MTU_CRn_32BITS, CONFIG_SYS_TIMERBASE + MTU_CR(0)); - reset_timer(); - return 0; -}
-/* Restart counting from 0 */ -void reset_timer(void) -{ - ulong val; + /* Reset the timer */ writel(0, CONFIG_SYS_TIMERBASE + MTU_LR(0)); /* * The load-register isn't really immediate: it changes on clock @@ -59,6 +55,8 @@ void reset_timer(void) val = READ_TIMER(); while (READ_TIMER() == val) ; + + return 0; }
/* Return how many HZ passed since "base" */ diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c index f2e4deb..390c9c8 100644 --- a/arch/arm/cpu/arm926ejs/omap/timer.c +++ b/arch/arm/cpu/arm926ejs/omap/timer.c @@ -65,12 +65,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c index f691c99..5bc43c8 100644 --- a/arch/arm/cpu/arm926ejs/orion5x/timer.c +++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c @@ -119,11 +119,6 @@ ulong get_timer_masked(void) return timestamp; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm926ejs/pantheon/timer.c b/arch/arm/cpu/arm926ejs/pantheon/timer.c index b487416..2727adc 100644 --- a/arch/arm/cpu/arm926ejs/pantheon/timer.c +++ b/arch/arm/cpu/arm926ejs/pantheon/timer.c @@ -108,11 +108,6 @@ ulong get_timer_masked(void) return gd->tbu; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return ((get_timer_masked() / (CONFIG_SYS_HZ_CLOCK / 1000)) - diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c index 7305abd..cbef34f 100644 --- a/arch/arm/cpu/arm926ejs/spear/timer.c +++ b/arch/arm/cpu/arm926ejs/spear/timer.c @@ -76,12 +76,6 @@ int timer_init(void) /* * timer without interrupts */ - -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return (get_timer_masked() / GPT_RESOLUTION) - base; diff --git a/arch/arm/cpu/arm926ejs/versatile/timer.c b/arch/arm/cpu/arm926ejs/versatile/timer.c index 0e51a63..f58e151 100644 --- a/arch/arm/cpu/arm926ejs/versatile/timer.c +++ b/arch/arm/cpu/arm926ejs/versatile/timer.c @@ -94,12 +94,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/armv7/mx5/timer.c b/arch/arm/cpu/armv7/mx5/timer.c index 40ee0be..4525beb 100644 --- a/arch/arm/cpu/armv7/mx5/timer.c +++ b/arch/arm/cpu/armv7/mx5/timer.c @@ -69,11 +69,6 @@ int timer_init(void) return 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - void reset_timer_masked(void) { ulong val = __raw_readl(&cur_gpt->counter); diff --git a/arch/arm/cpu/armv7/omap-common/timer.c b/arch/arm/cpu/armv7/omap-common/timer.c index a0f6b7c..4756e26 100644 --- a/arch/arm/cpu/armv7/omap-common/timer.c +++ b/arch/arm/cpu/armv7/omap-common/timer.c @@ -63,11 +63,6 @@ int timer_init(void) /* * timer without interrupts */ -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/armv7/s5p-common/timer.c b/arch/arm/cpu/armv7/s5p-common/timer.c index 0b69f06..359c21f 100644 --- a/arch/arm/cpu/armv7/s5p-common/timer.c +++ b/arch/arm/cpu/armv7/s5p-common/timer.c @@ -50,11 +50,6 @@ int timer_init(void) /* * timer without interrupts */ -void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long get_timer(unsigned long base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/armv7/tegra2/timer.c b/arch/arm/cpu/armv7/tegra2/timer.c index 4458de9..2761c12 100644 --- a/arch/arm/cpu/armv7/tegra2/timer.c +++ b/arch/arm/cpu/armv7/tegra2/timer.c @@ -48,11 +48,6 @@ struct timerus *timer_base = (struct timerus *)NV_PA_TMRUS_BASE; #define TIMER_LOAD_VAL 0xffffffff
/* timer without interrupts */ -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/ixp/timer.c b/arch/arm/cpu/ixp/timer.c index c25e72f..087ddf8 100644 --- a/arch/arm/cpu/ixp/timer.c +++ b/arch/arm/cpu/ixp/timer.c @@ -89,11 +89,6 @@ void reset_timer_masked(void) gd->timestamp = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer_masked(void) { return tick_to_time(get_ticks()); diff --git a/arch/arm/cpu/lh7a40x/timer.c b/arch/arm/cpu/lh7a40x/timer.c index 6c6277d..58b35b1 100644 --- a/arch/arm/cpu/lh7a40x/timer.c +++ b/arch/arm/cpu/lh7a40x/timer.c @@ -74,12 +74,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return (get_timer_masked() - base); diff --git a/arch/arm/cpu/pxa/timer.c b/arch/arm/cpu/pxa/timer.c index 8900a70..44dae9a 100644 --- a/arch/arm/cpu/pxa/timer.c +++ b/arch/arm/cpu/pxa/timer.c @@ -59,16 +59,11 @@ static inline unsigned long long us_to_tick(unsigned long long us)
int timer_init (void) { - reset_timer(); + reset_timer_masked();
return 0; }
-void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/s3c44b0/timer.c b/arch/arm/cpu/s3c44b0/timer.c index d30e1aa..ce48952 100644 --- a/arch/arm/cpu/s3c44b0/timer.c +++ b/arch/arm/cpu/s3c44b0/timer.c @@ -59,12 +59,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/sa1100/timer.c b/arch/arm/cpu/sa1100/timer.c index 10ad964..694c03a 100644 --- a/arch/arm/cpu/sa1100/timer.c +++ b/arch/arm/cpu/sa1100/timer.c @@ -34,11 +34,6 @@ int timer_init (void) return 0; }
-void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked (); diff --git a/arch/avr32/cpu/interrupts.c b/arch/avr32/cpu/interrupts.c index 8406f91..6681e13 100644 --- a/arch/avr32/cpu/interrupts.c +++ b/arch/avr32/cpu/interrupts.c @@ -62,13 +62,6 @@ unsigned long long get_ticks(void) return ((unsigned long long)hi_now << 32) | lo; }
-void reset_timer(void) -{ - sysreg_write(COUNT, 0); - cpu_sync_pipeline(); /* process any pending interrupts */ - timer_overflow = 0; -} - unsigned long get_timer(unsigned long base) { u64 now = get_ticks(); diff --git a/arch/blackfin/cpu/interrupts.c b/arch/blackfin/cpu/interrupts.c index 54a67b4..9189816 100644 --- a/arch/blackfin/cpu/interrupts.c +++ b/arch/blackfin/cpu/interrupts.c @@ -152,8 +152,3 @@ ulong get_timer(ulong base)
return (milisec - base); } - -void reset_timer(void) -{ - timer_init(); -} diff --git a/arch/m68k/cpu/mcf547x_8x/slicetimer.c b/arch/m68k/cpu/mcf547x_8x/slicetimer.c index 49dba6a..467a807 100644 --- a/arch/m68k/cpu/mcf547x_8x/slicetimer.c +++ b/arch/m68k/cpu/mcf547x_8x/slicetimer.c @@ -95,11 +95,6 @@ void timer_init(void) timerp->cr = SLT_CR_RUN | SLT_CR_IEN | SLT_CR_TEN; }
-void reset_timer(void) -{ - timestamp = 0; -} - ulong get_timer(ulong base) { return (timestamp - base); diff --git a/arch/m68k/lib/time.c b/arch/m68k/lib/time.c index d10bcc7..a316cdf 100644 --- a/arch/m68k/lib/time.c +++ b/arch/m68k/lib/time.c @@ -116,11 +116,6 @@ void timer_init(void) DTIM_DTMR_FRR | DTIM_DTMR_ORRI | DTIM_DTMR_RST_EN; }
-void reset_timer(void) -{ - timestamp = 0; -} - ulong get_timer(ulong base) { return (timestamp - base); diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index 59ed126..a167755 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -28,11 +28,6 @@
volatile int timestamp = 0;
-void reset_timer (void) -{ - timestamp = 0; -} - #ifdef CONFIG_SYS_TIMER_0 ulong get_timer (ulong base) { @@ -61,7 +56,7 @@ int timer_init (void) tmr->control = TIMER_INTERRUPT | TIMER_RESET; tmr->control = TIMER_ENABLE | TIMER_ENABLE_INTR | TIMER_RELOAD | TIMER_DOWN_COUNT; - reset_timer (); + timestamp = 0; install_interrupt_handler (CONFIG_SYS_TIMER_0_IRQ, timer_isr, (void *)tmr); return 0; } diff --git a/arch/mips/cpu/mips32/time.c b/arch/mips/cpu/mips32/time.c index b0a9c1f..350896a 100644 --- a/arch/mips/cpu/mips32/time.c +++ b/arch/mips/cpu/mips32/time.c @@ -42,12 +42,6 @@ int timer_init(void) return 0; }
-void reset_timer(void) -{ - timestamp = 0; - write_c0_compare(read_c0_count() + CYCLES_PER_JIFFY); -} - ulong get_timer(ulong base) { unsigned int count; diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c index 847ad37..aeae413 100644 --- a/arch/powerpc/lib/interrupts.c +++ b/arch/powerpc/lib/interrupts.c @@ -137,11 +137,6 @@ void timer_interrupt (struct pt_regs *regs) #endif /* CONFIG_SHOW_ACTIVITY */ }
-void reset_timer (void) -{ - timestamp = 0; -} - ulong get_timer (ulong base) { return (timestamp - base); diff --git a/arch/sh/lib/time.c b/arch/sh/lib/time.c index c4bfc86..c70baed 100644 --- a/arch/sh/lib/time.c +++ b/arch/sh/lib/time.c @@ -139,13 +139,6 @@ unsigned long get_timer (unsigned long base) return tick_to_time(get_ticks()) - base; }
-void reset_timer (void) -{ - tmu_timer_stop(0); - writel(0, TCNT0); - tmu_timer_start(0); -} - unsigned long get_tbclk (void) { return timer_freq; diff --git a/arch/sh/lib/time_sh2.c b/arch/sh/lib/time_sh2.c index a5c838b..5827118 100644 --- a/arch/sh/lib/time_sh2.c +++ b/arch/sh/lib/time_sh2.c @@ -90,14 +90,6 @@ ulong get_timer(ulong base) return (get_usec() / 1000) - base; }
-void reset_timer(void) -{ - cmt_timer_stop(0); - writew(CMT_TIMER_RESET, CMCOR_0); - cmt0_timer = 0; - cmt_timer_start(0); -} - void __udelay(unsigned long usec) { unsigned long end = get_usec() + usec; diff --git a/arch/sparc/lib/interrupts.c b/arch/sparc/lib/interrupts.c index 5274311..61ee90b 100644 --- a/arch/sparc/lib/interrupts.c +++ b/arch/sparc/lib/interrupts.c @@ -90,11 +90,6 @@ void timer_interrupt(struct pt_regs *regs) timestamp++; }
-void reset_timer(void) -{ - timestamp = 0; -} - ulong get_timer(ulong base) { return (timestamp - base); @@ -104,7 +99,7 @@ void timer_interrupt_init(void) { int irq;
- reset_timer(); + timestamp = 0;
irq = timer_interrupt_init_cpu();
diff --git a/arch/x86/lib/timer.c b/arch/x86/lib/timer.c index 199ca8e..a822d66 100644 --- a/arch/x86/lib/timer.c +++ b/arch/x86/lib/timer.c @@ -94,11 +94,6 @@ void timer_isr(void *unused) } }
-void reset_timer (void) -{ - system_ticks = 0; -} - ulong get_timer (ulong base) { return (system_ticks - base); diff --git a/board/armltd/integrator/timer.c b/board/armltd/integrator/timer.c index 5406066..6734e8d 100644 --- a/board/armltd/integrator/timer.c +++ b/board/armltd/integrator/timer.c @@ -107,11 +107,6 @@ int timer_init (void) /* * timer without interrupts */ -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base_ticks) { return get_timer_masked () - base_ticks; diff --git a/board/armltd/vexpress/ca9x4_ct_vxp.c b/board/armltd/vexpress/ca9x4_ct_vxp.c index 6e5884b..da6f14d 100644 --- a/board/armltd/vexpress/ca9x4_ct_vxp.c +++ b/board/armltd/vexpress/ca9x4_ct_vxp.c @@ -199,11 +199,6 @@ void reset_timer_masked(void) timestamp = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer_masked(void) { ulong now = readl(&systimer_base->timer0value) / 1000; diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c index 3d6c248..c48c7ef 100644 --- a/board/nvidia/common/board.c +++ b/board/nvidia/common/board.c @@ -62,7 +62,6 @@ int board_early_init_f(void) */ int timer_init(void) { - reset_timer(); return 0; }
-- 1.7.5.2.317.g391b14

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- Changes since v2: - Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
arch/arm/cpu/arm1136/mx31/timer.c | 5 ----- arch/arm/cpu/arm1136/mx35/timer.c | 5 ----- arch/arm/cpu/arm1136/omap24xx/timer.c | 5 ----- arch/arm/cpu/arm1176/s3c64xx/timer.c | 5 ----- arch/arm/cpu/arm1176/tnetv107x/timer.c | 9 --------- arch/arm/cpu/arm720t/interrupts.c | 5 ----- arch/arm/cpu/arm920t/a320/timer.c | 6 ------ arch/arm/cpu/arm920t/at91/timer.c | 6 ------ arch/arm/cpu/arm920t/at91rm9200/timer.c | 6 ------ arch/arm/cpu/arm920t/ep93xx/timer.c | 5 ----- arch/arm/cpu/arm920t/imx/timer.c | 6 ------ arch/arm/cpu/arm920t/ks8695/timer.c | 7 +------ arch/arm/cpu/arm920t/s3c24x0/timer.c | 6 ------ arch/arm/cpu/arm925t/timer.c | 6 ------ arch/arm/cpu/arm926ejs/armada100/timer.c | 5 ----- arch/arm/cpu/arm926ejs/davinci/timer.c | 5 ----- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx25/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx27/timer.c | 5 ----- arch/arm/cpu/arm926ejs/nomadik/timer.c | 12 +++++------- arch/arm/cpu/arm926ejs/omap/timer.c | 6 ------ arch/arm/cpu/arm926ejs/orion5x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/pantheon/timer.c | 5 ----- arch/arm/cpu/arm926ejs/spear/timer.c | 6 ------ arch/arm/cpu/arm926ejs/versatile/timer.c | 6 ------ arch/arm/cpu/armv7/mx5/timer.c | 5 ----- arch/arm/cpu/armv7/omap-common/timer.c | 5 ----- arch/arm/cpu/armv7/s5p-common/timer.c | 5 ----- arch/arm/cpu/armv7/tegra2/timer.c | 5 ----- arch/arm/cpu/ixp/timer.c | 5 ----- arch/arm/cpu/lh7a40x/timer.c | 6 ------ arch/arm/cpu/pxa/timer.c | 7 +------ arch/arm/cpu/s3c44b0/timer.c | 6 ------ arch/arm/cpu/sa1100/timer.c | 5 ----- arch/avr32/cpu/interrupts.c | 7 ------- arch/blackfin/cpu/interrupts.c | 5 ----- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 5 ----- arch/m68k/lib/time.c | 5 ----- arch/microblaze/cpu/timer.c | 7 +------ arch/mips/cpu/mips32/time.c | 6 ------ arch/powerpc/lib/interrupts.c | 5 ----- arch/sh/lib/time.c | 7 ------- arch/sh/lib/time_sh2.c | 8 -------- arch/sparc/lib/interrupts.c | 7 +------ arch/x86/lib/timer.c | 5 ----- board/armltd/integrator/timer.c | 5 ----- board/armltd/vexpress/ca9x4_ct_vxp.c | 5 ----- board/nvidia/common/board.c | 1 - 49 files changed, 9 insertions(+), 270 deletions(-)
diff --git a/arch/arm/cpu/arm1136/mx31/timer.c b/arch/arm/cpu/arm1136/mx31/timer.c index d51acbb..eac4ffb 100644 --- a/arch/arm/cpu/arm1136/mx31/timer.c +++ b/arch/arm/cpu/arm1136/mx31/timer.c @@ -113,11 +113,6 @@ void reset_timer_masked (void) gd->tbl = 0; /* start "advancing" time stamp from 0 */ }
-void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long long get_ticks (void) { ulong now = GPTCNT; /* current tick value */ diff --git a/arch/arm/cpu/arm1136/mx35/timer.c b/arch/arm/cpu/arm1136/mx35/timer.c index 6dfb63a..80c0675 100644 --- a/arch/arm/cpu/arm1136/mx35/timer.c +++ b/arch/arm/cpu/arm1136/mx35/timer.c @@ -73,11 +73,6 @@ inline ulong get_timer_masked(void) return val; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { ulong tmp; diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c index d6267ba..6f1ebbf 100644 --- a/arch/arm/cpu/arm1136/omap24xx/timer.c +++ b/arch/arm/cpu/arm1136/omap24xx/timer.c @@ -57,11 +57,6 @@ int timer_init (void) /* * timer without interrupts */ -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm1176/s3c64xx/timer.c b/arch/arm/cpu/arm1176/s3c64xx/timer.c index 8e54060..bc21f86 100644 --- a/arch/arm/cpu/arm1176/s3c64xx/timer.c +++ b/arch/arm/cpu/arm1176/s3c64xx/timer.c @@ -142,11 +142,6 @@ void reset_timer_masked(void) timestamp = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer_masked(void) { unsigned long long res = get_ticks(); diff --git a/arch/arm/cpu/arm1176/tnetv107x/timer.c b/arch/arm/cpu/arm1176/tnetv107x/timer.c index c27375c..b3123c5 100644 --- a/arch/arm/cpu/arm1176/tnetv107x/timer.c +++ b/arch/arm/cpu/arm1176/tnetv107x/timer.c @@ -60,15 +60,6 @@ int timer_init(void) return 0; }
-void reset_timer(void) -{ - lastinc = timestamp = 0; - - __raw_writel(0, ®s->tcr); - __raw_writel(0, ®s->tim34); - __raw_writel(2 << 22, ®s->tcr); -} - static ulong get_timer_raw(void) { ulong now = __raw_readl(®s->tim34); diff --git a/arch/arm/cpu/arm720t/interrupts.c b/arch/arm/cpu/arm720t/interrupts.c index 164ca5d..9cd7fee 100644 --- a/arch/arm/cpu/arm720t/interrupts.c +++ b/arch/arm/cpu/arm720t/interrupts.c @@ -209,11 +209,6 @@ int timer_init (void)
#if defined(CONFIG_IMPA7) || defined(CONFIG_EP7312) || defined(CONFIG_NETARM) || defined(CONFIG_ARMADILLO) || defined(CONFIG_LPC2292)
-void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm920t/a320/timer.c b/arch/arm/cpu/arm920t/a320/timer.c index b9c83c0..443d31d 100644 --- a/arch/arm/cpu/arm920t/a320/timer.c +++ b/arch/arm/cpu/arm920t/a320/timer.c @@ -81,12 +81,6 @@ void reset_timer_masked(void) debug("%s(): lastdec = %lx\n", __func__, lastdec); }
-void reset_timer(void) -{ - debug("%s()\n", __func__); - reset_timer_masked(); -} - /* * return timer ticks */ diff --git a/arch/arm/cpu/arm920t/at91/timer.c b/arch/arm/cpu/arm920t/at91/timer.c index a69de57..374cc25 100644 --- a/arch/arm/cpu/arm920t/at91/timer.c +++ b/arch/arm/cpu/arm920t/at91/timer.c @@ -72,12 +72,6 @@ int timer_init(void) /* * timer without interrupts */ - -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm920t/at91rm9200/timer.c b/arch/arm/cpu/arm920t/at91rm9200/timer.c index 0bcb775..9a1ae85 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/timer.c +++ b/arch/arm/cpu/arm920t/at91rm9200/timer.c @@ -71,12 +71,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm920t/ep93xx/timer.c b/arch/arm/cpu/arm920t/ep93xx/timer.c index 4a0ce4d..f19ec61 100644 --- a/arch/arm/cpu/arm920t/ep93xx/timer.c +++ b/arch/arm/cpu/arm920t/ep93xx/timer.c @@ -97,11 +97,6 @@ void reset_timer_masked(void) timer.ticks = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - void __udelay(unsigned long usec) { unsigned long long target; diff --git a/arch/arm/cpu/arm920t/imx/timer.c b/arch/arm/cpu/arm920t/imx/timer.c index ff85a41..cdb2148 100644 --- a/arch/arm/cpu/arm920t/imx/timer.c +++ b/arch/arm/cpu/arm920t/imx/timer.c @@ -51,12 +51,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm920t/ks8695/timer.c b/arch/arm/cpu/arm920t/ks8695/timer.c index 8e14109..c78fd90 100644 --- a/arch/arm/cpu/arm920t/ks8695/timer.c +++ b/arch/arm/cpu/arm920t/ks8695/timer.c @@ -33,7 +33,7 @@ ulong timer_ticks;
int timer_init (void) { - reset_timer(); + reset_timer_masked();
return 0; } @@ -55,11 +55,6 @@ void reset_timer_masked(void) timer_ticks = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer_masked(void) { /* Check for timer wrap */ diff --git a/arch/arm/cpu/arm920t/s3c24x0/timer.c b/arch/arm/cpu/arm920t/s3c24x0/timer.c index bba06d5..9c71b80 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/timer.c +++ b/arch/arm/cpu/arm920t/s3c24x0/timer.c @@ -83,12 +83,6 @@ int timer_init(void) /* * timer without interrupts */ - -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm925t/timer.c b/arch/arm/cpu/arm925t/timer.c index fdaeda5..9c965e0 100644 --- a/arch/arm/cpu/arm925t/timer.c +++ b/arch/arm/cpu/arm925t/timer.c @@ -64,12 +64,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm926ejs/armada100/timer.c b/arch/arm/cpu/arm926ejs/armada100/timer.c index eb49234..86da0ce 100644 --- a/arch/arm/cpu/arm926ejs/armada100/timer.c +++ b/arch/arm/cpu/arm926ejs/armada100/timer.c @@ -100,11 +100,6 @@ ulong get_timer_masked(void) return gd->tbu; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return ((get_timer_masked() / (CONFIG_SYS_HZ_CLOCK / 1000)) - diff --git a/arch/arm/cpu/arm926ejs/davinci/timer.c b/arch/arm/cpu/arm926ejs/davinci/timer.c index 1c6fa4a..8b1734c 100644 --- a/arch/arm/cpu/arm926ejs/davinci/timer.c +++ b/arch/arm/cpu/arm926ejs/davinci/timer.c @@ -78,11 +78,6 @@ int timer_init(void) return(0); }
-void reset_timer(void) -{ - gd->timer_reset_value = get_ticks(); -} - /* * Get the current 64 bit timer tick count */ diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c index e890edb..5beb3f5 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c @@ -112,11 +112,6 @@ ulong get_timer_masked(void) return timestamp; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c index 6966b0d..5f54085 100644 --- a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c +++ b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c @@ -121,11 +121,6 @@ void __udelay(unsigned long usec) /*NOP*/; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c index af26b4c..9a84b50 100644 --- a/arch/arm/cpu/arm926ejs/mx25/timer.c +++ b/arch/arm/cpu/arm926ejs/mx25/timer.c @@ -130,11 +130,6 @@ void reset_timer_masked(void) timestamp = 0; /* start "advancing" time stamp from 0 */ }
-void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long long get_ticks (void) { struct gpt_regs *gpt = (struct gpt_regs *)IMX_GPT1_BASE; diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c index 127e670..058dbee 100644 --- a/arch/arm/cpu/arm926ejs/mx27/timer.c +++ b/arch/arm/cpu/arm926ejs/mx27/timer.c @@ -133,11 +133,6 @@ void reset_timer_masked(void) timestamp = 0; /* start "advancing" time stamp from 0 */ }
-void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long long get_ticks (void) { struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE; diff --git a/arch/arm/cpu/arm926ejs/nomadik/timer.c b/arch/arm/cpu/arm926ejs/nomadik/timer.c index 1d98ef3..1cd0e1f 100644 --- a/arch/arm/cpu/arm926ejs/nomadik/timer.c +++ b/arch/arm/cpu/arm926ejs/nomadik/timer.c @@ -40,16 +40,12 @@ /* Configure a free-running, auto-wrap counter with no prescaler */ int timer_init(void) { + ulong val; + writel(MTU_CRn_ENA | MTU_CRn_PRESCALE_1 | MTU_CRn_32BITS, CONFIG_SYS_TIMERBASE + MTU_CR(0)); - reset_timer(); - return 0; -}
-/* Restart counting from 0 */ -void reset_timer(void) -{ - ulong val; + /* Reset the timer */ writel(0, CONFIG_SYS_TIMERBASE + MTU_LR(0)); /* * The load-register isn't really immediate: it changes on clock @@ -59,6 +55,8 @@ void reset_timer(void) val = READ_TIMER(); while (READ_TIMER() == val) ; + + return 0; }
/* Return how many HZ passed since "base" */ diff --git a/arch/arm/cpu/arm926ejs/omap/timer.c b/arch/arm/cpu/arm926ejs/omap/timer.c index f2e4deb..390c9c8 100644 --- a/arch/arm/cpu/arm926ejs/omap/timer.c +++ b/arch/arm/cpu/arm926ejs/omap/timer.c @@ -65,12 +65,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c index f691c99..5bc43c8 100644 --- a/arch/arm/cpu/arm926ejs/orion5x/timer.c +++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c @@ -119,11 +119,6 @@ ulong get_timer_masked(void) return timestamp; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/arm926ejs/pantheon/timer.c b/arch/arm/cpu/arm926ejs/pantheon/timer.c index b487416..2727adc 100644 --- a/arch/arm/cpu/arm926ejs/pantheon/timer.c +++ b/arch/arm/cpu/arm926ejs/pantheon/timer.c @@ -108,11 +108,6 @@ ulong get_timer_masked(void) return gd->tbu; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return ((get_timer_masked() / (CONFIG_SYS_HZ_CLOCK / 1000)) - diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c index 7305abd..cbef34f 100644 --- a/arch/arm/cpu/arm926ejs/spear/timer.c +++ b/arch/arm/cpu/arm926ejs/spear/timer.c @@ -76,12 +76,6 @@ int timer_init(void) /* * timer without interrupts */ - -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return (get_timer_masked() / GPT_RESOLUTION) - base; diff --git a/arch/arm/cpu/arm926ejs/versatile/timer.c b/arch/arm/cpu/arm926ejs/versatile/timer.c index 0e51a63..f58e151 100644 --- a/arch/arm/cpu/arm926ejs/versatile/timer.c +++ b/arch/arm/cpu/arm926ejs/versatile/timer.c @@ -94,12 +94,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/armv7/mx5/timer.c b/arch/arm/cpu/armv7/mx5/timer.c index 40ee0be..4525beb 100644 --- a/arch/arm/cpu/armv7/mx5/timer.c +++ b/arch/arm/cpu/armv7/mx5/timer.c @@ -69,11 +69,6 @@ int timer_init(void) return 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - void reset_timer_masked(void) { ulong val = __raw_readl(&cur_gpt->counter); diff --git a/arch/arm/cpu/armv7/omap-common/timer.c b/arch/arm/cpu/armv7/omap-common/timer.c index a0f6b7c..4756e26 100644 --- a/arch/arm/cpu/armv7/omap-common/timer.c +++ b/arch/arm/cpu/armv7/omap-common/timer.c @@ -63,11 +63,6 @@ int timer_init(void) /* * timer without interrupts */ -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/armv7/s5p-common/timer.c b/arch/arm/cpu/armv7/s5p-common/timer.c index 0b69f06..359c21f 100644 --- a/arch/arm/cpu/armv7/s5p-common/timer.c +++ b/arch/arm/cpu/armv7/s5p-common/timer.c @@ -50,11 +50,6 @@ int timer_init(void) /* * timer without interrupts */ -void reset_timer(void) -{ - reset_timer_masked(); -} - unsigned long get_timer(unsigned long base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/armv7/tegra2/timer.c b/arch/arm/cpu/armv7/tegra2/timer.c index 4458de9..2761c12 100644 --- a/arch/arm/cpu/armv7/tegra2/timer.c +++ b/arch/arm/cpu/armv7/tegra2/timer.c @@ -48,11 +48,6 @@ struct timerus *timer_base = (struct timerus *)NV_PA_TMRUS_BASE; #define TIMER_LOAD_VAL 0xffffffff
/* timer without interrupts */ -void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer(ulong base) { return get_timer_masked() - base; diff --git a/arch/arm/cpu/ixp/timer.c b/arch/arm/cpu/ixp/timer.c index c25e72f..087ddf8 100644 --- a/arch/arm/cpu/ixp/timer.c +++ b/arch/arm/cpu/ixp/timer.c @@ -89,11 +89,6 @@ void reset_timer_masked(void) gd->timestamp = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer_masked(void) { return tick_to_time(get_ticks()); diff --git a/arch/arm/cpu/lh7a40x/timer.c b/arch/arm/cpu/lh7a40x/timer.c index 6c6277d..58b35b1 100644 --- a/arch/arm/cpu/lh7a40x/timer.c +++ b/arch/arm/cpu/lh7a40x/timer.c @@ -74,12 +74,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return (get_timer_masked() - base); diff --git a/arch/arm/cpu/pxa/timer.c b/arch/arm/cpu/pxa/timer.c index 8900a70..44dae9a 100644 --- a/arch/arm/cpu/pxa/timer.c +++ b/arch/arm/cpu/pxa/timer.c @@ -59,16 +59,11 @@ static inline unsigned long long us_to_tick(unsigned long long us)
int timer_init (void) { - reset_timer(); + reset_timer_masked();
return 0; }
-void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/s3c44b0/timer.c b/arch/arm/cpu/s3c44b0/timer.c index d30e1aa..ce48952 100644 --- a/arch/arm/cpu/s3c44b0/timer.c +++ b/arch/arm/cpu/s3c44b0/timer.c @@ -59,12 +59,6 @@ int timer_init (void) /* * timer without interrupts */ - -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked () - base; diff --git a/arch/arm/cpu/sa1100/timer.c b/arch/arm/cpu/sa1100/timer.c index 10ad964..694c03a 100644 --- a/arch/arm/cpu/sa1100/timer.c +++ b/arch/arm/cpu/sa1100/timer.c @@ -34,11 +34,6 @@ int timer_init (void) return 0; }
-void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base) { return get_timer_masked (); diff --git a/arch/avr32/cpu/interrupts.c b/arch/avr32/cpu/interrupts.c index 8406f91..6681e13 100644 --- a/arch/avr32/cpu/interrupts.c +++ b/arch/avr32/cpu/interrupts.c @@ -62,13 +62,6 @@ unsigned long long get_ticks(void) return ((unsigned long long)hi_now << 32) | lo; }
-void reset_timer(void) -{ - sysreg_write(COUNT, 0); - cpu_sync_pipeline(); /* process any pending interrupts */ - timer_overflow = 0; -} - unsigned long get_timer(unsigned long base) { u64 now = get_ticks(); diff --git a/arch/blackfin/cpu/interrupts.c b/arch/blackfin/cpu/interrupts.c index 54a67b4..9189816 100644 --- a/arch/blackfin/cpu/interrupts.c +++ b/arch/blackfin/cpu/interrupts.c @@ -152,8 +152,3 @@ ulong get_timer(ulong base)
return (milisec - base); } - -void reset_timer(void) -{ - timer_init(); -} diff --git a/arch/m68k/cpu/mcf547x_8x/slicetimer.c b/arch/m68k/cpu/mcf547x_8x/slicetimer.c index 49dba6a..467a807 100644 --- a/arch/m68k/cpu/mcf547x_8x/slicetimer.c +++ b/arch/m68k/cpu/mcf547x_8x/slicetimer.c @@ -95,11 +95,6 @@ void timer_init(void) timerp->cr = SLT_CR_RUN | SLT_CR_IEN | SLT_CR_TEN; }
-void reset_timer(void) -{ - timestamp = 0; -} - ulong get_timer(ulong base) { return (timestamp - base); diff --git a/arch/m68k/lib/time.c b/arch/m68k/lib/time.c index d10bcc7..a316cdf 100644 --- a/arch/m68k/lib/time.c +++ b/arch/m68k/lib/time.c @@ -116,11 +116,6 @@ void timer_init(void) DTIM_DTMR_FRR | DTIM_DTMR_ORRI | DTIM_DTMR_RST_EN; }
-void reset_timer(void) -{ - timestamp = 0; -} - ulong get_timer(ulong base) { return (timestamp - base); diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index 59ed126..a167755 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -28,11 +28,6 @@
volatile int timestamp = 0;
-void reset_timer (void) -{ - timestamp = 0; -} - #ifdef CONFIG_SYS_TIMER_0 ulong get_timer (ulong base) { @@ -61,7 +56,7 @@ int timer_init (void) tmr->control = TIMER_INTERRUPT | TIMER_RESET; tmr->control = TIMER_ENABLE | TIMER_ENABLE_INTR | TIMER_RELOAD | TIMER_DOWN_COUNT; - reset_timer (); + timestamp = 0; install_interrupt_handler (CONFIG_SYS_TIMER_0_IRQ, timer_isr, (void *)tmr); return 0; } diff --git a/arch/mips/cpu/mips32/time.c b/arch/mips/cpu/mips32/time.c index b0a9c1f..350896a 100644 --- a/arch/mips/cpu/mips32/time.c +++ b/arch/mips/cpu/mips32/time.c @@ -42,12 +42,6 @@ int timer_init(void) return 0; }
-void reset_timer(void) -{ - timestamp = 0; - write_c0_compare(read_c0_count() + CYCLES_PER_JIFFY); -} - ulong get_timer(ulong base) { unsigned int count; diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c index 847ad37..aeae413 100644 --- a/arch/powerpc/lib/interrupts.c +++ b/arch/powerpc/lib/interrupts.c @@ -137,11 +137,6 @@ void timer_interrupt (struct pt_regs *regs) #endif /* CONFIG_SHOW_ACTIVITY */ }
-void reset_timer (void) -{ - timestamp = 0; -} - ulong get_timer (ulong base) { return (timestamp - base); diff --git a/arch/sh/lib/time.c b/arch/sh/lib/time.c index c4bfc86..c70baed 100644 --- a/arch/sh/lib/time.c +++ b/arch/sh/lib/time.c @@ -139,13 +139,6 @@ unsigned long get_timer (unsigned long base) return tick_to_time(get_ticks()) - base; }
-void reset_timer (void) -{ - tmu_timer_stop(0); - writel(0, TCNT0); - tmu_timer_start(0); -} - unsigned long get_tbclk (void) { return timer_freq; diff --git a/arch/sh/lib/time_sh2.c b/arch/sh/lib/time_sh2.c index a5c838b..5827118 100644 --- a/arch/sh/lib/time_sh2.c +++ b/arch/sh/lib/time_sh2.c @@ -90,14 +90,6 @@ ulong get_timer(ulong base) return (get_usec() / 1000) - base; }
-void reset_timer(void) -{ - cmt_timer_stop(0); - writew(CMT_TIMER_RESET, CMCOR_0); - cmt0_timer = 0; - cmt_timer_start(0); -} - void __udelay(unsigned long usec) { unsigned long end = get_usec() + usec; diff --git a/arch/sparc/lib/interrupts.c b/arch/sparc/lib/interrupts.c index 5274311..61ee90b 100644 --- a/arch/sparc/lib/interrupts.c +++ b/arch/sparc/lib/interrupts.c @@ -90,11 +90,6 @@ void timer_interrupt(struct pt_regs *regs) timestamp++; }
-void reset_timer(void) -{ - timestamp = 0; -} - ulong get_timer(ulong base) { return (timestamp - base); @@ -104,7 +99,7 @@ void timer_interrupt_init(void) { int irq;
- reset_timer(); + timestamp = 0;
irq = timer_interrupt_init_cpu();
diff --git a/arch/x86/lib/timer.c b/arch/x86/lib/timer.c index 199ca8e..a822d66 100644 --- a/arch/x86/lib/timer.c +++ b/arch/x86/lib/timer.c @@ -94,11 +94,6 @@ void timer_isr(void *unused) } }
-void reset_timer (void) -{ - system_ticks = 0; -} - ulong get_timer (ulong base) { return (system_ticks - base); diff --git a/board/armltd/integrator/timer.c b/board/armltd/integrator/timer.c index 5406066..6734e8d 100644 --- a/board/armltd/integrator/timer.c +++ b/board/armltd/integrator/timer.c @@ -107,11 +107,6 @@ int timer_init (void) /* * timer without interrupts */ -void reset_timer (void) -{ - reset_timer_masked (); -} - ulong get_timer (ulong base_ticks) { return get_timer_masked () - base_ticks; diff --git a/board/armltd/vexpress/ca9x4_ct_vxp.c b/board/armltd/vexpress/ca9x4_ct_vxp.c index 6e5884b..da6f14d 100644 --- a/board/armltd/vexpress/ca9x4_ct_vxp.c +++ b/board/armltd/vexpress/ca9x4_ct_vxp.c @@ -199,11 +199,6 @@ void reset_timer_masked(void) timestamp = 0; }
-void reset_timer(void) -{ - reset_timer_masked(); -} - ulong get_timer_masked(void) { ulong now = readl(&systimer_base->timer0value) / 1000; diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c index 3d6c248..c48c7ef 100644 --- a/board/nvidia/common/board.c +++ b/board/nvidia/common/board.c @@ -62,7 +62,6 @@ int board_early_init_f(void) */ int timer_init(void) { - reset_timer(); return 0; }
-- 1.7.5.2.317.g391b14

Dear Graeme Russ,
In message 1310809000-3402-1-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Changes since v2:
- Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
arch/arm/cpu/arm1136/mx31/timer.c | 5 ----- arch/arm/cpu/arm1136/mx35/timer.c | 5 ----- arch/arm/cpu/arm1136/omap24xx/timer.c | 5 ----- arch/arm/cpu/arm1176/s3c64xx/timer.c | 5 ----- arch/arm/cpu/arm1176/tnetv107x/timer.c | 9 --------- arch/arm/cpu/arm720t/interrupts.c | 5 ----- arch/arm/cpu/arm920t/a320/timer.c | 6 ------ arch/arm/cpu/arm920t/at91/timer.c | 6 ------ arch/arm/cpu/arm920t/at91rm9200/timer.c | 6 ------ arch/arm/cpu/arm920t/ep93xx/timer.c | 5 ----- arch/arm/cpu/arm920t/imx/timer.c | 6 ------ arch/arm/cpu/arm920t/ks8695/timer.c | 7 +------ arch/arm/cpu/arm920t/s3c24x0/timer.c | 6 ------ arch/arm/cpu/arm925t/timer.c | 6 ------ arch/arm/cpu/arm926ejs/armada100/timer.c | 5 ----- arch/arm/cpu/arm926ejs/davinci/timer.c | 5 ----- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx25/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx27/timer.c | 5 ----- arch/arm/cpu/arm926ejs/nomadik/timer.c | 12 +++++------- arch/arm/cpu/arm926ejs/omap/timer.c | 6 ------ arch/arm/cpu/arm926ejs/orion5x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/pantheon/timer.c | 5 ----- arch/arm/cpu/arm926ejs/spear/timer.c | 6 ------ arch/arm/cpu/arm926ejs/versatile/timer.c | 6 ------ arch/arm/cpu/armv7/mx5/timer.c | 5 ----- arch/arm/cpu/armv7/omap-common/timer.c | 5 ----- arch/arm/cpu/armv7/s5p-common/timer.c | 5 ----- arch/arm/cpu/armv7/tegra2/timer.c | 5 ----- arch/arm/cpu/ixp/timer.c | 5 ----- arch/arm/cpu/lh7a40x/timer.c | 6 ------ arch/arm/cpu/pxa/timer.c | 7 +------ arch/arm/cpu/s3c44b0/timer.c | 6 ------ arch/arm/cpu/sa1100/timer.c | 5 ----- arch/avr32/cpu/interrupts.c | 7 ------- arch/blackfin/cpu/interrupts.c | 5 ----- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 5 ----- arch/m68k/lib/time.c | 5 ----- arch/microblaze/cpu/timer.c | 7 +------ arch/mips/cpu/mips32/time.c | 6 ------ arch/powerpc/lib/interrupts.c | 5 ----- arch/sh/lib/time.c | 7 ------- arch/sh/lib/time_sh2.c | 8 -------- arch/sparc/lib/interrupts.c | 7 +------ arch/x86/lib/timer.c | 5 ----- board/armltd/integrator/timer.c | 5 ----- board/armltd/vexpress/ca9x4_ct_vxp.c | 5 ----- board/nvidia/common/board.c | 1 - 49 files changed, 9 insertions(+), 270 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

On Tuesday, July 26, 2011 08:53:37 Wolfgang Denk wrote:
Dear Graeme Russ,
In message 1310809000-3402-1-git-send-email-graeme.russ@gmail.com you
wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Changes since v2:
- Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
arch/arm/cpu/arm1136/mx31/timer.c | 5 ----- arch/arm/cpu/arm1136/mx35/timer.c | 5 ----- arch/arm/cpu/arm1136/omap24xx/timer.c | 5 ----- arch/arm/cpu/arm1176/s3c64xx/timer.c | 5 ----- arch/arm/cpu/arm1176/tnetv107x/timer.c | 9 --------- arch/arm/cpu/arm720t/interrupts.c | 5 ----- arch/arm/cpu/arm920t/a320/timer.c | 6 ------ arch/arm/cpu/arm920t/at91/timer.c | 6 ------ arch/arm/cpu/arm920t/at91rm9200/timer.c | 6 ------ arch/arm/cpu/arm920t/ep93xx/timer.c | 5 ----- arch/arm/cpu/arm920t/imx/timer.c | 6 ------ arch/arm/cpu/arm920t/ks8695/timer.c | 7 +------ arch/arm/cpu/arm920t/s3c24x0/timer.c | 6 ------ arch/arm/cpu/arm925t/timer.c | 6 ------ arch/arm/cpu/arm926ejs/armada100/timer.c | 5 ----- arch/arm/cpu/arm926ejs/davinci/timer.c | 5 ----- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx25/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx27/timer.c | 5 ----- arch/arm/cpu/arm926ejs/nomadik/timer.c | 12 +++++------- arch/arm/cpu/arm926ejs/omap/timer.c | 6 ------ arch/arm/cpu/arm926ejs/orion5x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/pantheon/timer.c | 5 ----- arch/arm/cpu/arm926ejs/spear/timer.c | 6 ------ arch/arm/cpu/arm926ejs/versatile/timer.c | 6 ------ arch/arm/cpu/armv7/mx5/timer.c | 5 ----- arch/arm/cpu/armv7/omap-common/timer.c | 5 ----- arch/arm/cpu/armv7/s5p-common/timer.c | 5 ----- arch/arm/cpu/armv7/tegra2/timer.c | 5 ----- arch/arm/cpu/ixp/timer.c | 5 ----- arch/arm/cpu/lh7a40x/timer.c | 6 ------ arch/arm/cpu/pxa/timer.c | 7 +------ arch/arm/cpu/s3c44b0/timer.c | 6 ------ arch/arm/cpu/sa1100/timer.c | 5 ----- arch/avr32/cpu/interrupts.c | 7 ------- arch/blackfin/cpu/interrupts.c | 5 ----- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 5 ----- arch/m68k/lib/time.c | 5 ----- arch/microblaze/cpu/timer.c | 7 +------ arch/mips/cpu/mips32/time.c | 6 ------ arch/powerpc/lib/interrupts.c | 5 ----- arch/sh/lib/time.c | 7 ------- arch/sh/lib/time_sh2.c | 8 -------- arch/sparc/lib/interrupts.c | 7 +------ arch/x86/lib/timer.c | 5 ----- board/armltd/integrator/timer.c | 5 ----- board/armltd/vexpress/ca9x4_ct_vxp.c | 5 ----- board/nvidia/common/board.c | 1 - 49 files changed, 9 insertions(+), 270 deletions(-)
Applied, thanks.
Wolfgang: is there something wrong with your application process ? it seems that Graeme had a proper s-o-b tag in his patch on the mailing list, but the patch that's actually in git is missing it (as are some others). any idea ? -mike

Mike,
On Saturday, August 20, 2011, Mike Frysinger vapier@gentoo.org wrote:
On Tuesday, July 26, 2011 08:53:37 Wolfgang Denk wrote:
Dear Graeme Russ,
In message 1310809000-3402-1-git-send-email-graeme.russ@gmail.com you
wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Changes since v2:
- Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
arch/arm/cpu/arm1136/mx31/timer.c | 5 ----- arch/arm/cpu/arm1136/mx35/timer.c | 5 ----- arch/arm/cpu/arm1136/omap24xx/timer.c | 5 ----- arch/arm/cpu/arm1176/s3c64xx/timer.c | 5 ----- arch/arm/cpu/arm1176/tnetv107x/timer.c | 9 --------- arch/arm/cpu/arm720t/interrupts.c | 5 ----- arch/arm/cpu/arm920t/a320/timer.c | 6 ------ arch/arm/cpu/arm920t/at91/timer.c | 6 ------ arch/arm/cpu/arm920t/at91rm9200/timer.c | 6 ------ arch/arm/cpu/arm920t/ep93xx/timer.c | 5 ----- arch/arm/cpu/arm920t/imx/timer.c | 6 ------ arch/arm/cpu/arm920t/ks8695/timer.c | 7 +------ arch/arm/cpu/arm920t/s3c24x0/timer.c | 6 ------ arch/arm/cpu/arm925t/timer.c | 6 ------ arch/arm/cpu/arm926ejs/armada100/timer.c | 5 ----- arch/arm/cpu/arm926ejs/davinci/timer.c | 5 ----- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx25/timer.c | 5 ----- arch/arm/cpu/arm926ejs/mx27/timer.c | 5 ----- arch/arm/cpu/arm926ejs/nomadik/timer.c | 12 +++++------- arch/arm/cpu/arm926ejs/omap/timer.c | 6 ------ arch/arm/cpu/arm926ejs/orion5x/timer.c | 5 ----- arch/arm/cpu/arm926ejs/pantheon/timer.c | 5 ----- arch/arm/cpu/arm926ejs/spear/timer.c | 6 ------ arch/arm/cpu/arm926ejs/versatile/timer.c | 6 ------ arch/arm/cpu/armv7/mx5/timer.c | 5 ----- arch/arm/cpu/armv7/omap-common/timer.c | 5 ----- arch/arm/cpu/armv7/s5p-common/timer.c | 5 ----- arch/arm/cpu/armv7/tegra2/timer.c | 5 ----- arch/arm/cpu/ixp/timer.c | 5 ----- arch/arm/cpu/lh7a40x/timer.c | 6 ------ arch/arm/cpu/pxa/timer.c | 7 +------ arch/arm/cpu/s3c44b0/timer.c | 6 ------ arch/arm/cpu/sa1100/timer.c | 5 ----- arch/avr32/cpu/interrupts.c | 7 ------- arch/blackfin/cpu/interrupts.c | 5 ----- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 5 ----- arch/m68k/lib/time.c | 5 ----- arch/microblaze/cpu/timer.c | 7 +------
Wolfgang: is there something wrong with your application process ? it
seems
that Graeme had a proper s-o-b tag in his patch on the mailing list, but
the
patch that's actually in git is missing it (as are some others). any idea
?
I wonder if git needs a blank line between the sob and ---
Regards,
Graeme

Dear Mike Frysinger,
In message 201108191724.22580.vapier@gentoo.org you wrote:
Wolfgang: is there something wrong with your application process ? it seems that Graeme had a proper s-o-b tag in his patch on the mailing list, but the patch that's actually in git is missing it (as are some others). any idea ?
I think this might be a problem with PatchWork which matches patches based on their hash over the body only; if several versions of a the same patch get posted that differonly in the commit message, the hash based mapping will (incorrectly) pick the oldest entry.
Best regards,
Wolfgang Denk

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- arch/arm/cpu/arm920t/at91rm9200/spi.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/cpu/arm920t/at91rm9200/spi.c b/arch/arm/cpu/arm920t/at91rm9200/spi.c index f3cb5d8..c70efc6 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/spi.c +++ b/arch/arm/cpu/arm920t/at91rm9200/spi.c @@ -108,6 +108,7 @@ void AT91F_SpiEnable(int cs) unsigned int AT91F_SpiWrite ( AT91PS_DataflashDesc pDesc ) { unsigned int timeout; + unsigned long start;
pDesc->state = BUSY;
@@ -132,12 +133,12 @@ unsigned int AT91F_SpiWrite ( AT91PS_DataflashDesc pDesc ) }
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0); timeout = 0;
AT91C_BASE_SPI->SPI_PTCR = AT91C_PDC_TXTEN + AT91C_PDC_RXTEN; while(!(AT91C_BASE_SPI->SPI_SR & AT91C_SPI_RXBUFF) && - ((timeout = get_timer_masked() ) < CONFIG_SYS_SPI_WRITE_TOUT)); + ((timeout = get_timer(start) ) < CONFIG_SYS_SPI_WRITE_TOUT)); AT91C_BASE_SPI->SPI_PTCR = AT91C_PDC_TXTDIS + AT91C_PDC_RXTDIS; pDesc->state = IDLE;

Dear Graeme Russ,
Am 28.06.2011 13:40, schrieb Graeme Russ:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
arch/arm/cpu/arm920t/at91rm9200/spi.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
don't mind arm920t/at91rm9200, it will be removed in this merge window (see end of doc/README.at91-soc and various discussion threads).
regards
Andreas Bießmann

--- Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
arch/arm/cpu/arm920t/at91rm9200/spi.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/cpu/arm920t/at91rm9200/spi.c b/arch/arm/cpu/arm920t/at91rm9200/spi.c index f3cb5d8..c70efc6 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/spi.c +++ b/arch/arm/cpu/arm920t/at91rm9200/spi.c @@ -108,6 +108,7 @@ void AT91F_SpiEnable(int cs) unsigned int AT91F_SpiWrite ( AT91PS_DataflashDesc pDesc ) { unsigned int timeout; + unsigned long start;
pDesc->state = BUSY;
@@ -132,12 +133,12 @@ unsigned int AT91F_SpiWrite ( AT91PS_DataflashDesc pDesc ) }
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0); timeout = 0;
AT91C_BASE_SPI->SPI_PTCR = AT91C_PDC_TXTEN + AT91C_PDC_RXTEN; while(!(AT91C_BASE_SPI->SPI_SR & AT91C_SPI_RXBUFF) && - ((timeout = get_timer_masked() ) < CONFIG_SYS_SPI_WRITE_TOUT)); + ((timeout = get_timer(start) ) < CONFIG_SYS_SPI_WRITE_TOUT)); AT91C_BASE_SPI->SPI_PTCR = AT91C_PDC_TXTDIS + AT91C_PDC_RXTDIS; pDesc->state = IDLE;
-- 1.7.5.2.317.g391b14

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- Changes since v2: - Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
arch/arm/cpu/arm920t/at91rm9200/spi.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/cpu/arm920t/at91rm9200/spi.c b/arch/arm/cpu/arm920t/at91rm9200/spi.c index f3cb5d8..c70efc6 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/spi.c +++ b/arch/arm/cpu/arm920t/at91rm9200/spi.c @@ -108,6 +108,7 @@ void AT91F_SpiEnable(int cs) unsigned int AT91F_SpiWrite ( AT91PS_DataflashDesc pDesc ) { unsigned int timeout; + unsigned long start;
pDesc->state = BUSY;
@@ -132,12 +133,12 @@ unsigned int AT91F_SpiWrite ( AT91PS_DataflashDesc pDesc ) }
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + start = get_timer(0); timeout = 0;
AT91C_BASE_SPI->SPI_PTCR = AT91C_PDC_TXTEN + AT91C_PDC_RXTEN; while(!(AT91C_BASE_SPI->SPI_SR & AT91C_SPI_RXBUFF) && - ((timeout = get_timer_masked() ) < CONFIG_SYS_SPI_WRITE_TOUT)); + ((timeout = get_timer(start) ) < CONFIG_SYS_SPI_WRITE_TOUT)); AT91C_BASE_SPI->SPI_PTCR = AT91C_PDC_TXTDIS + AT91C_PDC_RXTDIS; pDesc->state = IDLE;
-- 1.7.5.2.317.g391b14

Dear Graeme Russ,
In message 1310809041-3442-1-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Changes since v2:
- Added Signed-off-by
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
arch/arm/cpu/arm920t/at91rm9200/spi.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Fold implementation into timer_init() where needed
Signed-off-by: Graeme Russ graeme.russ@gmail.com --- arch/arm/cpu/arm1136/mx31/timer.c | 7 ------- arch/arm/cpu/arm1136/omap24xx/timer.c | 14 +++++++------- arch/arm/cpu/arm1176/s3c64xx/timer.c | 7 ------- arch/arm/cpu/arm720t/interrupts.c | 7 ------- arch/arm/cpu/arm920t/at91/timer.c | 8 -------- arch/arm/cpu/arm920t/at91rm9200/timer.c | 7 ------- arch/arm/cpu/arm920t/ep93xx/timer.c | 10 +++------- arch/arm/cpu/arm920t/imx/timer.c | 10 +++------- arch/arm/cpu/arm920t/ks8695/timer.c | 15 +++++---------- arch/arm/cpu/arm920t/s3c24x0/timer.c | 7 ------- arch/arm/cpu/arm925t/timer.c | 12 +++--------- arch/arm/cpu/arm926ejs/armada100/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 14 +++----------- arch/arm/cpu/arm926ejs/mx25/timer.c | 9 --------- arch/arm/cpu/arm926ejs/mx27/timer.c | 9 --------- arch/arm/cpu/arm926ejs/orion5x/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/pantheon/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/spear/timer.c | 11 +++-------- arch/arm/cpu/armv7/mx5/timer.c | 10 ++++------ arch/arm/cpu/armv7/omap-common/timer.c | 11 +++-------- arch/arm/cpu/armv7/tegra2/timer.c | 7 ------- arch/arm/cpu/ixp/timer.c | 8 -------- arch/arm/cpu/pxa/timer.c | 8 +------- arch/arm/cpu/s3c44b0/timer.c | 7 ------- arch/arm/cpu/sa1100/timer.c | 6 ------ board/armltd/integrator/timer.c | 13 ++++--------- 27 files changed, 47 insertions(+), 210 deletions(-)
diff --git a/arch/arm/cpu/arm1136/mx31/timer.c b/arch/arm/cpu/arm1136/mx31/timer.c index eac4ffb..c05a39d 100644 --- a/arch/arm/cpu/arm1136/mx31/timer.c +++ b/arch/arm/cpu/arm1136/mx31/timer.c @@ -106,13 +106,6 @@ int timer_init (void) return 0; }
-void reset_timer_masked (void) -{ - /* reset time */ - gd->lastinc = GPTCNT; /* capture current incrementer value time */ - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - unsigned long long get_ticks (void) { ulong now = GPTCNT; /* current tick value */ diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c index 6f1ebbf..73bf4a7 100644 --- a/arch/arm/cpu/arm1136/omap24xx/timer.c +++ b/arch/arm/cpu/arm1136/omap24xx/timer.c @@ -41,6 +41,13 @@
DECLARE_GLOBAL_DATA_PTR;
+static void reset_timer_masked (void) +{ + /* reset time */ + gd->lastinc = READ_TIMER; /* capture current incrementer value time */ + gd->tbl = 0; /* start "advancing" time stamp from 0 */ +} + int timer_init (void) { int32_t val; @@ -85,13 +92,6 @@ void __udelay (unsigned long usec) /*NOP*/; }
-void reset_timer_masked (void) -{ - /* reset time */ - gd->lastinc = READ_TIMER; /* capture current incrementer value time */ - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked (void) { ulong now = READ_TIMER; /* current tick value */ diff --git a/arch/arm/cpu/arm1176/s3c64xx/timer.c b/arch/arm/cpu/arm1176/s3c64xx/timer.c index bc21f86..f16a37b 100644 --- a/arch/arm/cpu/arm1176/s3c64xx/timer.c +++ b/arch/arm/cpu/arm1176/s3c64xx/timer.c @@ -135,13 +135,6 @@ ulong get_tbclk(void) return (ulong)(timer_load_val / 100); }
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = read_timer(); - timestamp = 0; -} - ulong get_timer_masked(void) { unsigned long long res = get_ticks(); diff --git a/arch/arm/cpu/arm720t/interrupts.c b/arch/arm/cpu/arm720t/interrupts.c index 9cd7fee..fa9c5a2 100644 --- a/arch/arm/cpu/arm720t/interrupts.c +++ b/arch/arm/cpu/arm720t/interrupts.c @@ -233,13 +233,6 @@ void __udelay (unsigned long usec) #endif }
-void reset_timer_masked (void) -{ - /* reset time */ - lastdec = READ_TIMER; - timestamp = 0; -} - ulong get_timer_masked (void) { ulong now = READ_TIMER; diff --git a/arch/arm/cpu/arm920t/at91/timer.c b/arch/arm/cpu/arm920t/at91/timer.c index 374cc25..c321e28 100644 --- a/arch/arm/cpu/arm920t/at91/timer.c +++ b/arch/arm/cpu/arm920t/at91/timer.c @@ -82,14 +82,6 @@ void __udelay(unsigned long usec) udelay_masked(usec); }
-void reset_timer_masked(void) -{ - /* reset time */ - at91_tc_t *tc = (at91_tc_t *) ATMEL_BASE_TC; - gd->lastinc = readl(&tc->tc[0].cv) & 0x0000ffff; - gd->tbl = 0; -} - ulong get_timer_raw(void) { at91_tc_t *tc = (at91_tc_t *) ATMEL_BASE_TC; diff --git a/arch/arm/cpu/arm920t/at91rm9200/timer.c b/arch/arm/cpu/arm920t/at91rm9200/timer.c index 9a1ae85..fbe74b6 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/timer.c +++ b/arch/arm/cpu/arm920t/at91rm9200/timer.c @@ -81,13 +81,6 @@ void __udelay (unsigned long usec) udelay_masked(usec); }
-void reset_timer_masked (void) -{ - /* reset time */ - lastinc = READ_TIMER; - timestamp = 0; -} - ulong get_timer_raw (void) { ulong now = READ_TIMER; diff --git a/arch/arm/cpu/arm920t/ep93xx/timer.c b/arch/arm/cpu/arm920t/ep93xx/timer.c index f19ec61..a3990a7 100644 --- a/arch/arm/cpu/arm920t/ep93xx/timer.c +++ b/arch/arm/cpu/arm920t/ep93xx/timer.c @@ -91,12 +91,6 @@ unsigned long get_timer(unsigned long base) return get_timer_masked() - base; }
-void reset_timer_masked(void) -{ - read_timer(); - timer.ticks = 0; -} - void __udelay(unsigned long usec) { unsigned long long target; @@ -123,7 +117,9 @@ int timer_init(void) writel(TIMER_ENABLE | TIMER_CLKSEL, &timer_regs->timer3.control);
- reset_timer_masked(); + /* Reset the timer */ + read_timer(); + timer.ticks = 0;
return 0; } diff --git a/arch/arm/cpu/arm920t/imx/timer.c b/arch/arm/cpu/arm920t/imx/timer.c index cdb2148..6141bd4 100644 --- a/arch/arm/cpu/arm920t/imx/timer.c +++ b/arch/arm/cpu/arm920t/imx/timer.c @@ -43,7 +43,9 @@ int timer_init (void) TPRER1 = get_PERCLK1() / 1000000; /* 1 MHz */ TCTL1 |= TCTL_FRR | (1<<1); /* Freerun Mode, PERCLK1 input */
- reset_timer_masked(); + /* Reset the timer */ + TCTL1 &= ~TCTL_TEN; + TCTL1 |= TCTL_TEN; /* Enable timer */
return (0); } @@ -56,12 +58,6 @@ ulong get_timer (ulong base) return get_timer_masked() - base; }
-void reset_timer_masked (void) -{ - TCTL1 &= ~TCTL_TEN; - TCTL1 |= TCTL_TEN; /* Enable timer */ -} - ulong get_timer_masked (void) { return TCN1; diff --git a/arch/arm/cpu/arm920t/ks8695/timer.c b/arch/arm/cpu/arm920t/ks8695/timer.c index c78fd90..234fe91 100644 --- a/arch/arm/cpu/arm920t/ks8695/timer.c +++ b/arch/arm/cpu/arm920t/ks8695/timer.c @@ -33,7 +33,11 @@ ulong timer_ticks;
int timer_init (void) { - reset_timer_masked(); + /* Set the hadware timer for 1ms */ + ks8695_write(KS8695_TIMER1, TIMER_COUNT); + ks8695_write(KS8695_TIMER1_PCOUNT, TIMER_PULSE); + ks8695_write(KS8695_TIMER_CTRL, 0x2); + timer_ticks = 0;
return 0; } @@ -46,15 +50,6 @@ int timer_init (void) #define TIMER_COUNT (TIMER_INTERVAL / 2) #define TIMER_PULSE TIMER_COUNT
-void reset_timer_masked(void) -{ - /* Set the hadware timer for 1ms */ - ks8695_write(KS8695_TIMER1, TIMER_COUNT); - ks8695_write(KS8695_TIMER1_PCOUNT, TIMER_PULSE); - ks8695_write(KS8695_TIMER_CTRL, 0x2); - timer_ticks = 0; -} - ulong get_timer_masked(void) { /* Check for timer wrap */ diff --git a/arch/arm/cpu/arm920t/s3c24x0/timer.c b/arch/arm/cpu/arm920t/s3c24x0/timer.c index 4e50291..7327d6c 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/timer.c +++ b/arch/arm/cpu/arm920t/s3c24x0/timer.c @@ -101,13 +101,6 @@ void __udelay (unsigned long usec) /*NOP*/; }
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = READ_TIMER(); - timestamp = 0; -} - ulong get_timer_masked(void) { ulong tmr = get_ticks(); diff --git a/arch/arm/cpu/arm925t/timer.c b/arch/arm/cpu/arm925t/timer.c index 9c965e0..1b9386b 100644 --- a/arch/arm/cpu/arm925t/timer.c +++ b/arch/arm/cpu/arm925t/timer.c @@ -56,7 +56,9 @@ int timer_init (void) CONFIG_SYS_TIMERBASE + CNTL_TIMER);
/* init the timestamp and lastdec value */ - reset_timer_masked(); + lastdec = __raw_readl(CONFIG_SYS_TIMERBASE + READ_TIM) / + (TIMER_CLOCK / CONFIG_SYS_HZ); + timestamp = 0; /* start "advancing" time stamp from 0 */
return 0; } @@ -85,14 +87,6 @@ void __udelay (unsigned long usec) } }
-void reset_timer_masked (void) -{ - /* reset time */ - lastdec = __raw_readl(CONFIG_SYS_TIMERBASE + READ_TIM) / - (TIMER_CLOCK / CONFIG_SYS_HZ); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked (void) { uint32_t now = __raw_readl(CONFIG_SYS_TIMERBASE + READ_TIM) / diff --git a/arch/arm/cpu/arm926ejs/armada100/timer.c b/arch/arm/cpu/arm926ejs/armada100/timer.c index 86da0ce..82a6d7b 100644 --- a/arch/arm/cpu/arm926ejs/armada100/timer.c +++ b/arch/arm/cpu/arm926ejs/armada100/timer.c @@ -77,13 +77,6 @@ ulong read_timer(void) return(readl(&armd1timers->cvwr)); }
-void reset_timer_masked(void) -{ - /* reset time */ - gd->tbl = read_timer(); - gd->tbu = 0; -} - ulong get_timer_masked(void) { ulong now = read_timer(); @@ -142,7 +135,8 @@ int timer_init(void) /* Enable timer 0 */ writel(0x1, &armd1timers->cer); /* init the gd->tbu and gd->tbl value */ - reset_timer_masked(); + gd->tbl = read_timer(); + gd->tbu = 0;
return 0; } diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c index 5beb3f5..b4f6cf8 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c @@ -88,13 +88,6 @@ DECLARE_GLOBAL_DATA_PTR; #define timestamp gd->tbl #define lastdec gd->lastinc
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = READ_TIMER; - timestamp = 0; -} - ulong get_timer_masked(void) { ulong now = READ_TIMER; @@ -154,7 +147,8 @@ int timer_init(void) writel(cntmrctrl, CNTMR_CTRL_REG);
/* init the timestamp and lastdec value */ - reset_timer_masked(); + lastdec = READ_TIMER; + timestamp = 0;
return 0; } diff --git a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c index 5f54085..8f38056 100644 --- a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c +++ b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c @@ -68,7 +68,9 @@ int timer_init(void)
writel(ctrl, &timer->control);
- reset_timer_masked(); + /* capture current value time */ + lastdec = readl(&timer->value); + timestamp = 0; /* start "advancing" time stamp from 0 */
return 0; } @@ -94,16 +96,6 @@ unsigned long long get_ticks(void) return timestamp; }
-void reset_timer_masked(void) -{ - struct mb86r0x_timer * timer = (struct mb86r0x_timer *) - MB86R0x_TIMER_BASE; - - /* capture current value time */ - lastdec = readl(&timer->value); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked(void) { return tick_to_time(get_ticks()); diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c index 9a84b50..131d600 100644 --- a/arch/arm/cpu/arm926ejs/mx25/timer.c +++ b/arch/arm/cpu/arm926ejs/mx25/timer.c @@ -121,15 +121,6 @@ int timer_init(void) return 0; }
-void reset_timer_masked(void) -{ - struct gpt_regs *gpt = (struct gpt_regs *)IMX_GPT1_BASE; - /* reset time */ - /* capture current incrementer value time */ - lastinc = readl(&gpt->counter); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - unsigned long long get_ticks (void) { struct gpt_regs *gpt = (struct gpt_regs *)IMX_GPT1_BASE; diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c index 058dbee..df76d16 100644 --- a/arch/arm/cpu/arm926ejs/mx27/timer.c +++ b/arch/arm/cpu/arm926ejs/mx27/timer.c @@ -124,15 +124,6 @@ int timer_init(void) return 0; }
-void reset_timer_masked(void) -{ - struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE; - /* reset time */ - /* capture current incrementer value time */ - lastinc = readl(®s->gpt_tcn); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - unsigned long long get_ticks (void) { struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE; diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c index 5bc43c8..17df68f 100644 --- a/arch/arm/cpu/arm926ejs/orion5x/timer.c +++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c @@ -95,13 +95,6 @@ DECLARE_GLOBAL_DATA_PTR; #define timestamp gd->tbl #define lastdec gd->lastinc
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = read_timer(); - timestamp = 0; -} - ulong get_timer_masked(void) { ulong now = read_timer(); @@ -171,5 +164,6 @@ int timer_init(void) void timer_init_r(void) { /* init the timestamp and lastdec value */ - reset_timer_masked(); + lastdec = read_timer(); + timestamp = 0; } diff --git a/arch/arm/cpu/arm926ejs/pantheon/timer.c b/arch/arm/cpu/arm926ejs/pantheon/timer.c index 2727adc..c71162a 100644 --- a/arch/arm/cpu/arm926ejs/pantheon/timer.c +++ b/arch/arm/cpu/arm926ejs/pantheon/timer.c @@ -85,13 +85,6 @@ ulong read_timer(void) return val; }
-void reset_timer_masked(void) -{ - /* reset time */ - gd->tbl = read_timer(); - gd->tbu = 0; -} - ulong get_timer_masked(void) { ulong now = read_timer(); @@ -151,7 +144,8 @@ int timer_init(void) /* Enable timer 0 */ writel(0x1, &panthtimers->cer); /* init the gd->tbu and gd->tbl value */ - reset_timer_masked(); + gd->tbl = read_timer(); + gd->tbu = 0;
return 0; } diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c index cbef34f..1dc7860 100644 --- a/arch/arm/cpu/arm926ejs/spear/timer.c +++ b/arch/arm/cpu/arm926ejs/spear/timer.c @@ -68,7 +68,9 @@ int timer_init(void) /* auto reload, start timer */ writel(readl(&gpt_regs_p->control) | GPT_ENABLE, &gpt_regs_p->control);
- reset_timer_masked(); + /* Reset the timer */ + lastdec = READ_TIMER(); + timestamp = 0;
return 0; } @@ -97,13 +99,6 @@ void __udelay(unsigned long usec) ; }
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = READ_TIMER(); - timestamp = 0; -} - ulong get_timer_masked(void) { ulong now = READ_TIMER(); diff --git a/arch/arm/cpu/armv7/mx5/timer.c b/arch/arm/cpu/armv7/mx5/timer.c index 4525beb..2544b08 100644 --- a/arch/arm/cpu/armv7/mx5/timer.c +++ b/arch/arm/cpu/armv7/mx5/timer.c @@ -52,6 +52,7 @@ DECLARE_GLOBAL_DATA_PTR; int timer_init(void) { int i; + ulong val;
/* setup GP Timer 1 */ __raw_writel(GPTCR_SWR, &cur_gpt->control); @@ -65,15 +66,12 @@ int timer_init(void) /* Freerun Mode, PERCLK1 input */ i = __raw_readl(&cur_gpt->control); __raw_writel(i | GPTCR_CLKSOURCE_32 | GPTCR_TEN, &cur_gpt->control); - reset_timer_masked(); - return 0; -}
-void reset_timer_masked(void) -{ - ulong val = __raw_readl(&cur_gpt->counter); + val = __raw_readl(&cur_gpt->counter); lastinc = val / (CONFIG_SYS_MX5_CLK32 / CONFIG_SYS_HZ); timestamp = 0; + + return 0; }
ulong get_timer_masked(void) diff --git a/arch/arm/cpu/armv7/omap-common/timer.c b/arch/arm/cpu/armv7/omap-common/timer.c index 24ab853..83d9dc7 100644 --- a/arch/arm/cpu/armv7/omap-common/timer.c +++ b/arch/arm/cpu/armv7/omap-common/timer.c @@ -54,7 +54,9 @@ int timer_init(void) writel((CONFIG_SYS_PTV << 2) | TCLR_PRE | TCLR_AR | TCLR_ST, &timer_base->tclr);
- reset_timer_masked(); /* init the timestamp and lastinc value */ + /* reset time, capture current incrementer value time */ + gd->lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ); + gd->tbl = 0; /* start "advancing" time stamp from 0 */
return 0; } @@ -83,13 +85,6 @@ void __udelay(unsigned long usec) } }
-void reset_timer_masked(void) -{ - /* reset time, capture current incrementer value time */ - gd->lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ); - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked(void) { /* current tick value */ diff --git a/arch/arm/cpu/armv7/tegra2/timer.c b/arch/arm/cpu/armv7/tegra2/timer.c index 2761c12..0b9fa64 100644 --- a/arch/arm/cpu/armv7/tegra2/timer.c +++ b/arch/arm/cpu/armv7/tegra2/timer.c @@ -69,13 +69,6 @@ void __udelay(unsigned long usec) } }
-void reset_timer_masked(void) -{ - /* reset time, capture current incrementer value time */ - gd->lastinc = readl(&timer_base->cntr_1us) / (TIMER_CLK/CONFIG_SYS_HZ); - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked(void) { ulong now; diff --git a/arch/arm/cpu/ixp/timer.c b/arch/arm/cpu/ixp/timer.c index 1ab8cd3..54585c7 100644 --- a/arch/arm/cpu/ixp/timer.c +++ b/arch/arm/cpu/ixp/timer.c @@ -101,14 +101,6 @@ void __udelay (unsigned long usec)
static ulong reload_constant = 0xfffffff0;
-void reset_timer_masked (void) -{ - ulong reload = reload_constant | IXP425_OST_ONE_SHOT | IXP425_OST_ENABLE; - - *IXP425_OSST = IXP425_OSST_TIMER_1_PEND; - *IXP425_OSRT1 = reload; -} - ulong get_timer_masked (void) { /* diff --git a/arch/arm/cpu/pxa/timer.c b/arch/arm/cpu/pxa/timer.c index 44dae9a..2866745 100644 --- a/arch/arm/cpu/pxa/timer.c +++ b/arch/arm/cpu/pxa/timer.c @@ -59,7 +59,7 @@ static inline unsigned long long us_to_tick(unsigned long long us)
int timer_init (void) { - reset_timer_masked(); + writel(0, OSCR);
return 0; } @@ -74,12 +74,6 @@ void __udelay (unsigned long usec) udelay_masked (usec); }
- -void reset_timer_masked (void) -{ - writel(0, OSCR); -} - ulong get_timer_masked (void) { return tick_to_time(get_ticks()); diff --git a/arch/arm/cpu/s3c44b0/timer.c b/arch/arm/cpu/s3c44b0/timer.c index ce48952..6c2f066 100644 --- a/arch/arm/cpu/s3c44b0/timer.c +++ b/arch/arm/cpu/s3c44b0/timer.c @@ -78,13 +78,6 @@ void __udelay (unsigned long usec) /*NOP*/; }
-void reset_timer_masked (void) -{ - /* reset time */ - lastdec = READ_TIMER; - timestamp = 0; -} - ulong get_timer_masked (void) { ulong now = READ_TIMER; diff --git a/arch/arm/cpu/sa1100/timer.c b/arch/arm/cpu/sa1100/timer.c index 694c03a..53bec0b 100644 --- a/arch/arm/cpu/sa1100/timer.c +++ b/arch/arm/cpu/sa1100/timer.c @@ -44,12 +44,6 @@ void __udelay (unsigned long usec) udelay_masked (usec); }
- -void reset_timer_masked (void) -{ - OSCR = 0; -} - ulong get_timer_masked (void) { return OSCR; diff --git a/board/armltd/integrator/timer.c b/board/armltd/integrator/timer.c index 6734e8d..f10a026 100644 --- a/board/armltd/integrator/timer.c +++ b/board/armltd/integrator/timer.c @@ -95,7 +95,10 @@ int timer_init (void)
/* init the timestamp */ total_count = 0ULL; - reset_timer_masked(); + /* capure current decrementer value */ + lastdec = READ_TIMER; + /* start "advancing" time stamp from 0 */ + timestamp = 0L;
div_timer = CONFIG_SYS_HZ_CLOCK; do_div(div_timer, CONFIG_SYS_HZ); @@ -129,14 +132,6 @@ void __udelay (unsigned long usec) } }
-void reset_timer_masked (void) -{ - /* capure current decrementer value */ - lastdec = READ_TIMER; - /* start "advancing" time stamp from 0 */ - timestamp = 0L; -} - /* converts the timer reading to U-Boot ticks */ /* the timestamp is the number of ticks since reset */ ulong get_timer_masked (void)

Dear Graeme Russ,
In message 1309261269-4363-8-git-send-email-graeme.russ@gmail.com you wrote:
Fold implementation into timer_init() where needed
This needs a better description, then, if you don;t really remove it.
I'm otherwise fine with that, too.
Best regards,
Wolfgang Denk

In some circumstances, reset_timer_masked() was called be timer_init() in order to perform architecture specific timer initialisation. In such cases, the required code in reset_timer_masked() has been moved into timer_init() --- Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6 - Updated description
arch/arm/cpu/arm1136/mx31/timer.c | 7 ------- arch/arm/cpu/arm1136/omap24xx/timer.c | 14 +++++++------- arch/arm/cpu/arm1176/s3c64xx/timer.c | 7 ------- arch/arm/cpu/arm720t/interrupts.c | 7 ------- arch/arm/cpu/arm920t/at91/timer.c | 8 -------- arch/arm/cpu/arm920t/at91rm9200/timer.c | 7 ------- arch/arm/cpu/arm920t/ep93xx/timer.c | 10 +++------- arch/arm/cpu/arm920t/imx/timer.c | 10 +++------- arch/arm/cpu/arm920t/ks8695/timer.c | 15 +++++---------- arch/arm/cpu/arm920t/s3c24x0/timer.c | 7 ------- arch/arm/cpu/arm925t/timer.c | 12 +++--------- arch/arm/cpu/arm926ejs/armada100/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 14 +++----------- arch/arm/cpu/arm926ejs/mx25/timer.c | 9 --------- arch/arm/cpu/arm926ejs/mx27/timer.c | 9 --------- arch/arm/cpu/arm926ejs/orion5x/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/pantheon/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/spear/timer.c | 11 +++-------- arch/arm/cpu/armv7/mx5/timer.c | 10 ++++------ arch/arm/cpu/armv7/omap-common/timer.c | 11 +++-------- arch/arm/cpu/armv7/tegra2/timer.c | 7 ------- arch/arm/cpu/pxa/timer.c | 8 +------- arch/arm/cpu/s3c44b0/timer.c | 7 ------- arch/arm/cpu/sa1100/timer.c | 6 ------ board/armltd/integrator/timer.c | 13 ++++--------- 26 files changed, 47 insertions(+), 202 deletions(-)
diff --git a/arch/arm/cpu/arm1136/mx31/timer.c b/arch/arm/cpu/arm1136/mx31/timer.c index eac4ffb..c05a39d 100644 --- a/arch/arm/cpu/arm1136/mx31/timer.c +++ b/arch/arm/cpu/arm1136/mx31/timer.c @@ -106,13 +106,6 @@ int timer_init (void) return 0; }
-void reset_timer_masked (void) -{ - /* reset time */ - gd->lastinc = GPTCNT; /* capture current incrementer value time */ - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - unsigned long long get_ticks (void) { ulong now = GPTCNT; /* current tick value */ diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c index 6f1ebbf..73bf4a7 100644 --- a/arch/arm/cpu/arm1136/omap24xx/timer.c +++ b/arch/arm/cpu/arm1136/omap24xx/timer.c @@ -41,6 +41,13 @@
DECLARE_GLOBAL_DATA_PTR;
+static void reset_timer_masked (void) +{ + /* reset time */ + gd->lastinc = READ_TIMER; /* capture current incrementer value time */ + gd->tbl = 0; /* start "advancing" time stamp from 0 */ +} + int timer_init (void) { int32_t val; @@ -85,13 +92,6 @@ void __udelay (unsigned long usec) /*NOP*/; }
-void reset_timer_masked (void) -{ - /* reset time */ - gd->lastinc = READ_TIMER; /* capture current incrementer value time */ - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked (void) { ulong now = READ_TIMER; /* current tick value */ diff --git a/arch/arm/cpu/arm1176/s3c64xx/timer.c b/arch/arm/cpu/arm1176/s3c64xx/timer.c index bc21f86..f16a37b 100644 --- a/arch/arm/cpu/arm1176/s3c64xx/timer.c +++ b/arch/arm/cpu/arm1176/s3c64xx/timer.c @@ -135,13 +135,6 @@ ulong get_tbclk(void) return (ulong)(timer_load_val / 100); }
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = read_timer(); - timestamp = 0; -} - ulong get_timer_masked(void) { unsigned long long res = get_ticks(); diff --git a/arch/arm/cpu/arm720t/interrupts.c b/arch/arm/cpu/arm720t/interrupts.c index 9cd7fee..fa9c5a2 100644 --- a/arch/arm/cpu/arm720t/interrupts.c +++ b/arch/arm/cpu/arm720t/interrupts.c @@ -233,13 +233,6 @@ void __udelay (unsigned long usec) #endif }
-void reset_timer_masked (void) -{ - /* reset time */ - lastdec = READ_TIMER; - timestamp = 0; -} - ulong get_timer_masked (void) { ulong now = READ_TIMER; diff --git a/arch/arm/cpu/arm920t/at91/timer.c b/arch/arm/cpu/arm920t/at91/timer.c index 374cc25..c321e28 100644 --- a/arch/arm/cpu/arm920t/at91/timer.c +++ b/arch/arm/cpu/arm920t/at91/timer.c @@ -82,14 +82,6 @@ void __udelay(unsigned long usec) udelay_masked(usec); }
-void reset_timer_masked(void) -{ - /* reset time */ - at91_tc_t *tc = (at91_tc_t *) ATMEL_BASE_TC; - gd->lastinc = readl(&tc->tc[0].cv) & 0x0000ffff; - gd->tbl = 0; -} - ulong get_timer_raw(void) { at91_tc_t *tc = (at91_tc_t *) ATMEL_BASE_TC; diff --git a/arch/arm/cpu/arm920t/at91rm9200/timer.c b/arch/arm/cpu/arm920t/at91rm9200/timer.c index 9a1ae85..fbe74b6 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/timer.c +++ b/arch/arm/cpu/arm920t/at91rm9200/timer.c @@ -81,13 +81,6 @@ void __udelay (unsigned long usec) udelay_masked(usec); }
-void reset_timer_masked (void) -{ - /* reset time */ - lastinc = READ_TIMER; - timestamp = 0; -} - ulong get_timer_raw (void) { ulong now = READ_TIMER; diff --git a/arch/arm/cpu/arm920t/ep93xx/timer.c b/arch/arm/cpu/arm920t/ep93xx/timer.c index f19ec61..a3990a7 100644 --- a/arch/arm/cpu/arm920t/ep93xx/timer.c +++ b/arch/arm/cpu/arm920t/ep93xx/timer.c @@ -91,12 +91,6 @@ unsigned long get_timer(unsigned long base) return get_timer_masked() - base; }
-void reset_timer_masked(void) -{ - read_timer(); - timer.ticks = 0; -} - void __udelay(unsigned long usec) { unsigned long long target; @@ -123,7 +117,9 @@ int timer_init(void) writel(TIMER_ENABLE | TIMER_CLKSEL, &timer_regs->timer3.control);
- reset_timer_masked(); + /* Reset the timer */ + read_timer(); + timer.ticks = 0;
return 0; } diff --git a/arch/arm/cpu/arm920t/imx/timer.c b/arch/arm/cpu/arm920t/imx/timer.c index cdb2148..6141bd4 100644 --- a/arch/arm/cpu/arm920t/imx/timer.c +++ b/arch/arm/cpu/arm920t/imx/timer.c @@ -43,7 +43,9 @@ int timer_init (void) TPRER1 = get_PERCLK1() / 1000000; /* 1 MHz */ TCTL1 |= TCTL_FRR | (1<<1); /* Freerun Mode, PERCLK1 input */
- reset_timer_masked(); + /* Reset the timer */ + TCTL1 &= ~TCTL_TEN; + TCTL1 |= TCTL_TEN; /* Enable timer */
return (0); } @@ -56,12 +58,6 @@ ulong get_timer (ulong base) return get_timer_masked() - base; }
-void reset_timer_masked (void) -{ - TCTL1 &= ~TCTL_TEN; - TCTL1 |= TCTL_TEN; /* Enable timer */ -} - ulong get_timer_masked (void) { return TCN1; diff --git a/arch/arm/cpu/arm920t/ks8695/timer.c b/arch/arm/cpu/arm920t/ks8695/timer.c index c78fd90..234fe91 100644 --- a/arch/arm/cpu/arm920t/ks8695/timer.c +++ b/arch/arm/cpu/arm920t/ks8695/timer.c @@ -33,7 +33,11 @@ ulong timer_ticks;
int timer_init (void) { - reset_timer_masked(); + /* Set the hadware timer for 1ms */ + ks8695_write(KS8695_TIMER1, TIMER_COUNT); + ks8695_write(KS8695_TIMER1_PCOUNT, TIMER_PULSE); + ks8695_write(KS8695_TIMER_CTRL, 0x2); + timer_ticks = 0;
return 0; } @@ -46,15 +50,6 @@ int timer_init (void) #define TIMER_COUNT (TIMER_INTERVAL / 2) #define TIMER_PULSE TIMER_COUNT
-void reset_timer_masked(void) -{ - /* Set the hadware timer for 1ms */ - ks8695_write(KS8695_TIMER1, TIMER_COUNT); - ks8695_write(KS8695_TIMER1_PCOUNT, TIMER_PULSE); - ks8695_write(KS8695_TIMER_CTRL, 0x2); - timer_ticks = 0; -} - ulong get_timer_masked(void) { /* Check for timer wrap */ diff --git a/arch/arm/cpu/arm920t/s3c24x0/timer.c b/arch/arm/cpu/arm920t/s3c24x0/timer.c index 9c71b80..9571870 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/timer.c +++ b/arch/arm/cpu/arm920t/s3c24x0/timer.c @@ -101,13 +101,6 @@ void __udelay (unsigned long usec) /*NOP*/; }
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = READ_TIMER(); - timestamp = 0; -} - ulong get_timer_masked(void) { ulong tmr = get_ticks(); diff --git a/arch/arm/cpu/arm925t/timer.c b/arch/arm/cpu/arm925t/timer.c index 9c965e0..1b9386b 100644 --- a/arch/arm/cpu/arm925t/timer.c +++ b/arch/arm/cpu/arm925t/timer.c @@ -56,7 +56,9 @@ int timer_init (void) CONFIG_SYS_TIMERBASE + CNTL_TIMER);
/* init the timestamp and lastdec value */ - reset_timer_masked(); + lastdec = __raw_readl(CONFIG_SYS_TIMERBASE + READ_TIM) / + (TIMER_CLOCK / CONFIG_SYS_HZ); + timestamp = 0; /* start "advancing" time stamp from 0 */
return 0; } @@ -85,14 +87,6 @@ void __udelay (unsigned long usec) } }
-void reset_timer_masked (void) -{ - /* reset time */ - lastdec = __raw_readl(CONFIG_SYS_TIMERBASE + READ_TIM) / - (TIMER_CLOCK / CONFIG_SYS_HZ); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked (void) { uint32_t now = __raw_readl(CONFIG_SYS_TIMERBASE + READ_TIM) / diff --git a/arch/arm/cpu/arm926ejs/armada100/timer.c b/arch/arm/cpu/arm926ejs/armada100/timer.c index 86da0ce..82a6d7b 100644 --- a/arch/arm/cpu/arm926ejs/armada100/timer.c +++ b/arch/arm/cpu/arm926ejs/armada100/timer.c @@ -77,13 +77,6 @@ ulong read_timer(void) return(readl(&armd1timers->cvwr)); }
-void reset_timer_masked(void) -{ - /* reset time */ - gd->tbl = read_timer(); - gd->tbu = 0; -} - ulong get_timer_masked(void) { ulong now = read_timer(); @@ -142,7 +135,8 @@ int timer_init(void) /* Enable timer 0 */ writel(0x1, &armd1timers->cer); /* init the gd->tbu and gd->tbl value */ - reset_timer_masked(); + gd->tbl = read_timer(); + gd->tbu = 0;
return 0; } diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c index 5beb3f5..b4f6cf8 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c @@ -88,13 +88,6 @@ DECLARE_GLOBAL_DATA_PTR; #define timestamp gd->tbl #define lastdec gd->lastinc
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = READ_TIMER; - timestamp = 0; -} - ulong get_timer_masked(void) { ulong now = READ_TIMER; @@ -154,7 +147,8 @@ int timer_init(void) writel(cntmrctrl, CNTMR_CTRL_REG);
/* init the timestamp and lastdec value */ - reset_timer_masked(); + lastdec = READ_TIMER; + timestamp = 0;
return 0; } diff --git a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c index 5f54085..8f38056 100644 --- a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c +++ b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c @@ -68,7 +68,9 @@ int timer_init(void)
writel(ctrl, &timer->control);
- reset_timer_masked(); + /* capture current value time */ + lastdec = readl(&timer->value); + timestamp = 0; /* start "advancing" time stamp from 0 */
return 0; } @@ -94,16 +96,6 @@ unsigned long long get_ticks(void) return timestamp; }
-void reset_timer_masked(void) -{ - struct mb86r0x_timer * timer = (struct mb86r0x_timer *) - MB86R0x_TIMER_BASE; - - /* capture current value time */ - lastdec = readl(&timer->value); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked(void) { return tick_to_time(get_ticks()); diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c index 9a84b50..131d600 100644 --- a/arch/arm/cpu/arm926ejs/mx25/timer.c +++ b/arch/arm/cpu/arm926ejs/mx25/timer.c @@ -121,15 +121,6 @@ int timer_init(void) return 0; }
-void reset_timer_masked(void) -{ - struct gpt_regs *gpt = (struct gpt_regs *)IMX_GPT1_BASE; - /* reset time */ - /* capture current incrementer value time */ - lastinc = readl(&gpt->counter); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - unsigned long long get_ticks (void) { struct gpt_regs *gpt = (struct gpt_regs *)IMX_GPT1_BASE; diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c index 058dbee..df76d16 100644 --- a/arch/arm/cpu/arm926ejs/mx27/timer.c +++ b/arch/arm/cpu/arm926ejs/mx27/timer.c @@ -124,15 +124,6 @@ int timer_init(void) return 0; }
-void reset_timer_masked(void) -{ - struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE; - /* reset time */ - /* capture current incrementer value time */ - lastinc = readl(®s->gpt_tcn); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - unsigned long long get_ticks (void) { struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE; diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c index 5bc43c8..17df68f 100644 --- a/arch/arm/cpu/arm926ejs/orion5x/timer.c +++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c @@ -95,13 +95,6 @@ DECLARE_GLOBAL_DATA_PTR; #define timestamp gd->tbl #define lastdec gd->lastinc
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = read_timer(); - timestamp = 0; -} - ulong get_timer_masked(void) { ulong now = read_timer(); @@ -171,5 +164,6 @@ int timer_init(void) void timer_init_r(void) { /* init the timestamp and lastdec value */ - reset_timer_masked(); + lastdec = read_timer(); + timestamp = 0; } diff --git a/arch/arm/cpu/arm926ejs/pantheon/timer.c b/arch/arm/cpu/arm926ejs/pantheon/timer.c index 2727adc..c71162a 100644 --- a/arch/arm/cpu/arm926ejs/pantheon/timer.c +++ b/arch/arm/cpu/arm926ejs/pantheon/timer.c @@ -85,13 +85,6 @@ ulong read_timer(void) return val; }
-void reset_timer_masked(void) -{ - /* reset time */ - gd->tbl = read_timer(); - gd->tbu = 0; -} - ulong get_timer_masked(void) { ulong now = read_timer(); @@ -151,7 +144,8 @@ int timer_init(void) /* Enable timer 0 */ writel(0x1, &panthtimers->cer); /* init the gd->tbu and gd->tbl value */ - reset_timer_masked(); + gd->tbl = read_timer(); + gd->tbu = 0;
return 0; } diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c index cbef34f..1dc7860 100644 --- a/arch/arm/cpu/arm926ejs/spear/timer.c +++ b/arch/arm/cpu/arm926ejs/spear/timer.c @@ -68,7 +68,9 @@ int timer_init(void) /* auto reload, start timer */ writel(readl(&gpt_regs_p->control) | GPT_ENABLE, &gpt_regs_p->control);
- reset_timer_masked(); + /* Reset the timer */ + lastdec = READ_TIMER(); + timestamp = 0;
return 0; } @@ -97,13 +99,6 @@ void __udelay(unsigned long usec) ; }
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = READ_TIMER(); - timestamp = 0; -} - ulong get_timer_masked(void) { ulong now = READ_TIMER(); diff --git a/arch/arm/cpu/armv7/mx5/timer.c b/arch/arm/cpu/armv7/mx5/timer.c index 4525beb..2544b08 100644 --- a/arch/arm/cpu/armv7/mx5/timer.c +++ b/arch/arm/cpu/armv7/mx5/timer.c @@ -52,6 +52,7 @@ DECLARE_GLOBAL_DATA_PTR; int timer_init(void) { int i; + ulong val;
/* setup GP Timer 1 */ __raw_writel(GPTCR_SWR, &cur_gpt->control); @@ -65,15 +66,12 @@ int timer_init(void) /* Freerun Mode, PERCLK1 input */ i = __raw_readl(&cur_gpt->control); __raw_writel(i | GPTCR_CLKSOURCE_32 | GPTCR_TEN, &cur_gpt->control); - reset_timer_masked(); - return 0; -}
-void reset_timer_masked(void) -{ - ulong val = __raw_readl(&cur_gpt->counter); + val = __raw_readl(&cur_gpt->counter); lastinc = val / (CONFIG_SYS_MX5_CLK32 / CONFIG_SYS_HZ); timestamp = 0; + + return 0; }
ulong get_timer_masked(void) diff --git a/arch/arm/cpu/armv7/omap-common/timer.c b/arch/arm/cpu/armv7/omap-common/timer.c index 4756e26..9f8bc93 100644 --- a/arch/arm/cpu/armv7/omap-common/timer.c +++ b/arch/arm/cpu/armv7/omap-common/timer.c @@ -55,7 +55,9 @@ int timer_init(void) writel((CONFIG_SYS_PTV << 2) | TCLR_PRE | TCLR_AR | TCLR_ST, &timer_base->tclr);
- reset_timer_masked(); /* init the timestamp and lastinc value */ + /* reset time, capture current incrementer value time */ + gd->lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ); + gd->tbl = 0; /* start "advancing" time stamp from 0 */
return 0; } @@ -84,13 +86,6 @@ void __udelay(unsigned long usec) } }
-void reset_timer_masked(void) -{ - /* reset time, capture current incrementer value time */ - gd->lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ); - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked(void) { /* current tick value */ diff --git a/arch/arm/cpu/armv7/tegra2/timer.c b/arch/arm/cpu/armv7/tegra2/timer.c index 2761c12..0b9fa64 100644 --- a/arch/arm/cpu/armv7/tegra2/timer.c +++ b/arch/arm/cpu/armv7/tegra2/timer.c @@ -69,13 +69,6 @@ void __udelay(unsigned long usec) } }
-void reset_timer_masked(void) -{ - /* reset time, capture current incrementer value time */ - gd->lastinc = readl(&timer_base->cntr_1us) / (TIMER_CLK/CONFIG_SYS_HZ); - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked(void) { ulong now; diff --git a/arch/arm/cpu/pxa/timer.c b/arch/arm/cpu/pxa/timer.c index 44dae9a..2866745 100644 --- a/arch/arm/cpu/pxa/timer.c +++ b/arch/arm/cpu/pxa/timer.c @@ -59,7 +59,7 @@ static inline unsigned long long us_to_tick(unsigned long long us)
int timer_init (void) { - reset_timer_masked(); + writel(0, OSCR);
return 0; } @@ -74,12 +74,6 @@ void __udelay (unsigned long usec) udelay_masked (usec); }
- -void reset_timer_masked (void) -{ - writel(0, OSCR); -} - ulong get_timer_masked (void) { return tick_to_time(get_ticks()); diff --git a/arch/arm/cpu/s3c44b0/timer.c b/arch/arm/cpu/s3c44b0/timer.c index ce48952..6c2f066 100644 --- a/arch/arm/cpu/s3c44b0/timer.c +++ b/arch/arm/cpu/s3c44b0/timer.c @@ -78,13 +78,6 @@ void __udelay (unsigned long usec) /*NOP*/; }
-void reset_timer_masked (void) -{ - /* reset time */ - lastdec = READ_TIMER; - timestamp = 0; -} - ulong get_timer_masked (void) { ulong now = READ_TIMER; diff --git a/arch/arm/cpu/sa1100/timer.c b/arch/arm/cpu/sa1100/timer.c index 694c03a..53bec0b 100644 --- a/arch/arm/cpu/sa1100/timer.c +++ b/arch/arm/cpu/sa1100/timer.c @@ -44,12 +44,6 @@ void __udelay (unsigned long usec) udelay_masked (usec); }
- -void reset_timer_masked (void) -{ - OSCR = 0; -} - ulong get_timer_masked (void) { return OSCR; diff --git a/board/armltd/integrator/timer.c b/board/armltd/integrator/timer.c index 6734e8d..f10a026 100644 --- a/board/armltd/integrator/timer.c +++ b/board/armltd/integrator/timer.c @@ -95,7 +95,10 @@ int timer_init (void)
/* init the timestamp */ total_count = 0ULL; - reset_timer_masked(); + /* capure current decrementer value */ + lastdec = READ_TIMER; + /* start "advancing" time stamp from 0 */ + timestamp = 0L;
div_timer = CONFIG_SYS_HZ_CLOCK; do_div(div_timer, CONFIG_SYS_HZ); @@ -129,14 +132,6 @@ void __udelay (unsigned long usec) } }
-void reset_timer_masked (void) -{ - /* capure current decrementer value */ - lastdec = READ_TIMER; - /* start "advancing" time stamp from 0 */ - timestamp = 0L; -} - /* converts the timer reading to U-Boot ticks */ /* the timestamp is the number of ticks since reset */ ulong get_timer_masked (void) -- 1.7.5.2.317.g391b14

In some circumstances, reset_timer_masked() was called by timer_init() in order to perform architecture specific timer initialisation. In such cases, the required code in reset_timer_masked() has been moved into timer_init()
Signed-off-by: Graeme Russ graeme.russ@gmail.com --- Changes since v2: - Added Signed-off-by - Fixed typo in description (be->by)
Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6 - Updated description
arch/arm/cpu/arm1136/mx31/timer.c | 7 ------- arch/arm/cpu/arm1136/omap24xx/timer.c | 14 +++++++------- arch/arm/cpu/arm1176/s3c64xx/timer.c | 7 ------- arch/arm/cpu/arm720t/interrupts.c | 7 ------- arch/arm/cpu/arm920t/at91/timer.c | 8 -------- arch/arm/cpu/arm920t/at91rm9200/timer.c | 7 ------- arch/arm/cpu/arm920t/ep93xx/timer.c | 10 +++------- arch/arm/cpu/arm920t/imx/timer.c | 10 +++------- arch/arm/cpu/arm920t/ks8695/timer.c | 15 +++++---------- arch/arm/cpu/arm920t/s3c24x0/timer.c | 7 ------- arch/arm/cpu/arm925t/timer.c | 12 +++--------- arch/arm/cpu/arm926ejs/armada100/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 14 +++----------- arch/arm/cpu/arm926ejs/mx25/timer.c | 9 --------- arch/arm/cpu/arm926ejs/mx27/timer.c | 9 --------- arch/arm/cpu/arm926ejs/orion5x/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/pantheon/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/spear/timer.c | 11 +++-------- arch/arm/cpu/armv7/mx5/timer.c | 10 ++++------ arch/arm/cpu/armv7/omap-common/timer.c | 11 +++-------- arch/arm/cpu/armv7/tegra2/timer.c | 7 ------- arch/arm/cpu/pxa/timer.c | 8 +------- arch/arm/cpu/s3c44b0/timer.c | 7 ------- arch/arm/cpu/sa1100/timer.c | 6 ------ board/armltd/integrator/timer.c | 13 ++++--------- 26 files changed, 47 insertions(+), 202 deletions(-)
diff --git a/arch/arm/cpu/arm1136/mx31/timer.c b/arch/arm/cpu/arm1136/mx31/timer.c index eac4ffb..c05a39d 100644 --- a/arch/arm/cpu/arm1136/mx31/timer.c +++ b/arch/arm/cpu/arm1136/mx31/timer.c @@ -106,13 +106,6 @@ int timer_init (void) return 0; }
-void reset_timer_masked (void) -{ - /* reset time */ - gd->lastinc = GPTCNT; /* capture current incrementer value time */ - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - unsigned long long get_ticks (void) { ulong now = GPTCNT; /* current tick value */ diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c index 6f1ebbf..73bf4a7 100644 --- a/arch/arm/cpu/arm1136/omap24xx/timer.c +++ b/arch/arm/cpu/arm1136/omap24xx/timer.c @@ -41,6 +41,13 @@
DECLARE_GLOBAL_DATA_PTR;
+static void reset_timer_masked (void) +{ + /* reset time */ + gd->lastinc = READ_TIMER; /* capture current incrementer value time */ + gd->tbl = 0; /* start "advancing" time stamp from 0 */ +} + int timer_init (void) { int32_t val; @@ -85,13 +92,6 @@ void __udelay (unsigned long usec) /*NOP*/; }
-void reset_timer_masked (void) -{ - /* reset time */ - gd->lastinc = READ_TIMER; /* capture current incrementer value time */ - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked (void) { ulong now = READ_TIMER; /* current tick value */ diff --git a/arch/arm/cpu/arm1176/s3c64xx/timer.c b/arch/arm/cpu/arm1176/s3c64xx/timer.c index bc21f86..f16a37b 100644 --- a/arch/arm/cpu/arm1176/s3c64xx/timer.c +++ b/arch/arm/cpu/arm1176/s3c64xx/timer.c @@ -135,13 +135,6 @@ ulong get_tbclk(void) return (ulong)(timer_load_val / 100); }
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = read_timer(); - timestamp = 0; -} - ulong get_timer_masked(void) { unsigned long long res = get_ticks(); diff --git a/arch/arm/cpu/arm720t/interrupts.c b/arch/arm/cpu/arm720t/interrupts.c index 9cd7fee..fa9c5a2 100644 --- a/arch/arm/cpu/arm720t/interrupts.c +++ b/arch/arm/cpu/arm720t/interrupts.c @@ -233,13 +233,6 @@ void __udelay (unsigned long usec) #endif }
-void reset_timer_masked (void) -{ - /* reset time */ - lastdec = READ_TIMER; - timestamp = 0; -} - ulong get_timer_masked (void) { ulong now = READ_TIMER; diff --git a/arch/arm/cpu/arm920t/at91/timer.c b/arch/arm/cpu/arm920t/at91/timer.c index 374cc25..c321e28 100644 --- a/arch/arm/cpu/arm920t/at91/timer.c +++ b/arch/arm/cpu/arm920t/at91/timer.c @@ -82,14 +82,6 @@ void __udelay(unsigned long usec) udelay_masked(usec); }
-void reset_timer_masked(void) -{ - /* reset time */ - at91_tc_t *tc = (at91_tc_t *) ATMEL_BASE_TC; - gd->lastinc = readl(&tc->tc[0].cv) & 0x0000ffff; - gd->tbl = 0; -} - ulong get_timer_raw(void) { at91_tc_t *tc = (at91_tc_t *) ATMEL_BASE_TC; diff --git a/arch/arm/cpu/arm920t/at91rm9200/timer.c b/arch/arm/cpu/arm920t/at91rm9200/timer.c index 9a1ae85..fbe74b6 100644 --- a/arch/arm/cpu/arm920t/at91rm9200/timer.c +++ b/arch/arm/cpu/arm920t/at91rm9200/timer.c @@ -81,13 +81,6 @@ void __udelay (unsigned long usec) udelay_masked(usec); }
-void reset_timer_masked (void) -{ - /* reset time */ - lastinc = READ_TIMER; - timestamp = 0; -} - ulong get_timer_raw (void) { ulong now = READ_TIMER; diff --git a/arch/arm/cpu/arm920t/ep93xx/timer.c b/arch/arm/cpu/arm920t/ep93xx/timer.c index f19ec61..a3990a7 100644 --- a/arch/arm/cpu/arm920t/ep93xx/timer.c +++ b/arch/arm/cpu/arm920t/ep93xx/timer.c @@ -91,12 +91,6 @@ unsigned long get_timer(unsigned long base) return get_timer_masked() - base; }
-void reset_timer_masked(void) -{ - read_timer(); - timer.ticks = 0; -} - void __udelay(unsigned long usec) { unsigned long long target; @@ -123,7 +117,9 @@ int timer_init(void) writel(TIMER_ENABLE | TIMER_CLKSEL, &timer_regs->timer3.control);
- reset_timer_masked(); + /* Reset the timer */ + read_timer(); + timer.ticks = 0;
return 0; } diff --git a/arch/arm/cpu/arm920t/imx/timer.c b/arch/arm/cpu/arm920t/imx/timer.c index cdb2148..6141bd4 100644 --- a/arch/arm/cpu/arm920t/imx/timer.c +++ b/arch/arm/cpu/arm920t/imx/timer.c @@ -43,7 +43,9 @@ int timer_init (void) TPRER1 = get_PERCLK1() / 1000000; /* 1 MHz */ TCTL1 |= TCTL_FRR | (1<<1); /* Freerun Mode, PERCLK1 input */
- reset_timer_masked(); + /* Reset the timer */ + TCTL1 &= ~TCTL_TEN; + TCTL1 |= TCTL_TEN; /* Enable timer */
return (0); } @@ -56,12 +58,6 @@ ulong get_timer (ulong base) return get_timer_masked() - base; }
-void reset_timer_masked (void) -{ - TCTL1 &= ~TCTL_TEN; - TCTL1 |= TCTL_TEN; /* Enable timer */ -} - ulong get_timer_masked (void) { return TCN1; diff --git a/arch/arm/cpu/arm920t/ks8695/timer.c b/arch/arm/cpu/arm920t/ks8695/timer.c index c78fd90..234fe91 100644 --- a/arch/arm/cpu/arm920t/ks8695/timer.c +++ b/arch/arm/cpu/arm920t/ks8695/timer.c @@ -33,7 +33,11 @@ ulong timer_ticks;
int timer_init (void) { - reset_timer_masked(); + /* Set the hadware timer for 1ms */ + ks8695_write(KS8695_TIMER1, TIMER_COUNT); + ks8695_write(KS8695_TIMER1_PCOUNT, TIMER_PULSE); + ks8695_write(KS8695_TIMER_CTRL, 0x2); + timer_ticks = 0;
return 0; } @@ -46,15 +50,6 @@ int timer_init (void) #define TIMER_COUNT (TIMER_INTERVAL / 2) #define TIMER_PULSE TIMER_COUNT
-void reset_timer_masked(void) -{ - /* Set the hadware timer for 1ms */ - ks8695_write(KS8695_TIMER1, TIMER_COUNT); - ks8695_write(KS8695_TIMER1_PCOUNT, TIMER_PULSE); - ks8695_write(KS8695_TIMER_CTRL, 0x2); - timer_ticks = 0; -} - ulong get_timer_masked(void) { /* Check for timer wrap */ diff --git a/arch/arm/cpu/arm920t/s3c24x0/timer.c b/arch/arm/cpu/arm920t/s3c24x0/timer.c index 9c71b80..9571870 100644 --- a/arch/arm/cpu/arm920t/s3c24x0/timer.c +++ b/arch/arm/cpu/arm920t/s3c24x0/timer.c @@ -101,13 +101,6 @@ void __udelay (unsigned long usec) /*NOP*/; }
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = READ_TIMER(); - timestamp = 0; -} - ulong get_timer_masked(void) { ulong tmr = get_ticks(); diff --git a/arch/arm/cpu/arm925t/timer.c b/arch/arm/cpu/arm925t/timer.c index 9c965e0..1b9386b 100644 --- a/arch/arm/cpu/arm925t/timer.c +++ b/arch/arm/cpu/arm925t/timer.c @@ -56,7 +56,9 @@ int timer_init (void) CONFIG_SYS_TIMERBASE + CNTL_TIMER);
/* init the timestamp and lastdec value */ - reset_timer_masked(); + lastdec = __raw_readl(CONFIG_SYS_TIMERBASE + READ_TIM) / + (TIMER_CLOCK / CONFIG_SYS_HZ); + timestamp = 0; /* start "advancing" time stamp from 0 */
return 0; } @@ -85,14 +87,6 @@ void __udelay (unsigned long usec) } }
-void reset_timer_masked (void) -{ - /* reset time */ - lastdec = __raw_readl(CONFIG_SYS_TIMERBASE + READ_TIM) / - (TIMER_CLOCK / CONFIG_SYS_HZ); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked (void) { uint32_t now = __raw_readl(CONFIG_SYS_TIMERBASE + READ_TIM) / diff --git a/arch/arm/cpu/arm926ejs/armada100/timer.c b/arch/arm/cpu/arm926ejs/armada100/timer.c index 86da0ce..82a6d7b 100644 --- a/arch/arm/cpu/arm926ejs/armada100/timer.c +++ b/arch/arm/cpu/arm926ejs/armada100/timer.c @@ -77,13 +77,6 @@ ulong read_timer(void) return(readl(&armd1timers->cvwr)); }
-void reset_timer_masked(void) -{ - /* reset time */ - gd->tbl = read_timer(); - gd->tbu = 0; -} - ulong get_timer_masked(void) { ulong now = read_timer(); @@ -142,7 +135,8 @@ int timer_init(void) /* Enable timer 0 */ writel(0x1, &armd1timers->cer); /* init the gd->tbu and gd->tbl value */ - reset_timer_masked(); + gd->tbl = read_timer(); + gd->tbu = 0;
return 0; } diff --git a/arch/arm/cpu/arm926ejs/kirkwood/timer.c b/arch/arm/cpu/arm926ejs/kirkwood/timer.c index 5beb3f5..b4f6cf8 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/timer.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/timer.c @@ -88,13 +88,6 @@ DECLARE_GLOBAL_DATA_PTR; #define timestamp gd->tbl #define lastdec gd->lastinc
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = READ_TIMER; - timestamp = 0; -} - ulong get_timer_masked(void) { ulong now = READ_TIMER; @@ -154,7 +147,8 @@ int timer_init(void) writel(cntmrctrl, CNTMR_CTRL_REG);
/* init the timestamp and lastdec value */ - reset_timer_masked(); + lastdec = READ_TIMER; + timestamp = 0;
return 0; } diff --git a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c index 5f54085..8f38056 100644 --- a/arch/arm/cpu/arm926ejs/mb86r0x/timer.c +++ b/arch/arm/cpu/arm926ejs/mb86r0x/timer.c @@ -68,7 +68,9 @@ int timer_init(void)
writel(ctrl, &timer->control);
- reset_timer_masked(); + /* capture current value time */ + lastdec = readl(&timer->value); + timestamp = 0; /* start "advancing" time stamp from 0 */
return 0; } @@ -94,16 +96,6 @@ unsigned long long get_ticks(void) return timestamp; }
-void reset_timer_masked(void) -{ - struct mb86r0x_timer * timer = (struct mb86r0x_timer *) - MB86R0x_TIMER_BASE; - - /* capture current value time */ - lastdec = readl(&timer->value); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked(void) { return tick_to_time(get_ticks()); diff --git a/arch/arm/cpu/arm926ejs/mx25/timer.c b/arch/arm/cpu/arm926ejs/mx25/timer.c index 9a84b50..131d600 100644 --- a/arch/arm/cpu/arm926ejs/mx25/timer.c +++ b/arch/arm/cpu/arm926ejs/mx25/timer.c @@ -121,15 +121,6 @@ int timer_init(void) return 0; }
-void reset_timer_masked(void) -{ - struct gpt_regs *gpt = (struct gpt_regs *)IMX_GPT1_BASE; - /* reset time */ - /* capture current incrementer value time */ - lastinc = readl(&gpt->counter); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - unsigned long long get_ticks (void) { struct gpt_regs *gpt = (struct gpt_regs *)IMX_GPT1_BASE; diff --git a/arch/arm/cpu/arm926ejs/mx27/timer.c b/arch/arm/cpu/arm926ejs/mx27/timer.c index 058dbee..df76d16 100644 --- a/arch/arm/cpu/arm926ejs/mx27/timer.c +++ b/arch/arm/cpu/arm926ejs/mx27/timer.c @@ -124,15 +124,6 @@ int timer_init(void) return 0; }
-void reset_timer_masked(void) -{ - struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE; - /* reset time */ - /* capture current incrementer value time */ - lastinc = readl(®s->gpt_tcn); - timestamp = 0; /* start "advancing" time stamp from 0 */ -} - unsigned long long get_ticks (void) { struct gpt_regs *regs = (struct gpt_regs *)IMX_TIM1_BASE; diff --git a/arch/arm/cpu/arm926ejs/orion5x/timer.c b/arch/arm/cpu/arm926ejs/orion5x/timer.c index 5bc43c8..17df68f 100644 --- a/arch/arm/cpu/arm926ejs/orion5x/timer.c +++ b/arch/arm/cpu/arm926ejs/orion5x/timer.c @@ -95,13 +95,6 @@ DECLARE_GLOBAL_DATA_PTR; #define timestamp gd->tbl #define lastdec gd->lastinc
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = read_timer(); - timestamp = 0; -} - ulong get_timer_masked(void) { ulong now = read_timer(); @@ -171,5 +164,6 @@ int timer_init(void) void timer_init_r(void) { /* init the timestamp and lastdec value */ - reset_timer_masked(); + lastdec = read_timer(); + timestamp = 0; } diff --git a/arch/arm/cpu/arm926ejs/pantheon/timer.c b/arch/arm/cpu/arm926ejs/pantheon/timer.c index 2727adc..c71162a 100644 --- a/arch/arm/cpu/arm926ejs/pantheon/timer.c +++ b/arch/arm/cpu/arm926ejs/pantheon/timer.c @@ -85,13 +85,6 @@ ulong read_timer(void) return val; }
-void reset_timer_masked(void) -{ - /* reset time */ - gd->tbl = read_timer(); - gd->tbu = 0; -} - ulong get_timer_masked(void) { ulong now = read_timer(); @@ -151,7 +144,8 @@ int timer_init(void) /* Enable timer 0 */ writel(0x1, &panthtimers->cer); /* init the gd->tbu and gd->tbl value */ - reset_timer_masked(); + gd->tbl = read_timer(); + gd->tbu = 0;
return 0; } diff --git a/arch/arm/cpu/arm926ejs/spear/timer.c b/arch/arm/cpu/arm926ejs/spear/timer.c index cbef34f..1dc7860 100644 --- a/arch/arm/cpu/arm926ejs/spear/timer.c +++ b/arch/arm/cpu/arm926ejs/spear/timer.c @@ -68,7 +68,9 @@ int timer_init(void) /* auto reload, start timer */ writel(readl(&gpt_regs_p->control) | GPT_ENABLE, &gpt_regs_p->control);
- reset_timer_masked(); + /* Reset the timer */ + lastdec = READ_TIMER(); + timestamp = 0;
return 0; } @@ -97,13 +99,6 @@ void __udelay(unsigned long usec) ; }
-void reset_timer_masked(void) -{ - /* reset time */ - lastdec = READ_TIMER(); - timestamp = 0; -} - ulong get_timer_masked(void) { ulong now = READ_TIMER(); diff --git a/arch/arm/cpu/armv7/mx5/timer.c b/arch/arm/cpu/armv7/mx5/timer.c index 4525beb..2544b08 100644 --- a/arch/arm/cpu/armv7/mx5/timer.c +++ b/arch/arm/cpu/armv7/mx5/timer.c @@ -52,6 +52,7 @@ DECLARE_GLOBAL_DATA_PTR; int timer_init(void) { int i; + ulong val;
/* setup GP Timer 1 */ __raw_writel(GPTCR_SWR, &cur_gpt->control); @@ -65,15 +66,12 @@ int timer_init(void) /* Freerun Mode, PERCLK1 input */ i = __raw_readl(&cur_gpt->control); __raw_writel(i | GPTCR_CLKSOURCE_32 | GPTCR_TEN, &cur_gpt->control); - reset_timer_masked(); - return 0; -}
-void reset_timer_masked(void) -{ - ulong val = __raw_readl(&cur_gpt->counter); + val = __raw_readl(&cur_gpt->counter); lastinc = val / (CONFIG_SYS_MX5_CLK32 / CONFIG_SYS_HZ); timestamp = 0; + + return 0; }
ulong get_timer_masked(void) diff --git a/arch/arm/cpu/armv7/omap-common/timer.c b/arch/arm/cpu/armv7/omap-common/timer.c index 4756e26..9f8bc93 100644 --- a/arch/arm/cpu/armv7/omap-common/timer.c +++ b/arch/arm/cpu/armv7/omap-common/timer.c @@ -55,7 +55,9 @@ int timer_init(void) writel((CONFIG_SYS_PTV << 2) | TCLR_PRE | TCLR_AR | TCLR_ST, &timer_base->tclr);
- reset_timer_masked(); /* init the timestamp and lastinc value */ + /* reset time, capture current incrementer value time */ + gd->lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ); + gd->tbl = 0; /* start "advancing" time stamp from 0 */
return 0; } @@ -84,13 +86,6 @@ void __udelay(unsigned long usec) } }
-void reset_timer_masked(void) -{ - /* reset time, capture current incrementer value time */ - gd->lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ); - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked(void) { /* current tick value */ diff --git a/arch/arm/cpu/armv7/tegra2/timer.c b/arch/arm/cpu/armv7/tegra2/timer.c index 2761c12..0b9fa64 100644 --- a/arch/arm/cpu/armv7/tegra2/timer.c +++ b/arch/arm/cpu/armv7/tegra2/timer.c @@ -69,13 +69,6 @@ void __udelay(unsigned long usec) } }
-void reset_timer_masked(void) -{ - /* reset time, capture current incrementer value time */ - gd->lastinc = readl(&timer_base->cntr_1us) / (TIMER_CLK/CONFIG_SYS_HZ); - gd->tbl = 0; /* start "advancing" time stamp from 0 */ -} - ulong get_timer_masked(void) { ulong now; diff --git a/arch/arm/cpu/pxa/timer.c b/arch/arm/cpu/pxa/timer.c index 44dae9a..2866745 100644 --- a/arch/arm/cpu/pxa/timer.c +++ b/arch/arm/cpu/pxa/timer.c @@ -59,7 +59,7 @@ static inline unsigned long long us_to_tick(unsigned long long us)
int timer_init (void) { - reset_timer_masked(); + writel(0, OSCR);
return 0; } @@ -74,12 +74,6 @@ void __udelay (unsigned long usec) udelay_masked (usec); }
- -void reset_timer_masked (void) -{ - writel(0, OSCR); -} - ulong get_timer_masked (void) { return tick_to_time(get_ticks()); diff --git a/arch/arm/cpu/s3c44b0/timer.c b/arch/arm/cpu/s3c44b0/timer.c index ce48952..6c2f066 100644 --- a/arch/arm/cpu/s3c44b0/timer.c +++ b/arch/arm/cpu/s3c44b0/timer.c @@ -78,13 +78,6 @@ void __udelay (unsigned long usec) /*NOP*/; }
-void reset_timer_masked (void) -{ - /* reset time */ - lastdec = READ_TIMER; - timestamp = 0; -} - ulong get_timer_masked (void) { ulong now = READ_TIMER; diff --git a/arch/arm/cpu/sa1100/timer.c b/arch/arm/cpu/sa1100/timer.c index 694c03a..53bec0b 100644 --- a/arch/arm/cpu/sa1100/timer.c +++ b/arch/arm/cpu/sa1100/timer.c @@ -44,12 +44,6 @@ void __udelay (unsigned long usec) udelay_masked (usec); }
- -void reset_timer_masked (void) -{ - OSCR = 0; -} - ulong get_timer_masked (void) { return OSCR; diff --git a/board/armltd/integrator/timer.c b/board/armltd/integrator/timer.c index 6734e8d..f10a026 100644 --- a/board/armltd/integrator/timer.c +++ b/board/armltd/integrator/timer.c @@ -95,7 +95,10 @@ int timer_init (void)
/* init the timestamp */ total_count = 0ULL; - reset_timer_masked(); + /* capure current decrementer value */ + lastdec = READ_TIMER; + /* start "advancing" time stamp from 0 */ + timestamp = 0L;
div_timer = CONFIG_SYS_HZ_CLOCK; do_div(div_timer, CONFIG_SYS_HZ); @@ -129,14 +132,6 @@ void __udelay (unsigned long usec) } }
-void reset_timer_masked (void) -{ - /* capure current decrementer value */ - lastdec = READ_TIMER; - /* start "advancing" time stamp from 0 */ - timestamp = 0L; -} - /* converts the timer reading to U-Boot ticks */ /* the timestamp is the number of ticks since reset */ ulong get_timer_masked (void) -- 1.7.5.2.317.g391b14

Dear Graeme Russ,
In message 1310809080-3481-1-git-send-email-graeme.russ@gmail.com you wrote:
In some circumstances, reset_timer_masked() was called by timer_init() in order to perform architecture specific timer initialisation. In such cases, the required code in reset_timer_masked() has been moved into timer_init()
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Changes since v2:
- Added Signed-off-by
- Fixed typo in description (be->by)
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
- Updated description
arch/arm/cpu/arm1136/mx31/timer.c | 7 ------- arch/arm/cpu/arm1136/omap24xx/timer.c | 14 +++++++------- arch/arm/cpu/arm1176/s3c64xx/timer.c | 7 ------- arch/arm/cpu/arm720t/interrupts.c | 7 ------- arch/arm/cpu/arm920t/at91/timer.c | 8 -------- arch/arm/cpu/arm920t/at91rm9200/timer.c | 7 ------- arch/arm/cpu/arm920t/ep93xx/timer.c | 10 +++------- arch/arm/cpu/arm920t/imx/timer.c | 10 +++------- arch/arm/cpu/arm920t/ks8695/timer.c | 15 +++++---------- arch/arm/cpu/arm920t/s3c24x0/timer.c | 7 ------- arch/arm/cpu/arm925t/timer.c | 12 +++--------- arch/arm/cpu/arm926ejs/armada100/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 14 +++----------- arch/arm/cpu/arm926ejs/mx25/timer.c | 9 --------- arch/arm/cpu/arm926ejs/mx27/timer.c | 9 --------- arch/arm/cpu/arm926ejs/orion5x/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/pantheon/timer.c | 10 ++-------- arch/arm/cpu/arm926ejs/spear/timer.c | 11 +++-------- arch/arm/cpu/armv7/mx5/timer.c | 10 ++++------ arch/arm/cpu/armv7/omap-common/timer.c | 11 +++-------- arch/arm/cpu/armv7/tegra2/timer.c | 7 ------- arch/arm/cpu/pxa/timer.c | 8 +------- arch/arm/cpu/s3c44b0/timer.c | 7 ------- arch/arm/cpu/sa1100/timer.c | 6 ------ board/armltd/integrator/timer.c | 13 ++++--------- 26 files changed, 47 insertions(+), 202 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- include/common.h | 36 ++++++++++++++++++++---------------- lib/time.c | 26 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/include/common.h b/include/common.h index 340e585..9735d47 100644 --- a/include/common.h +++ b/include/common.h @@ -584,11 +584,29 @@ void timer_interrupt (struct pt_regs *); void external_interrupt (struct pt_regs *); void irq_install_handler(int, interrupt_handler_t *, void *); void irq_free_handler (int); -void reset_timer (void); -ulong get_timer (ulong base); void enable_interrupts (void); int disable_interrupts (void);
+/* + * Timer API + */ +void reset_timer (void); +ulong get_timer (ulong base); +u64 get_ticks(void); +void wait_ticks(unsigned long); +void __udelay(unsigned long); +ulong usec2ticks(unsigned long usec); +ulong ticks2usec(unsigned long ticks); +int init_timebase(void); + +/* lib/time.c */ +void udelay(unsigned long); + +u32 time_now_ms(void); +u32 time_since_ms(u32 from, u32 to); +u32 time_max_since_ms(u32 from, u32 to); +u32 time_resolution_ms(void); + /* $(CPU)/.../commproc.c */ int dpram_init (void); uint dpram_base(void); @@ -616,17 +634,6 @@ void flush_cache (unsigned long, unsigned long); void flush_dcache_range(unsigned long start, unsigned long stop); void invalidate_dcache_range(unsigned long start, unsigned long stop);
- -/* arch/$(ARCH)/lib/ticks.S */ -unsigned long long get_ticks(void); -void wait_ticks (unsigned long); - -/* arch/$(ARCH)/lib/time.c */ -void __udelay (unsigned long); -ulong usec2ticks (unsigned long usec); -ulong ticks2usec (unsigned long ticks); -int init_timebase (void); - /* lib/gunzip.c */ int gunzip(void *, int, unsigned char *, unsigned long *); int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, @@ -644,9 +651,6 @@ void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); int strcmp_compar(const void *, const void *);
-/* lib/time.c */ -void udelay (unsigned long); - /* lib/vsprintf.c */ ulong simple_strtoul(const char *cp,char **endp,unsigned int base); int strict_strtoul(const char *cp, unsigned int base, unsigned long *res); diff --git a/lib/time.c b/lib/time.c index a309c26..1563507 100644 --- a/lib/time.c +++ b/lib/time.c @@ -41,3 +41,29 @@ void udelay(unsigned long usec) usec -= kv; } while(usec); } + +u32 time_since_ms(u32 from) +{ + u32 delta = time_now_ms() - from; + + /* round down */ + if (delta < time_ms_resolution()) + return 0; + + return delta - time_resolution_ms(); +} + +u32 time_max_since_ms(u32 from) +{ + u32 delta = time_now_ms() - from; + + return delta + time_resolution_ms(); +} + +__attribute__((weak)) +u32 time_resolution_ms(void) {return 1;} + +u32 time_now_ms(void) +{ + return get_timer(0); +}

Hi Graeme,
What a mammoth effort and what a fantastic clean up.
I'm a bit unsure of this patch which seems to have two prototypes for the since functions:
On Tue, Jun 28, 2011 at 4:41 AM, Graeme Russ graeme.russ@gmail.com wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
include/common.h | 36 ++++++++++++++++++++---------------- lib/time.c | 26 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/include/common.h b/include/common.h index 340e585..9735d47 100644 --- a/include/common.h +++ b/include/common.h @@ -584,11 +584,29 @@ void timer_interrupt (struct pt_regs *); void external_interrupt (struct pt_regs *); void irq_install_handler(int, interrupt_handler_t *, void *); void irq_free_handler (int); -void reset_timer (void); -ulong get_timer (ulong base); void enable_interrupts (void); int disable_interrupts (void);
+/*
- Timer API
- */
+void reset_timer (void); +ulong get_timer (ulong base); +u64 get_ticks(void); +void wait_ticks(unsigned long); +void __udelay(unsigned long); +ulong usec2ticks(unsigned long usec); +ulong ticks2usec(unsigned long ticks); +int init_timebase(void);
+/* lib/time.c */ +void udelay(unsigned long);
+u32 time_now_ms(void); +u32 time_since_ms(u32 from, u32 to); +u32 time_max_since_ms(u32 from, u32 to);
Here they have two parameters
+u32 time_resolution_ms(void);
/* $(CPU)/.../commproc.c */ int dpram_init (void); uint dpram_base(void); @@ -616,17 +634,6 @@ void flush_cache (unsigned long, unsigned long); void flush_dcache_range(unsigned long start, unsigned long stop); void invalidate_dcache_range(unsigned long start, unsigned long stop);
-/* arch/$(ARCH)/lib/ticks.S */ -unsigned long long get_ticks(void); -void wait_ticks (unsigned long);
-/* arch/$(ARCH)/lib/time.c */ -void __udelay (unsigned long); -ulong usec2ticks (unsigned long usec); -ulong ticks2usec (unsigned long ticks); -int init_timebase (void);
/* lib/gunzip.c */ int gunzip(void *, int, unsigned char *, unsigned long *); int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, @@ -644,9 +651,6 @@ void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); int strcmp_compar(const void *, const void *);
-/* lib/time.c */ -void udelay (unsigned long);
/* lib/vsprintf.c */ ulong simple_strtoul(const char *cp,char **endp,unsigned int base); int strict_strtoul(const char *cp, unsigned int base, unsigned long *res); diff --git a/lib/time.c b/lib/time.c index a309c26..1563507 100644 --- a/lib/time.c +++ b/lib/time.c @@ -41,3 +41,29 @@ void udelay(unsigned long usec) usec -= kv; } while(usec); }
+u32 time_since_ms(u32 from)
and here only one (which is what I expect).
Can you please explain what I am missing?
Thanks, Simon
+{
- u32 delta = time_now_ms() - from;
- /* round down */
- if (delta < time_ms_resolution())
- return 0;
- return delta - time_resolution_ms();
+}
+u32 time_max_since_ms(u32 from) +{
- u32 delta = time_now_ms() - from;
- return delta + time_resolution_ms();
+}
+__attribute__((weak)) +u32 time_resolution_ms(void) {return 1;}
+u32 time_now_ms(void) +{
- return get_timer(0);
+}
1.7.5.2.317.g391b14
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi Simon,
On Wed, Jun 29, 2011 at 2:31 PM, Simon Glass sjg@chromium.org wrote:
Hi Graeme,
What a mammoth effort and what a fantastic clean up.
I'm a bit unsure of this patch which seems to have two prototypes for the since functions:
[snip]
+u32 time_now_ms(void); +u32 time_since_ms(u32 from, u32 to); +u32 time_max_since_ms(u32 from, u32 to);
Here they have two parameters
[snip]
+u32 time_since_ms(u32 from)
and here only one (which is what I expect).
Can you please explain what I am missing?
The fact I haven't tried to build it yet ;)
I'll add that to the list of fixes for v2 - Thanks
Regards,
Graeme

Hi Graeme,
On Tue, Jun 28, 2011 at 9:36 PM, Graeme Russ graeme.russ@gmail.com wrote:
Hi Simon,
Can you please explain what I am missing?
The fact I haven't tried to build it yet ;)
Oh, OK. That explains the mystery :-) I haven't built it yet either but it certainly looks good.
Regards, Simon
I'll add that to the list of fixes for v2 - Thanks
Regards,
Graeme

Dear Graeme Russ,
In message 1309261269-4363-9-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Please define "userland" in U-Boot context ?
+u32 time_now_ms(void); +u32 time_since_ms(u32 from, u32 to); +u32 time_max_since_ms(u32 from, u32 to); +u32 time_resolution_ms(void);
I'm unhappy about these. Sorry, but I don't want to have that. See previous message(s).
Best regards,
Wolfgang Denk

Hi Wolfgang,
On 12/07/11 08:05, Wolfgang Denk wrote:
Dear Graeme Russ,
In message 1309261269-4363-9-git-send-email-graeme.russ@gmail.com you wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
Please define "userland" in U-Boot context ?
Used outside of /arch (i.e. in board or driver code). Anything in arch/ binds the architecture specific implementation to lib/
+u32 time_now_ms(void); +u32 time_since_ms(u32 from, u32 to); +u32 time_max_since_ms(u32 from, u32 to); +u32 time_resolution_ms(void);
I'm unhappy about these. Sorry, but I don't want to have that. See previous message(s).
Will do
Thanks,
Graeme

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- drivers/block/mg_disk.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index 2198017..c8cc195 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -88,17 +88,16 @@ static void mg_dump_status (const char *msg, unsigned int stat, unsigned err) static unsigned int mg_wait (u32 expect, u32 msec) { u8 status; - u32 from, cur, err; + u32 ts, err;
err = MG_ERR_NONE; #ifdef CONFIG_NIOS2 reset_timer(); #endif - from = get_timer(0); + ts = time_now_ms();
status = readb(mg_base() + MG_REG_STATUS); do { - cur = get_timer(from); if (status & MG_REG_STATUS_BIT_BUSY) { if (expect == MG_REG_STATUS_BIT_BUSY) break; @@ -119,9 +118,9 @@ static unsigned int mg_wait (u32 expect, u32 msec) break; } status = readb(mg_base() + MG_REG_STATUS); - } while (cur < msec); + } while (time_since_ms(ts) < msec);
- if (cur >= msec) + if (time_since_ms(ts) >= msec) err = MG_ERR_TIMEOUT;
return err;

Hi Graeme,
On Tue, Jun 28, 2011 at 4:41 AM, Graeme Russ graeme.russ@gmail.com wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
drivers/block/mg_disk.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index 2198017..c8cc195 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -88,17 +88,16 @@ static void mg_dump_status (const char *msg, unsigned int stat, unsigned err) static unsigned int mg_wait (u32 expect, u32 msec) { u8 status;
- u32 from, cur, err;
- u32 ts, err;
err = MG_ERR_NONE; #ifdef CONFIG_NIOS2 reset_timer(); #endif
- from = get_timer(0);
- ts = time_now_ms();
status = readb(mg_base() + MG_REG_STATUS); do {
- cur = get_timer(from);
...
- } while (cur < msec);
- } while (time_since_ms(ts) < msec);
Well I know i have asked this before, but I feel I should ask again because I didn't like the answer much.
Imagine we change this code to:
ts = time_now_ms() + msec do { ... } while (time_since_ms(ts) < 0);
That should be legal, right? But I don't think this can work since the 'since' functions return an unsigned.
[aside: this provides for another idiom that I think we talked about:
ts = time_future_ms(msec) do { ... } while (!time_passed(ts))
which I am not at all suggesting should be in the API :-) end aside]
Regards. Simon
- if (cur >= msec)
- if (time_since_ms(ts) >= msec)
err = MG_ERR_TIMEOUT;
return err;
1.7.5.2.317.g391b14
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Dear All,
Well I know i have asked this before, but I feel I should ask again because I didn't like the answer much.
Imagine we change this code to:
ts = time_now_ms() + msec do { ... } while (time_since_ms(ts)< 0);
That should be legal, right? But I don't think this can work since the 'since' functions return an unsigned.
[aside: this provides for another idiom that I think we talked about:
ts = time_future_ms(msec) do { ... } while (!time_passed(ts))
which I am not at all suggesting should be in the API :-) end aside]
I still vouch for this concept, which is simple, clean, and easy to understand.
Reinhard

Hi Reinhard,
On Wed, Jun 29, 2011 at 3:06 PM, Reinhard Meyer u-boot@emk-elektronik.de wrote:
Dear All,
Well I know i have asked this before, but I feel I should ask again because I didn't like the answer much.
Imagine we change this code to:
ts = time_now_ms() + msec do { ... } while (time_since_ms(ts)< 0);
That should be legal, right? But I don't think this can work since the 'since' functions return an unsigned.
[aside: this provides for another idiom that I think we talked about:
ts = time_future_ms(msec) do { ... } while (!time_passed(ts))
which I am not at all suggesting should be in the API :-) end aside]
I still vouch for this concept, which is simple, clean, and easy to understand.
It really is a matter of personal taste ;) I find
u32 start = time_now_ms();
do { ...blah... } while(time_since_ms(start) < timeout);
much easier to understand (Do whatever while time elapsed since I started is less than the timeout)
u32 end = time_future_ms(timeout);
do { ...blah... } while(time_now_ms() < end);
to me is a bit more clunky. Yes, it is probably computationally more efficient, but it does not naturally support:
u32 start = time_now_ms(); u32 duration;
...blah...
duration = time_since_ms(start);
/* or duration = time_max_since_ms(start); */
Which we want for profiling.
Also there are a few instances where there are multiple cascaded timeouts
u32 start = time_now_ms();
do { ...blah... } while(time_since_ms(start) < timeout_1); do { ...blah... } while(time_since_ms(start) < timeout_2);
Which means setting up all your timeouts in advance
Regards,
Graeme

Hi Graeme,
On Tue, Jun 28, 2011 at 10:19 PM, Graeme Russ graeme.russ@gmail.com wrote:
Hi Reinhard,
On Wed, Jun 29, 2011 at 3:06 PM, Reinhard Meyer u-boot@emk-elektronik.de wrote:
Dear All,
Well I know i have asked this before, but I feel I should ask again because I didn't like the answer much.
Imagine we change this code to:
ts = time_now_ms() + msec do { ... } while (time_since_ms(ts)< 0);
That should be legal, right? But I don't think this can work since the 'since' functions return an unsigned.
[aside: this provides for another idiom that I think we talked about:
ts = time_future_ms(msec) do { ... } while (!time_passed(ts))
which I am not at all suggesting should be in the API :-) end aside]
I still vouch for this concept, which is simple, clean, and easy to understand.
It really is a matter of personal taste ;) I find
u32 start = time_now_ms();
do { ...blah... } while(time_since_ms(start) < timeout);
much easier to understand (Do whatever while time elapsed since I started is less than the timeout)
u32 end = time_future_ms(timeout);
do { ...blah... } while(time_now_ms() < end);
...
Actually:
} while (time_passed_ms(end))
but anyway I agree it is a matter of taste and I'm quite happy with the approach here at the moment.
But what about my question about signed ints for deltas?
Regards, Simon

Hi Simon,
u32 end = time_future_ms(timeout);
do { ...blah... } while(time_now_ms() < end);
...
Actually:
} while (time_passed_ms(end))
Sorry, but I think you've lost me here...
but anyway I agree it is a matter of taste and I'm quite happy with the approach here at the moment.
But what about my question about signed ints for deltas?
We use signed int's to allow seamless roll-overs of the timer counter. One thing the API does not require is that a given low-level timer counts from zero - It can start with any value and therefore may roll-over at any time. By using unsigned provided there is at most one rollover between timing events (which for a 32-bit millisecond counter is a very long time) the logic remain trivial (time = end - start) - We don't have to try and detect the rollover.
Also, we assume the u-Boot will never be installed in a time machine, and will therefore never need to calculate negative time. Please let us know if you plan to boot a TARDIS using U-Boot ;)
Regards,
Graeme

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);

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- arch/nios2/cpu/interrupts.c | 38 -------------------------------------- drivers/block/mg_disk.c | 3 --- drivers/mtd/cfi_flash.c | 6 ------ 3 files changed, 0 insertions(+), 47 deletions(-)
diff --git a/arch/nios2/cpu/interrupts.c b/arch/nios2/cpu/interrupts.c index 0a97fa6..5603894 100644 --- a/arch/nios2/cpu/interrupts.c +++ b/arch/nios2/cpu/interrupts.c @@ -54,44 +54,6 @@ static struct irq_action vecs[32]; /*************************************************************************/ volatile ulong timestamp = 0;
-void reset_timer (void) -{ - nios_timer_t *tmr =(nios_timer_t *)CONFIG_SYS_NIOS_TMRBASE; - - /* From Embedded Peripherals Handbook: - * - * "When the hardware is configured with Writeable period - * disabled, writing to one of the period_n registers causes - * the counter to reset to the fixed Timeout Period specified - * at system generation time." - * - * Here we force a reload to prevent early timeouts from - * get_timer() when the interrupt period is greater than - * than 1 msec. - * - * Simply write to periodl with its own value to force an - * internal counter reload, THEN reset the timestamp. - */ - writel (readl (&tmr->periodl), &tmr->periodl); - timestamp = 0; - - /* From Embedded Peripherals Handbook: - * - * "Writing to one of the period_n registers stops the internal - * counter, except when the hardware is configured with Start/Stop - * control bits off. If Start/Stop control bits is off, writing - * either register does not stop the counter." - * - * In order to accomodate either configuration, the control - * register is re-written. If the counter is stopped, it will - * be restarted. If it is running, the write is essentially - * a nop. - */ - writel (NIOS_TIMER_ITO | NIOS_TIMER_CONT | NIOS_TIMER_START, - &tmr->control); - -} - ulong get_timer (ulong base) { WATCHDOG_RESET (); diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index c8cc195..c56adfc 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -91,9 +91,6 @@ static unsigned int mg_wait (u32 expect, u32 msec) u32 ts, err;
err = MG_ERR_NONE; -#ifdef CONFIG_NIOS2 - reset_timer(); -#endif ts = time_now_ms();
status = readb(mg_base() + MG_REG_STATUS); diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index dad80c5..9918157 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -573,9 +573,6 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector, #endif
/* Wait for command completion */ -#ifdef CONFIG_NIOS2 - reset_timer(); -#endif start = time_now_ms(); while (flash_is_busy (info, sector)) { if (time_since_ms(start) > tout) { @@ -664,9 +661,6 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst, #endif
/* Wait for command completion */ -#ifdef CONFIG_NIOS2 - reset_timer(); -#endif start = time_now_ms(); while (1) { switch (info->portwidth) {

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- drivers/fpga/ACEX1K.c | 5 ++- drivers/fpga/cyclon2.c | 5 ++- drivers/fpga/spartan2.c | 30 +++++++++++-------- drivers/fpga/spartan3.c | 32 +++++++++++++-------- drivers/fpga/virtex2.c | 20 ++++++++----- drivers/i2c/bfin-twi_i2c.c | 6 ++-- drivers/i2c/spr_i2c.c | 28 ++++++++++-------- drivers/i2c/u8500_i2c.c | 8 ++-- drivers/input/ps2mult.c | 6 ++-- drivers/mmc/omap_hsmmc.c | 57 ++++++++++++++++++++----------------- drivers/mtd/spi/atmel.c | 4 +- drivers/net/4xx_enet.c | 8 ++--- drivers/net/bcm570x.c | 2 +- drivers/net/cs8900.c | 17 ++++++----- drivers/net/dm9000x.c | 6 ++-- drivers/net/ethoc.c | 6 ++-- drivers/net/fec_mxc.c | 18 ++++++------ drivers/net/ftgmac100.c | 6 ++-- drivers/net/ftmac100.c | 6 ++-- drivers/net/greth.c | 16 +++++----- drivers/net/lan91c96.c | 5 ++- drivers/net/ne2000_base.c | 6 ++-- drivers/net/netarm_eth.c | 12 ++++--- drivers/net/ns7520_eth.c | 5 ++- drivers/net/ns9750_eth.c | 4 +- drivers/net/rtl8139.c | 6 ++-- drivers/net/rtl8169.c | 26 ++++++++--------- drivers/net/smc91111.c | 4 +- drivers/serial/serial_clps7111.c | 6 ++-- drivers/serial/serial_netarm.c | 4 +- drivers/spi/atmel_dataflash_spi.c | 8 ++--- drivers/usb/gadget/ether.c | 25 ++++++++-------- drivers/usb/host/ehci-hcd.c | 8 ++-- drivers/usb/host/sl811-hcd.c | 5 ++- 34 files changed, 220 insertions(+), 190 deletions(-)
diff --git a/drivers/fpga/ACEX1K.c b/drivers/fpga/ACEX1K.c index 06b4247..7a8e744 100644 --- a/drivers/fpga/ACEX1K.c +++ b/drivers/fpga/ACEX1K.c @@ -156,10 +156,11 @@ static int ACEX1K_ps_load (Altera_desc * desc, void *buf, size_t bsize) udelay(2); /* T_cf2st1 < 4us */
/* Wait for nSTATUS to be released (i.e. deasserted) */ - ts = get_timer (0); /* get current time */ + ts = timer_ms_now(); /* get current time */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + if (time_ms_delta_min(ts, timer_ms_now()) > + CONFIG_SYS_FPGA_WAIT) { /* check the time */ puts ("** Timeout waiting for STATUS to go high.\n"); (*fn->abort) (cookie); return FPGA_FAIL; diff --git a/drivers/fpga/cyclon2.c b/drivers/fpga/cyclon2.c index 4622b4e..5dd6cdd 100644 --- a/drivers/fpga/cyclon2.c +++ b/drivers/fpga/cyclon2.c @@ -139,10 +139,11 @@ static int CYC2_ps_load (Altera_desc * desc, void *buf, size_t bsize) udelay(2); /* T_cfg > 2us */
/* Wait for nSTATUS to be asserted */ - ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + /* check the time */ + if (time_since_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for STATUS to go high.\n"); (*fn->abort) (cookie); return FPGA_FAIL; diff --git a/drivers/fpga/spartan2.c b/drivers/fpga/spartan2.c index cd16a9c..cab68ef 100644 --- a/drivers/fpga/spartan2.c +++ b/drivers/fpga/spartan2.c @@ -168,11 +168,12 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->pgm) (FALSE, TRUE, cookie); /* Deassert the program, commit */
- ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ /* Now wait for INIT and BUSY to go high */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + /* check the time */ + if (time_sine_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for INIT to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ return FPGA_FAIL; @@ -195,7 +196,7 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */
#ifdef CONFIG_SYS_FPGA_CHECK_BUSY - ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ while ((*fn->busy) (cookie)) { /* XXX - we should have a check in here somewhere to * make sure we aren't busy forever... */ @@ -205,7 +206,8 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */
- if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + /* check the time */ + if (time_since_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for BUSY to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ return FPGA_FAIL; @@ -228,7 +230,7 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) #endif
/* now check for done signal */ - ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ ret_val = FPGA_SUCCESS; while ((*fn->done) (cookie) == FPGA_FAIL) {
@@ -237,7 +239,8 @@ static int Spartan2_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */
- if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + /* check the time */ + if (time_sine_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for DONE to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ ret_val = FPGA_FAIL; @@ -354,10 +357,11 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->pgm) (TRUE, TRUE, cookie); /* Assert the program, commit */
/* Wait for INIT state (init low) */ - ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + /* check the time */ + if (time_since_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for INIT to start.\n"); return FPGA_FAIL; } @@ -367,11 +371,12 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->pgm) (FALSE, TRUE, cookie); /* Deassert the program, commit */
- ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ /* Now wait for INIT to go high */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + /* check the time */ + if (time_since_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for INIT to clear.\n"); return FPGA_FAIL; } @@ -415,7 +420,7 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) #endif
/* now check for done signal */ - ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ ret_val = FPGA_SUCCESS; (*fn->wr) (TRUE, TRUE, cookie);
@@ -428,7 +433,8 @@ static int Spartan2_ss_load (Xilinx_desc * desc, void *buf, size_t bsize)
putc ('*');
- if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + /* check the time */ + if (time_since_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for DONE to clear.\n"); ret_val = FPGA_FAIL; break; diff --git a/drivers/fpga/spartan3.c b/drivers/fpga/spartan3.c index 1dd6f26..8282a23 100644 --- a/drivers/fpga/spartan3.c +++ b/drivers/fpga/spartan3.c @@ -173,11 +173,12 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->pgm) (FALSE, TRUE, cookie); /* Deassert the program, commit */
- ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ /* Now wait for INIT and BUSY to go high */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + /* check the time */ + if (time_since_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for INIT to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ return FPGA_FAIL; @@ -200,7 +201,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */
#ifdef CONFIG_SYS_FPGA_CHECK_BUSY - ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ while ((*fn->busy) (cookie)) { /* XXX - we should have a check in here somewhere to * make sure we aren't busy forever... */ @@ -210,7 +211,8 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */
- if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + /* check the time */ + if (time_since_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for BUSY to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ return FPGA_FAIL; @@ -233,7 +235,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) #endif
/* now check for done signal */ - ts = get_timer (0); /* get current time */ + ts = time_since_ms(); /* get current time */ ret_val = FPGA_SUCCESS; while ((*fn->done) (cookie) == FPGA_FAIL) { /* XXX - we should have a check in here somewhere to @@ -244,7 +246,8 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->clk) (TRUE, TRUE, cookie); /* Assert the clock pin */
- if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + /* check the time */ + if (time_since_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for DONE to clear.\n"); (*fn->abort) (cookie); /* abort the burn */ ret_val = FPGA_FAIL; @@ -361,10 +364,12 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->pgm) (TRUE, TRUE, cookie); /* Assert the program, commit */
/* Wait for INIT state (init low) */ - ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + + /* check the time */ + if (time_since_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for INIT to start.\n"); if (*fn->abort) (*fn->abort) (cookie); @@ -376,11 +381,13 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) CONFIG_FPGA_DELAY (); (*fn->pgm) (FALSE, TRUE, cookie); /* Deassert the program, commit */
- ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ /* Now wait for INIT to go high */ do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + + /* check the time */ + if (time_since_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for INIT to clear.\n"); if (*fn->abort) (*fn->abort) (cookie); @@ -432,7 +439,7 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize) #endif
/* now check for done signal */ - ts = get_timer (0); /* get current time */ + ts = time_now_ms(); /* get current time */ ret_val = FPGA_SUCCESS; (*fn->wr) (TRUE, TRUE, cookie);
@@ -447,7 +454,8 @@ static int Spartan3_ss_load (Xilinx_desc * desc, void *buf, size_t bsize)
putc ('*');
- if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT) { /* check the time */ + /* check the time */ + if (time_since_ms(ts) > CONFIG_SYS_FPGA_WAIT) { puts ("** Timeout waiting for DONE to clear.\n"); ret_val = FPGA_FAIL; break; diff --git a/drivers/fpga/virtex2.c b/drivers/fpga/virtex2.c index d1b4d15..d1995e6 100644 --- a/drivers/fpga/virtex2.c +++ b/drivers/fpga/virtex2.c @@ -223,9 +223,10 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) */ (*fn->pgm) (TRUE, TRUE, cookie); udelay (10); - ts = get_timer (0); + ts = time_ms_now(); do { - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_INIT) { + if (time_ms_delta_min(ts, timer_ms_now()) + > CONFIG_SYS_FPGA_WAIT_INIT) { printf ("%s:%d: ** Timeout after %d ticks waiting for INIT" " to assert.\n", __FUNCTION__, __LINE__, CONFIG_SYS_FPGA_WAIT_INIT); @@ -241,10 +242,11 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) /* * Start a timer and wait for INIT_B to go high */ - ts = get_timer (0); + ts = time_ms_now(); do { CONFIG_FPGA_DELAY (); - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_INIT) { + if (time_ms_delta_min(ts, timer_ms_now()) + > CONFIG_SYS_FPGA_WAIT_INIT) { printf ("%s:%d: ** Timeout after %d ticks waiting for INIT" " to deassert.\n", __FUNCTION__, __LINE__, CONFIG_SYS_FPGA_WAIT_INIT); @@ -297,9 +299,10 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) (*fn->clk) (TRUE, TRUE, cookie);
#ifdef CONFIG_SYS_FPGA_CHECK_BUSY - ts = get_timer (0); + ts = time_ms_now(); while ((*fn->busy) (cookie)) { - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_BUSY) { + if (time_ms_delta_min(ts, timer_ms_now()) + > CONFIG_SYS_FPGA_WAIT_BUSY) { printf ("%s:%d: ** Timeout after %d ticks waiting for" " BUSY to deassert\n", __FUNCTION__, __LINE__, CONFIG_SYS_FPGA_WAIT_BUSY); @@ -330,10 +333,11 @@ static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize) * Check for successful configuration. FPGA INIT_B and DONE should * both be high upon successful configuration. */ - ts = get_timer (0); + ts = time_ms_now(); ret_val = FPGA_SUCCESS; while (((*fn->done) (cookie) == FPGA_FAIL) || (*fn->init) (cookie)) { - if (get_timer (ts) > CONFIG_SYS_FPGA_WAIT_CONFIG) { + if (time_ms_delta_min(ts, timer_ms_now()) + > CONFIG_SYS_FPGA_WAIT_CONFIG) { printf ("%s:%d: ** Timeout after %d ticks waiting for DONE to" "assert and INIT to deassert\n", __FUNCTION__, __LINE__, CONFIG_SYS_FPGA_WAIT_CONFIG); diff --git a/drivers/i2c/bfin-twi_i2c.c b/drivers/i2c/bfin-twi_i2c.c index b3a04d3..66f3677 100644 --- a/drivers/i2c/bfin-twi_i2c.c +++ b/drivers/i2c/bfin-twi_i2c.c @@ -94,7 +94,7 @@ struct i2c_msg { static int wait_for_completion(struct i2c_msg *msg) { uint16_t int_stat; - ulong timebase = get_timer(0); + u32 timebase = time_ms_now();
do { int_stat = twi->int_stat; @@ -146,9 +146,9 @@ static int wait_for_completion(struct i2c_msg *msg)
/* If we were able to do something, reset timeout */ if (int_stat) - timebase = get_timer(0); + timebase = time_ms_now();
- } while (get_timer(timebase) < I2C_TIMEOUT); + } while time_ms_delta_min(timebase, timer_ms_now()) < I2C_TIMEOUT);
return msg->len; } diff --git a/drivers/i2c/spr_i2c.c b/drivers/i2c/spr_i2c.c index eabfe84..de5cd10 100644 --- a/drivers/i2c/spr_i2c.c +++ b/drivers/i2c/spr_i2c.c @@ -168,13 +168,14 @@ static void i2c_flush_rxfifo(void) */ static int i2c_wait_for_bb(void) { - unsigned long start_time_bb = get_timer(0); + u32 start_time_bb = time_ms_now();
while ((readl(&i2c_regs_p->ic_status) & IC_STATUS_MA) || !(readl(&i2c_regs_p->ic_status) & IC_STATUS_TFE)) {
/* Evaluate timeout */ - if (get_timer(start_time_bb) > (unsigned long)(I2C_BYTE_TO_BB)) + if (time_ms_delta_min(start_time_bb, timer_ms_now()) + > (unsigned long)(I2C_BYTE_TO_BB)) return 1; }
@@ -217,13 +218,14 @@ static int i2c_xfer_init(uchar chip, uint addr)
static int i2c_xfer_finish(void) { - ulong start_stop_det = get_timer(0); + u32 start_stop_det = time_ms_now();
while (1) { if ((readl(&i2c_regs_p->ic_raw_intr_stat) & IC_STOP_DET)) { readl(&i2c_regs_p->ic_clr_stop_det); break; - } else if (get_timer(start_stop_det) > I2C_STOPDET_TO) { + } else if (time_ms_delta_min(start_stop_det, timer_ms_now()) + > I2C_STOPDET_TO) { break; } } @@ -253,7 +255,7 @@ static int i2c_xfer_finish(void) */ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) { - unsigned long start_time_rx; + u32 start_time_rx;
if (check_params(addr, alen, buffer, len)) return 1; @@ -261,16 +263,17 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) if (i2c_xfer_init(chip, addr)) return 1;
- start_time_rx = get_timer(0); + start_time_rx = time_ms_now(); while (len) { writel(IC_CMD, &i2c_regs_p->ic_cmd_data);
if (readl(&i2c_regs_p->ic_status) & IC_STATUS_RFNE) { *buffer++ = (uchar)readl(&i2c_regs_p->ic_cmd_data); len--; - start_time_rx = get_timer(0); + start_time_rx = time_ms_now();
- } else if (get_timer(start_time_rx) > I2C_BYTE_TO) { + } else if (time_ms_delta_min(start_time_rx, timer_ms_now()) + > I2C_BYTE_TO) { printf("Timed out. i2c read Failed\n"); return 1; } @@ -292,7 +295,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) { int nb = len; - unsigned long start_time_tx; + u32 start_time_tx;
if (check_params(addr, alen, buffer, len)) return 1; @@ -300,15 +303,16 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) if (i2c_xfer_init(chip, addr)) return 1;
- start_time_tx = get_timer(0); + start_time_tx = time_ms_now(); while (len) { if (readl(&i2c_regs_p->ic_status) & IC_STATUS_TFNF) { writel(*buffer, &i2c_regs_p->ic_cmd_data); buffer++; len--; - start_time_tx = get_timer(0); + start_time_tx = time_ms_now();
- } else if (get_timer(start_time_tx) > (nb * I2C_BYTE_TO)) { + } else if (time_ms_delta_min(start_time_tx, timer_ms_now() + > (nb * I2C_BYTE_TO)) { printf("Timed out. i2c write Failed\n"); return 1; } diff --git a/drivers/i2c/u8500_i2c.c b/drivers/i2c/u8500_i2c.c index ea8a71d..488c1ea 100644 --- a/drivers/i2c/u8500_i2c.c +++ b/drivers/i2c/u8500_i2c.c @@ -180,12 +180,12 @@ void i2c_init(int speed, int slaveaddr) */ static int loop_till_bit_clear(void *io_reg, u32 mask, unsigned long timeout) { - unsigned long timebase = get_timer(0); + unsigned long timebase = time_now_ms();
do { if ((readl(io_reg) & mask) == 0x0UL) return 0; - } while (get_timer(timebase) < timeout); + } while (time_since_ms(timebase) < timeout);
debug("loop_till_bit_clear timed out\n"); return -1; @@ -199,12 +199,12 @@ static int loop_till_bit_clear(void *io_reg, u32 mask, unsigned long timeout) */ static int loop_till_bit_set(void *io_reg, u32 mask, unsigned long timeout) { - unsigned long timebase = get_timer(0); + unsigned long timebase = time_now_ms();
do { if ((readl(io_reg) & mask) != 0x0UL) return 0; - } while (get_timer(timebase) < timeout); + } while (time_since_ms(timebase) < timeout);
debug("loop_till_bit_set timed out\n"); return -1; diff --git a/drivers/input/ps2mult.c b/drivers/input/ps2mult.c index ab74933..e841bd3 100644 --- a/drivers/input/ps2mult.c +++ b/drivers/input/ps2mult.c @@ -39,7 +39,7 @@ #endif
-static ulong start_time; +static u32 st; static int init_done = 0;
static int received_escape = 0; @@ -66,7 +66,7 @@ static u_char ps2mult_buf_status [PS2BUF_SIZE]; #endif void ps2mult_early_init (void) { - start_time = get_timer(0); + st = time_ms_now()); }
static void ps2mult_send_byte(u_char byte, u_char sel) @@ -365,7 +365,7 @@ int ps2mult_init (void) int kbd_found = 0; int mouse_found = 0;
- while (get_timer(start_time) < CONFIG_PS2MULT_DELAY); + while (time_ms_delta_min(ts, time_ms_now()) < CONFIG_PS2MULT_DELAY);
ps2ser_init();
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c index ef12ecd..edf117b 100644 --- a/drivers/mmc/omap_hsmmc.c +++ b/drivers/mmc/omap_hsmmc.c @@ -74,14 +74,14 @@ unsigned char mmc_board_init(hsmmc_t *mmc_base)
void mmc_init_stream(hsmmc_t *mmc_base) { - ulong start; + u32 st;
writel(readl(&mmc_base->con) | INIT_INITSTREAM, &mmc_base->con);
writel(MMC_CMD0, &mmc_base->cmd); - start = get_timer(0); + st = time_ms_now(); while (!(readl(&mmc_base->stat) & CC_MASK)) { - if (get_timer(0) - start > MAX_RETRY_MS) { + if (time_ms_delta_min(ts, time_ms_now()) > MAX_RETRY_MS) { printf("%s: timedout waiting for cc!\n", __func__); return; } @@ -90,9 +90,9 @@ void mmc_init_stream(hsmmc_t *mmc_base) ; writel(MMC_CMD0, &mmc_base->cmd) ; - start = get_timer(0); + st = time_ms_now(); while (!(readl(&mmc_base->stat) & CC_MASK)) { - if (get_timer(0) - start > MAX_RETRY_MS) { + if (time_ms_delta_min(ts, time_ms_now()) > MAX_RETRY_MS) { printf("%s: timedout waiting for cc2!\n", __func__); return; } @@ -106,23 +106,23 @@ static int mmc_init_setup(struct mmc *mmc) hsmmc_t *mmc_base = (hsmmc_t *)mmc->priv; unsigned int reg_val; unsigned int dsor; - ulong start; + u32 st;
mmc_board_init(mmc_base);
writel(readl(&mmc_base->sysconfig) | MMC_SOFTRESET, &mmc_base->sysconfig); - start = get_timer(0); + st = time_ms_now(); while ((readl(&mmc_base->sysstatus) & RESETDONE) == 0) { - if (get_timer(0) - start > MAX_RETRY_MS) { + if (time_ms_delta_min(ts, time_ms_now()) > MAX_RETRY_MS) { printf("%s: timedout waiting for cc2!\n", __func__); return TIMEOUT; } } writel(readl(&mmc_base->sysctl) | SOFTRESETALL, &mmc_base->sysctl); - start = get_timer(0); + st = time_ms_now(); while ((readl(&mmc_base->sysctl) & SOFTRESETALL) != 0x0) { - if (get_timer(0) - start > MAX_RETRY_MS) { + if (time_ms_delta_min(ts, time_ms_now()) > MAX_RETRY_MS) { printf("%s: timedout waiting for softresetall!\n", __func__); return TIMEOUT; @@ -143,9 +143,9 @@ static int mmc_init_setup(struct mmc *mmc) (ICE_STOP | DTO_15THDTO | CEN_DISABLE)); mmc_reg_out(&mmc_base->sysctl, ICE_MASK | CLKD_MASK, (dsor << CLKD_OFFSET) | ICE_OSCILLATE); - start = get_timer(0); + st = time_ms_now(); while ((readl(&mmc_base->sysctl) & ICS_MASK) == ICS_NOTREADY) { - if (get_timer(0) - start > MAX_RETRY_MS) { + if (time_ms_delta_min(ts, time_ms_now()) > MAX_RETRY_MS) { printf("%s: timedout waiting for ics!\n", __func__); return TIMEOUT; } @@ -169,19 +169,19 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, { hsmmc_t *mmc_base = (hsmmc_t *)mmc->priv; unsigned int flags, mmc_stat; - ulong start; + u32 st;
- start = get_timer(0); + st = time_ms_now(); while ((readl(&mmc_base->pstate) & DATI_MASK) == DATI_CMDDIS) { - if (get_timer(0) - start > MAX_RETRY_MS) { + if (time_ms_delta_min(ts, time_ms_now()) > MAX_RETRY_MS) { printf("%s: timedout waiting for cmddis!\n", __func__); return TIMEOUT; } } writel(0xFFFFFFFF, &mmc_base->stat); - start = get_timer(0); + st = time_ms_now(); while (readl(&mmc_base->stat)) { - if (get_timer(0) - start > MAX_RETRY_MS) { + if (time_ms_delta_min(ts, time_ms_now()) > MAX_RETRY_MS) { printf("%s: timedout waiting for stat!\n", __func__); return TIMEOUT; } @@ -241,10 +241,11 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, writel(cmd->cmdarg, &mmc_base->arg); writel((cmd->cmdidx << 24) | flags, &mmc_base->cmd);
- start = get_timer(0); + st = time_ms_now(); do { mmc_stat = readl(&mmc_base->stat); - if (get_timer(0) - start > MAX_RETRY_MS) { + if (time_ms_delta_min(ts, time_ms_now()) + > MAX_RETRY_MS) { printf("%s : timeout: No status update\n", __func__); return TIMEOUT; } @@ -285,6 +286,7 @@ static int mmc_read_data(hsmmc_t *mmc_base, char *buf, unsigned int size) unsigned int *output_buf = (unsigned int *)buf; unsigned int mmc_stat; unsigned int count; + u32 st;
/* * Start Polled Read @@ -293,10 +295,11 @@ static int mmc_read_data(hsmmc_t *mmc_base, char *buf, unsigned int size) count /= 4;
while (size) { - ulong start = get_timer(0); + st = time_ms_now(); do { mmc_stat = readl(&mmc_base->stat); - if (get_timer(0) - start > MAX_RETRY_MS) { + if (time_ms_delta_min(ts, time_ms_now()) + > MAX_RETRY_MS) { printf("%s: timedout waiting for status!\n", __func__); return TIMEOUT; @@ -336,6 +339,7 @@ static int mmc_write_data(hsmmc_t *mmc_base, const char *buf, unsigned int size) unsigned int *input_buf = (unsigned int *)buf; unsigned int mmc_stat; unsigned int count; + u32 st;
/* * Start Polled Read @@ -344,10 +348,11 @@ static int mmc_write_data(hsmmc_t *mmc_base, const char *buf, unsigned int size) count /= 4;
while (size) { - ulong start = get_timer(0); + st = time_ms_now(); do { mmc_stat = readl(&mmc_base->stat); - if (get_timer(0) - start > MAX_RETRY_MS) { + if (time_ms_delta_min(ts, time_ms_now()) + > MAX_RETRY_MS) { printf("%s: timedout waiting for status!\n", __func__); return TIMEOUT; @@ -386,7 +391,7 @@ static void mmc_set_ios(struct mmc *mmc) { hsmmc_t *mmc_base = (hsmmc_t *)mmc->priv; unsigned int dsor = 0; - ulong start; + u32 st;
/* configue bus width */ switch (mmc->bus_width) { @@ -425,9 +430,9 @@ static void mmc_set_ios(struct mmc *mmc) mmc_reg_out(&mmc_base->sysctl, ICE_MASK | CLKD_MASK, (dsor << CLKD_OFFSET) | ICE_OSCILLATE);
- start = get_timer(0); + st = time_ms_now(); while ((readl(&mmc_base->sysctl) & ICS_MASK) == ICS_NOTREADY) { - if (get_timer(0) - start > MAX_RETRY_MS) { + if (time_ms_delta_min(ts, time_ms_now()) > MAX_RETRY_MS) { printf("%s: timedout waiting for ics!\n", __func__); return; } diff --git a/drivers/mtd/spi/atmel.c b/drivers/mtd/spi/atmel.c index 1ecece0..b2dbf86 100644 --- a/drivers/mtd/spi/atmel.c +++ b/drivers/mtd/spi/atmel.c @@ -119,7 +119,7 @@ static int at45_wait_ready(struct spi_flash *flash, unsigned long timeout) u8 cmd = CMD_AT45_READ_STATUS; u8 status;
- timebase = get_timer(0); + timebase = time_now_ms();
ret = spi_xfer(spi, 8, &cmd, NULL, SPI_XFER_BEGIN); if (ret) @@ -132,7 +132,7 @@ static int at45_wait_ready(struct spi_flash *flash, unsigned long timeout)
if (status & AT45_STATUS_READY) break; - } while (get_timer(timebase) < timeout); + } while (time_since_ms(timebase) < timeout);
/* Deactivate CS */ spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END); diff --git a/drivers/net/4xx_enet.c b/drivers/net/4xx_enet.c index b1763b1..79ec451 100644 --- a/drivers/net/4xx_enet.c +++ b/drivers/net/4xx_enet.c @@ -1564,7 +1564,7 @@ static int ppc_4xx_eth_send (struct eth_device *dev, volatile void *ptr, int len) { struct enet_frame *ef_ptr; - ulong time_start, time_now; + u32 ts; unsigned long temp_txm0; EMAC_4XX_HW_PST hw_p = dev->priv;
@@ -1609,7 +1609,7 @@ static int ppc_4xx_eth_send (struct eth_device *dev, volatile void *ptr, /*-----------------------------------------------------------------------+ * poll unitl the packet is sent and then make sure it is OK *-----------------------------------------------------------------------*/ - time_start = get_timer (0); + ts = time_ms_now(); while (1) { temp_txm0 = in_be32((void *)EMAC0_TMR0 + hw_p->hw_addr); /* loop until either TINT turns on or 3 seconds elapse */ @@ -1618,10 +1618,8 @@ static int ppc_4xx_eth_send (struct eth_device *dev, volatile void *ptr, * If there is an error, an interrupt should * happen when we return */ - time_now = get_timer (0); - if ((time_now - time_start) > 3000) { + if (time_ms_delta_min(ts, time_ms_now()) > 3000) return (-1); - } } else { return (len); } diff --git a/drivers/net/bcm570x.c b/drivers/net/bcm570x.c index c250d44..5440e57 100644 --- a/drivers/net/bcm570x.c +++ b/drivers/net/bcm570x.c @@ -1204,7 +1204,7 @@ LM_STATUS MM_FreeRxBuffer (PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket)
unsigned long MM_AnGetCurrentTime_us (PAN_STATE_INFO pAnInfo) { - return get_timer (0); + return time_ms_now(); }
/* diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c index 9424fb2..8e434d9 100644 --- a/drivers/net/cs8900.c +++ b/drivers/net/cs8900.c @@ -98,7 +98,7 @@ static void put_reg(struct eth_device *dev, int regno, u16 val)
static void cs8900_reset(struct eth_device *dev) { - int tmo; + u32 st; u16 us;
/* reset NIC */ @@ -108,9 +108,10 @@ static void cs8900_reset(struct eth_device *dev) udelay(200000); /* Wait until the chip is reset */
- tmo = get_timer(0) + 1 * CONFIG_SYS_HZ; + st = time_ms_now(); while ((((us = get_reg_init_bus(dev, PP_SelfSTAT)) & - PP_SelfSTAT_InitD) == 0) && tmo < get_timer(0)) + PP_SelfSTAT_InitD) == 0) && + (time_ms_delta_min(st, time_ms_now()) < 1000)) /*NOP*/; }
@@ -220,7 +221,7 @@ static int cs8900_send(struct eth_device *dev, volatile void *packet, int length) { volatile u16 *addr; - int tmo; + u32 st; u16 s; struct cs8900_priv *priv = (struct cs8900_priv *)(dev->priv);
@@ -233,8 +234,8 @@ retry: if ((get_reg(dev, PP_BusSTAT) & PP_BusSTAT_TxRDY) == 0) { /* Oops... this should not happen! */ debug("cs: unable to send packet; retrying...\n"); - for (tmo = get_timer(0) + 5 * CONFIG_SYS_HZ; - get_timer(0) < tmo;) + for (st = time_ms_now(); + time_ms_delta_min(st, time_ms_now()) < 5000;) /*NOP*/; cs8900_reset(dev); cs8900_reginit(dev); @@ -247,9 +248,9 @@ retry: REG_WRITE(*addr++, &priv->regs->rtdata);
/* wait for transfer to succeed */ - tmo = get_timer(0) + 5 * CONFIG_SYS_HZ; + st = time_ms_now(); while ((s = get_reg(dev, PP_TER) & ~0x1F) == 0) { - if (get_timer(0) >= tmo) + if (time_ms_delta_min(st, time_ms_now()) >= 5000) break; }
diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c index b5c5573..8fb15cf 100644 --- a/drivers/net/dm9000x.c +++ b/drivers/net/dm9000x.c @@ -401,7 +401,7 @@ static int dm9000_init(struct eth_device *dev, bd_t *bd) static int dm9000_send(struct eth_device *netdev, volatile void *packet, int length) { - int tmo; + u32 st; struct board_info *db = &dm9000_info;
DM9000_DMP_PACKET(__func__ , packet, length); @@ -422,10 +422,10 @@ static int dm9000_send(struct eth_device *netdev, volatile void *packet, DM9000_iow(DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */
/* wait for end of transmission */ - tmo = get_timer(0) + 5 * CONFIG_SYS_HZ; + st = time_ms_now(); while ( !(DM9000_ior(DM9000_NSR) & (NSR_TX1END | NSR_TX2END)) || !(DM9000_ior(DM9000_ISR) & IMR_PTM) ) { - if (get_timer(0) >= tmo) { + if (time_ms_delta_min(st, time_ms_now()) >= 5000) { printf("transmission timeout\n"); break; } diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index 34cc47f..003fdc0 100644 --- a/drivers/net/ethoc.c +++ b/drivers/net/ethoc.c @@ -420,7 +420,7 @@ static int ethoc_send(struct eth_device *dev, volatile void *packet, int length) struct ethoc_bd bd; u32 entry; u32 pending; - int tmo; + u32 st;
entry = priv->cur_tx % priv->num_tx; ethoc_read_bd(dev, entry, &bd); @@ -440,7 +440,7 @@ static int ethoc_send(struct eth_device *dev, volatile void *packet, int length) ethoc_write_bd(dev, entry, &bd);
/* wait for transfer to succeed */ - tmo = get_timer(0) + 5 * CONFIG_SYS_HZ; + st = time_ms_now(); while (1) { pending = ethoc_read(dev, INT_SOURCE); ethoc_ack_irq(dev, pending & ~INT_MASK_RX); @@ -451,7 +451,7 @@ static int ethoc_send(struct eth_device *dev, volatile void *packet, int length) ethoc_tx(dev); break; } - if (get_timer(0) >= tmo) { + if (time_ms_delta_min(st, time_ms_now()) >= 5000) { debug("%s(): timed out\n", __func__); return -1; } diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index ab90afa..076e0dc 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -70,7 +70,7 @@ static int fec_miiphy_read(const char *dev, uint8_t phyAddr, uint8_t regAddr,
uint32_t reg; /* convenient holder for the PHY register */ uint32_t phy; /* convenient holder for the PHY */ - uint32_t start; + u32 st;
/* * reading from any PHY's register is done by properly @@ -86,9 +86,9 @@ static int fec_miiphy_read(const char *dev, uint8_t phyAddr, uint8_t regAddr, /* * wait for the related interrupt */ - start = get_timer(0); + start = time_ms_now(); while (!(readl(&fec->eth->ievent) & FEC_IEVENT_MII)) { - if (get_timer(start) > (CONFIG_SYS_HZ / 1000)) { + if (time_ms_delta_min(st, time_ms_now()) > 1) { printf("Read MDIO failed...\n"); return -1; } @@ -127,7 +127,7 @@ static int fec_miiphy_write(const char *dev, uint8_t phyAddr, uint8_t regAddr,
uint32_t reg; /* convenient holder for the PHY register */ uint32_t phy; /* convenient holder for the PHY */ - uint32_t start; + u32 st;
reg = regAddr << FEC_MII_DATA_RA_SHIFT; phy = phyAddr << FEC_MII_DATA_PA_SHIFT; @@ -138,9 +138,9 @@ static int fec_miiphy_write(const char *dev, uint8_t phyAddr, uint8_t regAddr, /* * wait for the MII interrupt */ - start = get_timer(0); + st = time_ms_now(); while (!(readl(&fec->eth->ievent) & FEC_IEVENT_MII)) { - if (get_timer(start) > (CONFIG_SYS_HZ / 1000)) { + if (time_ms_delta_min(st, time_ms_now()) > 1) { printf("Write MDIO failed...\n"); return -1; } @@ -183,15 +183,15 @@ static int miiphy_restart_aneg(struct eth_device *dev)
static int miiphy_wait_aneg(struct eth_device *dev) { - uint32_t start; + u32 st; uint16_t status;
/* * Wait for AN completion */ - start = get_timer(0); + st = time_ms_now(); do { - if (get_timer(start) > (CONFIG_SYS_HZ * 5)) { + if (time_ms_delta_min(st, time_ms_now()) > 5000) { printf("%s: Autonegotiation timeout\n", dev->name); return -1; } diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c index dc7a80e..5f24962 100644 --- a/drivers/net/ftgmac100.c +++ b/drivers/net/ftgmac100.c @@ -490,7 +490,7 @@ ftgmac100_send(struct eth_device *dev, void *packet, int length) struct ftgmac100 *ftgmac100 = (struct ftgmac100 *)dev->iobase; struct ftgmac100_data *priv = dev->priv; struct ftgmac100_txdes *curr_des = &priv->txdes[priv->tx_index]; - int start; + int st;
if (curr_des->txdes0 & FTGMAC100_TXDES0_TXDMA_OWN) { debug("%s(): no TX descriptor available\n", __func__); @@ -515,9 +515,9 @@ ftgmac100_send(struct eth_device *dev, void *packet, int length) writel(1, &ftgmac100->txpd);
/* wait for transfer to succeed */ - start = get_timer(0); + st = time_ms_now(); while (curr_des->txdes0 & FTGMAC100_TXDES0_TXDMA_OWN) { - if (get_timer(0) >= 5) { + if (time_ms_delta_min(st, time_ms_now()) >= 5) { debug("%s(): timed out\n", __func__); return -1; } diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index 94dc6d9..5e057a1 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -196,7 +196,7 @@ ftmac100_send (struct eth_device *dev, volatile void *packet, int length) struct ftmac100 *ftmac100 = (struct ftmac100 *)dev->iobase; struct ftmac100_data *priv = dev->priv; struct ftmac100_txdes *curr_des = priv->txdes; - ulong start; + ulong st;
if (curr_des->txdes0 & FTMAC100_TXDES0_TXDMA_OWN) { debug ("%s(): no TX descriptor available\n", __func__); @@ -224,9 +224,9 @@ ftmac100_send (struct eth_device *dev, volatile void *packet, int length)
/* wait for transfer to succeed */
- start = get_timer(0); + st = time_ms_now(); while (curr_des->txdes0 & FTMAC100_TXDES0_TXDMA_OWN) { - if (get_timer(start) >= 5) { + if (time_ms_delta_min(st, time_ms_now()) >= 5) { debug ("%s(): timed out\n", __func__); return -1; } diff --git a/drivers/net/greth.c b/drivers/net/greth.c index 6c32226..9653f64 100644 --- a/drivers/net/greth.c +++ b/drivers/net/greth.c @@ -230,7 +230,7 @@ int greth_init_phy(greth_priv * dev, bd_t * bis) { greth_regs *regs = dev->regs; int tmp, tmp1, tmp2, i; - unsigned int start, timeout; + unsigned int st; int phyaddr = GRETH_PHY_ADR_DEFAULT;
#ifndef CONFIG_SYS_GRLIB_GRETH_PHYADDR @@ -252,18 +252,16 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
debug("GRETH PHY ADDRESS: %d\n", phyaddr);
- /* X msecs to ticks */ - timeout = usec2ticks(GRETH_PHY_TIMEOUT_MS * 1000); - /* Get system timer0 current value * Total timeout is 5s */ - start = get_timer(0); + st = time_ms_now();
/* get phy control register default values */
while ((tmp = read_mii(phyaddr, 0, regs)) & 0x8000) { - if (get_timer(start) > timeout) { + if (time_ms_delta_min(st, time_ms_now()) + > GRETH_PHY_TIMEOUT_MS) { debug("greth_init_phy: PHY read 1 failed\n"); return 1; /* Fail */ } @@ -273,7 +271,8 @@ int greth_init_phy(greth_priv * dev, bd_t * bis) write_mii(phyaddr, 0, 0x8000 | tmp, regs);
while (((tmp = read_mii(phyaddr, 0, regs))) & 0x8000) { - if (get_timer(start) > timeout) { + if (time_ms_delta_min(st, time_ms_now()) + > GRETH_PHY_TIMEOUT_MS) { debug("greth_init_phy: PHY read 2 failed\n"); return 1; /* Fail */ } @@ -293,7 +292,8 @@ int greth_init_phy(greth_priv * dev, bd_t * bis) dev->auto_neg = 1; i = 0; while (!(((tmp = read_mii(phyaddr, 1, regs)) >> 5) & 1)) { - if (get_timer(start) > timeout) { + if (time_ms_delta_min(st, time_ms_now()) + > GRETH_PHY_TIMEOUT_MS) { printf("Auto negotiation timed out. " "Selecting default config\n"); tmp = read_mii(phyaddr, 0, regs); diff --git a/drivers/net/lan91c96.c b/drivers/net/lan91c96.c index 883f3a7..3aa825a 100644 --- a/drivers/net/lan91c96.c +++ b/drivers/net/lan91c96.c @@ -175,14 +175,15 @@ static void print_packet (byte *, int);
static int poll4int (struct eth_device *dev, byte mask, int timeout) { - int tmo = get_timer (0) + timeout * CONFIG_SYS_HZ; + int ts = time_ms_now(); int is_timeout = 0; word old_bank = SMC_inw(dev, LAN91C96_BANK_SELECT);
PRINTK2 ("Polling...\n"); SMC_SELECT_BANK(dev, 2); while ((SMC_inw(dev, LAN91C96_INT_STATS) & mask) == 0) { - if (get_timer (0) >= tmo) { + if (time_ms_delta_min(start, time_ms_now()) + >= timeout * 1000) { is_timeout = 1; break; } diff --git a/drivers/net/ne2000_base.c b/drivers/net/ne2000_base.c index f93f932..288da5c 100644 --- a/drivers/net/ne2000_base.c +++ b/drivers/net/ne2000_base.c @@ -733,21 +733,21 @@ int eth_rx() { }
int eth_send(volatile void *packet, int length) { - int tmo; + int ts;
PRINTK("### eth_send\n");
pkey = -1;
dp83902a_send((u8 *) packet, length, 666); - tmo = get_timer (0) + TOUT * CONFIG_SYS_HZ; + ts = time_ms_now(); while(1) { dp83902a_poll(); if (pkey != -1) { PRINTK("Packet sucesfully sent\n"); return 0; } - if (get_timer (0) >= tmo) { + if (time_ms_delta_min(ts, time_ms_now()) >= TOUT * 1000) { printf("transmission error (timoeut)\n"); return 0; } diff --git a/drivers/net/netarm_eth.c b/drivers/net/netarm_eth.c index f54817e..0b4b959 100644 --- a/drivers/net/netarm_eth.c +++ b/drivers/net/netarm_eth.c @@ -83,8 +83,9 @@ static int na_mii_poll_busy (void) { ulong start; /* arm simple, non interrupt dependent timer */ - start = get_timer(0)); - while (get_timer(start) < NA_MII_POLL_BUSY_DELAY) { + start = time_ms_now(); + while (time_ms_delta_min(start, time_ms_now()) + < NA_MII_POLL_BUSY_DELAY) { if (!(GET_EADDR (NETARM_ETH_MII_IND) & NETARM_ETH_MIII_BUSY)) { return 1; } @@ -172,13 +173,14 @@ static int reset_eth (void)
/* reset the phy */ na_mii_write (MII_PHY_CONTROL, 0x8000); - start = get_timer(0); - while (get_timer(start) < NA_MII_NEGOTIATE_DELAY) { + start = time_ms_now(); + while (time_ms_delta_min(start, time_ms_now()) + < NA_MII_NEGOTIATE_DELAY) { if ((na_mii_read (MII_PHY_STATUS) & 0x8000) == 0) { break; } } - if (get_timer(start) >= NA_MII_NEGOTIATE_DELAY) + if (time_ms_delta_min(start, time_ms_now()) >= NA_MII_NEGOTIATE_DELAY) printf ("phy reset timeout\n");
/* set the PCS reg */ diff --git a/drivers/net/ns7520_eth.c b/drivers/net/ns7520_eth.c index de82b04..687e42a 100644 --- a/drivers/net/ns7520_eth.c +++ b/drivers/net/ns7520_eth.c @@ -449,8 +449,9 @@ static void ns7520_link_auto_negotiate(void)
/* wait for completion */
- ulStartJiffies = get_timer(0); - while (get_timer(0) < ulStartJiffies + NS7520_MII_NEG_DELAY) { + ulStartJiffies = time_ms_now(); + while (time_ms_delta_min(ulStartJiffies, time_ms_now()) + < NS7520_MII_NEG_DELAY) { uiStatus = ns7520_mii_read(MII_BMSR); if ((uiStatus & (BMSR_ANEGCOMPLETE | BMSR_LSTATUS)) == diff --git a/drivers/net/ns9750_eth.c b/drivers/net/ns9750_eth.c index 9899563..b800048 100644 --- a/drivers/net/ns9750_eth.c +++ b/drivers/net/ns9750_eth.c @@ -291,7 +291,7 @@ int eth_send (volatile void *pPacket, int nLen) *get_eth_reg_addr (NS9750_ETH_EGCR2) &= ~NS9750_ETH_EGCR2_TCLER; *get_eth_reg_addr (NS9750_ETH_EGCR2) |= NS9750_ETH_EGCR2_TCLER;
- ulTimeout = get_timer (0); + ts = time_ms_now();
DEBUG_ARGS0 (DEBUG_TX | DEBUG_MINOR, "Waiting for transmission to finish\n"); @@ -299,7 +299,7 @@ int eth_send (volatile void *pPacket, int nLen) (*get_eth_reg_addr (NS9750_ETH_EINTR) & (NS9750_ETH_EINTR_TXDONE | NS9750_ETH_EINTR_TXERR))) { /* do nothing, wait for completion */ - if (get_timer (0) - ulTimeout > TX_TIMEOUT) { + if (time_ms_delta_min(ts, time_ms_now()) > TX_TIMEOUT) { DEBUG_ARGS0 (DEBUG_TX, "Transmit Timed out\n"); return -1; } diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index c2779db..eb503a7 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -98,7 +98,6 @@ #undef DEBUG_TX #undef DEBUG_RX
-#define currticks() get_timer(0) #define bus_to_phys(a) pci_mem_to_phys((pci_dev_t)dev->priv, a) #define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a)
@@ -425,6 +424,7 @@ static int rtl_transmit(struct eth_device *dev, volatile void *packet, int lengt memcpy((char *)tx_buffer, (char *)packet, (int)length);
#ifdef DEBUG_TX + u32 ts = time_now_ms(); printf("sending %d bytes\n", len); #endif
@@ -454,8 +454,8 @@ static int rtl_transmit(struct eth_device *dev, volatile void *packet, int lengt if (status & TxOK) { cur_tx = (cur_tx + 1) % NUM_TX_DESC; #ifdef DEBUG_TX - printf("tx done (%d ticks), status %hX txstatus %X\n", - to-currticks(), status, txstatus); + printf("tx done (%d ms), status %hX txstatus %X\n", + time_max_since_ms(ts), status, txstatus); #endif return length; } else { diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c index b81dcad..802a95a 100644 --- a/drivers/net/rtl8169.c +++ b/drivers/net/rtl8169.c @@ -68,9 +68,6 @@
static u32 ioaddr;
-/* Condensed operations for readability. */ -#define currticks() get_timer(0) - /* media options */ #define MAX_UNITS 8 static int media[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 }; @@ -473,9 +470,10 @@ static int rtl_send(struct eth_device *dev, volatile void *packet, int length) int entry = tpc->cur_tx % NUM_TX_DESC; u32 len = length; int ret; + u32 ts;
#ifdef DEBUG_RTL8169_TX - int stime = currticks(); + int stime = time_now_ms(); printf ("%s\n", __FUNCTION__); printf("sending %d bytes\n", len); #endif @@ -504,17 +502,17 @@ static int rtl_send(struct eth_device *dev, volatile void *packet, int length) RTL_W8(TxPoll, 0x40); /* set polling bit */
tpc->cur_tx++; - to = currticks() + TX_TIMEOUT; + ts = time_now_ms(); do { flush_cache((unsigned long)&tpc->TxDescArray[entry], sizeof(struct TxDesc)); } while ((le32_to_cpu(tpc->TxDescArray[entry].status) & OWNbit) - && (currticks() < to)); /* wait */ + && (time_since_ms(ts) < TX_TIMEOUT)); /* wait */
- if (currticks() >= to) { + if (time_since_ms(ts) >= TX_TIMEOUT) { #ifdef DEBUG_RTL8169_TX puts ("tx timeout/error\n"); - printf ("%s elapsed time : %d\n", __FUNCTION__, currticks()-stime); + printf ("%s elapsed time : %d\n", __FUNCTION__, time_max_since_ms(stime)); #endif ret = 0; } else { @@ -556,7 +554,7 @@ static void rtl8169_hw_start(struct eth_device *dev) u32 i;
#ifdef DEBUG_RTL8169 - int stime = currticks(); + int stime = time_now_ms(); printf ("%s\n", __FUNCTION__); #endif
@@ -616,7 +614,7 @@ static void rtl8169_hw_start(struct eth_device *dev) RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000);
#ifdef DEBUG_RTL8169 - printf ("%s elapsed time : %d\n", __FUNCTION__, currticks()-stime); + printf ("%s elapsed time : %d\n", __FUNCTION__, time_max_since_ms(stime)); #endif }
@@ -625,7 +623,7 @@ static void rtl8169_init_ring(struct eth_device *dev) int i;
#ifdef DEBUG_RTL8169 - int stime = currticks(); + int stime = time_now_ms(); printf ("%s\n", __FUNCTION__); #endif
@@ -654,7 +652,7 @@ static void rtl8169_init_ring(struct eth_device *dev) }
#ifdef DEBUG_RTL8169 - printf ("%s elapsed time : %d\n", __FUNCTION__, currticks()-stime); + printf ("%s elapsed time : %d\n", __FUNCTION__, time_max_sine_ms(stime)); #endif }
@@ -666,7 +664,7 @@ static int rtl_reset(struct eth_device *dev, bd_t *bis) int i;
#ifdef DEBUG_RTL8169 - int stime = currticks(); + int stime = time_now_ms(); printf ("%s\n", __FUNCTION__); #endif
@@ -695,7 +693,7 @@ static int rtl_reset(struct eth_device *dev, bd_t *bis) txb[5] = dev->enetaddr[5];
#ifdef DEBUG_RTL8169 - printf ("%s elapsed time : %d\n", __FUNCTION__, currticks()-stime); + printf ("%s elapsed time : %d\n", __FUNCTION__, time_max_since_ms(stime)); #endif return 0; } diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c index ba9c67e..7ae0580 100644 --- a/drivers/net/smc91111.c +++ b/drivers/net/smc91111.c @@ -251,14 +251,14 @@ static void print_packet( byte *, int );
static int poll4int (struct eth_device *dev, byte mask, int timeout) { - int tmo = get_timer (0) + timeout * CONFIG_SYS_HZ; + int ts = time_ms_now(); int is_timeout = 0; word old_bank = SMC_inw (dev, BSR_REG);
PRINTK2 ("Polling...\n"); SMC_SELECT_BANK (dev, 2); while ((SMC_inw (dev, SMC91111_INT_REG) & mask) == 0) { - if (get_timer (0) >= tmo) { + if (time_ms_delta_min(ts, time_ms_now()) >= (timeout * 1000)) { is_timeout = 1; break; } diff --git a/drivers/serial/serial_clps7111.c b/drivers/serial/serial_clps7111.c index a6aecad..aec70d5 100644 --- a/drivers/serial/serial_clps7111.c +++ b/drivers/serial/serial_clps7111.c @@ -76,15 +76,15 @@ int serial_init (void) */ void serial_putc (const char c) { - int tmo; + u32 ts;
/* If \n, also do \r */ if (c == '\n') serial_putc ('\r');
- tmo = get_timer (0) + 1 * CONFIG_SYS_HZ; + ts = time_now_ms(); while (IO_SYSFLG1 & SYSFLG1_UTXFF) - if (get_timer (0) > tmo) + if (time_since_ms(ts) > 1000) break;
IO_UARTDR1 = c; diff --git a/drivers/serial/serial_netarm.c b/drivers/serial/serial_netarm.c index d04790d..78f3c90 100644 --- a/drivers/serial/serial_netarm.c +++ b/drivers/serial/serial_netarm.c @@ -43,9 +43,9 @@ DECLARE_GLOBAL_DATA_PTR; /* wait until transmitter is ready for another character */ #define TXWAITRDY(registers) \ { \ - ulong tmo = get_timer(0) + 1 * CONFIG_SYS_HZ; \ + u32 st = time_now_ms(); \ while (((registers)->status_a & NETARM_SER_STATA_TX_RDY) == 0 ) { \ - if (get_timer(0) > tmo) \ + if (time_since_ms(st) > 1000) \ break; \ } \ } diff --git a/drivers/spi/atmel_dataflash_spi.c b/drivers/spi/atmel_dataflash_spi.c index e7d3ff0..d77c5fe 100644 --- a/drivers/spi/atmel_dataflash_spi.c +++ b/drivers/spi/atmel_dataflash_spi.c @@ -141,7 +141,6 @@ unsigned int AT91F_SpiWrite1(AT91PS_DataflashDesc pDesc);
unsigned int AT91F_SpiWrite(AT91PS_DataflashDesc pDesc) { - unsigned int timeout; unsigned int timebase;
pDesc->state = BUSY; @@ -174,19 +173,18 @@ unsigned int AT91F_SpiWrite(AT91PS_DataflashDesc pDesc) }
/* arm simple, non interrupt dependent timer */ - timebase = get_timer(0); - timeout = 0; + timebase = time_now_ms();
writel(AT91_SPI_TXTEN + AT91_SPI_RXTEN, ATMEL_BASE_SPI0 + AT91_SPI_PTCR); while (!(readl(ATMEL_BASE_SPI0 + AT91_SPI_SR) & AT91_SPI_RXBUFF) && - ((timeout = get_timer(timebase)) < CONFIG_SYS_SPI_WRITE_TOUT)) + (time_since_ms(timebase) < CONFIG_SYS_SPI_WRITE_TOUT)) ; writel(AT91_SPI_TXTDIS + AT91_SPI_RXTDIS, ATMEL_BASE_SPI0 + AT91_SPI_PTCR); pDesc->state = IDLE;
- if (timeout >= CONFIG_SYS_SPI_WRITE_TOUT) { + if (time_since_ms(timebase) >= CONFIG_SYS_SPI_WRITE_TOUT) { printf("Error Timeout\n\r"); return DATAFLASH_ERROR; } diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 9fb0e80..52396d0 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -1922,8 +1922,8 @@ static void eth_start(struct eth_dev *dev, gfp_t gfp_flags) static int eth_stop(struct eth_dev *dev) { #ifdef RNDIS_COMPLETE_SIGNAL_DISCONNECT - unsigned long ts; - unsigned long timeout = CONFIG_SYS_HZ; /* 1 sec to stop RNDIS */ + u32 ts; + u32 timeout = CONFIG_SYS_HZ; /* 1 sec to stop RNDIS */ #endif
if (rndis_active(dev)) { @@ -1932,8 +1932,8 @@ static int eth_stop(struct eth_dev *dev)
#ifdef RNDIS_COMPLETE_SIGNAL_DISCONNECT /* Wait until host receives OID_GEN_MEDIA_CONNECT_STATUS */ - ts = get_timer(0); - while (get_timer(ts) < timeout) + ts = time_now_ms(); + while (time_since_ms(start) < timeout) usb_gadget_handle_interrupts(); #endif
@@ -2332,8 +2332,8 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd) { struct eth_dev *dev = &l_ethdev; struct usb_gadget *gadget; - unsigned long ts; - unsigned long timeout = USB_CONNECT_TIMEOUT; + u32 ts; + u32 timeout = USB_CONNECT_TIMEOUT;
if (!netdev) { error("received NULL ptr"); @@ -2379,10 +2379,11 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd) if (getenv("cdc_connect_timeout")) timeout = simple_strtoul(getenv("cdc_connect_timeout"), NULL, 10) * CONFIG_SYS_HZ; - ts = get_timer(0); + ts = time_now_ms(); while (!l_ethdev.network_started) { /* Handle control-c and timeouts */ - if (ctrlc() || (get_timer(ts) > timeout)) { + if (ctrlc() || + (time_since_ms(ts) > timeout)) { error("The remote end did not respond in time."); goto fail; } @@ -2403,8 +2404,8 @@ static int usb_eth_send(struct eth_device *netdev, void *rndis_pkt = NULL; struct eth_dev *dev = &l_ethdev; struct usb_request *req = dev->tx_req; - unsigned long ts; - unsigned long timeout = USB_CONNECT_TIMEOUT; + u32 ts; + u32 timeout = USB_CONNECT_TIMEOUT;
debug("%s:...\n", __func__);
@@ -2443,7 +2444,7 @@ static int usb_eth_send(struct eth_device *netdev, ? ((dev->tx_qlen % qmult) != 0) : 0; #endif dev->tx_qlen = 1; - ts = get_timer(0); + ts = time_now_ms(); packet_sent = 0;
retval = usb_ep_queue(dev->in_ep, req, GFP_ATOMIC); @@ -2451,7 +2452,7 @@ static int usb_eth_send(struct eth_device *netdev, if (!retval) debug("%s: packet queued\n", __func__); while (!packet_sent) { - if (get_timer(ts) > timeout) { + if (time_since_ms(ts) > timeout) { printf("timeout sending packets to usb ethernet\n"); return -1; } diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 70c02c9..52751fa 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -314,12 +314,12 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, struct QH *qh; struct qTD *td; volatile struct qTD *vtd; - unsigned long ts; + u32 ts; uint32_t *tdp; uint32_t endpt, token, usbsts; uint32_t c, toggle; uint32_t cmd; - int timeout; + u32 timeout; int ret = 0;
debug("dev=%p, pipe=%lx, buffer=%p, length=%d, req=%p\n", dev, pipe, @@ -446,7 +446,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, }
/* Wait for TDs to be processed. */ - ts = get_timer(0); + ts = time_now_ms(); vtd = td; timeout = USB_TIMEOUT_MS(pipe); do { @@ -456,7 +456,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, if (!(token & 0x80)) break; WATCHDOG_RESET(); - } while (get_timer(ts) < timeout); + } while (time_since_ms(ts) < timeout);
/* Check that the TD processing happened */ if (token & 0x80) { diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 82a8b36..9e7dad7 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -234,7 +234,8 @@ static int sl811_send_packet(struct usb_device *dev, unsigned long pipe, __u8 *b { __u8 ctrl = SL811_USB_CTRL_ARM | SL811_USB_CTRL_ENABLE; __u16 status = 0; - int err = 0, time_start = get_timer(0); + int err = 0; + u32 ts = time_now_ms(); int need_preamble = !(rh_status.wPortStatus & USB_PORT_STAT_LOW_SPEED) && usb_pipeslow(pipe);
@@ -264,7 +265,7 @@ static int sl811_send_packet(struct usb_device *dev, unsigned long pipe, __u8 *b
sl811_write(SL811_CTRL_A, ctrl); while (!(sl811_read(SL811_INTRSTS) & SL811_INTR_DONE_A)) { - if (5*CONFIG_SYS_HZ < get_timer(time_start)) { + if (time_since_ms(ts) >= 5000) { printf("USB transmit timed out\n"); return -USB_ST_CRC_ERR; }

Hello Graeme,
Graeme Russ wrote: [...]
diff --git a/drivers/fpga/spartan3.c b/drivers/fpga/spartan3.c index 1dd6f26..8282a23 100644 --- a/drivers/fpga/spartan3.c +++ b/drivers/fpga/spartan3.c
[...]
@@ -233,7 +235,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) #endif
/* now check for done signal */
ts = get_timer (0); /* get current time */
ts = time_since_ms(); /* get current time */
Shouldn't time_now_ms() be here?
____ Regards, Vitaly.

Hi Vitaly,
On Tue, Jun 28, 2011 at 10:36 PM, Vitaly Kuzmichev vkuzmichev@mvista.com wrote:
Hello Graeme,
Graeme Russ wrote: [...]
diff --git a/drivers/fpga/spartan3.c b/drivers/fpga/spartan3.c index 1dd6f26..8282a23 100644 --- a/drivers/fpga/spartan3.c +++ b/drivers/fpga/spartan3.c
[...]
@@ -233,7 +235,7 @@ static int Spartan3_sp_load (Xilinx_desc * desc, void *buf, size_t bsize) #endif
/* now check for done signal */
- ts = get_timer (0); /* get current time */
- ts = time_since_ms(); /* get current time */
Shouldn't time_now_ms() be here?
Yes, it should be - Thanks
Regards,
Graeme

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- net/bootp.c | 6 +++--- net/net.c | 18 +++++++----------- net/sntp.c | 2 +- net/tftp.c | 4 ++-- 4 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/net/bootp.c b/net/bootp.c index 4db63cb..8c9560d 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -637,7 +637,7 @@ BootpRequest (void) bp->bp_htype = HWT_ETHER; bp->bp_hlen = HWL_ETHER; bp->bp_hops = 0; - bp->bp_secs = htons(get_timer(0) / 1000); + bp->bp_secs = htons(time_ms_now() / 1000); NetWriteIP(&bp->bp_ciaddr, 0); NetWriteIP(&bp->bp_yiaddr, 0); NetWriteIP(&bp->bp_siaddr, 0); @@ -660,7 +660,7 @@ BootpRequest (void) | ((ulong)NetOurEther[3] << 16) | ((ulong)NetOurEther[4] << 8) | (ulong)NetOurEther[5]; - BootpID += get_timer(0); + BootpID += time_now_ms(); BootpID = htonl(BootpID); NetCopyLong(&bp->bp_id, &BootpID);
@@ -819,7 +819,7 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer) bp->bp_htype = HWT_ETHER; bp->bp_hlen = HWL_ETHER; bp->bp_hops = 0; - bp->bp_secs = htons(get_timer(0) / 1000); + bp->bp_secs = htons(time_ms_now() / 1000); /* Do not set the client IP, your IP, or server IP yet, since it hasn't been ACK'ed by * the server yet */
diff --git a/net/net.c b/net/net.c index 7a60583..b574481 100644 --- a/net/net.c +++ b/net/net.c @@ -290,15 +290,11 @@ void ArpRequest(void)
void ArpTimeoutCheck(void) { - ulong t; - if (!NetArpWaitPacketIP) return;
- t = get_timer(0); - /* check for arp timeout */ - if ((t - NetArpWaitTimerStart) > ARP_TIMEOUT) { + if (time_since_ms(NetArpWaitTimerStart) > ARP_TIMEOUT) { NetArpWaitTry++;
if (NetArpWaitTry >= ARP_TIMEOUT_COUNT) { @@ -306,7 +302,7 @@ void ArpTimeoutCheck(void) NetArpWaitTry = 0; NetStartAgain(); } else { - NetArpWaitTimerStart = t; + NetArpWaitTimerStart = time_now_ms(); ArpRequest(); } } @@ -535,7 +531,7 @@ restart: * Check for a timeout, and run the timeout handler * if we have one. */ - if (timeHandler && ((get_timer(0) - timeStart) > timeDelta)) { + if (timeHandler && (time_since_ms(timeStart) > timeDelta)) { thand_f *x;
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) @@ -672,7 +668,7 @@ NetSetTimeout(ulong iv, thand_f *f) timeHandler = (thand_f *)0; } else { timeHandler = f; - timeStart = get_timer(0); + timeStart = time_now_ms(); timeDelta = iv; } } @@ -721,7 +717,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
/* and do the ARP request */ NetArpWaitTry = 1; - NetArpWaitTimerStart = get_timer(0); + NetArpWaitTimerStart = time_now_ms(); ArpRequest(); return 1; /* waiting */ } @@ -792,7 +788,7 @@ int PingSend(void)
/* and do the ARP request */ NetArpWaitTry = 1; - NetArpWaitTimerStart = get_timer(0); + NetArpWaitTimerStart = time_now_ms(); ArpRequest(); return 1; /* waiting */ } @@ -1960,7 +1956,7 @@ void copy_filename(char *dst, const char *src, int size) */ unsigned int random_port(void) { - return 1024 + (get_timer(0) % 0x4000); + return 1024 + (time_now_ms() % 0x4000); } #endif
diff --git a/net/sntp.c b/net/sntp.c index 82f2fe6..5bd2425 100644 --- a/net/sntp.c +++ b/net/sntp.c @@ -33,7 +33,7 @@ SntpSend (void)
memcpy ((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE, (char *)&pkt, pktlen);
- SntpOurPort = 10000 + (get_timer(0) % 4096); + SntpOurPort = 10000 + (time_now_ms() % 4096); sport = NTP_SERVICE_PORT;
NetSendUDPPacket (NetServerEther, NetNtpServerIP, sport, SntpOurPort, pktlen); diff --git a/net/tftp.c b/net/tftp.c index a893e02..52a5ddc 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -338,7 +338,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, debug("Got WRQ\n"); TftpRemoteIP = sip; TftpRemotePort = src; - TftpOurPort = 1024 + (get_timer(0) % 3072); + TftpOurPort = 1024 + (time_ms_now() % 3072); TftpLastBlock = 0; TftpBlockWrap = 0; TftpBlockWrapOffset = 0; @@ -654,7 +654,7 @@ TftpStart(void) TftpTimeoutCount = 0; TftpState = STATE_SEND_RRQ; /* Use a pseudo-random port unless a specific port is set */ - TftpOurPort = 1024 + (get_timer(0) % 3072); + TftpOurPort = 1024 + (time_now_ms() % 3072);
#ifdef CONFIG_TFTP_PORT ep = getenv("tftpdstp");

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- common/cmd_misc.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/cmd_misc.c b/common/cmd_misc.c index 061b1bb..40f84d2 100644 --- a/common/cmd_misc.c +++ b/common/cmd_misc.c @@ -29,7 +29,7 @@
int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - ulong start = get_timer(0); + ulong start = time_now_ms(); ulong delay;
if (argc != 2) @@ -37,7 +37,7 @@ int do_sleep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
delay = simple_strtoul(argv[1], NULL, 10) * CONFIG_SYS_HZ;
- while (get_timer(start) < delay) { + while (time_since_ms(start) < delay) { if (ctrlc ()) return (-1);

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- board/BuS/EB+MCF-EV123/flash.c | 8 +++--- board/LEOX/elpt860/flash.c | 12 +++++----- board/Marvell/common/flash.c | 16 ++++++------ board/Marvell/common/intel_flash.c | 19 ++++++--------- board/RPXClassic/flash.c | 8 +++--- board/RPXlite/flash.c | 8 +++--- board/RPXlite_dw/flash.c | 8 +++--- board/RRvision/flash.c | 8 +++--- board/a3000/flash.c | 8 +++--- board/alaska/flash.c | 34 ++++++++++++++-------------- board/altera/common/AMDLV065D.c | 8 +++--- board/altera/common/flash.c | 10 ++++---- board/amcc/common/flash.c | 16 ++++++------ board/amcc/taihu/flash.c | 16 ++++++------ board/amcc/yucca/flash.c | 16 ++++++------ board/amirix/ap1000/flash.c | 4 +- board/armadillo/flash.c | 4 +- board/astro/mcf5373l/mcf5373l.c | 4 +- board/atc/flash.c | 22 +++++++++--------- board/atmel/at91rm9200dk/flash.c | 8 +++--- board/atmel/atstk1000/flash.c | 2 +- board/bmw/flash.c | 8 +++--- board/c2mon/flash.c | 8 +++--- board/cerf250/flash.c | 8 +++--- board/cm4008/flash.c | 8 +++--- board/cm41xx/flash.c | 8 +++--- board/cmc_pu2/flash.c | 8 +++--- board/cmi/flash.c | 12 +++++----- board/cobra5272/flash.c | 8 +++--- board/cogent/flash.c | 14 ++++++------ board/cpc45/flash.c | 8 +++--- board/cpu86/flash.c | 16 ++++++------ board/cpu87/flash.c | 16 ++++++------ board/cradle/flash.c | 8 +++--- board/cray/L1/flash.c | 8 +++--- board/csb226/flash.c | 8 +++--- board/cu824/flash.c | 8 +++--- board/dave/common/flash.c | 8 +++--- board/dnp1110/flash.c | 8 +++--- board/earthlcd/favr-32-ezkit/flash.c | 2 +- board/eltec/bab7xx/flash.c | 8 +++--- board/eltec/elppc/flash.c | 8 +++--- board/eltec/mhpc/flash.c | 8 +++--- board/emk/common/flash.c | 18 +++++++------- board/ep7312/flash.c | 8 +++--- board/ep8260/flash.c | 8 +++--- board/esd/common/flash.c | 8 +++--- board/esd/cpci5200/strataflash.c | 4 +- board/esd/pf5200/flash.c | 18 +++++++------- board/esteem192e/flash.c | 18 +++++++------- board/etin/debris/flash.c | 16 ++++++------ board/etx094/flash.c | 12 +++++----- board/evb4510/flash.c | 4 +- board/evb64260/flash.c | 8 +++--- board/evb64260/intel_flash.c | 18 ++++++-------- board/fads/flash.c | 8 +++--- board/flagadm/flash.c | 22 +++++++++--------- board/freescale/m5253demo/flash.c | 14 ++++++------ board/freescale/mpc8260ads/flash.c | 12 +++++----- board/freescale/mpc8266ads/flash.c | 12 +++++----- board/funkwerk/vovpn-gw/flash.c | 16 ++++++------ board/g2000/strataflash.c | 4 +- board/gcplus/flash.c | 8 +++--- board/gen860t/flash.c | 16 ++++++------ board/genietv/flash.c | 8 +++--- board/gw8260/flash.c | 8 +++--- board/hermes/flash.c | 8 +++--- board/hidden_dragon/flash.c | 8 +++--- board/hymod/flash.c | 10 ++++---- board/icecube/flash.c | 18 +++++++------- board/icu862/flash.c | 8 +++--- board/idmr/flash.c | 8 +++--- board/impa7/flash.c | 8 +++--- board/incaip/flash.c | 22 +++++++++--------- board/innokom/flash.c | 8 +++--- board/ip860/flash.c | 8 +++--- board/iphase4539/flash.c | 8 +++--- board/ivm/flash.c | 8 +++--- board/ixdp425/flash.c | 8 +++--- board/jse/flash.c | 8 +++--- board/kup/common/flash.c | 12 +++++----- board/lantec/flash.c | 8 +++--- board/lart/flash.c | 8 +++--- board/linkstation/avr.c | 40 +++++++++++++++++----------------- board/lpd7a40x/flash.c | 8 +++--- board/lubbock/flash.c | 8 +++--- board/lwmon/flash.c | 10 ++++---- board/mbx8xx/flash.c | 8 +++--- board/modnet50/flash.c | 12 +++++----- board/mpl/common/flash.c | 16 ++++++------ board/mpl/mip405/mip405.c | 11 ++++----- board/mpl/vcma9/flash.c | 8 +++--- board/musenki/flash.c | 8 +++--- board/mvblue/flash.c | 8 +++--- board/mx1ads/syncflash.c | 2 +- board/mx1fs2/flash.c | 16 ++++++------ board/netphone/flash.c | 8 +++--- board/netta/flash.c | 8 +++--- board/netta2/flash.c | 8 +++--- board/netvia/flash.c | 8 +++--- board/ns9750dev/flash.c | 8 +++--- board/nx823/flash.c | 8 +++--- board/o2dnt/flash.c | 26 +++++++++++----------- board/oxc/flash.c | 8 +++--- board/pcippc2/flash.c | 8 +++--- board/pcs440ep/flash.c | 12 +++++----- board/pleb2/flash.c | 12 +++++----- board/pm520/flash.c | 22 +++++++++--------- board/pm826/flash.c | 8 +++--- board/pm828/flash.c | 8 +++--- board/ppmc7xx/flash.c | 8 +++--- board/ppmc8260/strataflash.c | 4 +- board/prodrive/common/flash.c | 12 +++++----- board/psyent/common/AMDLV065D.c | 8 +++--- board/r360mpi/flash.c | 8 +++--- board/rbc823/flash.c | 8 +++--- board/rmu/flash.c | 8 +++--- board/rpxsuper/flash.c | 8 +++--- board/rsdproto/flash.c | 8 +++--- board/sacsng/flash.c | 8 +++--- board/samsung/smdk2400/flash.c | 8 +++--- board/sandburst/common/flash.c | 8 +++--- board/sandpoint/flash.c | 8 +++--- board/sbc2410x/flash.c | 8 +++--- board/sbc405/strataflash.c | 4 +- board/sbc8240/flash.c | 8 +++--- board/sbc8260/flash.c | 8 +++--- board/scb9328/flash.c | 4 +- board/shannon/flash.c | 8 +++--- board/siemens/IAD210/flash.c | 8 +++--- board/siemens/SCM/flash.c | 8 +++--- board/siemens/SMN42/flash.c | 8 +++--- board/sixnet/flash.c | 12 +++++----- board/snmc/qs850/flash.c | 8 +++--- board/snmc/qs860t/flash.c | 18 +++++++------- board/stx/stxgp3/flash.c | 12 +++++----- board/svm_sc8xx/flash.c | 16 ++++++------ board/tb0229/flash.c | 18 +++++++------- board/ti/omap1610inn/flash.c | 8 +++--- board/ti/omap730p2/flash.c | 8 +++--- board/tqc/tqm5200/cam5200_flash.c | 16 ++++++------ board/trab/cmd_trab.c | 6 ++-- board/trab/flash.c | 8 +++--- board/utx8245/flash.c | 8 +++--- board/v37/flash.c | 12 +++++----- board/w7o/flash.c | 20 ++++++++-------- board/w7o/fpga.c | 10 ++++---- board/westel/amx860/flash.c | 8 +++--- board/xaeniax/flash.c | 8 +++--- board/xm250/flash.c | 16 ++++++------ board/zeus/zeus.c | 4 +- board/zylonite/flash.c | 8 +++--- 152 files changed, 781 insertions(+), 787 deletions(-)
diff --git a/board/BuS/EB+MCF-EV123/flash.c b/board/BuS/EB+MCF-EV123/flash.c index 8b7f957..e2fb44b 100644 --- a/board/BuS/EB+MCF-EV123/flash.c +++ b/board/BuS/EB+MCF-EV123/flash.c @@ -172,13 +172,13 @@ int amd_flash_erase_sector(flash_info_t * info, int sector)
/* wait until flash is ready */ state = 0; - start = get_timer(0); + start = time_now_ms();
do { result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; state = ERR_TIMOUT; } @@ -297,7 +297,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait until flash is ready */ state = 0; @@ -305,7 +305,7 @@ volatile static int amd_write_word (flash_info_t * info, ulong dest, u16 data) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { state = ERR_TIMOUT; } if (!state && ((result & BIT_RDY_MASK) == (data & BIT_RDY_MASK))) diff --git a/board/LEOX/elpt860/flash.c b/board/LEOX/elpt860/flash.c index 9a75aad..f8a86e6 100644 --- a/board/LEOX/elpt860/flash.c +++ b/board/LEOX/elpt860/flash.c @@ -378,12 +378,12 @@ flash_erase (flash_info_t *info, if ( l_sect < 0 ) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (volatile unsigned char *)(info->start[l_sect]); while ( (addr[0] & 0x80) != 0x80 ) { - if ( (now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT ) + if ( (now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT ) { printf ("Timeout\n"); return ( 1 ); @@ -553,10 +553,10 @@ write_word (flash_info_t *info, enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ( (*((vu_long *)dest) & 0x00800080) != (data & 0x00800080) ) { - if ( get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT ) + if ( time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT ) { return (1); } @@ -599,10 +599,10 @@ write_byte (flash_info_t *info, enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ( (*((volatile unsigned char *)dest) & 0x80) != (data & 0x80) ) { - if ( get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT ) + if ( time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT ) { return (1); } diff --git a/board/Marvell/common/flash.c b/board/Marvell/common/flash.c index 21eae0e..99acc1b 100644 --- a/board/Marvell/common/flash.c +++ b/board/Marvell/common/flash.c @@ -604,7 +604,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) mask = CHIP_STAT_RDY | (CHIP_STAT_RDY << 16); /* init. the timeout counter */ - start = get_timer (0); + start = time_now_ms(); /* keep looping while the flash is not ready */ /* exit the loop by timing out or the flash */ /* becomes ready again */ @@ -615,7 +615,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) start[sect] & mask) != mask) { /* has the timeout limit been reached? */ - if (get_timer (start) + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { @@ -771,12 +771,12 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (volatile unsigned char *) (info->start[l_sect]); /* broken for 2x16: TODO */ while ((addr[0] & 0x80) != 0x80) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -940,7 +940,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) flash_cmd (info->portwidth, addr, 0, CHIP_CMD_RD_STAT); /* init. the timeout counter */ - start = get_timer (0); + start = time_now_ms(); /* keep looping while the flash is not ready */ /* exit the loop by timing out or the flash */ /* becomes ready again */ @@ -955,7 +955,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) /* while (addr[0] & mask) != mask) */ { /* has the timeout limit been reached? */ - if (get_timer (start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { /* timeout limit reached */ printf ("Time out limit reached programming address %08lx with data %08lx\n", dest, data); @@ -1062,9 +1062,9 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *) dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/Marvell/common/intel_flash.c b/board/Marvell/common/intel_flash.c index 42b3ee1..d25c270 100644 --- a/board/Marvell/common/intel_flash.c +++ b/board/Marvell/common/intel_flash.c @@ -150,9 +150,9 @@ int write_word_intel (bank_addr_t addr, bank_word_t value) retval = 0;
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); do { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { retval = 1; goto done; } @@ -208,13 +208,12 @@ int flash_erase_intel (flash_info_t * info, int s_first, int s_last) printf ("- Warning: %d protected sector%s will not be erased!\n", prot, (prot > 1 ? "s" : "")); }
- start = get_timer (0); - last = 0; + start = time_ms_now(); + last = start; haderr = 0;
for (sect = s_first; sect <= s_last; sect++) { if (info->protect[sect] == 0) { /* not protected */ - ulong estart; int sectdone;
bank_erase_init (info, sect); @@ -222,21 +221,19 @@ int flash_erase_intel (flash_info_t * info, int s_first, int s_last) /* wait at least 80us - let's wait 1 ms */ udelay (1000);
- estart = get_timer (start); + start = time_now_ms();
do { - now = get_timer (start); - - if (now - estart > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout (sect %d)\n", sect); haderr = 1; break; } #ifndef FLASH_DEBUG /* show that we're waiting */ - if ((now - last) > 1000) { /* every second */ + if (time_since_ms(last) > 1000) { /* every second */ putc ('.'); - last = now; + last = time_now_ms(); } #endif
diff --git a/board/RPXClassic/flash.c b/board/RPXClassic/flash.c index f07d960..1fd2073 100644 --- a/board/RPXClassic/flash.c +++ b/board/RPXClassic/flash.c @@ -309,11 +309,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long *)(info->start[l_sect]); while ((addr[0] & 0x80808080) != 0x80808080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -434,9 +434,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/RPXlite/flash.c b/board/RPXlite/flash.c index 788fcdf..4032e11 100644 --- a/board/RPXlite/flash.c +++ b/board/RPXlite/flash.c @@ -386,11 +386,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long *)(info->start[l_sect]); while ((addr[0] & 0x80808080) != 0x80808080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -511,9 +511,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/RPXlite_dw/flash.c b/board/RPXlite_dw/flash.c index 91788af..9914a36 100644 --- a/board/RPXlite_dw/flash.c +++ b/board/RPXlite_dw/flash.c @@ -356,11 +356,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long *)(info->start[l_sect]); while ((addr[0] & 0x80808080) != 0x80808080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -480,9 +480,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/RRvision/flash.c b/board/RRvision/flash.c index fdbe928..2907d1f 100644 --- a/board/RRvision/flash.c +++ b/board/RRvision/flash.c @@ -384,11 +384,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long*)(info->start[l_sect]); while ((addr[0] & 0x00800080) != 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { puts ("Timeout\n"); return 1; } @@ -509,9 +509,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/a3000/flash.c b/board/a3000/flash.c index b671ce7..7320c8d 100644 --- a/board/a3000/flash.c +++ b/board/a3000/flash.c @@ -332,7 +332,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last; sect++) { @@ -356,7 +356,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while (((status = BS(*addr)) & BYTEME(0x00800080)) != BYTEME(0x00800080)) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = BS(0xB0); /* suspend erase */ *addr = BS(0xFF); /* reset to read mode */ @@ -436,10 +436,10 @@ static int write_data (flash_info_t *info, uchar *dest, uchar data) enable_interrupts(); }
- start = get_timer (0); + start = time_now_ms();
while (((status = BS(*addr)) & BYTEME(0x00800080)) != BYTEME(0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = BS(0xFF); /* restore read mode */ return 1; } diff --git a/board/alaska/flash.c b/board/alaska/flash.c index aed3b6f..90f63c3 100644 --- a/board/alaska/flash.c +++ b/board/alaska/flash.c @@ -359,9 +359,9 @@ static unsigned char intel_sector_protected (flash_info_t *info, ushort sector) addr = (FPWV *) info->start[sector]; *addr = (FPW) INTEL_STATUS;
- start = get_timer (0); + start = time_now_ms(); while ((*addr & (FPW) INTEL_FINISHED) != (FPW) INTEL_FINISHED) { - if (get_timer (start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = (FPW) INTEL_RESET; /* restore read mode */ printf("WSM busy too long, can't get prot status\n"); return 1; @@ -443,7 +443,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start;
/* Disable interrupts which might cause a timeout here */ @@ -458,7 +458,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer (0); + start = time_now_ms();
if (intel) { *addr = (FPW) 0x00500050; /* clear status register */ @@ -479,7 +479,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer (start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); if (intel) { *addr = (FPW) 0x00B000B0; /* suspend erase */ @@ -680,11 +680,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer (0); + start = time_now_ms();
/* wait while polling the status register */ while ((*addr & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } @@ -724,11 +724,11 @@ static int write_data_block (flash_info_t * info, ulong src, ulong dest) *dstaddr = (FPW) 0x00e800e8; /* write block setup */
/* arm simple, non interrupt dependent timer */ - start = get_timer (0); + start = time_now_ms();
/* wait while polling the status register */ while ((*dstaddr & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dstaddr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } @@ -742,11 +742,11 @@ static int write_data_block (flash_info_t * info, ulong src, ulong dest) *dstaddr = (FPW) 0x00d000d0; /* write 32 to buffer */
/* arm simple, non interrupt dependent timer */ - start = get_timer (0); + start = time_now_ms();
/* wait while polling the status register */ while ((*dstaddr & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dstaddr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } @@ -794,12 +794,12 @@ static int write_word_amd (flash_info_t * info, FPWV * dest, FPW data) if (flag) enable_interrupts ();
- start = get_timer (0); + start = time_now_ms();
/* data polling for D7 */ while (res == 0 && (*dest & (FPW) 0x00800080) != (data & (FPW) 0x00800080)) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00F000F0; /* reset bank */ res = 1; } @@ -853,10 +853,10 @@ int flash_real_protect (flash_info_t * info, long sector, int prot) *addr = INTEL_CONFIRM; /* clear */ }
- start = get_timer (0); + start = time_now_ms();
while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer (start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf ("Flash lock bit operation timed out\n"); rc = 1; break; @@ -903,13 +903,13 @@ int flash_real_protect (flash_info_t * info, long sector, int prot) info = &flash_info[bank]; for (i = 0; i < info->sector_count; i++) { if (info->protect[i]) { - start = get_timer (0); + start = time_now_ms(); addr = (FPWV *) (info->start[i]); *addr = INTEL_LOCKBIT; /* Sector lock bit */ *addr = INTEL_PROTECT; /* set */ while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer (start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf ("Flash lock bit operation timed out\n"); rc = 1; diff --git a/board/altera/common/AMDLV065D.c b/board/altera/common/AMDLV065D.c index 7a1b4d3..416a4eb 100644 --- a/board/altera/common/AMDLV065D.c +++ b/board/altera/common/AMDLV065D.c @@ -131,11 +131,11 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* Now just wait for 0xff & provide some user * feedback while we wait. */ - start = get_timer (0); + start = time_now_ms(); while ( readb (addr2) != 0xff) { udelay (1000 * 1000); putc ('.'); - if (get_timer (start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("timeout\n"); return 1; } @@ -175,9 +175,9 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt) writeb (b, dst);
/* Verify write */ - start = get_timer (0); + start = time_now_ms(); while (readb (dst) != b) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return 1; } } diff --git a/board/altera/common/flash.c b/board/altera/common/flash.c index 83bb7c2..53a713a 100644 --- a/board/altera/common/flash.c +++ b/board/altera/common/flash.c @@ -121,14 +121,14 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr2 = 0x30; /* Now just wait for 0xff & provide some user * feedback while we wait. Here we have to grant - * timer interrupts. Otherwise get_timer() can't + * timer interrupts. Otherwise time_*() can't * work right. */ ipri(oldpri); - start = get_timer (0); + start = time_now_ms(); while (*addr2 != 0xff) { udelay (1000 * 1000); putc ('.'); - if (get_timer (start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("timeout\n"); return 1; } @@ -179,9 +179,9 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt) *dst = b;
/* Verify write */ - start = get_timer (0); + start = time_now_ms(); while (*dst != b) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { ipri (oldpri); return 1; } diff --git a/board/amcc/common/flash.c b/board/amcc/common/flash.c index 8f23375..ba2df44 100644 --- a/board/amcc/common/flash.c +++ b/board/amcc/common/flash.c @@ -359,11 +359,11 @@ static int wait_for_DQ7_1(flash_info_t * info, int sect) volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]);
- start = get_timer(0); + start = time_now_ms(); last = start; while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return -1; } @@ -603,11 +603,11 @@ static int write_word(flash_info_t * info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080)) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } @@ -804,11 +804,11 @@ static int wait_for_DQ7_2(flash_info_t * info, int sect) volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]);
- start = get_timer(0); + start = time_now_ms(); last = start; while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return -1; } @@ -941,11 +941,11 @@ static int write_word_2(flash_info_t * info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080)) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/amcc/taihu/flash.c b/board/amcc/taihu/flash.c index e9fbbb1..15651a9 100644 --- a/board/amcc/taihu/flash.c +++ b/board/amcc/taihu/flash.c @@ -473,11 +473,11 @@ static int wait_for_DQ7_1(flash_info_t * info, int sect) volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]);
- start = get_timer(0); + start = time_now_ms(); last = start; while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return -1; } @@ -720,11 +720,11 @@ static int write_word(flash_info_t * info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080)) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return 1; } } @@ -932,11 +932,11 @@ static int wait_for_DQ7_2(flash_info_t * info, int sect) volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]);
- start = get_timer(0); + start = time_now_ms(); last = start; while (((CONFIG_SYS_FLASH_WORD_SIZE)addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x80808080) != (CONFIG_SYS_FLASH_WORD_SIZE) 0x80808080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return -1; } @@ -1069,11 +1069,11 @@ static int write_word_2(flash_info_t * info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x80808080) != (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x80808080)) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return 1; } } diff --git a/board/amcc/yucca/flash.c b/board/amcc/yucca/flash.c index 20b6af9..f7fbccb 100644 --- a/board/amcc/yucca/flash.c +++ b/board/amcc/yucca/flash.c @@ -385,11 +385,11 @@ static int wait_for_DQ7_1(flash_info_t * info, int sect) volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]);
- start = get_timer(0); + start = time_now_ms(); last = start; while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return -1; } @@ -620,11 +620,11 @@ static int write_word(flash_info_t * info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080)) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); } } @@ -810,11 +810,11 @@ static int wait_for_DQ7_2(flash_info_t * info, int sect) volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]);
- start = get_timer(0); + start = time_now_ms(); last = start; while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return -1; } @@ -942,11 +942,11 @@ static int write_word_2(flash_info_t * info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080)) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); } } diff --git a/board/amirix/ap1000/flash.c b/board/amirix/ap1000/flash.c index 1e742e5..588cec6 100644 --- a/board/amirix/ap1000/flash.c +++ b/board/amirix/ap1000/flash.c @@ -481,9 +481,9 @@ static int flash_status_check (flash_info_t * info, ulong sector, ulong tout, ulong start;
/* Wait for command completion */ - start = get_timer (0); + start = time_now_ms(); while (!flash_isset (info, sector, 0, FLASH_STATUS_DONE)) { - if (get_timer (start) > info->erase_blk_tout) { + if (time_since_ms(start) > info->erase_blk_tout) { printf ("Flash %s timeout at address %lx\n", prompt, info->start[sector]); flash_write_cmd (info, sector, 0, FLASH_CMD_RESET); diff --git a/board/armadillo/flash.c b/board/armadillo/flash.c index cf7d7f6..5219a6e 100644 --- a/board/armadillo/flash.c +++ b/board/armadillo/flash.c @@ -193,7 +193,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last && !ctrlc (); sect++) { /* ARM simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */
@@ -252,7 +252,7 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) flag = disable_interrupts ();
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
base = dest & 0xF0000000; FL_WORD (base + (0x555 << 1)) = 0xAA; diff --git a/board/astro/mcf5373l/mcf5373l.c b/board/astro/mcf5373l/mcf5373l.c index 3c09a21..3829702 100644 --- a/board/astro/mcf5373l/mcf5373l.c +++ b/board/astro/mcf5373l/mcf5373l.c @@ -160,8 +160,8 @@ void astro_put_char(char ch) * Wait for last character to go. Timeout of 6ms should * be enough for our lowest baud rate of 2400. */ - timer = get_timer(0); - while (get_timer(timer) < 6) { + timer = time_now_ms(); + while (time_since_ms(timer) < 6) { if (readb(&uart->usr) & UART_USR_TXRDY) break; } diff --git a/board/atc/flash.c b/board/atc/flash.c index fd76723..d6b8c3e 100644 --- a/board/atc/flash.c +++ b/board/atc/flash.c @@ -434,7 +434,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- last = get_timer(0); + last = time_now_ms();
/* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last && rcode == 0; sect++) { @@ -468,7 +468,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (flag) enable_interrupts();
- start = get_timer(0); + start = time_now_ms();
/* wait at least 50us for AMD, 80us for Intel. * Let's wait 1 ms. @@ -476,7 +476,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while ((*addr & (FPW)0x00800080) != (FPW)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n");
if (intel) { @@ -490,16 +490,16 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) }
/* show that we're waiting */ - if ((get_timer(last)) > CONFIG_SYS_HZ) {/* every second */ + if ((time_since_ms(last)) > CONFIG_SYS_HZ) {/* every second */ putc ('.'); - last = get_timer(0); + last = time_now_ms(); } }
/* show that we're waiting */ - if ((get_timer(last)) > CONFIG_SYS_HZ) { /* every second */ + if ((time_since_ms(last)) > CONFIG_SYS_HZ) { /* every second */ putc ('.'); - last = get_timer(0); + last = time_now_ms(); }
flash_reset(info); /* reset to read mode */ @@ -597,11 +597,11 @@ static int write_word_amd (flash_info_t *info, FPWV *dest, FPW data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
/* data polling for D7 */ while (res == 0 && (*dest & (FPW)0x00800080) != (data & (FPW)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW)0x00F000F0; /* reset bank */ res = 1; } @@ -644,10 +644,10 @@ static int write_word_intel (flash_info_t *info, FPWV *dest, FPW data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
while (res == 0 && (*dest & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW)0x00B000B0; /* Suspend program */ res = 1; } diff --git a/board/atmel/at91rm9200dk/flash.c b/board/atmel/at91rm9200dk/flash.c index be22743..ff7f20c 100644 --- a/board/atmel/at91rm9200dk/flash.c +++ b/board/atmel/at91rm9200dk/flash.c @@ -326,7 +326,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = (volatile u16 *) (info->start[sect]); @@ -346,7 +346,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -427,7 +427,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait until flash is ready */ chip1 = 0; @@ -435,7 +435,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; } diff --git a/board/atmel/atstk1000/flash.c b/board/atmel/atstk1000/flash.c index 0ba06dd..0ecea9c 100644 --- a/board/atmel/atstk1000/flash.c +++ b/board/atmel/atstk1000/flash.c @@ -108,7 +108,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
flags = disable_interrupts();
- start_time = get_timer(0); + start_time = time_now_ms();
/* Unlock sector */ writew(0xaa, fb + 0x555); diff --git a/board/bmw/flash.c b/board/bmw/flash.c index 57ffe08..12eceaa 100644 --- a/board/bmw/flash.c +++ b/board/bmw/flash.c @@ -620,14 +620,14 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (FLASH_WORD_SIZE *) (info->start[0] + ((info->start[l_sect] - info-> start[0]) << sh8b)); while ((addr[0] & (FLASH_WORD_SIZE) 0x00800080) != (FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -763,10 +763,10 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i << sh8b] & (FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (FLASH_WORD_SIZE) 0x00800080)) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/c2mon/flash.c b/board/c2mon/flash.c index d33cb6c..e9dda80 100644 --- a/board/c2mon/flash.c +++ b/board/c2mon/flash.c @@ -432,11 +432,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long*)(info->start[l_sect]); while ((addr[0] & 0x00800080) != 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -557,9 +557,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/cerf250/flash.c b/board/cerf250/flash.c index e1e7807..0055dcc 100644 --- a/board/cerf250/flash.c +++ b/board/cerf250/flash.c @@ -266,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -404,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/cm4008/flash.c b/board/cm4008/flash.c index d6fd519..459721e 100644 --- a/board/cm4008/flash.c +++ b/board/cm4008/flash.c @@ -251,7 +251,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
addr = (volatile unsigned char *) (info->start[sect]); *addr = 0x50; /* clear status register */ @@ -259,7 +259,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while (((status = *addr) & 0x80) != 0x80) { - if (get_timer(start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0xB0; /* suspend erase */ @@ -386,11 +386,11 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & 0x80) != 0x80) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0xFF; /* restore read mode */ return (1); } diff --git a/board/cm41xx/flash.c b/board/cm41xx/flash.c index d6fd519..459721e 100644 --- a/board/cm41xx/flash.c +++ b/board/cm41xx/flash.c @@ -251,7 +251,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
addr = (volatile unsigned char *) (info->start[sect]); *addr = 0x50; /* clear status register */ @@ -259,7 +259,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while (((status = *addr) & 0x80) != 0x80) { - if (get_timer(start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0xB0; /* suspend erase */ @@ -386,11 +386,11 @@ static int write_data (flash_info_t * info, ulong dest, unsigned char data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & 0x80) != 0x80) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0xFF; /* restore read mode */ return (1); } diff --git a/board/cmc_pu2/flash.c b/board/cmc_pu2/flash.c index d10faab..3209266 100644 --- a/board/cmc_pu2/flash.c +++ b/board/cmc_pu2/flash.c @@ -335,11 +335,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer(0); + start = time_now_ms(); last = 0; addr = (vu_short *)(info->start[l_sect]); while ((addr[0] & 0x0080) != 0x0080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -456,11 +456,11 @@ static int write_word_amd (flash_info_t *info, vu_short *dest, ushort data) if (flag) enable_interrupts();
- start = get_timer(0); + start = time_now_ms();
/* data polling for D7 */ while ((*dest & 0x0080) != (data & 0x0080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = 0x00F0; /* reset bank */ return (1); } diff --git a/board/cmi/flash.c b/board/cmi/flash.c index 630c330..cda5fda 100644 --- a/board/cmi/flash.c +++ b/board/cmi/flash.c @@ -317,7 +317,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start;
/* Start erase on unprotected sectors */ @@ -345,7 +345,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while (((status = *addr) & FLASH_STATUS_DONE) != FLASH_STATUS_DONE) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Flash erase timeout at address %lx\n", info->start[sect]); *addr = FLASH_CMD_SUSPEND_ERASE; *addr = FLASH_CMD_RESET; @@ -469,11 +469,11 @@ static int write_short (flash_info_t *info, ulong dest, ushort data) }
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms();
/* wait for error or finish */ while(!(addr[0] & FLASH_STATUS_DONE)){ - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { addr[0] = FLASH_CMD_RESET; return (1); } @@ -502,9 +502,9 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) }
/* wait for error or finish */ - start = get_timer (0); + start = time_now_ms(); while(!(addr[0] & FLASH_STATUS_DONE)){ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Flash protect timeout at address %lx\n", info->start[sector]); addr[0] = FLASH_CMD_RESET; return (1); diff --git a/board/cobra5272/flash.c b/board/cobra5272/flash.c index e8f02eb..b25da1c 100644 --- a/board/cobra5272/flash.c +++ b/board/cobra5272/flash.c @@ -191,7 +191,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = @@ -212,7 +212,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -293,7 +293,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait until flash is ready */ chip1 = 0; @@ -301,7 +301,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; } diff --git a/board/cogent/flash.c b/board/cogent/flash.c index e6c85b6..21660aa 100644 --- a/board/cogent/flash.c +++ b/board/cogent/flash.c @@ -262,9 +262,9 @@ c302f_write_word(c302f_addr_t addr, c302f_word_t value) retval = 0;
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); do { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { retval = 1; goto done; } @@ -453,7 +453,7 @@ flash_erase(flash_info_t *info, int s_first, int s_last) prot, (prot > 1 ? "s" : "")); }
- start = get_timer (0); + start = time_now_ms(); last = 0; haderr = 0;
@@ -467,10 +467,10 @@ flash_erase(flash_info_t *info, int s_first, int s_last) /* wait at least 80us - let's wait 1 ms */ udelay (1000);
- estart = get_timer(start); + estart = time_since_ms(start);
do { - now = get_timer(start); + now = time_since_ms(start);
if (now - estart > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout (sect %d)\n", sect); @@ -559,7 +559,7 @@ write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt) /* * handle word aligned part */ - start = get_timer (0); + start = time_now_ms(); last = 0; while (cnt >= 4) { data = 0; @@ -573,7 +573,7 @@ write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt) cnt -= 4;
/* show that we're waiting */ - now = get_timer(start); + now = time_since_ms(start); if ((now - last) > 1000) { /* every second */ putc ('.'); last = now; diff --git a/board/cpc45/flash.c b/board/cpc45/flash.c index 8fe7584..5847f95 100644 --- a/board/cpc45/flash.c +++ b/board/cpc45/flash.c @@ -276,7 +276,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last; sect++) { @@ -308,7 +308,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
while (((addr[0] & 0x00800080) != 0x00800080) || ((addr[1] & 0x00800080) != 0x00800080)) { - if ((now = get_timer (start)) > + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); addr[0] = 0x00B000B0; /* suspend erase */ @@ -482,11 +482,11 @@ static int write_data (flash_info_t * info, ulong dest, ulong * data) if (flag) enable_interrupts ();
- start = get_timer (0); + start = time_now_ms();
while (((addr[0] & 0x00800080) != 0x00800080) || ((addr[1] & 0x00800080) != 0x00800080)) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { addr[0] = 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/cpu86/flash.c b/board/cpu86/flash.c index 8135780..29cd5c6 100644 --- a/board/cpu86/flash.c +++ b/board/cpu86/flash.c @@ -378,11 +378,11 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto AMD_DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_char *)(info->start[l_sect]); while ((addr[0] & 0x80) != 0x80) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -408,7 +408,7 @@ AMD_DONE: volatile ulong *addr = (volatile unsigned long *) info->start[sect];
- start = get_timer (0); + start = time_now_ms(); last = start; if (info->protect[sect] == 0) { /* Disable interrupts which might cause a timeout here @@ -434,7 +434,7 @@ AMD_DONE: last = start; while ((addr[0] & 0x00800080) != 0x00800080 || (addr[1] & 0x00800080) != 0x00800080) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout (erase suspended!)\n"); /* Suspend erase */ @@ -547,9 +547,9 @@ static int write_word (flash_info_t * info, volatile unsigned long *addr, if (flag) enable_interrupts ();
- start = get_timer (0); + start = time_now_ms(); while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { /* Suspend program */ *addr = 0x00B000B0; @@ -602,9 +602,9 @@ static int write_byte (flash_info_t *info, ulong dest, uchar data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_char *)dest) & 0x80) != (data & 0x80)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/cpu87/flash.c b/board/cpu87/flash.c index c35757b..b315dfb 100644 --- a/board/cpu87/flash.c +++ b/board/cpu87/flash.c @@ -387,11 +387,11 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto AMD_DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_char *)(info->start[l_sect]); while ((addr[0] & 0x80) != 0x80) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -417,7 +417,7 @@ AMD_DONE: volatile ulong *addr = (volatile unsigned long *) info->start[sect];
- start = get_timer (0); + start = time_now_ms(); last = start; if (info->protect[sect] == 0) { /* Disable interrupts which might cause a timeout here @@ -443,7 +443,7 @@ AMD_DONE: last = start; while ((addr[0] & 0x00800080) != 0x00800080 || (addr[1] & 0x00800080) != 0x00800080) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout (erase suspended!)\n"); /* Suspend erase */ @@ -556,9 +556,9 @@ static int write_word (flash_info_t * info, volatile unsigned long *addr, if (flag) enable_interrupts ();
- start = get_timer (0); + start = time_now_ms(); while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { /* Suspend program */ *addr = 0x00B000B0; @@ -611,9 +611,9 @@ static int write_byte (flash_info_t *info, ulong dest, uchar data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_char *)dest) & 0x80) != (data & 0x80)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/cradle/flash.c b/board/cradle/flash.c index 1601782..bb188f7 100644 --- a/board/cradle/flash.c +++ b/board/cradle/flash.c @@ -174,7 +174,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -183,7 +183,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while ((*addr & 0x80) != 0x80) { - if (get_timer(start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0xB0; /* suspend erase */ *addr = 0xFF; /* reset to read mode */ @@ -248,11 +248,11 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((val = *addr) & 0x80) != 0x80) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0xB0; diff --git a/board/cray/L1/flash.c b/board/cray/L1/flash.c index a3d893e..8209bb1 100644 --- a/board/cray/L1/flash.c +++ b/board/cray/L1/flash.c @@ -250,10 +250,10 @@ int wait_for_DQ7(flash_info_t *info, int sect) ulong start, now, last; volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[sect]);
- start = get_timer (0); + start = time_now_ms(); last = start; while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return -1; } @@ -454,10 +454,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i] & (FLASH_WORD_SIZE)0x00800080) != (data2[i] & (FLASH_WORD_SIZE)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/csb226/flash.c b/board/csb226/flash.c index e103470..7a8e576 100644 --- a/board/csb226/flash.c +++ b/board/csb226/flash.c @@ -176,7 +176,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ u32 * volatile addr = (u32 * volatile)(info->start[sect]); @@ -190,7 +190,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) *addr = 0x00D000D0; /* erase confirm */
while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B000B0; /* suspend erase*/ *addr = 0x00FF00FF; /* read mode */ rc = ERR_TIMOUT; @@ -249,11 +249,11 @@ static int write_long (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while(((val = *addr) & 0x00800080) != 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0x00B000B0; diff --git a/board/cu824/flash.c b/board/cu824/flash.c index bd0f8d3..22e7d0d 100644 --- a/board/cu824/flash.c +++ b/board/cu824/flash.c @@ -235,7 +235,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last; sect++) { @@ -267,7 +267,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
while (((addr[0] & 0x00800080) != 0x00800080) || ((addr[1] & 0x00800080) != 0x00800080) ) { - if ((now=get_timer(start)) > + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); addr[0] = 0x00B000B0; /* suspend erase */ @@ -448,11 +448,11 @@ static int write_data (flash_info_t *info, ulong dest, ulong *data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
while (((addr[0] & 0x00800080) != 0x00800080) || ((addr[1] & 0x00800080) != 0x00800080) ) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { addr[0] = 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/dave/common/flash.c b/board/dave/common/flash.c index 29caf47..1d3efc8 100644 --- a/board/dave/common/flash.c +++ b/board/dave/common/flash.c @@ -535,11 +535,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[l_sect]); while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -691,10 +691,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/dnp1110/flash.c b/board/dnp1110/flash.c index 53f89ee..8b9fe78 100644 --- a/board/dnp1110/flash.c +++ b/board/dnp1110/flash.c @@ -257,14 +257,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
*addr = (FPW)0x00500050; /* clear status register */ *addr = (FPW)0x00200020; /* erase setup */ *addr = (FPW)0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW)0x00B000B0; /* suspend erase */ *addr = (FPW)0x00FF00FF; /* reset to read mode */ @@ -396,11 +396,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) { - if (start = get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (start = time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW)0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/earthlcd/favr-32-ezkit/flash.c b/board/earthlcd/favr-32-ezkit/flash.c index 0a26146..5cb5bf7 100644 --- a/board/earthlcd/favr-32-ezkit/flash.c +++ b/board/earthlcd/favr-32-ezkit/flash.c @@ -106,7 +106,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
flags = disable_interrupts();
- start_time = get_timer(0); + start_time = time_now_ms();
/* Unlock sector */ writew(0xaa, fb + 0x555); diff --git a/board/eltec/bab7xx/flash.c b/board/eltec/bab7xx/flash.c index 21ae098..89b4c0d 100644 --- a/board/eltec/bab7xx/flash.c +++ b/board/eltec/bab7xx/flash.c @@ -366,11 +366,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (FLASH_WORD_SIZE *)(info->start[l_sect]); while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -497,10 +497,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i] & (FLASH_WORD_SIZE)0x00800080) != (data2[i] & (FLASH_WORD_SIZE)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/eltec/elppc/flash.c b/board/eltec/elppc/flash.c index 21ae098..89b4c0d 100644 --- a/board/eltec/elppc/flash.c +++ b/board/eltec/elppc/flash.c @@ -366,11 +366,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (FLASH_WORD_SIZE *)(info->start[l_sect]); while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -497,10 +497,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i] & (FLASH_WORD_SIZE)0x00800080) != (data2[i] & (FLASH_WORD_SIZE)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/eltec/mhpc/flash.c b/board/eltec/mhpc/flash.c index 2fbdb27..8d1e3c9 100644 --- a/board/eltec/mhpc/flash.c +++ b/board/eltec/mhpc/flash.c @@ -254,7 +254,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last; sect++) { @@ -277,7 +277,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while (((status = SWAP(*addr)) & (FPW)0x00800080) != (FPW)0x00800080) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW)0xB000B000; /* suspend erase */ *addr = (FPW)0xFF00FF00; /* reset to read mode */ @@ -416,10 +416,10 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
while (((status = SWAP(*addr)) & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW)0xFF00FF00; /* restore read mode */ return (1); } diff --git a/board/emk/common/flash.c b/board/emk/common/flash.c index 8579cfa..3ff2f9c 100644 --- a/board/emk/common/flash.c +++ b/board/emk/common/flash.c @@ -417,7 +417,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- last = get_timer(0); + last = time_now_ms();
/* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last && rcode == 0; sect++) { @@ -451,7 +451,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (flag) enable_interrupts();
- start = get_timer(0); + start = time_now_ms();
/* wait at least 50us for AMD, 80us for Intel. * Let's wait 1 ms. @@ -459,7 +459,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while ((*addr & (FPW)0x00800080) != (FPW)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n");
if (intel) { @@ -473,16 +473,16 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) }
/* show that we're waiting */ - if ((get_timer(last)) > CONFIG_SYS_HZ) {/* every second */ + if ((time_since_ms(last)) > CONFIG_SYS_HZ) {/* every second */ putc ('.'); - last = get_timer(0); + last = time_now_ms(); } }
/* show that we're waiting */ - if ((get_timer(last)) > CONFIG_SYS_HZ) { /* every second */ + if ((time_since_ms(last)) > CONFIG_SYS_HZ) { /* every second */ putc ('.'); - last = get_timer(0); + last = time_now_ms(); }
flash_reset(info); /* reset to read mode */ @@ -577,11 +577,11 @@ static int write_word_amd (flash_info_t *info, FPWV *dest, FPW data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
/* data polling for D7 */ while (res == 0 && (*dest & (FPW)0x00800080) != (data & (FPW)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW)0x00F000F0; /* reset bank */ res = 1; } diff --git a/board/ep7312/flash.c b/board/ep7312/flash.c index 2ed9c9a..9dec9b7 100644 --- a/board/ep7312/flash.c +++ b/board/ep7312/flash.c @@ -157,7 +157,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -166,7 +166,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0xD0; /* erase confirm */
while ((*addr & 0x80) != 0x80) { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0xB0; /* suspend erase */ *addr = 0xFF; /* reset to read mode */ rc = ERR_TIMOUT; @@ -230,11 +230,11 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((val = *addr) & 0x80) != 0x80) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0xB0; diff --git a/board/ep8260/flash.c b/board/ep8260/flash.c index 2a81de5..eb3cefc 100644 --- a/board/ep8260/flash.c +++ b/board/ep8260/flash.c @@ -279,12 +279,12 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; while ((V_ULONG( info->start[l_sect] ) & 0x00800080) != 0x00800080 || (V_ULONG( info->start[l_sect] + 4 ) & 0x00800080) != 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -400,10 +400,10 @@ static int write_dword (flash_info_t *info, ulong dest, unsigned char * pdata) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while (((V_ULONG( dest ) & 0x00800080) != (ch & 0x00800080)) || ((V_ULONG( dest + 4 ) & 0x00800080) != (cl & 0x00800080))) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/esd/common/flash.c b/board/esd/common/flash.c index b9c7885..5ca9c02 100644 --- a/board/esd/common/flash.c +++ b/board/esd/common/flash.c @@ -527,11 +527,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[l_sect]); while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -659,10 +659,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/esd/cpci5200/strataflash.c b/board/esd/cpci5200/strataflash.c index 9b578b5..d90a2c9 100644 --- a/board/esd/cpci5200/strataflash.c +++ b/board/esd/cpci5200/strataflash.c @@ -408,9 +408,9 @@ static int flash_status_check(flash_info_t * info, ulong sector, ulong tout, ulong start;
/* Wait for command completion */ - start = get_timer(0); + start = time_now_ms(); while (!flash_isset(info, sector, 0, FLASH_STATUS_DONE)) { - if (get_timer(start) > info->erase_blk_tout) { + if (time_since_ms(start) > info->erase_blk_tout) { printf("Flash %s timeout at address %lx\n", prompt, info->start[sector]); flash_write_cmd(info, sector, 0, FLASH_CMD_RESET); diff --git a/board/esd/pf5200/flash.c b/board/esd/pf5200/flash.c index 9850445..65ca214 100644 --- a/board/esd/pf5200/flash.c +++ b/board/esd/pf5200/flash.c @@ -297,7 +297,7 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) { printf("\n"); }
- last = get_timer(0); + last = time_now_ms();
/* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last && rcode == 0; sect++) { @@ -329,14 +329,14 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) { if (flag) { enable_interrupts(); } - start = get_timer(0); + start = time_now_ms();
/* wait at least 50us for AMD, 80us for Intel. */ /* Let's wait 1 ms. */ udelay(1000);
while ((*addr & (FPW) 0x00800080) != (FPW) 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); if (intel) { /* suspend erase */ @@ -347,17 +347,17 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) { break; } /* show that we're waiting */ - if ((get_timer(last)) > CONFIG_SYS_HZ) { + if ((time_since_ms(last)) > CONFIG_SYS_HZ) { /* every second */ putc('.'); - last = get_timer(0); + last = time_now_ms(); } } /* show that we're waiting */ - if ((get_timer(last)) > CONFIG_SYS_HZ) { + if ((time_since_ms(last)) > CONFIG_SYS_HZ) { /* every second */ putc('.'); - last = get_timer(0); + last = time_now_ms(); } flash_reset(info); /* reset to read mode */ } @@ -447,12 +447,12 @@ static int write_word_amd(flash_info_t * info, FPWV * dest, FPW data) { if (flag) { enable_interrupts(); } - start = get_timer(0); + start = time_now_ms();
/* data polling for D7 */ while (res == 0 && (*dest & (FPW) 0x00800080) != (data & (FPW) 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00F000F0; /* reset bank */ res = 1; } diff --git a/board/esteem192e/flash.c b/board/esteem192e/flash.c index cce73fa..bf8fa52 100644 --- a/board/esteem192e/flash.c +++ b/board/esteem192e/flash.c @@ -764,12 +764,12 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (volatile FLASH_WORD_SIZE *) (info->start[l_sect]); while ((addr[0] & (0x00800080 & FLASH_ID_MASK)) != (0x00800080 & FLASH_ID_MASK)) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -1016,13 +1016,13 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms();
if (info->flash_id > FLASH_AMD_COMP) {
while ((*((vu_long *) dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } @@ -1030,7 +1030,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) } else {
while (!(addr[0] & 0x00800080)) { /* wait for error or finish */ - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); }
@@ -1091,12 +1091,12 @@ static int write_short (flash_info_t * info, ulong dest, ushort data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms();
if (info->flash_id < FLASH_AMD_COMP) { /* AMD stuff */ while ((*((vu_short *) dest) & 0x0080) != (data & 0x0080)) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } @@ -1104,7 +1104,7 @@ static int write_short (flash_info_t * info, ulong dest, ushort data) } else { /* intel stuff */ while (!(addr[0] & 0x0080)) { /* wait for error or finish */ - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); }
@@ -1123,7 +1123,7 @@ static int write_short (flash_info_t * info, ulong dest, ushort data) *addr = 0x00B0; *addr = 0x0070; while (!(addr[0] & 0x0080)) { /* wait for error or finish */ - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); } *addr = 0x00FF; diff --git a/board/etin/debris/flash.c b/board/etin/debris/flash.c index f9e8619..efecc03 100644 --- a/board/etin/debris/flash.c +++ b/board/etin/debris/flash.c @@ -94,13 +94,13 @@ static int cfi_write_dword(flash_info_t *flash, ulong dest, cfi_word data) cfi_write(flash, data, dest);
udelay(10); - start = get_timer (0); + start = time_now_ms(); for(;;) { status = cfi_read(flash, dest); status &= CMD(0x80); if(status == CMD(0x80)) break; - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { cfi_cmd(flash, 0xff, 0); return 1; } @@ -126,10 +126,10 @@ static int jedec_write_dword (flash_info_t *flash, ulong dest, cfi_word data) cfi_write(flash, data, dest);
udelay(10); - start = get_timer (0); + start = time_now_ms(); status = ~data; while(status != data) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return 1; status = cfi_read(flash, dest); udelay(1); @@ -223,7 +223,7 @@ static int cfi_erase_oneblock(flash_info_t *flash, uint32_t sect) enable_interrupts();
udelay(1000); - start = get_timer (0); + start = time_now_ms(); last = start;
for (;;) { @@ -231,7 +231,7 @@ static int cfi_erase_oneblock(flash_info_t *flash, uint32_t sect) status &= CMD(0x80); if (status == CMD(0x80)) break; - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { cfi_cmd(flash, 0xff, 0); printf ("Timeout\n"); return ERR_TIMOUT; @@ -290,14 +290,14 @@ static int jedec_erase(flash_info_t *flash, uint32_t s_first, uint32_t s_last) goto DONE;
udelay (1000); - start = get_timer (0); + start = time_now_ms(); last = start; for(;;) { status = cfi_read(flash, sa); if (status == CMD(0xffff)) break;
- if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return ERR_TIMOUT; } diff --git a/board/etx094/flash.c b/board/etx094/flash.c index fa51c90..9f9e9bb 100644 --- a/board/etx094/flash.c +++ b/board/etx094/flash.c @@ -506,7 +506,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last; sect++) { @@ -548,7 +548,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) #else while ((sect_addr[0] & 0x00800080) != 0x00800080) { #endif - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -691,9 +691,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_short *)dest) & 0x0080) != (high_data & 0x0080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } @@ -725,7 +725,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms();
#ifdef CONFIG_FLASH_16BIT while ((*((vu_short *)dest) & 0x0080) != (low_data & 0x0080)) { @@ -733,7 +733,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { #endif
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/evb4510/flash.c b/board/evb4510/flash.c index c9c6e02..d8c4393 100644 --- a/board/evb4510/flash.c +++ b/board/evb4510/flash.c @@ -200,8 +200,8 @@ static u16 _flash_poll (FLASH_DEV dev, u32 addr, u16 data, ulong timeOut) volatile u16 flashData;
data = data & 0xFF; - t0 = get_timer (0); - while (get_timer (t0) < timeOut) { + t0 = time_now_ms(); + while (time_since_ms(t0) < timeOut) { /* for( i = 0; i < POLL_LOOPS; i++) { */ /* Read the Data */ flashData = GET__U8 (addr); diff --git a/board/evb64260/flash.c b/board/evb64260/flash.c index 825bbaf..8935883 100644 --- a/board/evb64260/flash.c +++ b/board/evb64260/flash.c @@ -676,12 +676,12 @@ flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (volatile unsigned char *)(info->start[l_sect]); /* broken for 2x16: TODO */ while ((addr[0] & 0x80) != 0x80) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -843,9 +843,9 @@ write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/evb64260/intel_flash.c b/board/evb64260/intel_flash.c index 994264a..289b989 100644 --- a/board/evb64260/intel_flash.c +++ b/board/evb64260/intel_flash.c @@ -155,9 +155,9 @@ write_word_intel(bank_addr_t addr, bank_word_t value) retval = 0;
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); do { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_now_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { retval = 1; goto done; } @@ -215,8 +215,8 @@ flash_erase_intel(flash_info_t *info, int s_first, int s_last) prot, (prot > 1 ? "s" : "")); }
- start = get_timer (0); - last = 0; + start = time_now_ms(); + last = start; haderr = 0;
for (sect = s_first; sect <= s_last; sect++) { @@ -229,12 +229,10 @@ flash_erase_intel(flash_info_t *info, int s_first, int s_last) /* wait at least 80us - let's wait 1 ms */ udelay (1000);
- estart = get_timer(start); + start = time_now_ms();
do { - now = get_timer(start); - - if (now - estart > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout (sect %d)\n", sect); haderr = 1; break; @@ -242,9 +240,9 @@ flash_erase_intel(flash_info_t *info, int s_first, int s_last)
#ifndef FLASH_DEBUG /* show that we're waiting */ - if ((now - last) > 1000) { /* every second */ + if (time_since_ms(last) > 1000) { /* every second */ putc ('.'); - last = now; + last = time_now_ms(); } #endif
diff --git a/board/fads/flash.c b/board/fads/flash.c index b9afb75..d21e7aa 100644 --- a/board/fads/flash.c +++ b/board/fads/flash.c @@ -423,12 +423,12 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long *) (info->start[l_sect]); while ((addr[0] & 0xFFFFFFFF) != 0xFFFFFFFF) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return ERR_TIMOUT; } @@ -549,10 +549,10 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *) dest) & 0x80808080) != (data & 0x80808080)) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return ERR_TIMOUT; } } diff --git a/board/flagadm/flash.c b/board/flagadm/flash.c index a69b1a4..6b41931 100644 --- a/board/flagadm/flash.c +++ b/board/flagadm/flash.c @@ -374,7 +374,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms();
/* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last; sect++) { @@ -400,7 +400,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) *addr = 0x70; /*Read status register command*/ tmp = (short)*addr & 0x00FF; /* Read the status */ while (!(tmp & INTEL_FLASH_STATUS_WSMS)) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x0050; /* Reset the status register */ *addr = 0xffff; printf ("Timeout\n"); @@ -413,7 +413,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay(100000); /* 100 ms */ *addr = 0x0070; /*Read status register command*/ tmp = (short)*addr & 0x00FF; /* Read status */ - start = get_timer(0); + start = time_now_ms(); } if( tmp & INTEL_FLASH_STATUS_ES ) flash_decode_status_bits(tmp); @@ -557,11 +557,11 @@ int write_word (flash_info_t *info, ulong dest, ulong da) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); flag = 0; *addr = 0x0070; /*Read statusregister command */ while (((csr = *addr) & INTEL_FLASH_STATUS_WSMS)!=INTEL_FLASH_STATUS_WSMS) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { flag = 1; break; } @@ -642,13 +642,13 @@ int _flash_real_protect(flash_info_t *info, long idx, int prot) addr = (vu_short *)(info->start[idx]);
/* If chip is busy, wait for it */ - start = get_timer(0); + start = time_now_ms(); *addr = 0x0070; /*Read status register command*/ tmp = ((ushort)(*addr))&0x00ff; /*Read the status*/ while(!(tmp & INTEL_FLASH_STATUS_WSMS)) { /*Write State Machine Busy*/ /*Wait untill done or timeout.*/ - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0x0050; /* Reset the status register */ *addr = 0xffff; /* Reset the chip */ printf ("TTimeout\n"); @@ -656,7 +656,7 @@ int _flash_real_protect(flash_info_t *info, long idx, int prot) } *addr = 0x0070; tmp = ((ushort)(*addr))&0x00ff; /*Read the status*/ - start = get_timer(0); + start = time_now_ms(); }
/* Disable interrupts which might cause a timeout here */ @@ -671,12 +671,12 @@ int _flash_real_protect(flash_info_t *info, long idx, int prot) if (flag) enable_interrupts();
- start = get_timer(0); + start = time_now_ms(); *addr = 0x0070; /*Read status register command*/ tmp = ((ushort)(*addr)) & 0x00FF; /* Read the status */ while (!(tmp & INTEL_FLASH_STATUS_WSMS)) { /* Write State Machine Busy */ - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0x0050; /* Reset the status register */ *addr = 0xffff; printf ("Timeout\n"); @@ -689,7 +689,7 @@ int _flash_real_protect(flash_info_t *info, long idx, int prot) udelay(100000); /* 100 ms */ *addr = 0x70; /*Read status register command*/ tmp = (short)*addr & 0x00FF; /* Read status */ - start = get_timer(0); + start = time_now_ms(); } if( tmp & INTEL_FLASH_STATUS_PS ) flash_decode_status_bits(tmp); diff --git a/board/freescale/m5253demo/flash.c b/board/freescale/m5253demo/flash.c index 08f767d..976d38c 100644 --- a/board/freescale/m5253demo/flash.c +++ b/board/freescale/m5253demo/flash.c @@ -232,7 +232,7 @@ int flash_erase(flash_info_t * info, int s_first, int s_last)
flag = disable_interrupts();
- start = get_timer(0); + start = time_now_ms(); last = start;
if ((s_last - s_first) == (CONFIG_SYS_SST_SECT - 1)) { @@ -247,7 +247,7 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) *addr = 0x0030; /* erase chip */
count = 0; - start = get_timer(0); + start = time_now_ms();
while ((*addr & 0x0080) != 0x0080) { if (count++ > 0x10000) { @@ -255,7 +255,7 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) count = 0; }
- if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); *addr = 0x00F0; /* reset to read mode */
@@ -285,7 +285,7 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) printf(".");
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
switch (flashtype) { case 1: @@ -307,7 +307,7 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) enable_interrupts();
while ((*addr & 0x0080) != 0x0080) { - if (get_timer(start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); *addr = 0x00F0; /* reset to read mode */ @@ -439,12 +439,12 @@ int write_word(flash_info_t * info, FPWV * dest, u16 data) if (flag) enable_interrupts();
- start = get_timer(0); + start = time_now_ms();
/* data polling for D7 */ while (res == 0 && (*dest & (u8) 0x00800080) != (data & (u8) 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (u8) 0x00F000F0; /* reset bank */ res = 1; } diff --git a/board/freescale/mpc8260ads/flash.c b/board/freescale/mpc8260ads/flash.c index e03852f..1abd24d 100644 --- a/board/freescale/mpc8260ads/flash.c +++ b/board/freescale/mpc8260ads/flash.c @@ -252,7 +252,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *)(info->start[sect]);
- last = start = get_timer (0); + last = start = time_now_ms();
/* Disable interrupts which might cause a timeout here */ flag = disable_interrupts(); @@ -274,7 +274,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) enable_interrupts();
while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = INTEL_RESET; /* reset bank */ return 1; @@ -336,9 +336,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { printf("Write timed out\n"); rc = 1; break; @@ -452,9 +452,9 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) *addr = INTEL_CONFIRM; /* clear */ }
- start = get_timer(0); + start = time_now_ms(); while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf("Flash lock bit operation timed out\n"); rc = 1; break; diff --git a/board/freescale/mpc8266ads/flash.c b/board/freescale/mpc8266ads/flash.c index 06dde36..f300515 100644 --- a/board/freescale/mpc8266ads/flash.c +++ b/board/freescale/mpc8266ads/flash.c @@ -304,7 +304,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *)(info->start[sect]);
- last = start = get_timer (0); + last = start = time_now_ms();
/* Disable interrupts which might cause a timeout here */ flag = disable_interrupts(); @@ -336,7 +336,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) *addr = 0xFFFFFFFF; /* reset bank */ return 1; } - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0xFFFFFFFF; /* reset bank */ return 1; @@ -458,10 +458,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); flag = 0; while (((csr = *addr) & 0x80808080) != 0x80808080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { flag = 1; break; } @@ -497,9 +497,9 @@ static int clear_block_lock_bit(vu_long * addr) *addr = 0x60606060; *addr = 0xd0d0d0d0;
- start = get_timer (0); + start = time_now_ms(); while(*addr != 0x80808080){ - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout on clearing Block Lock Bit\n"); *addr = 0xFFFFFFFF; /* reset bank */ return 1; diff --git a/board/funkwerk/vovpn-gw/flash.c b/board/funkwerk/vovpn-gw/flash.c index fd3b16e..b6f77f7 100644 --- a/board/funkwerk/vovpn-gw/flash.c +++ b/board/funkwerk/vovpn-gw/flash.c @@ -236,7 +236,7 @@ flash_erase(flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start;
for (sect = s_first; sect<=s_last; sect++) { @@ -265,7 +265,7 @@ flash_erase(flash_info_t *info, int s_first, int s_last) udelay (1000);
while (((status = *addr) & FLASH_STATUS_DONE) != FLASH_STATUS_DONE) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Flash erase timeout at address %lx\n", info->start[sect]); *addr = FLASH_CMD_SUSPEND_ERASE; *addr = FLASH_CMD_RESET; @@ -293,7 +293,7 @@ write_buff2( volatile FLASH_WORD_SIZE *dst, FLASH_WORD_SIZE status; int flag, i;
- start = get_timer (0); + start = time_now_ms(); while (1) { /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts(); @@ -307,7 +307,7 @@ write_buff2( volatile FLASH_WORD_SIZE *dst, enable_interrupts(); }
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (-1); } } @@ -329,7 +329,7 @@ poll_status( volatile FLASH_WORD_SIZE *addr ) { unsigned long start;
- start = get_timer (0); + start = time_now_ms(); /* wait for error or finish */ while (1) { if (*addr == FLASH_STATUS_DONE) { @@ -337,7 +337,7 @@ poll_status( volatile FLASH_WORD_SIZE *addr ) break; } } - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = FLASH_CMD_RESET; return (-1); } @@ -433,9 +433,9 @@ flash_real_protect(flash_info_t *info, long sector, int prot) }
/* wait for error or finish */ - start = get_timer (0); + start = time_now_ms(); while(!(addr[0] & FLASH_STATUS_DONE)){ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Flash protect timeout at address %lx\n", info->start[sector]); addr[0] = FLASH_CMD_RESET; return (1); diff --git a/board/g2000/strataflash.c b/board/g2000/strataflash.c index effe65a..2e8d8ed 100644 --- a/board/g2000/strataflash.c +++ b/board/g2000/strataflash.c @@ -432,9 +432,9 @@ static int flash_status_check(flash_info_t * info, ulong sector, ulong tout, cha ulong start;
/* Wait for command completion */ - start = get_timer (0); + start = time_now_ms(); while(!flash_isset(info, sector, 0, FLASH_STATUS_DONE)) { - if (get_timer(start) > info->erase_blk_tout) { + if (time_since_ms(start) > info->erase_blk_tout) { printf("Flash %s timeout at address %lx\n", prompt, info->start[sector]); flash_write_cmd(info, sector, 0, FLASH_CMD_RESET); return ERR_TIMOUT; diff --git a/board/gcplus/flash.c b/board/gcplus/flash.c index ab567e8..0da5f13 100644 --- a/board/gcplus/flash.c +++ b/board/gcplus/flash.c @@ -270,7 +270,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ @@ -279,7 +279,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -412,11 +412,11 @@ write_data(flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/gen860t/flash.c b/board/gen860t/flash.c index 827d9e0..e418d76 100644 --- a/board/gen860t/flash.c +++ b/board/gen860t/flash.c @@ -353,7 +353,7 @@ flash_erase(flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start;
/* @@ -385,7 +385,7 @@ flash_erase(flash_info_t *info, int s_first, int s_last) udelay (1000);
while (((status = *addr) & SCS_SR7) != SCS_SR7) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = SCS_BLOCK_ERASE_SUSPEND_CMD; *addr = SCS_READ_CMD; @@ -425,7 +425,7 @@ write_flash_buffer8(flash_info_t *info_p, vu_char *src_p, vu_char *dest_p, ulong blocksize = info_p->size / (ulong)info_p->sector_count;
int i; - uint time = get_timer(0); + uint time = time_now_ms();
PRINTF("%s:%d: src: 0x%p dest: 0x%p count: %d\n", __FUNCTION__, __LINE__, src_p, dest_p, count); @@ -451,7 +451,7 @@ write_flash_buffer8(flash_info_t *info_p, vu_char *src_p, vu_char *dest_p, */ *block_addr_p = SCS_WRITE_BUF_CMD; while ((*block_addr_p & SCS_XSR7) != SCS_XSR7) { - if (get_timer(time) > CONFIG_SYS_FLASH_ALLOC_BUFFER_TOUT) { + if (time_since_ms(time) > CONFIG_SYS_FLASH_ALLOC_BUFFER_TOUT) { PRINTF("%s:%d: Buffer allocation timeout @ 0x%p (waited %d mS)\n", __FUNCTION__, __LINE__, block_addr_p, CONFIG_SYS_FLASH_ALLOC_BUFFER_TOUT); @@ -476,9 +476,9 @@ write_flash_buffer8(flash_info_t *info_p, vu_char *src_p, vu_char *dest_p, */ *block_addr_p = SCS_PROGRAM_RESUME_CMD; #if 1 - time = get_timer(0); + time = time_now_ms(); while ((*block_addr_p & SCS_SR7) != SCS_SR7) { - if (get_timer(time) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(time) > CONFIG_SYS_FLASH_WRITE_TOUT) { PRINTF("%s:%d: Write timeout @ 0x%p (waited %d mS)\n", __FUNCTION__, __LINE__, block_addr_p, CONFIG_SYS_FLASH_WRITE_TOUT); return 1; @@ -629,10 +629,10 @@ write_data8 (flash_info_t *info, ulong dest, uchar data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
while (((status = *addr) & SCS_SR7) != SCS_SR7) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = SCS_READ_CMD; return (1); } diff --git a/board/genietv/flash.c b/board/genietv/flash.c index 5313ad8..e719381 100644 --- a/board/genietv/flash.c +++ b/board/genietv/flash.c @@ -316,13 +316,13 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (volatile unsigned char *)(info->start[l_sect]);
while ((addr[0] & 0xFF) != 0xFF) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -451,10 +451,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*cdest ^ *cdata) & 0x80) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/gw8260/flash.c b/board/gw8260/flash.c index 6035f69..6ac7c64 100644 --- a/board/gw8260/flash.c +++ b/board/gw8260/flash.c @@ -353,11 +353,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long*)(info->start[l_sect]); while ((addr[0] & 0x80808080) != 0x80808080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -510,9 +510,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/hermes/flash.c b/board/hermes/flash.c index 888231c..a382ada 100644 --- a/board/hermes/flash.c +++ b/board/hermes/flash.c @@ -372,11 +372,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_char*)(info->start[l_sect]); while ((addr[0] & 0x80) != 0x80) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -447,9 +447,9 @@ static int write_byte (flash_info_t *info, ulong dest, uchar data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_char *)dest) & 0x80) != (data & 0x80)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/hidden_dragon/flash.c b/board/hidden_dragon/flash.c index 2ce1dc4..0efce69 100644 --- a/board/hidden_dragon/flash.c +++ b/board/hidden_dragon/flash.c @@ -419,14 +419,14 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (FLASH_WORD_SIZE *) (info->start[0] + ((info->start[l_sect] - info-> start[0]) << sh8b)); while ((addr[0] & (FLASH_WORD_SIZE) 0x00800080) != (FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -562,10 +562,10 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i << sh8b] & (FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (FLASH_WORD_SIZE) 0x00800080)) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/hymod/flash.c b/board/hymod/flash.c index e2cf38c..f3e2484 100644 --- a/board/hymod/flash.c +++ b/board/hymod/flash.c @@ -196,9 +196,9 @@ bank_write_word (volatile bank_addr_t addr, bank_word_t value) retval = 0;
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); do { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { retval = 1; goto done; } @@ -349,7 +349,7 @@ flash_erase (flash_info_t *info, int s_first, int s_last) prot, (prot > 1 ? "s" : "")); }
- start = get_timer (0); + start = time_now_ms(); last = 0; haderr = 0;
@@ -363,10 +363,10 @@ flash_erase (flash_info_t *info, int s_first, int s_last) /* wait at least 80us - let's wait 1 ms */ udelay (1000);
- estart = get_timer (start); + estart = time_since_ms(start);
do { - now = get_timer (start); + now = time_since_ms(start);
if (now - estart > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout (sect %d)\n", sect); diff --git a/board/icecube/flash.c b/board/icecube/flash.c index 7a433b3..ff3ad4a 100644 --- a/board/icecube/flash.c +++ b/board/icecube/flash.c @@ -318,7 +318,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- last = get_timer(0); + last = time_now_ms();
/* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last && rcode == 0; sect++) { @@ -352,7 +352,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (flag) enable_interrupts();
- start = get_timer(0); + start = time_now_ms();
/* wait at least 50us for AMD, 80us for Intel. * Let's wait 1 ms. @@ -360,7 +360,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while ((*addr & (FPW)0x00800080) != (FPW)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n");
if (intel) { @@ -374,16 +374,16 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) }
/* show that we're waiting */ - if ((get_timer(last)) > CONFIG_SYS_HZ) {/* every second */ + if ((time_since_ms(last)) > CONFIG_SYS_HZ) {/* every second */ putc ('.'); - last = get_timer(0); + last = time_now_ms(); } }
/* show that we're waiting */ - if ((get_timer(last)) > CONFIG_SYS_HZ) { /* every second */ + if ((time_since_ms(last)) > CONFIG_SYS_HZ) { /* every second */ putc ('.'); - last = get_timer(0); + last = time_now_ms(); }
flash_reset(info); /* reset to read mode */ @@ -478,11 +478,11 @@ static int write_word_amd (flash_info_t *info, FPWV *dest, FPW data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
/* data polling for D7 */ while (res == 0 && (*dest & (FPW)0x00800080) != (data & (FPW)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW)0x00F000F0; /* reset bank */ res = 1; } diff --git a/board/icu862/flash.c b/board/icu862/flash.c index 2afeff4..501213c 100644 --- a/board/icu862/flash.c +++ b/board/icu862/flash.c @@ -459,7 +459,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long*)(info->start[l_sect]); #if 0 @@ -468,7 +468,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) while ((addr[0] & 0xFFFFFFFF) != 0xFFFFFFFF) #endif { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { puts ("Timeout\n"); return 1; } @@ -599,14 +599,14 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); #if 0 while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) #else while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080)) #endif { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/idmr/flash.c b/board/idmr/flash.c index 9f4ff2b..07d2b48 100644 --- a/board/idmr/flash.c +++ b/board/idmr/flash.c @@ -171,7 +171,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ volatile u16 *addr = @@ -192,7 +192,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -274,7 +274,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait until flash is ready */ chip1 = 0; @@ -282,7 +282,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT * CONFIG_SYS_HZ / 1000) { chip1 = ERR | TMO; break; } diff --git a/board/impa7/flash.c b/board/impa7/flash.c index 6eae428..54ba14f 100644 --- a/board/impa7/flash.c +++ b/board/impa7/flash.c @@ -166,7 +166,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -175,7 +175,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) *addr = 0x00D000D0; /* erase confirm */
while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer(start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B000B0; /* suspend erase */ *addr = 0x00FF00FF; /* reset to read mode */ @@ -238,14 +238,14 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* read status register command */ *addr = 0x00700070;
/* wait while polling the status register */ while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; /* suspend program command */ *addr = 0x00B000B0; diff --git a/board/incaip/flash.c b/board/incaip/flash.c index cc11e24..0f283ad 100644 --- a/board/incaip/flash.c +++ b/board/incaip/flash.c @@ -442,7 +442,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- last = get_timer(0); + last = time_now_ms();
/* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last && rcode == 0; sect++) { @@ -476,7 +476,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (flag) enable_interrupts();
- start = get_timer(0); + start = time_now_ms();
/* wait at least 50us for AMD, 80us for Intel. * Let's wait 1 ms. @@ -484,7 +484,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while ((*addr & (FPW)0x00800080) != (FPW)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n");
if (intel) { @@ -498,16 +498,16 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) }
/* show that we're waiting */ - if ((get_timer(last)) > CONFIG_SYS_HZ) {/* every second */ + if ((time_since_ms(last)) > CONFIG_SYS_HZ) {/* every second */ putc ('.'); - last = get_timer(0); + last = time_now_ms(); } }
/* show that we're waiting */ - if ((get_timer(last)) > CONFIG_SYS_HZ) { /* every second */ + if ((time_since_ms(last)) > CONFIG_SYS_HZ) { /* every second */ putc ('.'); - last = get_timer(0); + last = time_now_ms(); }
flash_reset(info); /* reset to read mode */ @@ -605,11 +605,11 @@ static int write_word_amd (flash_info_t *info, FPWV *dest, FPW data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
/* data polling for D7 */ while (res == 0 && (*dest & (FPW)0x00800080) != (data & (FPW)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW)0x00F000F0; /* reset bank */ res = 1; } @@ -652,10 +652,10 @@ static int write_word_intel (flash_info_t *info, FPWV *dest, FPW data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
while (res == 0 && (*dest & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW)0x00B000B0; /* Suspend program */ res = 1; } diff --git a/board/innokom/flash.c b/board/innokom/flash.c index ed4b987..78d9ae4 100644 --- a/board/innokom/flash.c +++ b/board/innokom/flash.c @@ -219,7 +219,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) PRINTK("\n");
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ u16 * volatile addr = (u16 * volatile)(info->start[sect]); @@ -236,7 +236,7 @@ int flash_erase(flash_info_t *info, int s_first, int s_last)
while ((*addr & 0x0080) != 0x0080) { PRINTK("."); - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = 0x00B0; /* suspend erase*/ *addr = 0x00FF; /* read mode */ rc = ERR_TIMOUT; @@ -304,11 +304,11 @@ static int write_word (flash_info_t *info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while(((val = *addr) & 0x80) != 0x80) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { rc = ERR_TIMOUT; *addr = 0xB0; /* suspend program command */ goto outahere; diff --git a/board/ip860/flash.c b/board/ip860/flash.c index 6491af2..5f91cdc 100644 --- a/board/ip860/flash.c +++ b/board/ip860/flash.c @@ -283,7 +283,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start;
/* Start erase on unprotected sectors */ @@ -309,7 +309,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while ((*addr & 0x00800080) != 0x00800080) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0xFFFFFFFF; /* reset bank */ return 1; @@ -431,10 +431,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); flag = 0; while (((csr = *addr) & 0x00800080) != 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { flag = 1; break; } diff --git a/board/iphase4539/flash.c b/board/iphase4539/flash.c index 3dfee1f..710dd09 100644 --- a/board/iphase4539/flash.c +++ b/board/iphase4539/flash.c @@ -277,11 +277,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = info->start[l_sect]; while ((in8(addr) & 0x80) != 0x80) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -419,9 +419,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((in32(dest) & 0x80808080) != (data & 0x80808080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } iobarrier_rw(); diff --git a/board/ivm/flash.c b/board/ivm/flash.c index cf309d7..bb3311c 100644 --- a/board/ivm/flash.c +++ b/board/ivm/flash.c @@ -431,7 +431,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last; sect++) { @@ -454,7 +454,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while (((status = *addr) & 0x0080) != 0x0080) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0x00FF; /* reset to read mode */ return 1; @@ -580,10 +580,10 @@ static int write_data (flash_info_t *info, ulong dest, ulong data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
while (((status = *addr) & 0x0080) != 0x0080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0x00FF; /* restore read mode */ return (1); } diff --git a/board/ixdp425/flash.c b/board/ixdp425/flash.c index 5e4e0e7..7174dd5 100644 --- a/board/ixdp425/flash.c +++ b/board/ixdp425/flash.c @@ -261,7 +261,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(start); + start = time_since_ms(start);
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ @@ -270,7 +270,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ @@ -404,11 +404,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/jse/flash.c b/board/jse/flash.c index 5735f19..99e3f58 100644 --- a/board/jse/flash.c +++ b/board/jse/flash.c @@ -277,11 +277,11 @@ int wait_for_DQ7 (flash_info_t * info, int sect) volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *) (info->start[sect]);
- start = get_timer (0); + start = time_now_ms(); last = start; while ((addr[0] & (FLASH_WORD_SIZE) 0x00800080) != (FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return -1; } @@ -506,11 +506,11 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i] & (FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (FLASH_WORD_SIZE) 0x00800080)) {
- if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/kup/common/flash.c b/board/kup/common/flash.c index 134a9d5..c0f914c 100644 --- a/board/kup/common/flash.c +++ b/board/kup/common/flash.c @@ -283,7 +283,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last; sect++) { @@ -325,7 +325,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) #else while ((sect_addr[0] & 0x00800080) != 0x00800080) { #endif - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -465,9 +465,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_short *)dest) & 0x0080) != (high_data & 0x0080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } @@ -499,7 +499,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms();
#ifdef CONFIG_FLASH_16BIT while ((*((vu_short *)dest) & 0x0080) != (low_data & 0x0080)) { @@ -507,7 +507,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { #endif
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/lantec/flash.c b/board/lantec/flash.c index 97ed054..89f6cbd 100644 --- a/board/lantec/flash.c +++ b/board/lantec/flash.c @@ -487,11 +487,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long*)(info->start[l_sect]); while ((addr[0] & 0x00800080) != 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -612,9 +612,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/lart/flash.c b/board/lart/flash.c index 408c884..e931fc0 100644 --- a/board/lart/flash.c +++ b/board/lart/flash.c @@ -292,7 +292,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ @@ -306,7 +306,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) do { /* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = PUZZLE_TO_FLASH(CMD_SUSPEND); result = BIT_TIMEOUT; @@ -379,13 +379,13 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = PUZZLE_TO_FLASH(CMD_SUSPEND); result = BIT_TIMEOUT; diff --git a/board/linkstation/avr.c b/board/linkstation/avr.c index ec6d400..7ecd1d4 100644 --- a/board/linkstation/avr.c +++ b/board/linkstation/avr.c @@ -115,8 +115,8 @@ static inline char avr_getc(void)
static int push_timeout(char button_code) { - ulong push_start = get_timer(0); - while (get_timer(push_start) <= PUSHHOLD) + ulong push_start = time_now_ms(); + while (time_since_ms(push_start) <= PUSHHOLD) if (avr_tstc() && avr_getc() == button_code) return 0; return 1; @@ -132,21 +132,21 @@ static void next_boot_choice(void) char c;
button_on = 0; - return_start = get_timer(0); + return_start = time_now_ms();
on_times = boot_choice; led_state = 0; miconCntl_SendCmd(HDDLEDOFF); - pulse_start = get_timer(0); + pulse_start = time_now_ms();
- while (get_timer(return_start) <= NOBUTTON || button_on) { + while (time_since_ms(return_start) <= NOBUTTON || button_on) { if (avr_tstc()) { c = avr_getc(); if (c == PWRP) button_on = 1; else if (c == PWRR) { button_on = 0; - return_start = get_timer(0); + return_start = time_now_ms(); if (++boot_choice > MAX_BOOT_CHOICE) boot_choice = 1; sprintf(envbuffer, "bootcmd%d", boot_choice); @@ -157,12 +157,12 @@ static void next_boot_choice(void) on_times = boot_choice; led_state = 1; miconCntl_SendCmd(HDDLEDON); - pulse_start = get_timer(0); + pulse_start = time_now_ms(); } else { perror("Unexpected code: 0x%02X\n", c); } } - if (on_times && get_timer(pulse_start) > PULSETIME) { + if (on_times && time_since_ms(pulse_start) > PULSETIME) { if (led_state == 1) { --on_times; led_state = 0; @@ -171,13 +171,13 @@ static void next_boot_choice(void) led_state = 1; miconCntl_SendCmd(HDDLEDON); } - pulse_start = get_timer(0); + pulse_start = time_now_ms(); } - if (!on_times && get_timer(pulse_start) > LONGPAUSE) { + if (!on_times && time_since_ms(pulse_start) > LONGPAUSE) { on_times = boot_choice; led_state = 1; miconCntl_SendCmd(HDDLEDON); - pulse_start = get_timer(0); + pulse_start = time_now_ms(); } } if (led_state) @@ -195,21 +195,21 @@ void next_cons_choice(int console)
button_on = 0; cons_choice = console; - return_start = get_timer(0); + return_start = time_now_ms();
on_times = cons_choice+1; led_state = 1; miconCntl_SendCmd(HDDLEDON); - pulse_start = get_timer(0); + pulse_start = time_now_ms();
- while (get_timer(return_start) <= NOBUTTON || button_on) { + while (time_since_ms(return_start) <= NOBUTTON || button_on) { if (avr_tstc()) { c = avr_getc(); if (c == RESP) button_on = 1; else if (c == RESR) { button_on = 0; - return_start = get_timer(0); + return_start = time_now_ms(); cons_choice = (cons_choice + 1) % MAX_CONS_CHOICE; console_assign(stdin, consoles[cons_choice]); console_assign(stdout, consoles[cons_choice]); @@ -217,12 +217,12 @@ void next_cons_choice(int console) on_times = cons_choice+1; led_state = 0; miconCntl_SendCmd(HDDLEDOFF); - pulse_start = get_timer(0); + pulse_start = time_now_ms(); } else { perror("Unexpected code: 0x%02X\n", c); } } - if (on_times && get_timer(pulse_start) > PULSETIME) { + if (on_times && time_since_ms(pulse_start) > PULSETIME) { if (led_state == 0) { --on_times; led_state = 1; @@ -231,13 +231,13 @@ void next_cons_choice(int console) led_state = 0; miconCntl_SendCmd(HDDLEDOFF); } - pulse_start = get_timer(0); + pulse_start = time_now_ms(); } - if (!on_times && get_timer(pulse_start) > LONGPAUSE) { + if (!on_times && time_since_ms(pulse_start) > LONGPAUSE) { on_times = cons_choice+1; led_state = 0; miconCntl_SendCmd(HDDLEDOFF); - pulse_start = get_timer(0); + pulse_start = time_now_ms(); } } if (led_state); diff --git a/board/lpd7a40x/flash.c b/board/lpd7a40x/flash.c index f5c0713..65db949 100644 --- a/board/lpd7a40x/flash.c +++ b/board/lpd7a40x/flash.c @@ -285,7 +285,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) sect, info->start[sect]);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -298,7 +298,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* wait until flash is ready */ do { /* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_STATUS_RESET; result = BIT_TIMEOUT; break; @@ -389,12 +389,12 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_SUSPEND; result = BIT_TIMEOUT; break; diff --git a/board/lubbock/flash.c b/board/lubbock/flash.c index 1ea2893..8dac9c5 100644 --- a/board/lubbock/flash.c +++ b/board/lubbock/flash.c @@ -266,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -404,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start)) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start)) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/lwmon/flash.c b/board/lwmon/flash.c index f71cc24..93d9e7b 100644 --- a/board/lwmon/flash.c +++ b/board/lwmon/flash.c @@ -392,7 +392,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last; sect++) { @@ -409,7 +409,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000); /* This takes awfully long - up to 50 ms and more */ while (((status = *addr) & 0x00800080) != 0x00800080) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0x00FF00FF; /* reset to read mode */ return 1; @@ -435,7 +435,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while (((status = *addr) & 0x00800080) != 0x00800080) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0x00B000B0; /* suspend erase */ *addr = 0x00FF00FF; /* reset to read mode */ @@ -558,9 +558,9 @@ static int flash_status_check(vu_long *addr, ulong tout, char * prompt) ulong start;
/* Wait for command completion */ - start = get_timer (0); + start = time_now_ms(); while(((status = *addr) & 0x00800080) != 0x00800080) { - if (get_timer(start) > tout) { + if (time_since_ms(start) > tout) { printf("Flash %s timeout at address %p\n", prompt, addr); *addr = 0x00FF00FF; /* restore read mode */ return (1); diff --git a/board/mbx8xx/flash.c b/board/mbx8xx/flash.c index 2ec420d..321a096 100644 --- a/board/mbx8xx/flash.c +++ b/board/mbx8xx/flash.c @@ -270,11 +270,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long*)(info->start[l_sect]); while ((addr[0] & 0x80808080) != 0x80808080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -395,9 +395,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/modnet50/flash.c b/board/modnet50/flash.c index 4834e21..668fcb7 100644 --- a/board/modnet50/flash.c +++ b/board/modnet50/flash.c @@ -339,14 +339,14 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) (__u16) SECERASE_CMD;
/* wait some time */ - start = get_timer(0); - while (get_timer(start) < 1000) { + start = time_now_ms(); + while (time_since_ms(start) < 1000) { }
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms(); while (flash_check_erase_amd (info->start[sect])) { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("timeout!\n"); /* OOPS: reach timeout, * try to reset chip @@ -448,10 +448,10 @@ static int write_word (flash_info_t * info, ulong dest, ushort data) }
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
while (flash_check_write_amd (dest)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { printf ("timeout! @ %08lX\n", dest); /* OOPS: reach timeout, * try to reset chip */ diff --git a/board/mpl/common/flash.c b/board/mpl/common/flash.c index 61f031a..1b81275 100644 --- a/board/mpl/common/flash.c +++ b/board/mpl/common/flash.c @@ -552,10 +552,10 @@ int wait_for_DQ7(flash_info_t *info, int sect) ulong start, now, last; volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[sect]);
- start = get_timer (0); + start = time_now_ms(); last = start; while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return ERR_TIMOUT; } @@ -573,10 +573,10 @@ int intel_wait_for_DQ7(flash_info_t *info, int sect) ulong start, now, last, status; volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[sect]);
- start = get_timer (0); + start = time_now_ms(); last = start; while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return ERR_TIMOUT; } @@ -848,11 +848,11 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) if (flag) enable_interrupts(); /* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); udelay(10); while ((dest2[i] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); } dest2[i] = (FLASH_WORD_SIZE)0x00FF00FF; /* return to read mode */ @@ -870,10 +870,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) if (flag) enable_interrupts(); /* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i] & (FLASH_WORD_SIZE)0x00800080) != (data2[i] & (FLASH_WORD_SIZE)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/mpl/mip405/mip405.c b/board/mpl/mip405/mip405.c index e93d994..ad5299a 100644 --- a/board/mpl/mip405/mip405.c +++ b/board/mpl/mip405/mip405.c @@ -686,7 +686,7 @@ int misc_init_r (void)
/* check, if RTC is running */ rtc_get (&tm); - start=get_timer(0); + start=time_now_ms(); /* if MIP405 has booted from PCI, reset CCR0[24] as described in errata PCI_18 */ if (mfdcr(CPC0_PSR) & PSR_ROM_LOC) mtspr(SPRN_CCR0, (mfspr(SPRN_CCR0) & ~0x80)); @@ -711,7 +711,6 @@ extern int mk_date (char *, struct rtc_time *);
int last_stage_init (void) { - unsigned long stop; struct rtc_time newtm; char *s;
@@ -728,11 +727,11 @@ int last_stage_init (void) stdio_print_current_devices (); check_env (); /* check if RTC time is valid */ - stop=get_timer(start); - while(stop<1200) { /* we wait 1.2 sec to check if the RTC is running */ + + /* we wait 1.2 sec to check if the RTC is running */ + while(time_since_ms(start) < 1200) udelay(1000); - stop=get_timer(start); - } + rtc_get (&newtm); if(tm.tm_sec==newtm.tm_sec) { s=getenv("defaultdate"); diff --git a/board/mpl/vcma9/flash.c b/board/mpl/vcma9/flash.c index 5d49204..6b8694b 100644 --- a/board/mpl/vcma9/flash.c +++ b/board/mpl/vcma9/flash.c @@ -216,7 +216,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -236,7 +236,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer(start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip = TMO; @@ -325,7 +325,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait until flash is ready */ chip = 0; @@ -333,7 +333,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip = ERR | TMO; break; } diff --git a/board/musenki/flash.c b/board/musenki/flash.c index 40965be..f3470c9 100644 --- a/board/musenki/flash.c +++ b/board/musenki/flash.c @@ -390,7 +390,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last; sect++) { @@ -414,7 +414,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while (((status = BS(*addr)) & BYTEME(0x00800080)) != BYTEME(0x00800080)) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = BS(0xB0); /* suspend erase */ *addr = BS(0xFF); /* reset to read mode */ @@ -494,10 +494,10 @@ static int write_data (flash_info_t *info, uchar *dest, uchar data) enable_interrupts(); }
- start = get_timer (0); + start = time_now_ms();
while (((status = BS(*addr)) & BYTEME(0x00800080)) != BYTEME(0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = BS(0xFF); /* restore read mode */ return 1; } diff --git a/board/mvblue/flash.c b/board/mvblue/flash.c index 2d6acf5..107e8bc 100644 --- a/board/mvblue/flash.c +++ b/board/mvblue/flash.c @@ -411,12 +411,12 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (FDT *)(info->start[l_sect]);
while ((addr[0] & ERASE_CONFIRM_DATA) != ERASE_CONFIRM_DATA) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -551,10 +551,10 @@ static int write_char (flash_info_t *info, ulong dest, uchar data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); addr = (vu_char *)dest; while (( (*addr) & WRITE_CONFIRM_DATA) != (data & WRITE_CONFIRM_DATA)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { printf(" *** ERROR: Flash write timeout !"); return (1); } diff --git a/board/mx1ads/syncflash.c b/board/mx1ads/syncflash.c index 7331efa..e0dc105 100644 --- a/board/mx1ads/syncflash.c +++ b/board/mx1ads/syncflash.c @@ -276,7 +276,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) {
/* arm simple, non interrupt dependent timer */
- get_timer(0); + time_now_ms();
SF_NvmodeErase(); SF_NvmodeWrite(); diff --git a/board/mx1fs2/flash.c b/board/mx1fs2/flash.c index da4ebe6..246327f 100644 --- a/board/mx1fs2/flash.c +++ b/board/mx1fs2/flash.c @@ -488,7 +488,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last) printf("\n"); }
- start = get_timer(0); + start = time_now_ms(); last = start;
/* Start erase on unprotected sectors */ @@ -528,7 +528,7 @@ flash_erase(flash_info_t * info, int s_first, int s_last) udelay(1000);
while ((*addr & (FPW) 0x00800080) != (FPW) 0x00800080) { - if ((now = get_timer(0)) - start > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n");
if (intel) { @@ -542,9 +542,9 @@ flash_erase(flash_info_t * info, int s_first, int s_last) }
/* show that we're waiting */ - if ((now - last) > 1000) { /* every second */ + if (time_since_ms(last) > 1000) { /* every second */ putc('.'); - last = now; + last = time_now_ms(); } }
@@ -715,12 +715,12 @@ write_word_amd(flash_info_t * info, FPWV * dest, FPW data) if (flag) enable_interrupts();
- start = get_timer(0); + start = time_now_ms();
/* data polling for D7 */ while (res == 0 && (*dest & (FPW) 0x00800080) != (data & (FPW) 0x00800080)) { - if (get_timer(0) - start > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00F000F0; /* reset bank */ printf("SHA timeout\n"); res = 1; @@ -765,10 +765,10 @@ write_word_intel(flash_info_t * info, FPWV * dest, FPW data) if (flag) enable_interrupts();
- start = get_timer(0); + start = time_now_ms();
while (res == 0 && (*dest & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00B000B0; /* Suspend program */ res = 1; } diff --git a/board/netphone/flash.c b/board/netphone/flash.c index 349d98e..47a3ac5 100644 --- a/board/netphone/flash.c +++ b/board/netphone/flash.c @@ -444,11 +444,11 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer(0); + start = time_now_ms(); last = start; addr = (vu_char *) (info->start[l_sect]); while ((addr[0] & 0x80) != 0x80) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return 1; } @@ -519,9 +519,9 @@ static int write_byte(flash_info_t * info, ulong dest, uchar data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((*((vu_char *) dest) & 0x80) != (data & 0x80)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/netta/flash.c b/board/netta/flash.c index 565fd67..fc00b29 100644 --- a/board/netta/flash.c +++ b/board/netta/flash.c @@ -423,11 +423,11 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer(0); + start = time_now_ms(); last = start; addr = (vu_char *) (info->start[l_sect]); while ((addr[0] & 0x80) != 0x80) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return 1; } @@ -498,9 +498,9 @@ static int write_byte(flash_info_t * info, ulong dest, uchar data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((*((vu_char *) dest) & 0x80) != (data & 0x80)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/netta2/flash.c b/board/netta2/flash.c index 53a4e1e..1bb5f30 100644 --- a/board/netta2/flash.c +++ b/board/netta2/flash.c @@ -421,11 +421,11 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer(0); + start = time_now_ms(); last = start; addr = (vu_char *) (info->start[l_sect]); while ((addr[0] & 0x80) != 0x80) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return 1; } @@ -496,9 +496,9 @@ static int write_byte(flash_info_t * info, ulong dest, uchar data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((*((vu_char *) dest) & 0x80) != (data & 0x80)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/netvia/flash.c b/board/netvia/flash.c index b987434..34dddd8 100644 --- a/board/netvia/flash.c +++ b/board/netvia/flash.c @@ -423,11 +423,11 @@ int flash_erase(flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer(0); + start = time_now_ms(); last = start; addr = (vu_char *) (info->start[l_sect]); while ((addr[0] & 0x80) != 0x80) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return 1; } @@ -498,9 +498,9 @@ static int write_byte(flash_info_t * info, ulong dest, uchar data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((*((vu_char *) dest) & 0x80) != (data & 0x80)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/ns9750dev/flash.c b/board/ns9750dev/flash.c index 185bc2d..d3ca222 100644 --- a/board/ns9750dev/flash.c +++ b/board/ns9750dev/flash.c @@ -308,7 +308,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -317,7 +317,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -451,11 +451,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/nx823/flash.c b/board/nx823/flash.c index 336e704..dee5b8b 100644 --- a/board/nx823/flash.c +++ b/board/nx823/flash.c @@ -272,7 +272,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect<=s_last; sect++) { @@ -295,7 +295,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) { - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW)0x00B000B0; /* suspend erase */ *addr = (FPW)0x00FF00FF; /* reset to read mode */ @@ -450,10 +450,10 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
while (((status = *addr) & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW)0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/o2dnt/flash.c b/board/o2dnt/flash.c index 9f30880..e7f2069 100644 --- a/board/o2dnt/flash.c +++ b/board/o2dnt/flash.c @@ -302,7 +302,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) prot);
printf ("\n"); - last = get_timer(0); + last = time_now_ms();
/* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last && rcode == 0; sect++) { @@ -322,13 +322,13 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (flag) enable_interrupts();
- start = get_timer(0); + start = time_now_ms();
/* wait at least 80us for Intel - let's wait 1 ms */ udelay (1000);
while ((*addr & (FPW) INTEL_FINISHED) != (FPW) INTEL_FINISHED) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) INTEL_SUSPEND;/* suspend erase */ flash_reset(info); /* reset to read mode */ @@ -337,9 +337,9 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) }
/* show that we're waiting */ - if ((get_timer(last)) > CONFIG_SYS_HZ) { /* every second */ + if ((time_since_ms(last)) > CONFIG_SYS_HZ) { /* every second */ putc ('.'); - last = get_timer(0); + last = time_now_ms(); } }
@@ -421,11 +421,11 @@ static int write_data (flash_info_t *info, FPWV *dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) INTEL_FINISHED) != (FPW) INTEL_FINISHED) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) INTEL_RESET; /* restore read mode */ return (1); } @@ -461,10 +461,10 @@ int flash_real_protect (flash_info_t * info, long sector, int prot) *addr = INTEL_CONFIRM; /* clear */ }
- start = get_timer (0); + start = time_now_ms();
while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer (start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf ("Flash lock bit operation timed out\n"); rc = 1; break; @@ -487,13 +487,13 @@ int flash_real_protect (flash_info_t * info, long sector, int prot) if (!prot) { for (i = 0; i < info->sector_count; i++) { if (info->protect[i]) { - start = get_timer (0); + start = time_now_ms(); addr = (FPWV *) (info->start[i]); *addr = INTEL_LOCKBIT; /* Sector lock bit */ *addr = INTEL_PROTECT; /* set */ while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer (start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf ("Flash lock bit operation timed out\n"); rc = 1; @@ -561,9 +561,9 @@ static unsigned char intel_sector_protected (flash_info_t *info, ushort sector) addr = (FPWV *) info->start[sector]; *addr = (FPW) INTEL_STATUS;
- start = get_timer (0); + start = time_now_ms(); while ((*addr & (FPW) INTEL_FINISHED) != (FPW) INTEL_FINISHED) { - if (get_timer (start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = (FPW) INTEL_RESET; /* restore read mode */ printf("WSM busy too long, can't get prot status\n"); return 1; diff --git a/board/oxc/flash.c b/board/oxc/flash.c index 36e0fca..1824bd1 100644 --- a/board/oxc/flash.c +++ b/board/oxc/flash.c @@ -282,11 +282,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_char *)(info->start[l_sect]); while ((addr[0] & 0x80) != 0x80) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -359,9 +359,9 @@ static int write_byte (flash_info_t *info, ulong dest, uchar data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_char *)dest) & 0x80) != (data & 0x80)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/pcippc2/flash.c b/board/pcippc2/flash.c index ec604e0..0c094cf 100644 --- a/board/pcippc2/flash.c +++ b/board/pcippc2/flash.c @@ -352,14 +352,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = info->start[l_sect];
DEBUGF ("Start erase timeout: %d\n", CONFIG_SYS_FLASH_ERASE_TOUT);
while ((in8(addr) & 0x80) != 0x80) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); flash_reset (info->start[0]); return 1; @@ -486,9 +486,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((in8(dest+i) & 0x80) != (data_ch[i] & 0x80)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { flash_reset (addr); return (1); } diff --git a/board/pcs440ep/flash.c b/board/pcs440ep/flash.c index f90a221..1d41133 100644 --- a/board/pcs440ep/flash.c +++ b/board/pcs440ep/flash.c @@ -454,10 +454,10 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) }
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((addr2[0] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); } } else { @@ -487,11 +487,11 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[l_sect]); while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -611,10 +611,10 @@ static int write_word(flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); } } diff --git a/board/pleb2/flash.c b/board/pleb2/flash.c index 2406c5f..64def77 100644 --- a/board/pleb2/flash.c +++ b/board/pleb2/flash.c @@ -525,7 +525,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* Disable interrupts which might cause a timeout here */ flag = disable_interrupts ();
- start = get_timer(0); + start = time_now_ms(); last = 0;
addr = (FPWV *) (info->start[sect]); @@ -557,7 +557,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
while ((*addr & (FPW) 0x00800080) != (FPW) 0x00800080) { if ((now = - get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n");
if (intel) { @@ -682,12 +682,12 @@ static int write_word_amd (flash_info_t * info, FPWV * dest, FPW data) if (flag) enable_interrupts ();
- start = get_timer(0); + start = time_now_ms();
/* data polling for D7 */ while (res == 0 && (*dest & (FPW) 0x00800080) != (data & (FPW) 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00F000F0; /* reset bank */ res = 1; } @@ -730,10 +730,10 @@ static int write_word_intel (flash_info_t * info, FPWV * dest, FPW data) if (flag) enable_interrupts ();
- start = get_timer(0); + start = time_now_ms();
while (res == 0 && (*dest & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW) 0x00B000B0; /* Suspend program */ res = 1; } diff --git a/board/pm520/flash.c b/board/pm520/flash.c index 64c8624..0576d43 100644 --- a/board/pm520/flash.c +++ b/board/pm520/flash.c @@ -339,9 +339,9 @@ static unsigned char intel_sector_protected (flash_info_t *info, ushort sector) addr = (FPWV *) info->start[sector]; *addr = (FPW) INTEL_STATUS;
- start = get_timer (0); + start = time_now_ms(); while ((*addr & (FPW) INTEL_FINISHED) != (FPW) INTEL_FINISHED) { - if (get_timer (start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = (FPW) INTEL_RESET; /* restore read mode */ printf("WSM busy too long, can't get prot status\n"); return 1; @@ -403,7 +403,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start;
/* Disable interrupts which might cause a timeout here */ @@ -418,14 +418,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -556,11 +556,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } @@ -603,10 +603,10 @@ int flash_real_protect (flash_info_t *info, long sector, int prot) *addr = INTEL_CONFIRM; /* clear */ }
- start = get_timer(0); + start = time_now_ms();
while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf("Flash lock bit operation timed out\n"); rc = 1; break; @@ -637,13 +637,13 @@ int flash_real_protect (flash_info_t *info, long sector, int prot) { if (info->protect[i]) { - start = get_timer(0); + start = time_now_ms(); addr = (vu_long *)(info->start[i]); *addr = INTEL_LOCKBIT; /* Sector lock bit */ *addr = INTEL_PROTECT; /* set */ while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf("Flash lock bit operation timed out\n"); rc = 1; diff --git a/board/pm826/flash.c b/board/pm826/flash.c index 010f59a..e8881dd 100644 --- a/board/pm826/flash.c +++ b/board/pm826/flash.c @@ -241,7 +241,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) volatile ulong *addr = (volatile unsigned long *) info->start[sect];
- start = get_timer (0); + start = time_now_ms(); last = start; if (info->protect[sect] == 0) { /* Disable interrupts which might cause a timeout here @@ -267,7 +267,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) last = start; while ((addr[0] & 0x00800080) != 0x00800080 || (addr[1] & 0x00800080) != 0x00800080) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout (erase suspended!)\n"); /* Suspend erase */ @@ -360,9 +360,9 @@ static int write_word (flash_info_t * info, volatile unsigned long *addr, if (flag) enable_interrupts ();
- start = get_timer (0); + start = time_now_ms(); while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { /* Suspend program */ *addr = 0x00B000B0; diff --git a/board/pm828/flash.c b/board/pm828/flash.c index 4958a95..5a6f01d 100644 --- a/board/pm828/flash.c +++ b/board/pm828/flash.c @@ -241,7 +241,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) volatile ulong *addr = (volatile unsigned long *) info->start[sect];
- start = get_timer (0); + start = time_now_ms(); last = start; if (info->protect[sect] == 0) { /* Disable interrupts which might cause a timeout here @@ -267,7 +267,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) last = start; while ((addr[0] & 0x00800080) != 0x00800080 || (addr[1] & 0x00800080) != 0x00800080) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout (erase suspended!)\n"); /* Suspend erase */ @@ -360,9 +360,9 @@ static int write_word (flash_info_t * info, volatile unsigned long *addr, if (flag) enable_interrupts ();
- start = get_timer (0); + start = time_now_ms(); while ((*addr & 0x00800080) != 0x00800080) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { /* Suspend program */ *addr = 0x00B000B0; diff --git a/board/ppmc7xx/flash.c b/board/ppmc7xx/flash.c index e724227..b13b71b 100644 --- a/board/ppmc7xx/flash.c +++ b/board/ppmc7xx/flash.c @@ -354,12 +354,12 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; while ((*(volatile DWORD*)info->start[l_sect] & 0x0080008000800080LL ) != 0x0080008000800080LL ) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -475,9 +475,9 @@ static int write_dword (flash_info_t * info, ulong dest, unsigned char *pdata) set_msr(msr);
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while (*(volatile DWORD*)dest != data ) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/ppmc8260/strataflash.c b/board/ppmc8260/strataflash.c index cc91627..4754a38 100644 --- a/board/ppmc8260/strataflash.c +++ b/board/ppmc8260/strataflash.c @@ -398,9 +398,9 @@ static int flash_status_check(flash_info_t * info, ulong sector, ulong tout, cha ulong start;
/* Wait for command completion */ - start = get_timer (0); + start = time_now_ms(); while(!flash_isset(info, sector, 0, FLASH_STATUS_DONE)) { - if (get_timer(start) > info->erase_blk_tout) { + if (time_since_ms(start) > info->erase_blk_tout) { printf("Flash %s timeout at address %lx\n", prompt, info->start[sector]); flash_write_cmd(info, sector, 0, FLASH_CMD_RESET); return ERR_TIMOUT; diff --git a/board/prodrive/common/flash.c b/board/prodrive/common/flash.c index c42fa83..7013433 100644 --- a/board/prodrive/common/flash.c +++ b/board/prodrive/common/flash.c @@ -391,10 +391,10 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) }
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((addr2[0] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); } } else { @@ -424,11 +424,11 @@ int flash_erase(flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[l_sect]); while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -548,10 +548,10 @@ static int write_word(flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); } } diff --git a/board/psyent/common/AMDLV065D.c b/board/psyent/common/AMDLV065D.c index 72b0a9f..c2b6a37 100644 --- a/board/psyent/common/AMDLV065D.c +++ b/board/psyent/common/AMDLV065D.c @@ -131,11 +131,11 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* Now just wait for 0xff & provide some user * feedback while we wait. */ - start = get_timer (0); + start = time_now_ms(); while ( readb (addr2) != 0xff) { udelay (1000 * 1000); putc ('.'); - if (get_timer (start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("timeout\n"); return 1; } @@ -175,9 +175,9 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt) writeb (dst, b);
/* Verify write */ - start = get_timer (0); + start = time_now_ms(); while (readb (dst) != b) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return 1; } } diff --git a/board/r360mpi/flash.c b/board/r360mpi/flash.c index 45cccf7..7062f69 100644 --- a/board/r360mpi/flash.c +++ b/board/r360mpi/flash.c @@ -312,7 +312,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("\n"); }
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last; sect++) { @@ -335,7 +335,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) udelay (1000);
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -469,10 +469,10 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) if (flag) enable_interrupts ();
- start = get_timer (0); + start = time_now_ms();
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/rbc823/flash.c b/board/rbc823/flash.c index cb1e089..06c0925 100644 --- a/board/rbc823/flash.c +++ b/board/rbc823/flash.c @@ -316,13 +316,13 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (volatile unsigned char *)(info->start[l_sect]);
while ((addr[0] & 0xFF) != 0xFF) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -451,10 +451,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*cdest ^ *cdata) & 0x80) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/rmu/flash.c b/board/rmu/flash.c index 283b19d..1ef8344 100644 --- a/board/rmu/flash.c +++ b/board/rmu/flash.c @@ -402,11 +402,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long *)(info->start[l_sect]); while ((addr[0] & 0x80808080) != 0x80808080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -527,9 +527,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/rpxsuper/flash.c b/board/rpxsuper/flash.c index be29b65..b9e9a6b 100644 --- a/board/rpxsuper/flash.c +++ b/board/rpxsuper/flash.c @@ -287,12 +287,12 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long*)(info->start[l_sect]); while ( (addr[0] & 0x80808080) != 0x80808080 || (addr[1] & 0x80808080) != 0x80808080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -421,9 +421,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/rsdproto/flash.c b/board/rsdproto/flash.c index e99c2a6..2e5722f 100644 --- a/board/rsdproto/flash.c +++ b/board/rsdproto/flash.c @@ -256,10 +256,10 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms(); do { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { /* write reset command, command address is unimportant */ /* this command turns the flash back to read mode */ f_addr = @@ -384,10 +384,10 @@ static unsigned char write_ull(flash_info_t *info, f_command = data; ull_write(f_addr, &f_command);
- start = get_timer (0); + start = time_now_ms(); do { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { /* write reset command, command address is unimportant */ /* this command turns the flash back to read mode */ diff --git a/board/sacsng/flash.c b/board/sacsng/flash.c index 8b30f50..94dd8df 100644 --- a/board/sacsng/flash.c +++ b/board/sacsng/flash.c @@ -370,11 +370,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_short*)(info->start[l_sect]); while ((addr[0] & 0x0080) != 0x0080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); addr[0] = 0xF0F0; /* reset bank */ __asm__ __volatile__(" sync\n "); @@ -507,9 +507,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while (*(vu_short *)dest != (ushort)data) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/samsung/smdk2400/flash.c b/board/samsung/smdk2400/flash.c index 47382fe..2ff9900 100644 --- a/board/samsung/smdk2400/flash.c +++ b/board/samsung/smdk2400/flash.c @@ -287,7 +287,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) sect, info->start[sect]);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -300,7 +300,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) /* wait until flash is ready */ do { /* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_me(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_STATUS_RESET; result = BIT_TIMEOUT; break; @@ -391,12 +391,12 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait until flash is ready */ do { /* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { *addr = CMD_SUSPEND; result = BIT_TIMEOUT; break; diff --git a/board/sandburst/common/flash.c b/board/sandburst/common/flash.c index c65cb96..74d8619 100644 --- a/board/sandburst/common/flash.c +++ b/board/sandburst/common/flash.c @@ -281,10 +281,10 @@ int wait_for_DQ7(flash_info_t *info, int sect) ulong start, now, last; volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[sect]);
- start = get_timer (0); + start = time_now_ms(); last = start; while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return -1; } @@ -498,11 +498,11 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i] & (FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (FLASH_WORD_SIZE) 0x00800080)) {
- if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/sandpoint/flash.c b/board/sandpoint/flash.c index e366cc6..dd9adbf 100644 --- a/board/sandpoint/flash.c +++ b/board/sandpoint/flash.c @@ -607,12 +607,12 @@ flash_erase(flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (FLASH_WORD_SIZE *)(info->start[0] + ( (info->start[l_sect] - info->start[0]) << sh8b)); while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -748,10 +748,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i << sh8b] & (FLASH_WORD_SIZE)0x00800080) != (data2[i] & (FLASH_WORD_SIZE)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/sbc2410x/flash.c b/board/sbc2410x/flash.c index d209a6f..a65469c 100644 --- a/board/sbc2410x/flash.c +++ b/board/sbc2410x/flash.c @@ -214,7 +214,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ vu_short *addr = (vu_short *) (info->start[sect]); @@ -234,7 +234,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer(start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip = TMO; @@ -324,7 +324,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) *addr = data;
/* arm simple, non interrupt dependent timer */ - get_timer(start); + time_now_ms(start);
/* wait until flash is ready */ chip = 0; @@ -332,7 +332,7 @@ static int write_hword (flash_info_t * info, ulong dest, ushort data) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip = ERR | TMO; break; } diff --git a/board/sbc405/strataflash.c b/board/sbc405/strataflash.c index e5863d6..c8f32e1 100644 --- a/board/sbc405/strataflash.c +++ b/board/sbc405/strataflash.c @@ -436,9 +436,9 @@ static int flash_status_check(flash_info_t * info, ulong sector, ulong tout, cha ulong start;
/* Wait for command completion */ - start = get_timer (0); + start = time_now_ms(); while(!flash_isset(info, sector, 0, FLASH_STATUS_DONE)) { - if (get_timer(start) > info->erase_blk_tout) { + if (time_since_ms(start) > info->erase_blk_tout) { printf("Flash %s timeout at address %lx\n", prompt, info->start[sector]); flash_write_cmd(info, sector, 0, FLASH_CMD_RESET); return ERR_TIMOUT; diff --git a/board/sbc8240/flash.c b/board/sbc8240/flash.c index a095753..ea4232b 100644 --- a/board/sbc8240/flash.c +++ b/board/sbc8240/flash.c @@ -395,11 +395,11 @@ int wait_for_DQ7 (flash_info_t * info, int sect) volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *) (info->start[sect]);
- start = get_timer (0); + start = time_now_ms(); last = start; while ((addr[0] & (FLASH_WORD_SIZE) 0x00800080) != (FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return -1; } @@ -624,11 +624,11 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i] & (FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (FLASH_WORD_SIZE) 0x00800080)) {
- if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/sbc8260/flash.c b/board/sbc8260/flash.c index 645c67f..f7d8e71 100644 --- a/board/sbc8260/flash.c +++ b/board/sbc8260/flash.c @@ -254,11 +254,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long*)(info->start[l_sect]); while ((addr[0] & 0x80808080) != 0x80808080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -379,9 +379,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/scb9328/flash.c b/board/scb9328/flash.c index 00c660a..67fb617 100644 --- a/board/scb9328/flash.c +++ b/board/scb9328/flash.c @@ -99,10 +99,10 @@ static int flash_ready (ulong timeout) int ok = 1; ulong start;
- start = get_timer(0); + start = time_now_ms(); while ((flash_status_reg () & FLASH_CMD (CFI_INTEL_SR_READY)) != FLASH_CMD (CFI_INTEL_SR_READY)) { - if (get_timer(start) > timeout && timeout != 0) { + if (time_since_ms(start) > timeout && timeout != 0) { ok = 0; break; } diff --git a/board/shannon/flash.c b/board/shannon/flash.c index 179ec5f..11f9ccc 100644 --- a/board/shannon/flash.c +++ b/board/shannon/flash.c @@ -232,7 +232,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ @@ -254,7 +254,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; @@ -351,7 +351,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait until flash is ready */ chip1 = chip2 = 0; @@ -360,7 +360,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { chip1 = ERR | TMO; break; diff --git a/board/siemens/IAD210/flash.c b/board/siemens/IAD210/flash.c index c262e0f..96935c1 100644 --- a/board/siemens/IAD210/flash.c +++ b/board/siemens/IAD210/flash.c @@ -364,11 +364,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long*)(info->start[l_sect]); while ((addr[0] & 0x00800080) != 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -489,9 +489,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/siemens/SCM/flash.c b/board/siemens/SCM/flash.c index 4a6d538..184abdb 100644 --- a/board/siemens/SCM/flash.c +++ b/board/siemens/SCM/flash.c @@ -359,12 +359,12 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; while ((V_ULONG (info->start[l_sect]) & 0x00800080) != 0x00800080 || (V_ULONG (info->start[l_sect] + 4) & 0x00800080) != 0x00800080) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -477,10 +477,10 @@ static int write_dword (flash_info_t * info, ulong dest, unsigned char *pdata) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while (((V_ULONG (dest) & 0x00800080) != (ch & 0x00800080)) || ((V_ULONG (dest + 4) & 0x00800080) != (cl & 0x00800080))) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/siemens/SMN42/flash.c b/board/siemens/SMN42/flash.c index fc91574..d16e154 100644 --- a/board/siemens/SMN42/flash.c +++ b/board/siemens/SMN42/flash.c @@ -180,11 +180,11 @@ static int wait_for_DQ7_32(flash_info_t * info, int sect) volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]);
- start = get_timer(0); + start = time_now_ms(); last = start; while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return -1; } @@ -408,11 +408,11 @@ static int write_word(flash_info_t * info, ulong dest, ushort data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((*dest2 & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (*data2 & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080)) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { printf("WRITE_TOUT\n"); return (1); } diff --git a/board/sixnet/flash.c b/board/sixnet/flash.c index 2090802..4ccf063 100644 --- a/board/sixnet/flash.c +++ b/board/sixnet/flash.c @@ -503,7 +503,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("\n"); }
- start = get_timer(0); + start = time_now_ms(); last = start;
/* Start erase on unprotected sectors */ @@ -544,7 +544,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) udelay (1000);
while ((*addr & (FPW)0x00800080) != (FPW)0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n");
if (intel) { @@ -659,11 +659,11 @@ static int write_word_amd (flash_info_t *info, FPWV *dest, FPW data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
/* data polling for D7 */ while (res == 0 && (*dest & (FPW)0x00800080) != (data & (FPW)0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW)0x00F000F0; /* reset bank */ res = 1; } @@ -706,10 +706,10 @@ static int write_word_intel (flash_info_t *info, FPWV *dest, FPW data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
while (res == 0 && (*dest & (FPW)0x00800080) != (FPW)0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *dest = (FPW)0x00B000B0; /* Suspend program */ res = 1; } diff --git a/board/snmc/qs850/flash.c b/board/snmc/qs850/flash.c index b592285..200260d 100644 --- a/board/snmc/qs850/flash.c +++ b/board/snmc/qs850/flash.c @@ -474,13 +474,13 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (volatile FLASH_WORD_SIZE*)(info->start[l_sect]); while ((addr[0] & (0x00800080&FLASH_ID_MASK)) != (0x00800080&FLASH_ID_MASK) ) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -604,10 +604,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms();
while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/snmc/qs860t/flash.c b/board/snmc/qs860t/flash.c index e725115..63dedd7 100644 --- a/board/snmc/qs860t/flash.c +++ b/board/snmc/qs860t/flash.c @@ -685,12 +685,12 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (volatile FLASH_WORD_SIZE *) (info->start[l_sect]); while ((addr[0] & (0x00800080 & FLASH_ID_MASK)) != (0x00800080 & FLASH_ID_MASK)) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -1011,17 +1011,17 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms();
if(info->flash_id > FLASH_AMD_COMP) { while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } } else { while(!(addr[0] & 0x00800080)) { /* wait for error or finish */ - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); }
@@ -1076,12 +1076,12 @@ static int write_short (flash_info_t *info, ulong dest, ushort data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms();
if(info->flash_id < FLASH_AMD_COMP) { /* AMD stuff */ while ((*((vu_short *)dest) & 0x0080) != (data & 0x0080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } @@ -1089,7 +1089,7 @@ static int write_short (flash_info_t *info, ulong dest, ushort data) } else { /* intel stuff */ while(!(addr[0] & 0x0080)){ /* wait for error or finish */ - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); }
if( addr[0] & 0x003A) { /* check for error */ @@ -1103,7 +1103,7 @@ static int write_short (flash_info_t *info, ulong dest, ushort data) *addr = 0x00B0; *addr = 0x0070; while(!(addr[0] & 0x0080)){ /* wait for error or finish */ - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); } *addr = 0x00FF; } diff --git a/board/stx/stxgp3/flash.c b/board/stx/stxgp3/flash.c index 61c9602..4d40246 100644 --- a/board/stx/stxgp3/flash.c +++ b/board/stx/stxgp3/flash.c @@ -291,7 +291,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) vu_long *addr = (vu_long *)(info->start[sect]); asm("sync");
- last = start = get_timer (0); + last = start = time_now_ms();
/* Disable interrupts which might cause a timeout here */ flag = disable_interrupts(); @@ -329,7 +329,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) asm("sync"); return 1; } - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0xFFFFFFFF; /* reset bank */ asm("sync"); @@ -454,11 +454,11 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); flag = 0;
while (((csr = *addr) & 0x00800080) != 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { flag = 1; break; } @@ -500,9 +500,9 @@ static int clear_block_lock_bit(vu_long * addr) *addr = 0xd0d0d0d0; asm("sync");
- start = get_timer (0); + start = time_now_ms(); while((*addr & 0x00800080) != 0x00800080){ - if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now=time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout on clearing Block Lock Bit\n"); *addr = 0xFFFFFFFF; /* reset bank */ asm("sync"); diff --git a/board/svm_sc8xx/flash.c b/board/svm_sc8xx/flash.c index db1f21a..088f73d 100644 --- a/board/svm_sc8xx/flash.c +++ b/board/svm_sc8xx/flash.c @@ -548,7 +548,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long*)(info->start[l_sect]); #if defined (CONFIG_BOOT_8B) @@ -561,7 +561,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) # error CONFIG_BOOT_(size)B missing. #endif { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -707,10 +707,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms(); last = start; while( ( my_in_8((unsigned char *) (dest+i)) ) != ( data_ch[i] ) ) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT ) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT ) { return 1; } } @@ -727,10 +727,10 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) /* re-enable interrupts if necessary */ if (flag) enable_interrupts(); - start = get_timer (0); + start = time_now_ms(); last = start; while( ( my_in_be16((unsigned short *) (dest+(i*2))) ) != ( data_short[i] ) ) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT ) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT ) { return 1; } } @@ -747,9 +747,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/tb0229/flash.c b/board/tb0229/flash.c index 75d7769..42dc353 100644 --- a/board/tb0229/flash.c +++ b/board/tb0229/flash.c @@ -736,12 +736,12 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (volatile FLASH_WORD_SIZE *) (info->start[l_sect]); while ((addr[0] & (0x00800080 & FLASH_ID_MASK)) != (0x00800080 & FLASH_ID_MASK)) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -1070,13 +1070,13 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms();
if (info->flash_id < FLASH_AMD_COMP) {
while ((*((vu_long *) dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { printf ("timeout\n"); return (1); } @@ -1085,7 +1085,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) } else {
while (!(addr[0] & 0x00800080)) { /* wait for error or finish */ - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { printf ("timeout\n"); return (1); } @@ -1152,12 +1152,12 @@ static int write_short (flash_info_t * info, ulong dest, ushort data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms();
if (info->flash_id < FLASH_AMD_COMP) { /* AMD stuff */ while ((*((vu_short *) dest) & 0x0080) != (data & 0x0080)) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } @@ -1165,7 +1165,7 @@ static int write_short (flash_info_t * info, ulong dest, ushort data) } else { /* intel stuff */ while (!(addr[0] & 0x0080)) { /* wait for error or finish */ - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); }
@@ -1184,7 +1184,7 @@ static int write_short (flash_info_t * info, ulong dest, ushort data) *addr = 0x00B0; *addr = 0x0070; while (!(addr[0] & 0x0080)) { /* wait for error or finish */ - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); }
diff --git a/board/ti/omap1610inn/flash.c b/board/ti/omap1610inn/flash.c index 1b67d08..23da1cf 100644 --- a/board/ti/omap1610inn/flash.c +++ b/board/ti/omap1610inn/flash.c @@ -325,7 +325,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -334,7 +334,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -467,11 +467,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/ti/omap730p2/flash.c b/board/ti/omap730p2/flash.c index 185bc2d..d3ca222 100644 --- a/board/ti/omap730p2/flash.c +++ b/board/ti/omap730p2/flash.c @@ -308,7 +308,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
*addr = (FPW) 0x00500050;/* clear status register */ *addr = (FPW) 0x00200020;/* erase setup */ @@ -317,7 +317,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); /* suspend erase */ @@ -451,11 +451,11 @@ static int write_data (flash_info_t * info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/tqc/tqm5200/cam5200_flash.c b/board/tqc/tqm5200/cam5200_flash.c index 4c8922f..a21eb57 100644 --- a/board/tqc/tqm5200/cam5200_flash.c +++ b/board/tqc/tqm5200/cam5200_flash.c @@ -245,11 +245,11 @@ static int wait_for_DQ7_32(flash_info_t * info, int sect) volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]);
- start = get_timer(0); + start = time_now_ms(); last = start; while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return -1; } @@ -465,11 +465,11 @@ static int write_word(flash_info_t * info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080)) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) return (1); } } @@ -588,11 +588,11 @@ static int wait_for_DQ7_16(flash_info_t * info, int sect) volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]);
- start = get_timer(0); + start = time_now_ms(); last = start; while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x80008000) != (CONFIG_SYS_FLASH_WORD_SIZE) 0x80008000) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf("Timeout\n"); return -1; } @@ -712,11 +712,11 @@ static int write_word_16(flash_info_t * info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer(0); + start = time_now_ms(); while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x80008000) != (swap16(data2[i]) & (CONFIG_SYS_FLASH_WORD_SIZE) 0x80008000)) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/trab/cmd_trab.c b/board/trab/cmd_trab.c index 17890d9..0b055a3 100644 --- a/board/trab/cmd_trab.c +++ b/board/trab/cmd_trab.c @@ -201,7 +201,7 @@ int do_burn_in (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * avoid timestamp overflow problem after about 68 minutes of * udelay() time. */ - get_timer(0); + time_now_ms(); for (i = 0; i < BIF_MAX; i++) {
/* call test function */ @@ -715,7 +715,7 @@ static void led_blink (void)
/* blink LED. This function does not return! */ while (1) { - get_timer(0); + time_now_ms(); led_set (1); udelay (1000000 / LED_BLINK_FREQ / 2); led_set (0); @@ -860,7 +860,7 @@ int do_temp_log (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * reset timer to avoid timestamp overflow problem * after about 68 minutes of udelay() time. */ - get_timer(0); + time_now_ms(); sdelay (delay); }
diff --git a/board/trab/flash.c b/board/trab/flash.c index bde1f77..22cd576 100644 --- a/board/trab/flash.c +++ b/board/trab/flash.c @@ -238,7 +238,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) sect, info->start[sect]);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
if (info->protect[sect] == 0) { /* not protected */ vu_long *addr = (vu_long *) (info->start[sect]); @@ -258,7 +258,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { MEM_FLASH_ADDR1 = CMD_READ_ARRAY; chip1 = TMO; break; @@ -350,7 +350,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start= get_timer(0); + start= time_now_ms();
/* wait until flash is ready */ chip1 = chip2 = 0; @@ -358,7 +358,7 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) result = *addr;
/* check timeout */ - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { chip1 = ERR | TMO; break; } diff --git a/board/utx8245/flash.c b/board/utx8245/flash.c index aac8116..46eb9fd 100644 --- a/board/utx8245/flash.c +++ b/board/utx8245/flash.c @@ -376,14 +376,14 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (FLASH_WORD_SIZE *) (info->start[0] + ((info->start[l_sect] - info-> start[0]) << sh8b)); while ((addr[0] & (FLASH_WORD_SIZE) 0x00800080) != (FLASH_WORD_SIZE) 0x00800080) { - if ((now = get_timer (start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -521,10 +521,10 @@ static int write_word (flash_info_t * info, ulong dest, ulong data) enable_interrupts ();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((dest2[i << sh8b] & (FLASH_WORD_SIZE) 0x00800080) != (data2[i] & (FLASH_WORD_SIZE) 0x00800080)) { - if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/v37/flash.c b/board/v37/flash.c index 9b817ec..04ed244 100644 --- a/board/v37/flash.c +++ b/board/v37/flash.c @@ -391,11 +391,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_short *)(info->start[l_sect]); while ((addr[0] & 0x8080) != 0x8080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -522,9 +522,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_short *)dest) & 0x8080) != (sdata & 0x8080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } @@ -546,9 +546,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_short *)dest + 1) & 0x8080) != (sdata & 0x8080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/w7o/flash.c b/board/w7o/flash.c index 184661b..913af9b 100644 --- a/board/w7o/flash.c +++ b/board/w7o/flash.c @@ -496,7 +496,7 @@ static int flash_erase32(flash_info_t *info, int s_first, int s_last) else printf ("\n");
- start = get_timer (0); + start = time_now_ms(); last = start; /* Start erase on unprotected sectors */ for (sect = s_first; sect <= s_last; sect++) { @@ -520,7 +520,7 @@ static int flash_erase32(flash_info_t *info, int s_first, int s_last) udelay (1000);
while (((status = *addr) & 0x00800080) != 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = 0x00B000B0; /* suspend erase */ *addr = 0x00FF00FF; /* reset to read mode */ @@ -560,7 +560,7 @@ static int write_buff8(flash_info_t *info, uchar *src, ulong addr, ulong cnt) ulong start; int i, l, rc;
- start = get_timer (0); + start = time_now_ms();
wp = (addr & ~3); /* get lower word aligned address */ @@ -601,10 +601,10 @@ static int write_buff8(flash_info_t *info, uchar *src, ulong addr, ulong cnt) } wp += 4; cnt -= 4; - if (get_timer(start) > 1000) { /* every second */ + if (time_since_ms(start) > 1000) { /* every second */ WATCHDOG_RESET(); putc ('.'); - start = get_timer(0); + start = time_now_ms(); } }
@@ -634,7 +634,7 @@ static int write_buff32 (flash_info_t *info, uchar *src, ulong addr, ulong cnt) int i, l, rc; ulong start;
- start = get_timer (0); + start = time_now_ms();
if (info->flash_id == FLASH_UNKNOWN) { return 4; @@ -678,9 +678,9 @@ static int write_buff32 (flash_info_t *info, uchar *src, ulong addr, ulong cnt) } wp += FLASH_WIDTH; cnt -= FLASH_WIDTH; - if (get_timer(start) > 990) { /* every second */ + if (time_since_ms(start) > 990) { /* every second */ putc ('.'); - start = get_timer(0); + start = time_now_ms(); } }
@@ -783,11 +783,11 @@ static int write_word32(flash_info_t *info, ulong dest, ulong data) if (flag) enable_interrupts();
- start = get_timer (0); + start = time_now_ms();
while (((status = *addr) & 0x00800080) != 0x00800080) { WATCHDOG_RESET(); - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/w7o/fpga.c b/board/w7o/fpga.c index 100bce4..f6d39bb 100644 --- a/board/w7o/fpga.c +++ b/board/w7o/fpga.c @@ -84,12 +84,12 @@ fpgaDownload(unsigned char *saddr, out32(PPC405GP_GPIO0_OR, grego);
/* Setup timeout timer */ - start = get_timer(0); + start = time_now_ms();
/* Wait for FPGA init line */ while(in32(PPC405GP_GPIO0_IR) & GPIO_XCV_INIT) { /* Wait INIT line low */ /* Check for timeout - 100us max, so use 3ms */ - if (get_timer(start) > 3) { + if (time_since_ms(start) > 3) { printf(" failed to start init.\n"); log_warn(ERR_XINIT0); /* Don't halt */
@@ -106,7 +106,7 @@ fpgaDownload(unsigned char *saddr, while(!(in32(PPC405GP_GPIO0_IR) & GPIO_XCV_INIT)) { /* Wait for INIT hi */
/* Check for timeout */ - if (get_timer(start) > 3) { + if (time_since_ms(start) > 3) { printf(" failed to exit init.\n"); log_warn(ERR_XINIT1);
@@ -177,13 +177,13 @@ fpgaDownload(unsigned char *saddr, }
/* Setup timer */ - start = get_timer(0); + start = time_now_ms();
/* Wait for FPGA end of programming period . */ while(!(in32(PPC405GP_GPIO0_IR) & GPIO_XCV_DONE)) { /* Test DONE low */
/* Check for timeout */ - if (get_timer(start) > 3) { + if (time_since_ms(start) > 3) { printf(" done failed to come high.\n"); log_warn(ERR_XDONE1);
diff --git a/board/westel/amx860/flash.c b/board/westel/amx860/flash.c index fe8bce4..f39b541 100644 --- a/board/westel/amx860/flash.c +++ b/board/westel/amx860/flash.c @@ -499,11 +499,11 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) if (l_sect < 0) goto DONE;
- start = get_timer (0); + start = time_now_ms(); last = start; addr = (vu_long*)(info->start[l_sect]); while ((addr[0] & 0x00800080) != 0x00800080) { - if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if ((now = time_since_ms(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); return 1; } @@ -624,9 +624,9 @@ static int write_word (flash_info_t *info, ulong dest, ulong data) enable_interrupts();
/* data polling for D7 */ - start = get_timer (0); + start = time_now_ms(); while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { return (1); } } diff --git a/board/xaeniax/flash.c b/board/xaeniax/flash.c index 6cb0aca..8201bfb 100644 --- a/board/xaeniax/flash.c +++ b/board/xaeniax/flash.c @@ -266,14 +266,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -404,11 +404,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } diff --git a/board/xm250/flash.c b/board/xm250/flash.c index e825aba..53fb67c 100644 --- a/board/xm250/flash.c +++ b/board/xm250/flash.c @@ -295,14 +295,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -433,11 +433,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); } @@ -480,10 +480,10 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) *addr = INTEL_CONFIRM; /* clear */ }
- start = get_timer(0); + start = time_now_ms();
while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf("Flash lock bit operation timed out\n"); rc = 1; break; @@ -509,13 +509,13 @@ int flash_real_protect(flash_info_t *info, long sector, int prot) { if (info->protect[i]) { - start = get_timer(0); + start = time_now_ms(); addr = (vu_long *)(info->start[i]); *addr = INTEL_LOCKBIT; /* Sector lock bit */ *addr = INTEL_PROTECT; /* set */ while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) { - if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) + if (time_since_ms(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) { printf("Flash lock bit operation timed out\n"); rc = 1; diff --git a/board/zeus/zeus.c b/board/zeus/zeus.c index 18cb85f..d92d717 100644 --- a/board/zeus/zeus.c +++ b/board/zeus/zeus.c @@ -97,7 +97,7 @@ int misc_init_r(void) /* * Get current time */ - start_time = get_timer(0); + start_time = time_now_ms();
/* * FLASH stuff... @@ -337,7 +337,7 @@ int do_chkreset(cmd_tbl_t* cmdtp, int flag, int argc, char * const argv[]) printf("Waiting for SW-Reset button to be released.");
while (1) { - delta = get_timer(start_time); + delta = time_since_ms(start_time); if (!sw_reset_pressed()) break;
diff --git a/board/zylonite/flash.c b/board/zylonite/flash.c index 3ee0ab8..ee425b0 100644 --- a/board/zylonite/flash.c +++ b/board/zylonite/flash.c @@ -269,14 +269,14 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
*addr = (FPW) 0x00500050; /* clear status register */ *addr = (FPW) 0x00200020; /* erase setup */ *addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_ERASE_TOUT) { printf ("Timeout\n"); *addr = (FPW) 0x00B000B0; /* suspend erase */ *addr = (FPW) 0x00FF00FF; /* reset to read mode */ @@ -407,11 +407,11 @@ static int write_data (flash_info_t *info, ulong dest, FPW data) *addr = data;
/* arm simple, non interrupt dependent timer */ - start = get_timer(0); + start = time_now_ms();
/* wait while polling the status register */ while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) { - if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { + if (time_since_ms(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { *addr = (FPW) 0x00FF00FF; /* restore read mode */ return (1); }

Signed-off-by: Graeme Russ graeme.russ@gmail.com --- arch/blackfin/cpu/jtag-console.c | 4 ++-- arch/microblaze/lib/time.c | 4 ++-- arch/nios2/cpu/epcs.c | 12 ++++++------ arch/powerpc/cpu/mpc824x/drivers/i2c/i2c.c | 8 ++++---- arch/powerpc/cpu/mpc8260/ether_fcc.c | 12 ++++++------ 5 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/arch/blackfin/cpu/jtag-console.c b/arch/blackfin/cpu/jtag-console.c index e0f2975..97ff1de 100644 --- a/arch/blackfin/cpu/jtag-console.c +++ b/arch/blackfin/cpu/jtag-console.c @@ -48,11 +48,11 @@ static inline uint32_t bfin_read_emudat(void) static bool jtag_write_emudat(uint32_t emudat) { static bool overflowed = false; - ulong timeout = get_timer(0) + CONFIG_JTAG_CONSOLE_TIMEOUT; + ulong start = time_now_ms(); while (bfin_read_DBGSTAT() & 0x1) { if (overflowed) return overflowed; - if (timeout < get_timer(0)) + if (time_since_ms(start) >= CONFIG_JTAG_CONSOLE_TIMEOUT) overflowed = true; } overflowed = false; diff --git a/arch/microblaze/lib/time.c b/arch/microblaze/lib/time.c index da016a0..e5ed3bf 100644 --- a/arch/microblaze/lib/time.c +++ b/arch/microblaze/lib/time.c @@ -30,8 +30,8 @@ void __udelay (unsigned long usec) { int i; - i = get_timer (0); - while ((get_timer (0) - i) < (usec / 1000)) ; + i = time_now_ms(); + while (time_since_ms(i) < (usec / 1000)) ; } #else void __udelay (unsigned long usec) diff --git a/arch/nios2/cpu/epcs.c b/arch/nios2/cpu/epcs.c index 2369431..90e5b99 100644 --- a/arch/nios2/cpu/epcs.c +++ b/arch/nios2/cpu/epcs.c @@ -88,9 +88,9 @@ static int epcs_cs (int assert) writel (tmp | NIOS_SPI_SSO, &epcs->control); } else { /* Let all bits shift out */ - start = get_timer (0); + start = time_now_ms(); while ((readl (&epcs->status) & NIOS_SPI_TMT) == 0) - if (get_timer (start) > EPCS_TIMEOUT) + if (time_since_ms(start) > EPCS_TIMEOUT) return (-1); tmp = readl (&epcs->control); writel (tmp & ~NIOS_SPI_SSO, &epcs->control); @@ -102,9 +102,9 @@ static int epcs_tx (unsigned char c) { ulong start;
- start = get_timer (0); + start = time_now_ms(); while ((readl (&epcs->status) & NIOS_SPI_TRDY) == 0) - if (get_timer (start) > EPCS_TIMEOUT) + if (time_since_ms(start) > EPCS_TIMEOUT) return (-1); writel (c, &epcs->txdata); return (0); @@ -114,9 +114,9 @@ static int epcs_rx (void) { ulong start;
- start = get_timer (0); + start = time_now_ms(); while ((readl (&epcs->status) & NIOS_SPI_RRDY) == 0) - if (get_timer (start) > EPCS_TIMEOUT) + if (time_since_ms(start) > EPCS_TIMEOUT) return (-1); return (readl (&epcs->rxdata)); } diff --git a/arch/powerpc/cpu/mpc824x/drivers/i2c/i2c.c b/arch/powerpc/cpu/mpc824x/drivers/i2c/i2c.c index 637ae4c..7822811 100644 --- a/arch/powerpc/cpu/mpc824x/drivers/i2c/i2c.c +++ b/arch/powerpc/cpu/mpc824x/drivers/i2c/i2c.c @@ -97,10 +97,10 @@ void i2c_init (int speed, int slaveadd)
static __inline__ int i2c_wait4bus (void) { - ulong timeval = get_timer (0); + ulong timeval = time_now_ms();
while (readl (I2CCSR) & MPC107_CSR_MBB) - if (get_timer (timeval) > TIMEOUT) + if (time_since_ms(timeval) > TIMEOUT) return -1;
return 0; @@ -109,7 +109,7 @@ static __inline__ int i2c_wait4bus (void) static __inline__ int i2c_wait (int write) { u32 csr; - ulong timeval = get_timer (0); + ulong timeval = time_now_ms();
do { csr = readl (I2CCSR); @@ -141,7 +141,7 @@ static __inline__ int i2c_wait (int write) }
return 0; - } while (get_timer (timeval) < TIMEOUT); + } while (time_since_ms(timeval) < TIMEOUT);
#ifdef I2CDBG printf ("i2c_wait: timed out\n"); diff --git a/arch/powerpc/cpu/mpc8260/ether_fcc.c b/arch/powerpc/cpu/mpc8260/ether_fcc.c index c82958d..89703d9 100644 --- a/arch/powerpc/cpu/mpc8260/ether_fcc.c +++ b/arch/powerpc/cpu/mpc8260/ether_fcc.c @@ -887,7 +887,7 @@ eth_loopback_test (void) */
clear_ctrlc (); - runtime = get_timer (0); + runtime = time_now_ms();
do { nclosed = 0; @@ -931,7 +931,7 @@ eth_loopback_test (void) __asm__ __volatile__ ("eieio"); } while (cp->cp_cpcr & CPM_CR_FLG);
- ecp->clstime = get_timer (0); + ecp->clstime = time_now_ms(); ecp->state = Closing; } /* fall through ... */ @@ -990,7 +990,7 @@ eth_loopback_test (void) }
if (ecp->state == Closing) - ecp->clstime = get_timer (0); + ecp->clstime = time_now_ms();
/* make it ready again */ bdp->cbd_sc |= BD_ENET_TX_READY; @@ -1092,7 +1092,7 @@ eth_loopback_test (void) }
if (ecp->state == Closing) - ecp->clstime = get_timer (0); + ecp->clstime = time_now_ms();
/* make it empty again */ bdp->cbd_sc |= BD_ENET_RX_EMPTY; @@ -1106,7 +1106,7 @@ eth_loopback_test (void) * waited long enough */
- if (get_timer (ecp->clstime) >= ELBT_CLSWAIT) { + if (time_since_ms(ecp->clstime) >= ELBT_CLSWAIT) { /* write GFMR: disable tx/rx */ fcp->fcc_gfmr &= \ ~(FCC_GFMR_ENT | FCC_GFMR_ENR); @@ -1123,7 +1123,7 @@ eth_loopback_test (void)
} while (nclosed < (FCC_END_LOOP - FCC_START_LOOP + 1));
- runtime = get_timer (runtime); + runtime = time_max_since_ms(runtime); if (runtime <= ELBT_CLSWAIT) { printf ("Whoops! somehow elapsed time (%ld) is wrong (<= %d)\n", runtime, ELBT_CLSWAIT);

Hi Graeme,
On Tue, Jun 28, 2011 at 4:41 AM, Graeme Russ graeme.russ@gmail.com wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
arch/blackfin/cpu/jtag-console.c | 4 ++-- arch/microblaze/lib/time.c | 4 ++-- arch/nios2/cpu/epcs.c | 12 ++++++------ arch/powerpc/cpu/mpc824x/drivers/i2c/i2c.c | 8 ++++---- arch/powerpc/cpu/mpc8260/ether_fcc.c | 12 ++++++------ 5 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/arch/blackfin/cpu/jtag-console.c b/arch/blackfin/cpu/jtag-console.c index e0f2975..97ff1de 100644 --- a/arch/blackfin/cpu/jtag-console.c +++ b/arch/blackfin/cpu/jtag-console.c @@ -48,11 +48,11 @@ static inline uint32_t bfin_read_emudat(void) static bool jtag_write_emudat(uint32_t emudat) { static bool overflowed = false;
- ulong timeout = get_timer(0) + CONFIG_JTAG_CONSOLE_TIMEOUT;
- ulong start = time_now_ms();
while (bfin_read_DBGSTAT() & 0x1) { if (overflowed) return overflowed;
- if (timeout < get_timer(0))
- if (time_since_ms(start) >= CONFIG_JTAG_CONSOLE_TIMEOUT)
overflowed = true; } overflowed = false;
Here I think I have found a use of future time. It is true what they say (or should say) that there is every kind of timeout in U-Boot.
Regards, Simon

Hi Simon,
On Wed, Jun 29, 2011 at 2:45 PM, Simon Glass sjg@chromium.org wrote:
Hi Graeme,
On Tue, Jun 28, 2011 at 4:41 AM, Graeme Russ graeme.russ@gmail.com wrote:
Signed-off-by: Graeme Russ graeme.russ@gmail.com
arch/blackfin/cpu/jtag-console.c | 4 ++-- arch/microblaze/lib/time.c | 4 ++-- arch/nios2/cpu/epcs.c | 12 ++++++------ arch/powerpc/cpu/mpc824x/drivers/i2c/i2c.c | 8 ++++---- arch/powerpc/cpu/mpc8260/ether_fcc.c | 12 ++++++------ 5 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/arch/blackfin/cpu/jtag-console.c b/arch/blackfin/cpu/jtag-console.c index e0f2975..97ff1de 100644 --- a/arch/blackfin/cpu/jtag-console.c +++ b/arch/blackfin/cpu/jtag-console.c @@ -48,11 +48,11 @@ static inline uint32_t bfin_read_emudat(void) static bool jtag_write_emudat(uint32_t emudat) { static bool overflowed = false;
- ulong timeout = get_timer(0) + CONFIG_JTAG_CONSOLE_TIMEOUT;
- ulong start = time_now_ms();
while (bfin_read_DBGSTAT() & 0x1) { if (overflowed) return overflowed;
- if (timeout < get_timer(0))
- if (time_since_ms(start) >= CONFIG_JTAG_CONSOLE_TIMEOUT)
overflowed = true; } overflowed = false;
Here I think I have found a use of future time. It is true what they say (or should say) that there is every kind of timeout in U-Boot.
I personally think that this particular use-case of the timer API is ugly, but I was not out to change any symantics, just do a blind translation from the old API to the new API
Hopefully, this will highlight a few dodgy use cases (which I am willing to apply fixes for as and when others suggest them)
Regards,
Graeme

On Wednesday, June 29, 2011 00:51:50 Graeme Russ wrote:
On Wed, Jun 29, 2011 at 2:45 PM, Simon Glass wrote:
On Tue, Jun 28, 2011 at 4:41 AM, Graeme Russ wrote:
--- a/arch/blackfin/cpu/jtag-console.c +++ b/arch/blackfin/cpu/jtag-console.c
ulong timeout = get_timer(0) + CONFIG_JTAG_CONSOLE_TIMEOUT;
ulong start = time_now_ms(); while (bfin_read_DBGSTAT() & 0x1) { if (overflowed) return overflowed;
if (timeout < get_timer(0))
if (time_since_ms(start) >= CONFIG_JTAG_CONSOLE_TIMEOUT) overflowed = true; }
Here I think I have found a use of future time. It is true what they say (or should say) that there is every kind of timeout in U-Boot.
I personally think that this particular use-case of the timer API is ugly, but I was not out to change any symantics, just do a blind translation from the old API to the new API
Hopefully, this will highlight a few dodgy use cases (which I am willing to apply fixes for as and when others suggest them)
i wrote this long before i really understood the timer api. after all, even now, there is 0 documentation on the API in the u-boot tree.
should be easy to change the two lines to use the API as designed. -mike

On Wednesday, June 29, 2011 01:15:53 Mike Frysinger wrote:
i wrote this long before i really understood the timer api. after all, even now, there is 0 documentation on the API in the u-boot tree.
unless i missed something, even this patchset doesnt include a new doc/README.timer (or similar) file, nor does the header include any comments above the func prototypes, nor comments above the func definitions in lib/time.c ... -mike

Hi Mike,
On Wed, Jun 29, 2011 at 3:26 PM, Mike Frysinger vapier@gentoo.org wrote:
On Wednesday, June 29, 2011 01:15:53 Mike Frysinger wrote:
i wrote this long before i really understood the timer api. after all, even now, there is 0 documentation on the API in the u-boot tree.
unless i missed something, even this patchset doesnt include a new doc/README.timer (or similar) file, nor does the header include any comments above the func prototypes, nor comments above the func definitions in lib/time.c ...
Correct - I am going on holidays on Friday and really needed to get something in the pipeline for discussion - The wiki has a detailed writeup of how the API works - I'll translate that into a README and code comments
Regards,
Graeme

Hi All,
[snip]
Graeme Russ (16): [Timer]Fix misuse of ARM *timer_masked() functions outside arch/arm [Timer]Remove calls to set_timer outside arch/ [Timer]Remove calls to set_timer in arch/ [Timer]Allow reset_timer() only for Nios2 [Timer]Remove reset_timer() for non-Nios2 arches [Timer]Fix at91rm9200/spi.c timer usage [Timer]Remove reset_timer_masked() [Timer]Create new userland timer API [Timer]Replace get_timer() usage in drivers/block/ [Timer]Replace get_timer() usage in driver/mtd and driver/block [Timer]Remove reset_timer() completely [Timer]Replace get_timer() usage in drivers/ [Timer]Replace get_timer() usage in net/ [Timer]Replace get_timer() usage in common/ [Timer]Replace get_timer() usage in board/ [Timer]Replace get_timer() usage in arch/
Patch 15 ([Timer]Replace get_timer() usage in board/) didn't make it through (too big) - I'll have to split it up (rather that that putting a lone patch on the wiki)
Regards,
Graeme

for future reference, could we use the "foo: " style in subjects instead of "[foo]". git likes to eat "[...]" automatically and i find it hard to quickly parse. it's an abomination on my eyes.
-[PATCH v1 (WIP) 00/16] [Timer]API Rewrite +[PATCH/WIP 00/16] timer: API Rewrite -mike

Hi Mike,
On Wed, Jun 29, 2011 at 3:08 PM, Mike Frysinger vapier@gentoo.org wrote:
for future reference, could we use the "foo: " style in subjects instead of "[foo]". git likes to eat "[...]" automatically and i find it hard to quickly parse. it's an abomination on my eyes.
-[PATCH v1 (WIP) 00/16] [Timer]API Rewrite +[PATCH/WIP 00/16] timer: API Rewrite -mike
Will do
Regards,
Graeme

On 28/06/11 21:40, Graeme Russ wrote:
The following series is a work-in-progress revamp of the timer API. The aim is to create a new userland API consisting of the following functions (along with a few arch level support functions):
[snip]
Graeme Russ (16): [Timer]Fix misuse of ARM *timer_masked() functions outside arch/arm [Timer]Remove calls to set_timer outside arch/ [Timer]Remove calls to set_timer in arch/ [Timer]Allow reset_timer() only for Nios2 [Timer]Remove reset_timer() for non-Nios2 arches [Timer]Fix at91rm9200/spi.c timer usage [Timer]Remove reset_timer_masked() [Timer]Create new userland timer API [Timer]Replace get_timer() usage in drivers/block/ [Timer]Replace get_timer() usage in driver/mtd and driver/block [Timer]Remove reset_timer() completely [Timer]Replace get_timer() usage in drivers/ [Timer]Replace get_timer() usage in net/ [Timer]Replace get_timer() usage in common/ [Timer]Replace get_timer() usage in board/ [Timer]Replace get_timer() usage in arch/
OK, I'm back from holidays and there has only been a few minor comments so far. I take that as either a) the work is generally OK as is and there are no major objections or b) everyone is too busy to care ;) - I'll work with option a) and rebase/re-spin this series. Now although the board/ patch was too big for the list, it looks like it hit patchwork OK, so I will leave that as is.
Wolfgang, a few quick question for you:
1) I understand that you would like each individual patch in the series to have the in-reply-to header set to the individual parent patch and not have the whole series in-reply-to the first (00/16) patch? (It will be a bit of a PITA to set in-reply-to for 16 individual patches, but I will do if that is the way you want it)
2) I will be changing the name of the series to a) drop the WIP and b) change "[Timer]" to "Timer:" as per Mike Frysinger's comment - Does this pose any issue to you provided the in-reply-to remains intact
3) The board/ series is a 'Big Patch' but it made it to Patchwork - Are you happy for me to leave it as-is? As it's in patchwork, can I forget about putting it on the Big Patches wiki?
4) I'm thinking about creating an Timer branch in my x86 repository and pushing the whole series through there - From there I can keep it rebased and simply issue a pull request when it's finished (and testers can just pull it if they want). Does this sound like a good plan?
5) Most importantly - Have you had a chance to look at this series? Is it to your liking?
Regards,
Graeme

Hi Greame,
Le 08/07/2011 02:25, Graeme Russ a écrit :
- I understand that you would like each individual patch in the series to
have the in-reply-to header set to the individual parent patch and not have the whole series in-reply-to the first (00/16) patch? (It will be a bit of a PITA to set in-reply-to for 16 individual patches, but I will do if that is the way you want it)
Not sure what you mean here, but if it is "make patch i/N of a series have be a reply-to patch i/N of the previous series, I agree that it would be a PITA which is not worth the effort considerong the benefit.
(the only benefit I can see is to be able to find back the previous series and e.g. check that comments to patch i/N-1 were taken into account by patch i/N. This can be accomplished more easily by having series N-1 and N in a local branch and doing a git diff between commits i/N and i/N-1)
Amicalement,

Dear Graeme Russ,
In message 1309261269-4363-1-git-send-email-graeme.russ@gmail.com you wrote:
The following series is a work-in-progress revamp of the timer API. The aim is to create a new userland API consisting of the following functions (along with a few arch level support functions):
I have to apologize for not commenting on all of this for such a long time. There are a number of reeasons for this silence - lack of available time being one of them (and probably the most pressing one), but I also needed some time to lean back and think through all of this.
One thing I always wanted to do in the previous discussion was to check what other projects (like Linux, barebox, etc.) are doing in this area. I think it is worth reading the Linux Documentation/timers/highres.txt document, especially the sections about John Stultz's Generic Time Of Day (GTOD) framework, please the documents linked there (i. e. the OLS slides [the link in Documentation/timers/highres.txt is stale; use http://www.kernel.org/pub/linux/kernel/people/tglx/hrtimers/ols2006-hrtimers... instead] and the paper "We Are Not Getting Any Younger: A New Approach to Time and Timers" by J. Stultz et al. in http://www.linuxsymposium.org/2005/linuxsymposium_procv1.pdf p. 219ff).
Having this still in mind, I took a look across the fence to what barebox is doing. Guess what? From "common/clock.c":
* clock.c - generic clocksource implementation * * This file contains the clocksource implementation from the Linux * kernel originally by John Stultz
OK. Message received.
What I'm asking myself (and now you) is: Should we really re-invent the wheel again?
Regarding the function names:
u32 time_now_ms(void); u32 time_since_ms(u32 from, u32 to); u32 time_max_since_ms(u32 from, u32 to);
I don't like these. They appear wrong to me, and they are not in sync with the wiki page either.
First, I would very much like to get rid of this "_ms" thing. We should rather make very clear in the documentation which unit the time services are based on, and use this consequently. Only functions using a different unit should make this clean in their names.
Second, I don't feel well with "time_now()" - what is this, what does it do? Does it set or get a time? The "get_time()" suggestion we discussed earlier feels still much better to me (as it clearly says which operation the function performs). Or we could even follow the example of the Unix system call time(2) and just use "time()".
The signature of time_since(from, to) is broken. For "time since" it seems logically to expect a single argument only: time_since(when). The wiki page still lists this function as time_delta() which seems way more logical to me [although I have to admit that I don;t understand what the "delta_type" argument might be.
Third: all this time_*_max(), ..._min() and ...raw() stuff. Aren't we over-engineering here? We have been successfully writing U-Boot code for 11 years now, and never needed these before. Neither does Linux need any of those, nor every other project I'm aware of. Come on, let's keep the code small and efficient and do without these bells and whistles. Quote Antoine de Saint-Exupery: "Perfection is reached, not when there is no longer anything to add, but when there is no longer anything to take away."
This current patch series migrates the users of the existing timer API consisting of get_timer() and reset_timer() to the new API while still retaining the arch specific framework in the background.
I feel bad that you already have spent so much work, and only now I come and call everything into question again. Sorry.
Best regards,
Wolfgang Denk

Hi Wolfgang,
On 12/07/11 07:56, Wolfgang Denk wrote:
Dear Graeme Russ,
In message 1309261269-4363-1-git-send-email-graeme.russ@gmail.com you wrote:
The following series is a work-in-progress revamp of the timer API. The aim is to create a new userland API consisting of the following functions (along with a few arch level support functions):
I have to apologize for not commenting on all of this for such a long time. There are a number of reeasons for this silence - lack of available time being one of them (and probably the most pressing one), but I also needed some time to lean back and think through all of this.
I understand - I also would rather spend more time on this and get it right now rather than going back and fixing it again
One thing I always wanted to do in the previous discussion was to check what other projects (like Linux, barebox, etc.) are doing in this area. I think it is worth reading the Linux Documentation/timers/highres.txt document, especially the sections about John Stultz's Generic Time Of Day (GTOD) framework, please the documents linked there (i. e. the OLS slides [the link in Documentation/timers/highres.txt is stale; use http://www.kernel.org/pub/linux/kernel/people/tglx/hrtimers/ols2006-hrtimers... instead] and the paper "We Are Not Getting Any Younger: A New Approach to Time and Timers" by J. Stultz et al. in http://www.linuxsymposium.org/2005/linuxsymposium_procv1.pdf p. 219ff).
Will do
Having this still in mind, I took a look across the fence to what barebox is doing. Guess what? From "common/clock.c":
* clock.c - generic clocksource implementation * * This file contains the clocksource implementation from the Linux * kernel originally by John Stultz
OK. Message received.
What I'm asking myself (and now you) is: Should we really re-invent the wheel again?
Regarding the function names:
u32 time_now_ms(void); u32 time_since_ms(u32 from, u32 to); u32 time_max_since_ms(u32 from, u32 to);
I don't like these. They appear wrong to me, and they are not in sync with the wiki page either.
I know - there was some discussion about these names and they were in a little bit of flux (hence WIP). I was looking to get some community clarity on this first before updating the wiki. In hindsight, I'm glad I didn't update the wiki as it looks like there may be a better approach anyway
First, I would very much like to get rid of this "_ms" thing. We should rather make very clear in the documentation which unit the time services are based on, and use this consequently. Only functions using a different unit should make this clean in their names.
Ideally, I think this should be microseconds (a lot happens in a microsecond on modern platforms, and a millisecond can be an eternity)
Second, I don't feel well with "time_now()" - what is this, what does it do? Does it set or get a time? The "get_time()" suggestion we discussed earlier feels still much better to me (as it clearly says which operation the function performs). Or we could even follow the example of the Unix system call time(2) and just use "time()".
Well time_ was the namespace for the new API and now is, well, now ;)
The signature of time_since(from, to) is broken. For "time since" it seems logically to expect a single argument only: time_since(when). The wiki page still lists this function as time_delta() which seems way more logical to me [although I have to admit that I don;t understand what the "delta_type" argument might be.
It was a refinement of your suggestion that sometimes we want to know that at least a specific period of time has passed (timeouts) and sometimes we want to know what the maximum amount of time that has passed is (profiling)
Third: all this time_*_max(), ..._min() and ...raw() stuff. Aren't we over-engineering here? We have been successfully writing U-Boot code for 11 years now, and never needed these before. Neither does Linux
Part of the problem came from the realisation that some architectures have really bad timer resolution (Nios2 in particular). In an ideal world, I think a uniform microsecond timer (millisecond is to coarse to cater for all needs such as udelay and profiling) would be sufficient to not need these functions but while ever we have platforms with 'poor' timers, I think you may find these functions have a place.
need any of those, nor every other project I'm aware of. Come on, let's keep the code small and efficient and do without these bells and whistles. Quote Antoine de Saint-Exupery: "Perfection is reached, not when there is no longer anything to add, but when there is no longer anything to take away."
As stated - This started from a suggestion made by yourself (albeit one you did not think was apparently necessary). The idea of the separate functions (rather than a parameter to a single function) was that if the functions were not used, they would be optimised out.
This current patch series migrates the users of the existing timer API consisting of get_timer() and reset_timer() to the new API while still retaining the arch specific framework in the background.
I feel bad that you already have spent so much work, and only now I come and call everything into question again. Sorry.
That's OK - Thanks for the feedback.
What would you like me to do with the clean-up patches that you have already ack'd which do not relate directly to the new API? Should I mark the current series as Rejected in patchwork and create a brand new smaller series which only has those specific patches?
Regards,
Graeme

Dear Graeme,
I'm trying to summarize your last 3 postings here.
In message 4E1B7E0C.8000900@gmail.com you wrote:
First, I would very much like to get rid of this "_ms" thing. We should rather make very clear in the documentation which unit the time services are based on, and use this consequently. Only functions using a different unit should make this clean in their names.
Ideally, I think this should be microseconds (a lot happens in a microsecond on modern platforms, and a millisecond can be an eternity)
Then we might as well follow the example of the Linux generic TOD framework and use nanoseconds instead - we will need u64 data types anyway when going for microseconds, so we can just follow their example.
Third: all this time_*_max(), ..._min() and ...raw() stuff. Aren't we over-engineering here? We have been successfully writing U-Boot code for 11 years now, and never needed these before. Neither does Linux
Part of the problem came from the realisation that some architectures have really bad timer resolution (Nios2 in particular). In an ideal world, I think a uniform microsecond timer (millisecond is to coarse to cater for all needs such as udelay and profiling) would be sufficient to not need these functions but while ever we have platforms with 'poor' timers, I think you may find these functions have a place.
No, I disagree here. We should not clutter up generic code with things that are only needed for a single (unusually restricted) architecture. Instead, we should try to come up with a design that hides such details in architecture specific code.
As stated - This started from a suggestion made by yourself (albeit one you did not think was apparently necessary). The idea of the separate functions (rather than a parameter to a single function) was that if the functions were not used, they would be optimised out.
You know how things go: if you offer the users a set of 20 functions so they can chose the one or two that fit their purposes best, they will end up with using all 20 of them, especially when diffferent parts of the code get maintained by different people with different preferences. Approaches like that always get out of hand quickly.
We don't have any such stuff now, and U-Boot is working fine. Let's keep it with that, or make it even more simple. But not the other way.
What would you like me to do with the clean-up patches that you have already ack'd which do not relate directly to the new API? Should I mark the current series as Rejected in patchwork and create a brand new smaller series which only has those specific patches?
I suggest you create a new patch series from the independent clean-up patches and submit this as normal patches (i. e. without the WIP / RFC part). This would already be a great improvement, I think. Thanks a lot for the efforts!
In message 4E1B88EE.9040104@gmail.com you wrote:
- Looking at the low-level framework described in ols2006-hrtimers.pdf
(Linux API), we are looking at implementing the same thing - An architecture specific free running, high speed, high resolution, high accuracy hardware counter/timer and a low speed interrupt which translates the hardware counter/timer to a common API. In this respect, we are not re-inventing that wheel at all
Indeed. We should also avoid re-inventing the algorithms, and eventually re-implementing the code. In any case, I think it would be great to use a compatible API so we don;t have to change too many things when adapting code from Linux etc.
- The rest of the Linux API is like hitting a thumb-tack with a
sledgehammer - Timer Queues, NTP, Callbacks, Scheduling etc, etc, etc. We only want to do two things:
Right. Linux is a full-blown OS with a lot of needs we don't have in U-Boot.
- Monitor timeouts
- Calculate code execution time (and even then, not everyone all the time)
Actrually we need just timestamps.
All the rest (like delays, timeouts, executin times etc.) can be derived from that.
- The Linux API is nanosecond resolution. We are hard pressed to get the
average hardware to support microsecond resolution
On the other hand, it makes little difference to the code wether we use microseconds or nanoseconds. It's just slightly different values in the u64 variables.
- The Linux API includes usage of 'clock events' - These are timer
interrupts driven by programmable hardware and relieve the stress on the timer scheduler keeping track of every single timer - Overkill for a boot loader
Agreed. Well, partially. We should still follow the example of keeping the generic code clean of architecture / timer specific code. This should be implemented in the respective arechitecture specific code.
- The Linux API includes 'Time of Day' (Wall Time) - Again, I don't think
we really need this in a boot loader (we have an RTC API we can use if we want to get the current Date and Time).
We could also say this is all we need. If we have a working high precision TOD timestamp, we can derive all other things we need from that.
So, all we need is a fixed resolution free running timer we can use to do simple (one at a time) timing operations. No callbacks, no scheduling, to 'Wall Time', no 'Clock Events', no NTP etc. The Linux API is 'Too Big'
I never proposed to adapt all of it.
My suggestion was to pick the parts that fit, and use them. especially, use the same API (like going for nanoseconds as unit of time), and use their algorithms (and ideally also their code) to solve the problems we have to deal with.
I don't think we are re-inventing the wheel with our underlying concept -
Not with the concept, but with the code.
In message 4E1BAED7.3070009@gmail.com you wrote:
I think I can safely say that:
a) We do not want to inherit the code from Linux. It's good code clean code, but it is just way too much for what we need. It handles registering and unregistering clock sources, change clock source 'rating' (what ever that is) and relies heavily on quite heavy (for U-Boot) struct's (which may need to be carted around in Global Data)
See above. You are right, simply copying code unreflected makes no sense. But we should use it as example for API, algorithms, and code.
b) Barebox doesn't really inherit that much from Linux anyway
Right, they did what I proposed, and copied only a part of it, i. e. the generic TOD framework.
Even if we assume that they made a good choice for this selection for the purposes of barebox, this still does not mean that the same selection should be made for U-Boot.
I'm the last to complein if we come up with a leaner implementation that still solves the problems we're trying to solve.
I think we have the basics right (and that is the same as Linux). We just need to settle on a few finer points such as:
- Raw time interval. Linux uses nanoseconds. A 64-bit nanosecond clock source goes for >580 years so even if the highest resolution clock available to us right now is microsecond, it will not hurt to go with a nanosecond time-base as that will provide us with the greatest flexibility going forward. However, this will lead to a lot of integer divides and/or multiplies to scale to millisecond and microsecond intervals
You argumented above against milliseconds (which still works reasonably well with 32 bit data types) and suggested to use microseconds. With a 32 bit data type and using microseconds as unit, you can get some 4,300 seconds for unsigned and some 2,100 seconds for signed data types - in other words, in the order of a little over one hour resp. half an hour. This is too tight - so we would have to use 64 bit data types here, too.
- Function naming
See my previous comments. And the longer I think about it, the more I think we should just use
u64 time(void)
as core of this new code.
- Performing time comparisons for timeouts - Barebox for example has a is_timeout function which takes a start time and a delay (in nanoseconds) an implements ndealy, udealy, and mdelay using is_timeout
Well, here I think we should have a look at Linux again here. In include/linux/jiffies.h they provide a nice set of inlines, which in our case would reuse directly:
time_after() time_after_eq() time_before() time_before_eq() time_in_range() time_in_range_open() The classic timeout code then becomes:
u64 then = time() + TIMEOUT; ... if (time_after(time(), then)) { /* handle timeout */ }
I think what has been proposed here recently and documented (slightly out-of-date) on the wiki is the way to go. Taking the Linux or Barebox source will be more effort than it's worth for the complexity it brings in.
I don't want to take all of it. But there is alarge amount of good things, and we should pick up bits and pieces we can use to save us efforts and pain.
Best regards,
Wolfgang Denk

Hi Wolfgang,
Thanks for the renewed feedback
On 12/07/11 18:49, Wolfgang Denk wrote:
Dear Graeme,
I'm trying to summarize your last 3 postings here.
In message 4E1B7E0C.8000900@gmail.com you wrote:
First, I would very much like to get rid of this "_ms" thing. We should rather make very clear in the documentation which unit the time services are based on, and use this consequently. Only functions using a different unit should make this clean in their names.
Ideally, I think this should be microseconds (a lot happens in a microsecond on modern platforms, and a millisecond can be an eternity)
Then we might as well follow the example of the Linux generic TOD framework and use nanoseconds instead - we will need u64 data types anyway when going for microseconds, so we can just follow their example.
Yes, I like the idea of using nanoseconds as a raw timebase
Third: all this time_*_max(), ..._min() and ...raw() stuff. Aren't we over-engineering here? We have been successfully writing U-Boot code for 11 years now, and never needed these before. Neither does Linux
Part of the problem came from the realisation that some architectures have really bad timer resolution (Nios2 in particular). In an ideal world, I think a uniform microsecond timer (millisecond is to coarse to cater for all needs such as udelay and profiling) would be sufficient to not need these functions but while ever we have platforms with 'poor' timers, I think you may find these functions have a place.
No, I disagree here. We should not clutter up generic code with things that are only needed for a single (unusually restricted) architecture. Instead, we should try to come up with a design that hides such details in architecture specific code.
So how do we deal with Nios2? It is what caused such a deep investigation into the timer API. We have three choices I can think of off the top of my head:
1. Move the whole timer API up to the architecture level and replicate code everywhere 2. Make the whole timer API weak 3. Fundamentally allow the timer API to handle arbitrary timer resolutions
1. Way ugly. We already have this, and that is why we are here today 2. Well, you know what will happen - Someone will be unhappy with the generic API and rewrite a completely different one (timer_masked anyone!) 3. Why is this so evil?
I'm open to other options if you have any
As stated - This started from a suggestion made by yourself (albeit one you did not think was apparently necessary). The idea of the separate functions (rather than a parameter to a single function) was that if the functions were not used, they would be optimised out.
You know how things go: if you offer the users a set of 20 functions so they can chose the one or two that fit their purposes best, they will end up with using all 20 of them, especially when diffferent parts of the code get maintained by different people with different preferences. Approaches like that always get out of hand quickly.
We don't have any such stuff now, and U-Boot is working fine. Let's keep it with that, or make it even more simple. But not the other way.
Realistically we are looking at the following functionality:
1) Get the current time 2) Report the minimum time elapsed since an arbitrary epoch 3) Report the maximum time elapsed since an arbitrary epoch 4) Delay for an arbitrary period of time
4 is a derivative of 2 - Just loop until at least the required time has elapsed.
And you then suggest bringing in no less than 6 functions from Linux
What would you like me to do with the clean-up patches that you have already ack'd which do not relate directly to the new API? Should I mark the current series as Rejected in patchwork and create a brand new smaller series which only has those specific patches?
I suggest you create a new patch series from the independent clean-up patches and submit this as normal patches (i. e. without the WIP / RFC part). This would already be a great improvement, I think. Thanks a lot for the efforts!
Done - I will reject the current series and rebase/repost the patches you have already ack'd and assign them to you in patchwork - I'll leave it up to you to pull them in
In message 4E1B88EE.9040104@gmail.com you wrote:
- Looking at the low-level framework described in ols2006-hrtimers.pdf
(Linux API), we are looking at implementing the same thing - An architecture specific free running, high speed, high resolution, high accuracy hardware counter/timer and a low speed interrupt which translates the hardware counter/timer to a common API. In this respect, we are not re-inventing that wheel at all
Indeed. We should also avoid re-inventing the algorithms, and eventually re-implementing the code. In any case, I think it would be great to use a compatible API so we don;t have to change too many things when adapting code from Linux etc.
OK, I'll spend some time digging into the Linux framework a bit more - I have only had a brief look so far
- The rest of the Linux API is like hitting a thumb-tack with a
sledgehammer - Timer Queues, NTP, Callbacks, Scheduling etc, etc, etc. We only want to do two things:
Right. Linux is a full-blown OS with a lot of needs we don't have in U-Boot.
- Monitor timeouts
- Calculate code execution time (and even then, not everyone all the time)
Actrually we need just timestamps.
All the rest (like delays, timeouts, executin times etc.) can be derived from that.
Agree, but we need to implement the derivative functions in lib/ otherwise we doom ourselves to the current mess all over again
- The Linux API is nanosecond resolution. We are hard pressed to get the
average hardware to support microsecond resolution
On the other hand, it makes little difference to the code wether we use microseconds or nanoseconds. It's just slightly different values in the u64 variables.
Agreed, nanoseconds it is
- The Linux API includes usage of 'clock events' - These are timer
interrupts driven by programmable hardware and relieve the stress on the timer scheduler keeping track of every single timer - Overkill for a boot loader
Agreed. Well, partially. We should still follow the example of keeping the generic code clean of architecture / timer specific code. This should be implemented in the respective arechitecture specific code.
And that is exactly what the proposed framework was working towards. The only feature the architecture (be it the CPU, SOC, Chipset, Board, whatever) must provide is a method of accessing a free-running counter and an indication of how fast that counter increments. All the rest is done in lib/
Provided you have access to an incrementing value which increments at a fixed rate and you know the rate, the rest is architecture independent
- The Linux API includes 'Time of Day' (Wall Time) - Again, I don't think
we really need this in a boot loader (we have an RTC API we can use if we want to get the current Date and Time).
We could also say this is all we need. If we have a working high precision TOD timestamp, we can derive all other things we need from that.
So you want to look at bringing in the Linux TOD API as well? That means we have to synchronise the timer to an RTC which is something not all boards have. I think we should stick (at least for the time being) to an arbitrary timer whose value means absolutely nothing other than the difference between two values during any given U-Boot execution represent the number of nanoseconds elapsed.
So, all we need is a fixed resolution free running timer we can use to do simple (one at a time) timing operations. No callbacks, no scheduling, to 'Wall Time', no 'Clock Events', no NTP etc. The Linux API is 'Too Big'
I never proposed to adapt all of it.
Phew ;)
My suggestion was to pick the parts that fit, and use them. especially, use the same API (like going for nanoseconds as unit of time), and use their algorithms (and ideally also their code) to solve the problems we have to deal with.
I don't think we are re-inventing the wheel with our underlying concept -
Not with the concept, but with the code.
In message 4E1BAED7.3070009@gmail.com you wrote:
I think I can safely say that:
a) We do not want to inherit the code from Linux. It's good code clean code, but it is just way too much for what we need. It handles registering and unregistering clock sources, change clock source 'rating' (what ever that is) and relies heavily on quite heavy (for U-Boot) struct's (which may need to be carted around in Global Data)
See above. You are right, simply copying code unreflected makes no sense. But we should use it as example for API, algorithms, and code.
b) Barebox doesn't really inherit that much from Linux anyway
Right, they did what I proposed, and copied only a part of it, i. e. the generic TOD framework.
Actually, when I look at it I see so little in common I am surprised they even bothered with the attribution at all. Maybe they started with more and progressively stripped it bare - I'll have a better look
Even if we assume that they made a good choice for this selection for the purposes of barebox, this still does not mean that the same selection should be made for U-Boot.
I'm the last to complein if we come up with a leaner implementation that still solves the problems we're trying to solve.
I think we have the basics right (and that is the same as Linux). We just need to settle on a few finer points such as:
- Raw time interval. Linux uses nanoseconds. A 64-bit nanosecond clock source goes for >580 years so even if the highest resolution clock available to us right now is microsecond, it will not hurt to go with a nanosecond time-base as that will provide us with the greatest flexibility going forward. However, this will lead to a lot of integer divides and/or multiplies to scale to millisecond and microsecond intervals
You argumented above against milliseconds (which still works reasonably well with 32 bit data types) and suggested to use microseconds. With a 32 bit data type and using microseconds as unit, you can get some 4,300 seconds for unsigned and some 2,100 seconds for signed data types - in other words, in the order of a little over one hour resp. half an hour. This is too tight - so we would have to use 64 bit data types here, too.
Well for starters, that was before I read the Linux framework and I never suggested a 32-bit timer either.
- Function naming
See my previous comments. And the longer I think about it, the more I think we should just use
u64 time(void)
as core of this new code.
Agreed - As said before (for the time being) the return value of any arbitrary call to time() means nothing. It _may_ mean the number of nanoseconds since power-up, but this is by no means guaranteed.
But what about delays (no-brainer - ndelay, udelay, mdelay) and 'elapsed time'
- Performing time comparisons for timeouts - Barebox for example has a is_timeout function which takes a start time and a delay (in nanoseconds) an implements ndealy, udealy, and mdelay using is_timeout
Well, here I think we should have a look at Linux again here. In include/linux/jiffies.h they provide a nice set of inlines, which in our case would reuse directly:
time_after() time_after_eq() time_before() time_before_eq() time_in_range() time_in_range_open()
When would we use time_in_range and time_in_range_open? I don't think we can build an argument based on portability of code from Linux as we will need to do a lot of code touch-ups because we will not be bringing in the complete Linux timer API anyway.
In some respects, I think it less confusing to clearly define our own API rather than generating a illusion of compatibility.
The classic timeout code then becomes:
u64 then = time() + TIMEOUT; ... if (time_after(time(), then)) { /* handle timeout */ }
Arrrgh - Sorry, but we have been around and around and around this. There are sooooo many way to do this - The two big contenders have been:
1) u64 start = time();
do { ...stuff... } while (time_since(start) < TIMEOUT);
2) u64 now = time(); u64 end = future_time(now, TIMEOUT);
do { ...stuff... } while(time() < end);
And now we throw a third into the mix.
time_since and future_time are designed to take into account the underlying resolution of the hardware timer/counter. The big thing to remember is that we _must_ handle the case where the underlying timer is too coarse
I think what has been proposed here recently and documented (slightly out-of-date) on the wiki is the way to go. Taking the Linux or Barebox source will be more effort than it's worth for the complexity it brings in.
I don't want to take all of it. But there is alarge amount of good things, and we should pick up bits and pieces we can use to save us efforts and pain.
As I said, I will have a closer look at the Linux API...
Regards,
Graeme

Dear Graeme Russ,
In message 4E1C23B8.6020101@gmail.com you wrote:
So how do we deal with Nios2? It is what caused such a deep investigation into the timer API. We have three choices I can think of off the top of my head:
- Move the whole timer API up to the architecture level and replicate
code everywhere 2. Make the whole timer API weak 3. Fundamentally allow the timer API to handle arbitrary timer resolutions
- Way ugly. We already have this, and that is why we are here today
- Well, you know what will happen - Someone will be unhappy with the
generic API and rewrite a completely different one (timer_masked anyone!) 3. Why is this so evil?
The big disadvantage of 3) is that you cannot make any reasonable assumptions any more in the code. If I place a "udelay(10)" in some device driver, I am probably aware that we don't have exact times, and that the actual delay may be 10 or 12 or eventually even 20 micro- seconds. We should make sure that the delay never takes less than 10 us, but we also have to guarantee that it does not take - for example - 10 milliseconds.
What exactly is the reason that we cannot have better timer resolutions in NIOS? I'm anything but a NIOS export, but skimming through the "Altera Embedded Peripherals IP User Guide", section "28. Interval Timer Core" I see that we can have "32-bit and 64-bit counters", "Two count modes: count down once and continuous count-down", and the example in section "Configuration: Timeout Period" on p. 28-3 reads:
For example, if the associated system clock has a frequency of 30 ns, and the specified Timeout Period value is 1 µs, the true timeout period will be 1.020 microseconds.
Well, if I understand this correctly, we can have a continuously running 64 bit counter with microsecond resolution.
There are other sections that describe configurations that might probably be used as well, for example in "HAL System Library Support":
Timestamp Driver The interval timer core may be used as a timestamp device ...
Also, the "Nios II Software Developer's Handbook" says in "Chapter 6: Developing Programs Using the Hardware Abstraction Layer - Using Timer Devices" on o. 6-16:
The HAL API provides two types of timer device drivers: - System clock driver--Supports alarms, such as you would use in a scheduler. - Timestamp driver--Supports high-resolution time measurement. ... You can obtain the rate at which the timestamp counter increments by calling the function alt_timestamp_freq(). This rate is typically the hardware frequency of the Nios II processor system--usually millions of cycles per second. The timestamp drivers are defined in the alt_timestamp.h header file.
High-resolution time measurement? Isn't this what we are looking for?
Or am I missing something?
Scott, maybe you can comment here?
I'm open to other options if you have any
At the moment I'm trying to understand if we really have a problem on NIOS2 that cannot be fixed in a way that is compatible with our current plans.
- Get the current time
Agreed. That's time().
- Report the minimum time elapsed since an arbitrary epoch
- Report the maximum time elapsed since an arbitrary epoch
I don't understand why we would need this.
- Delay for an arbitrary period of time
4 is a derivative of 2 - Just loop until at least the required time has elapsed.
Right. Both delays and timeouts work like that, the difference being that delays are "blocking", i. e. there is no other code running inbetween, and you can just sit in a tight spinning loop.
I have not seen any requirement yet for 3.
And you then suggest bringing in no less than 6 functions from Linux
It's just macros. And we don't need to use them all. Actually time_after() is all that's needed to satisfy our current usage.
Done - I will reject the current series and rebase/repost the patches you have already ack'd and assign them to you in patchwork - I'll leave it up to you to pull them in
Don't reject them - just mark them as RFC.
Provided you have access to an incrementing value which increments at a fixed rate and you know the rate, the rest is architecture independent
We also have to deal with decrementing counters, but this is just aan unimportant detail. And it appears that we actually can have this, even on NIOS.
We could also say this is all we need. If we have a working high precision TOD timestamp, we can derive all other things we need from that.
So you want to look at bringing in the Linux TOD API as well? That means we
No, I don't.
See my previous comments. And the longer I think about it, the more I think we should just use
u64 time(void)
as core of this new code.
Agreed - As said before (for the time being) the return value of any arbitrary call to time() means nothing. It _may_ mean the number of nanoseconds since power-up, but this is by no means guaranteed.
True. But it is also garanteet to be usable in constructs as the aforementioned
u64 then = time() + number_of_nanoseconds; ... if (time_after(time(), then)) ...
But what about delays (no-brainer - ndelay, udelay, mdelay) and 'elapsed time'
Well, like this:
void udelay(u32 usec) { u64 then = time() + (u64)usec * (u64)1000;
while (!time_after(time(), then)) ... do something, like trigger watchdogs etc ... }
For 'elapsed time' it should be sufficient to store the start value of time() as early as possible in the (architecture specific) code.
Well, here I think we should have a look at Linux again here. In include/linux/jiffies.h they provide a nice set of inlines, which in our case would reuse directly:
time_after() time_after_eq() time_before() time_before_eq() time_in_range() time_in_range_open()
When would we use time_in_range and time_in_range_open? I don't think we
I don;t suggest that we need to use all of these. As mentioned, currently I only see use for time_after() (and/or time_after_eq(), it if should make a difference).
The classic timeout code then becomes:
u64 then = time() + TIMEOUT; ... if (time_after(time(), then)) { /* handle timeout */ }
Arrrgh - Sorry, but we have been around and around and around this. There are sooooo many way to do this - The two big contenders have been:
Yes, and both of them do the compare in local code. This is what we should get rid of.
And now we throw a third into the mix.
Please read the comments for the implementation of the time_after() macro. It makes sense to do it this way.
time_since and future_time are designed to take into account the underlying resolution of the hardware timer/counter. The big thing to remember is that we _must_ handle the case where the underlying timer is too coarse
Do we? What exactly is the needed resolution of the underlying hardware timer? So far, it appears sufficient to have it ticking with 1000 Hz or more. Are there really systems that cannot provide that? The only architecture I remember that seemed prolematic was NIOS - but then the NIOS documentation suggests that this might actually be solvable.
Best regards,
Wolfgang Denk

Dear Wolfgang
Wolfgang Denk wrote:
What exactly is the reason that we cannot have better timer resolutions in NIOS?
You _can_ have better timer resolutions in Nios. However, there are legacy systems that implement timer(s) with a fixed period of 10 msec. The use of such implementations is very common. How do I know? Because my customers have such implementations. Why not upgrade? Because most sane engineers are loathe to change their rtl just so they can fix a simple software bug or add a simple custom feature.
My obvious preference is to continue to use the latest u-boot in such systems ... without having to create a custom branch for customers with older Nios implementations, where I use the old timer interfaces ... simply because we "improved" the API.
Scott, maybe you can comment here?
I have only one comment: Out of pure frustration, I have been avoiding any discussions regarding this timer re-write effort.
At the moment I'm trying to understand if we really have a problem on NIOS2 that cannot be fixed in a way that is compatible with our current plans.
This is where my frustration begins. I've said this several times before, and I don't know how else to say this ... but I'll give it one more try:
This is not a Nios problem.
If I can't use a 10 msec timer interrupt to detect a simple timeout condition when I'm programming a flash memory, then the timer API design is garbage. And quite frankly, the enormous amount of discussion in this matter reminds me of an undergraduate science project.
We also have to deal with decrementing counters, but this is just aan unimportant detail. And it appears that we actually can have this, even on NIOS.
Wow! Even on Nios! Arrggghh!
The only architecture I remember that seemed prolematic was NIOS
Really? There have been occasional issues that have required a patch here and there. But I consider most of them far from "problematic."
This is exhausting. As I recall, this entire fuss was born out of an issue with nested calls to get_timer() ... and that begat removing reset_timer ... and that begat ... and so on. And we're still spilling lots of intellectual seed here. And now we have what? A jack-of-all-trades API that can do everything with exacting precision ... other than handling a 10 msec interrupt?
Best Regards, --Scott

On 7/12/2011 8:23 AM, Scott McNutt wrote:
Dear Wolfgang
Wolfgang Denk wrote:
What exactly is the reason that we cannot have better timer resolutions in NIOS?
You _can_ have better timer resolutions in Nios. However, there are legacy systems that implement timer(s) with a fixed period of 10 msec. The use of such implementations is very common. How do I know? Because my customers have such implementations. Why not upgrade? Because most sane engineers are loathe to change their rtl just so they can fix a simple software bug or add a simple custom feature.
My obvious preference is to continue to use the latest u-boot in such systems ... without having to create a custom branch for customers with older Nios implementations, where I use the old timer interfaces ... simply because we "improved" the API.
Scott, maybe you can comment here?
I have only one comment: Out of pure frustration, I have been avoiding any discussions regarding this timer re-write effort.
At the moment I'm trying to understand if we really have a problem on NIOS2 that cannot be fixed in a way that is compatible with our current plans.
This is where my frustration begins. I've said this several times before, and I don't know how else to say this ... but I'll give it one more try:
This is not a Nios problem.
If I can't use a 10 msec timer interrupt to detect a simple timeout condition when I'm programming a flash memory, then the timer API design is garbage.
Hi All, I agree with the idea that mandating a particular timer resolution is an un-desired limitation. You may need it for some cases, but not for all. Proof of this concept is the number of legacy UNIX systems running on 10 ms timer ticks, or for that matter the number of systems running on line cycle interrupts (16.666 ms in the US). It is also however true that one cannot ignore the timer resolution. That is what produced the problem in the first place. Asking for a delay that is less than the resolution isn't going to work as expected. This problem can be easily fixed by always adding twice the timer resolution to any requested delay, to ensure you waited at least two ticks , or by having a routine that does this for you (like the suggested API does). Right now, there are many places in the u-boot code that wait a certain small number of milliseconds under the assumption that the timer resolution is either 1) not an issue at all, or 2) is 1 ms. Both cases are wrong, the first case more so than the second. I wonder how many delays in the program that say "wait 5 ms" are aware that you could exit the loop after 4ms plus epsilon every so often, even with 1 ms resolution? Perhaps the tolerance is built into the number 5, perhaps not. However, it is surely not if the timer resolution is 16.666 ms.
And quite frankly, the enormous amount of discussion in this matter reminds me of an undergraduate science project.
Or any government project. But when you will effect lots of people, you often must kill a few trees to make sure nobody (such as yourself and other NIOS users) somehow gets a bad deal.
I am now returning to "real work" and will be offline for a while. Good Luck All.
Best Regards, Bill Campbell
We also have to deal with decrementing counters, but this is just aan unimportant detail. And it appears that we actually can have this, even on NIOS.
Wow! Even on Nios! Arrggghh!
The only architecture I remember that seemed prolematic was NIOS
Really? There have been occasional issues that have required a patch here and there. But I consider most of them far from "problematic."
This is exhausting. As I recall, this entire fuss was born out of an issue with nested calls to get_timer() ... and that begat removing reset_timer ... and that begat ... and so on. And we're still spilling lots of intellectual seed here. And now we have what? A jack-of-all-trades API that can do everything with exacting precision ... other than handling a 10 msec interrupt?
Best Regards, --Scott
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Hi Wolfgang,
On 12/07/11 23:10, Wolfgang Denk wrote:
Dear Graeme Russ,
In message 4E1C23B8.6020101@gmail.com you wrote:
So how do we deal with Nios2? It is what caused such a deep investigation into the timer API. We have three choices I can think of off the top of my head:
- Move the whole timer API up to the architecture level and replicate
code everywhere 2. Make the whole timer API weak 3. Fundamentally allow the timer API to handle arbitrary timer resolutions
- Way ugly. We already have this, and that is why we are here today
- Well, you know what will happen - Someone will be unhappy with the
generic API and rewrite a completely different one (timer_masked anyone!) 3. Why is this so evil?
The big disadvantage of 3) is that you cannot make any reasonable assumptions any more in the code. If I place a "udelay(10)" in some device driver, I am probably aware that we don't have exact times, and that the actual delay may be 10 or 12 or eventually even 20 micro- seconds. We should make sure that the delay never takes less than 10 us, but we also have to guarantee that it does not take - for example - 10 milliseconds.
OK, I will assume you agree with me that #1 and #2 are unacceptable
In the case of Nios2 we cannot use the Timer API for udelay since any udelay will blow out to 20ms - Very Bad Indeed. Maybe udelay might need to be defined weak, but I fear this will be the thin end of the wedge...
[snip pondering on NIOS]
Also remember that if we are looking to inherit nanosecond time base from Linux, it will be extremely unlikely that every board will support a native 1ns clock source. Typical examples would be 33MHz (~30ns) or 66MHz (~15ns). In any case, there will be a lot of variance between boards, so we will still need to cater for arbitrary resolutions
- Get the current time
Agreed. That's time().
- Report the minimum time elapsed since an arbitrary epoch
- Report the maximum time elapsed since an arbitrary epoch
I don't understand why we would need this.
Profiling - Lets say your hardware counter is ms accurate, if an operation takes 0.5ms then using #2 would give a 50/50 chance of reporting that the elapsed time was 0ms. Using method #3, the 50/50 split would be 1ms/2ms. Now as you low-level hardware clock becomes more accurate, those numbers move down to the real 0.5ms, but will never report that the operation took 0ms.
I guess going to nanosecond time base, the need for #3 lessens as the hardware clock gets faster.
Also, given that the architecture will need to provide a 'nanoseconds per counter increment', #3 can be easily derived if someone really wants it, but as soon as two people want it, you may as well move it into lib/ as it is a trivial function which is 100% architecture independent.
- Delay for an arbitrary period of time
4 is a derivative of 2 - Just loop until at least the required time has elapsed.
Right. Both delays and timeouts work like that, the difference being that delays are "blocking", i. e. there is no other code running inbetween, and you can just sit in a tight spinning loop.
I have not seen any requirement yet for 3.
See above
And you then suggest bringing in no less than 6 functions from Linux
It's just macros. And we don't need to use them all. Actually time_after() is all that's needed to satisfy our current usage.
Oh please, macro, inline function, function - They are all API 'functions' - As you stated before, the bigger the API, the more people will abuse is by using the wrong functions. You stated that you want to keep the public profile of the API as small and tight as possible by rejecting the additional functions previously proposed.
Done - I will reject the current series and rebase/repost the patches you have already ack'd and assign them to you in patchwork - I'll leave it up to you to pull them in
Don't reject them - just mark them as RFC.
OK
Provided you have access to an incrementing value which increments at a fixed rate and you know the rate, the rest is architecture independent
We also have to deal with decrementing counters, but this is just aan unimportant detail. And it appears that we actually can have this, even on NIOS.
Trivial in the proposed architecture with a #define in the config CONFIG_SYS_HW_COUNTER_DECREMENTS (or similar)
We could also say this is all we need. If we have a working high precision TOD timestamp, we can derive all other things we need from that.
So you want to look at bringing in the Linux TOD API as well? That means we
No, I don't.
See my previous comments. And the longer I think about it, the more I think we should just use
u64 time(void)
as core of this new code.
Agreed - As said before (for the time being) the return value of any arbitrary call to time() means nothing. It _may_ mean the number of nanoseconds since power-up, but this is by no means guaranteed.
Actually, I do agree will Bill - time() is probably not the best name - get_current_ns() or similar may be more meaningful (I still have not had a chance to look at the Linux code)
True. But it is also garanteet to be usable in constructs as the aforementioned
u64 then = time() + number_of_nanoseconds; ... if (time_after(time(), then)) ...
But what about delays (no-brainer - ndelay, udelay, mdelay) and 'elapsed time'
Well, like this:
void udelay(u32 usec) { u64 then = time() + (u64)usec * (u64)1000;
while (!time_after(time(), then)) ... do something, like trigger watchdogs etc ... }
Yes, that is how I always imagined udelay()
For 'elapsed time' it should be sufficient to store the start value of time() as early as possible in the (architecture specific) code.
I did mean 'elapsed between two code locations' such as profiling the init functions - That was what API function #3 was all about.
Well, here I think we should have a look at Linux again here. In include/linux/jiffies.h they provide a nice set of inlines, which in our case would reuse directly:
time_after() time_after_eq() time_before() time_before_eq() time_in_range() time_in_range_open()
When would we use time_in_range and time_in_range_open? I don't think we
I don;t suggest that we need to use all of these. As mentioned, currently I only see use for time_after() (and/or time_after_eq(), it if should make a difference).
The classic timeout code then becomes:
u64 then = time() + TIMEOUT; ... if (time_after(time(), then)) { /* handle timeout */ }
Arrrgh - Sorry, but we have been around and around and around this. There are sooooo many way to do this - The two big contenders have been:
Yes, and both of them do the compare in local code. This is what we should get rid of.
OK, this is a new philosophy for the mix. I think it is a good one for the record. But since we will always use time_after(time(), then) why don't we simplify it to:
u64 start = time(); ... if (time_elapsed_since(start, TIMEOUT)) { /* handle timeout */ }
Again, I will look at the Linux code
And now we throw a third into the mix.
Please read the comments for the implementation of the time_after() macro. It makes sense to do it this way.
time_since and future_time are designed to take into account the underlying resolution of the hardware timer/counter. The big thing to remember is that we _must_ handle the case where the underlying timer is too coarse
Do we? What exactly is the needed resolution of the underlying hardware timer? So far, it appears sufficient to have it ticking with 1000 Hz or more. Are there really systems that cannot provide that? The only architecture I remember that seemed prolematic was NIOS - but then the NIOS documentation suggests that this might actually be solvable.
Yes, but as stated before, there is a FPGA gate count trade-off which may not always be possible. Plus, you break existing boards
Regards,
Graeme

Dear Graeme Russ,
In message 4E1CE6EC.1030900@gmail.com you wrote:
Also remember that if we are looking to inherit nanosecond time base from Linux, it will be extremely unlikely that every board will support a native 1ns clock source. Typical examples would be 33MHz (~30ns) or 66MHz (~15ns). In any case, there will be a lot of variance between boards, so we will still need to cater for arbitrary resolutions
Please note that Linux makes no assumption of a 1 ns clock source. We should hav eno problems on this front.
It's just macros. And we don't need to use them all. Actually time_after() is all that's needed to satisfy our current usage.
Oh please, macro, inline function, function - They are all API 'functions'
- As you stated before, the bigger the API, the more people will abuse is
by using the wrong functions. You stated that you want to keep the public profile of the API as small and tight as possible by rejecting the additional functions previously proposed.
OK, so let's start with time_after() only.
Agreed - As said before (for the time being) the return value of any arbitrary call to time() means nothing. It _may_ mean the number of nanoseconds since power-up, but this is by no means guaranteed.
Actually, I do agree will Bill - time() is probably not the best name - get_current_ns() or similar may be more meaningful (I still have not had a chance to look at the Linux code)
If you don't want to use time, then let's use get_time() please - this is close enough to the existing name so everybody familiar with the code recognizes it immediately.
void udelay(u32 usec) { u64 then = time() + (u64)usec * (u64)1000;
while (!time_after(time(), then)) ... do something, like trigger watchdogs etc ... }
Yes, that is how I always imagined udelay()
...except that udelay() is guaranteed to be available very early in the initialization sequence, long before we have "normal" timer services which may - for example - be interrupt based.
For 'elapsed time' it should be sufficient to store the start value of time() as early as possible in the (architecture specific) code.
I did mean 'elapsed between two code locations' such as profiling the init functions - That was what API function #3 was all about.
Sounds trivial: store the value of time() and the begin and the end of the interval and compute the difference?
OK, this is a new philosophy for the mix. I think it is a good one for the record. But since we will always use time_after(time(), then) why don't we simplify it to:
u64 start = time(); ... if (time_elapsed_since(start, TIMEOUT)) { /* handle timeout */ }
This does not fit. time_elapsed_since() suggests it returns the length of the interval, i. e. a number of tiume units - but it does something different.
I like the time_after() approach very much because it does exactly what the name says, and nothing more - so you can use it in a number of ways - I recognise good old UNIX philosophy here: do one simple thing, and do it well.
Regarding the "we will always use time_after(time() ...) - we might want to check if we really have to use time() here (and in a number of other places - or if we can manage to come up with a simple timestamp variable, similar to what jiffies is in Linux. That would simplify the code even further. [Maybe "#define jiffies time()"? ;-) }
Do we? What exactly is the needed resolution of the underlying hardware timer? So far, it appears sufficient to have it ticking with 1000 Hz or more. Are there really systems that cannot provide that? The only architecture I remember that seemed prolematic was NIOS - but then the NIOS documentation suggests that this might actually be solvable.
Yes, but as stated before, there is a FPGA gate count trade-off which may not always be possible. Plus, you break existing boards
Understood. Well, how work the Linux timers on these boards, then?
Best regards,
Wolfgang Denk

Hi Wolfgang.
On 12/07/11 20:36, Graeme Russ wrote:
As I said, I will have a closer look at the Linux API...
OK, I've had a look at how the Linux API is used - in particular time_after(). Here is a typical random example (from drivers/spi/ep93xx_spi.c):
timeout = jiffies + msecs_to_jiffies(SPI_TIMEOUT); while (ep93xx_spi_read_u16(espi, SSPSR) & SSPSR_RNE) { if (time_after(jiffies, timeout)) { dev_warn(&espi->pdev->dev, "timeout while flushing RX FIFO\n"); msg->status = -ETIMEDOUT; return; } ep93xx_spi_read_u16(espi, SSPDR); }
Now I personally do not like the global 'jiffies' variable for two reasons:
a) It assumes there is some interrupt source updating jiffies which we cannot guarantee. The discussions of the new API had the background counter being update by both a background interrupt (if available) or a call to get_timer() b) It has no fixed time base
So it looks like the nanosecond clocksource code and the time_after et al macros are not directly related (as evidenced by time_after being in jiffies.h)
So maybe we should look at something along the lines of:
timeout = get_ms_count() + SPI_TIMEOUT; while (ep93xx_spi_read_u16(espi, SSPSR) & SSPSR_RNE) { if (time_after(get_ms_count(), timeout)) { dev_warn(&espi->pdev->dev, "timeout while flushing RX FIFO\n"); msg->status = -ETIMEDOUT; return; } ep93xx_spi_read_u16(espi, SSPDR); }
The get_ms_count() name is up for debate
So this would mean minimal timer related code conversion bringing drivers from Linux, and a namespace which does not match Linux that will hence generate obvious compile errors.
If you really wanted to we could
#define jiffies get_ms_count() #define msecs_to_jiffies(x) x
But I think that might be dangerous
Now we can use the existing get_timer(0) call (as I already did with this patch series) now and create the underlying architecture intrusive re-write of the generic 'clocksource' API later.
And then phase 3 would be to revisit udelay
Regards,
Graeme

On 12/07/11 07:56, Wolfgang Denk wrote:
Dear Graeme Russ,
[snip]
One thing I always wanted to do in the previous discussion was to check what other projects (like Linux, barebox, etc.) are doing in this area. I think it is worth reading the Linux Documentation/timers/highres.txt document, especially the sections about John Stultz's Generic Time Of Day (GTOD) framework, please the documents linked there (i. e. the OLS slides [the link in Documentation/timers/highres.txt is stale; use http://www.kernel.org/pub/linux/kernel/people/tglx/hrtimers/ols2006-hrtimers... instead] and the paper "We Are Not Getting Any Younger: A New Approach to Time and Timers" by J. Stultz et al. in http://www.linuxsymposium.org/2005/linuxsymposium_procv1.pdf p. 219ff).
Having this still in mind, I took a look across the fence to what barebox is doing. Guess what? From "common/clock.c":
* clock.c - generic clocksource implementation * * This file contains the clocksource implementation from the Linux * kernel originally by John Stultz
OK. Message received.
Yes, and barebox is also pulling in slabs of other Linux code such as driver framework etc. I think you will find barebox will ultimately have a very large code-base and binary image because of that. I think that U-Boot and barebox are heading in two different directions (and so they should, what would be the point otherwise) - barebox will become modular but larger, U-Boot will continue to be homogeneous and small.
What I'm asking myself (and now you) is: Should we really re-invent the wheel again?
OK, I've now had a brief look and I have the following comments:
- Looking at the low-level framework described in ols2006-hrtimers.pdf (Linux API), we are looking at implementing the same thing - An architecture specific free running, high speed, high resolution, high accuracy hardware counter/timer and a low speed interrupt which translates the hardware counter/timer to a common API. In this respect, we are not re-inventing that wheel at all
- The rest of the Linux API is like hitting a thumb-tack with a sledgehammer - Timer Queues, NTP, Callbacks, Scheduling etc, etc, etc. We only want to do two things:
1. Monitor timeouts 2. Calculate code execution time (and even then, not everyone all the time)
- The Linux API is nanosecond resolution. We are hard pressed to get the average hardware to support microsecond resolution
- The Linux API includes usage of 'clock events' - These are timer interrupts driven by programmable hardware and relieve the stress on the timer scheduler keeping track of every single timer - Overkill for a boot loader
- The Linux API includes 'Time of Day' (Wall Time) - Again, I don't think we really need this in a boot loader (we have an RTC API we can use if we want to get the current Date and Time).
So, all we need is a fixed resolution free running timer we can use to do simple (one at a time) timing operations. No callbacks, no scheduling, to 'Wall Time', no 'Clock Events', no NTP etc. The Linux API is 'Too Big'
I don't think we are re-inventing the wheel with our underlying concept - Use a hardware counter to handle the accuracy and resolution and use a less frequent interrupt to map the hardware implementation to a common software API. In U-Boot, the interrupt can be as simple as the actual call into the API, but where the hardware timer does not have sufficient resolution (a 32-bit nanosecond timer of 16-bit millisecond timer for example) an additional hardware interrupt will be required.
I personally think we are headed in the right direction 'for U-Boot' - small, tight, elegant, and fit-for-purpose
Regards,
Graeme

On 12/07/11 09:36, Graeme Russ wrote:
On 12/07/11 07:56, Wolfgang Denk wrote:
Dear Graeme Russ,
[snip]
Having this still in mind, I took a look across the fence to what barebox is doing. Guess what? From "common/clock.c":
* clock.c - generic clocksource implementation * * This file contains the clocksource implementation from the Linux * kernel originally by John Stultz
OK. Message received.
Yes, and barebox is also pulling in slabs of other Linux code such as driver framework etc. I think you will find barebox will ultimately have a very large code-base and binary image because of that. I think that U-Boot and barebox are heading in two different directions (and so they should, what would be the point otherwise) - barebox will become modular but larger, U-Boot will continue to be homogeneous and small.
What I'm asking myself (and now you) is: Should we really re-invent the wheel again?
OK, I've now had a brief look and I have the following comments:
[snip]
OK, now I've had a look at the Linux code (\kernel\time*) and Barebox (http://git.pengutronix.de/?p=barebox.git;a=blob;f=common/clock.c;h=79c06c8dd...) I think I can safely say that:
a) We do not want to inherit the code from Linux. It's good code clean code, but it is just way too much for what we need. It handles registering and unregistering clock sources, change clock source 'rating' (what ever that is) and relies heavily on quite heavy (for U-Boot) struct's (which may need to be carted around in Global Data) b) Barebox doesn't really inherit that much from Linux anyway
I think we have the basics right (and that is the same as Linux). We just need to settle on a few finer points such as:
- Raw time interval. Linux uses nanoseconds. A 64-bit nanosecond clock source goes for >580 years so even if the highest resolution clock available to us right now is microsecond, it will not hurt to go with a nanosecond time-base as that will provide us with the greatest flexibility going forward. However, this will lead to a lot of integer divides and/or multiplies to scale to millisecond and microsecond intervals - Function naming - Performing time comparisons for timeouts - Barebox for example has a is_timeout function which takes a start time and a delay (in nanoseconds) an implements ndealy, udealy, and mdelay using is_timeout
I think what has been proposed here recently and documented (slightly out-of-date) on the wiki is the way to go. Taking the Linux or Barebox source will be more effort than it's worth for the complexity it brings in.
I recall an apt quote 'Good programmers know when to re-use, great programmers know when to re-write'
Regards,
Graeme

On 7/12/2011 6:10 AM, Wolfgang Denk wrote:
Dear Graeme Russ,
<snip>
Do we? What exactly is the needed resolution of the underlying hardware timer? So far, it appears sufficient to have it ticking with 1000 Hz or more. Are there really systems that cannot provide that? The only architecture I remember that seemed prolematic was NIOS - but then the NIOS documentation suggests that this might actually be
Hi All, The NIOS2 "systems" are a FPGA based architecture ("soft" core). They CAN have all different kinds of timers. However, there are many already out in the world that were built (generated) with a timer that has 10 ms resolution. We can't retro-actively change these. We can declare them not supported in future releases, but we can't fix the resolution problem retroactively. I have two comments regarding this discussion so far. First, I think using the "time" function name at all is a VERY BAD idea. People will confuse it with the "normal" c library function that returns the time of day since the epoch. One may say that they should RTFM, but it is lots easier to just use another name and avoid all such confusion. Second, I think forcing all systems to use 64 bit time stamps is not a good idea. The main purpose of the timer API is to provide hardware timeouts. 64 bits is vast overkill for such a purpose. Mandating 64 bit capability for all u-boots is I think counter-productive. A 32 bit timestamp in millisecond resolution plus udelay covers all practical cases. The 1 ms resolution is probably inadequate for performance measurement, but for every u-boot system that is sometimes used for performance measurement, there are 100 (probably even more, like 1000, but I don't really have the figures) systems that are just used to boot Linux or another stand alone program. So we may need a different API for performance measurement that uses higher resolution. On most "larger" CPUs, there are hardware timers that can already do this with minimal work. On some less-capable CPUs, it may be lots harder, but if you aren't doing performance measurement, you don't need it. So I suggest that mandating a 64 bit API for some of the processors (68K comes to mind) is not really a good idea. It seems counter to the elegant simplicity of the rest of u-boot to stick a 64 bit requirement on timestamps used to determine if the boot delay is expired.
Best Regards, J. William Campbell
Best regards,
Wolfgang Denk

Dear J. William Campbell, All
I have two comments regarding this discussion so far. First, I
think using the "time" function name at all is a VERY BAD idea. People will confuse it with the "normal" c library function that returns the time of day since the epoch. One may say that they should RTFM, but it is lots easier to just use another name and avoid all such confusion. Second, I think forcing all systems to use 64 bit time stamps is not a good idea. The main purpose of the timer API is to provide hardware timeouts. 64 bits is vast overkill for such a purpose. Mandating 64 bit capability for all u-boots is I think counter-productive. A 32 bit timestamp in millisecond resolution plus udelay covers all practical cases. The 1 ms resolution is probably inadequate for performance measurement, but for every u-boot system that is sometimes used for performance measurement, there are 100 (probably even more, like 1000, but I don't really have the figures) systems that are just used to boot Linux or another stand alone program. So we may need a different API for performance measurement that uses higher resolution. On most "larger" CPUs, there are hardware timers that can already do this with minimal work. On some less-capable CPUs, it may be lots harder, but if you aren't doing performance measurement, you don't need it. So I suggest that mandating a 64 bit API for some of the processors (68K comes to mind) is not really a good idea. It seems counter to the elegant simplicity of the rest of u-boot to stick a 64 bit requirement on timestamps used to determine if the boot delay is expired.
I can only FULLY agree here !!!
Lets just keep the current functions udelay(us) and u32 get_timer(), the latter maybe without parameter. Remove all *masked() and *reset() functions and lets change the timeout values used in code that also NIOS uses to be 20ms more than the hardware requires. It does not really matter if a *timeout* of 20ms is blown up to 40ms.
Reinhard

Hi Reinhard,
On 13/07/11 02:08, Reinhard Meyer wrote:
Dear J. William Campbell, All
[snip]
Lets just keep the current functions udelay(us) and u32 get_timer(), the latter maybe without parameter. Remove all *masked() and *reset() functions
This is happening and has Wolfgang's 100% support. Patches are done, just need to be rebased and resent
and lets change the timeout values used in code that also NIOS uses to be 20ms more than the hardware requires. It does not really matter if a *timeout* of 20ms is blown up to 40ms.
Can't do that - That would mean winding out common code (CFI, Network, Serial, FPGA etc, etc) timeouts to global worst-case scenario unless you want to add a #define and start littering the code with macro's - Urgh!
Regards,
Graeme

On 7/12/2011 5:33 PM, Graeme Russ wrote:
Hi Reinhard,
On 13/07/11 02:08, Reinhard Meyer wrote:
Dear J. William Campbell, All
[snip]
Lets just keep the current functions udelay(us) and u32 get_timer(), the latter maybe without parameter. Remove all *masked() and *reset() functions
This is happening and has Wolfgang's 100% support. Patches are done, just need to be rebased and resent
and lets change the timeout values used in code that also NIOS uses to be 20ms more than the hardware requires. It does not really matter if a *timeout* of 20ms is blown up to 40ms.
Can't do that - That would mean winding out common code (CFI, Network, Serial, FPGA etc, etc) timeouts to global worst-case scenario unless you want to add a #define and start littering the code with macro's - Urgh!
Hi All, Yes, this is true. However, the time_elapsed_since routine can do this dynamically (i.e. add twice the timer resolution) . I think you had another function name (at_least) involved, but you can define time_elapsed_since as always compensating for the resolution. That will fix any resolution questions in a processor-specific way. It is either that or the ifdefs. One way or another, the resolution must be addressed. Up to now, the implicit resolution has been 1 ms, but we now know that is not general enough.
Best Regards, Bill Campbell
Regards,
Graeme _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Dear "J. William Campbell",
In message 4E1CF2E0.1030702@comcast.net you wrote:
Yes, this is true. However, the time_elapsed_since routine can do
this dynamically (i.e. add twice the timer resolution) . I think you had
That would IMHO be a very bad idea. We have a number of places where we have to deal with pretty long timeouts (usually because of protocol specifications that require this - often in the order of several seconds), where the normal path is very fast. The typical approach is to break the timeout into a large number of very short loops. Sometimes we use udelay() for this, other places use get_timer().
So assume we have a timeout of 5 seconds, and implement this as 50,000 loops of 100 microseconds. If you silently turn each of these into 20 milliseconds on NIOS, the timeout would become 1,000 seconds instead of 5 - users would return boards as broken and report "it just freezes" because nobody expects that it will wake up again after some 16 minutes.
another function name (at_least) involved, but you can define time_elapsed_since as always compensating for the resolution. That will fix any resolution questions in a processor-specific way. It is either that or the ifdefs. One way or another, the resolution must be addressed. Up to now, the implicit resolution has been 1 ms, but we now know that is not general enough.
It's not as simple as this. You have to change a lot of code to make this work for such slow clock systems.
Best regards,
Wolfgang Denk

On 7/14/2011 12:41 PM, Wolfgang Denk wrote:
Dear "J. William Campbell",
In message4E1CF2E0.1030702@comcast.net you wrote:
Yes, this is true. However, the time_elapsed_since routine can do
this dynamically (i.e. add twice the timer resolution) . I think you had
That would IMHO be a very bad idea. We have a number of places where we have to deal with pretty long timeouts (usually because of protocol specifications that require this - often in the order of several seconds), where the normal path is very fast. The typical approach is to break the timeout into a large number of very short loops. Sometimes we use udelay() for this, other places use get_timer().
So assume we have a timeout of 5 seconds, and implement this as 50,000 loops of 100 microseconds. If you silently turn each of these into 20 milliseconds on NIOS, the timeout would become 1,000 seconds instead of 5 - users would return boards as broken and report "it just freezes" because nobody expects that it will wake up again after some 16 minutes.
Hi All, If such a condition existed, that is indeed what would happen. However, at present, such code is not being used on NIOS. We know this because the current "work-around" of resetting the timer at the start of any timeout operation extends the timeout to a minimum of 10 milliseconds. So we would be waiting 8 minutes currently, not 16, and I am pretty sure that is long enough for someone to notice. . I would be interested in seeing an example of such code as you refer to. Could you point me to one, because it seems to me that the only reason to code such a delay is that for some reason the user didn't want to keep looking at the termination condition so often. I think that that equivalent operation can be produced by a pretty simple re-coding of the loop. In any case, NIOS does not have the problem at present, so the suggested new work-around would be no worse than the present situation. It is also true that the hardware timer cannot be used in a reasonable version of udelay, as most of the desired delays may be very short relative to the timebase. A calibrated timing loop would be the best approach to the udelay problem.
another function name (at_least) involved, but you can define time_elapsed_since as always compensating for the resolution. That will fix any resolution questions in a processor-specific way. It is either that or the ifdefs. One way or another, the resolution must be addressed. Up to now, the implicit resolution has been 1 ms, but we now know that is not general enough.
It's not as simple as this. You have to change a lot of code to make this work for such slow clock systems.
In general, that is true. There may be a few cases where a delay of less than the resolution is essential to make something work. There are probably lots of other cases where we can easily remove the restriction on the resolution. We cannot fix the first kind, no matter what we do, to work on a lower resolution timer. The second kind we can and probably should fix, because they are coded in an overly-restrictive manner. In any case, we don't absolutely have to fix them until somebody decides to use the code on a CPU with a low resolution timer. Practically speaking, the suggested solution will therefore work on all extant cases.
Best Regards, Bill Campbell
Best regards,
Wolfgang Denk

Dear "J. William Campbell",
In message 4E1F8127.8030008@comcast.net you wrote:
I am pretty sure that is long enough for someone to notice. . I would be interested in seeing an example of such code as you refer to. Could you point me to one, because it seems to me that the only reason to code such a delay is that for some reason the user didn't want to keep looking at the termination condition so often. I think that that
arch/powerpc/cpu/mpc512x/i2c.c:
80 while (timeout-- && (status & I2C_BB)) { ... 88 udelay (1000); 89 status = mpc_reg_in (®s->msr); 90 }
103 while (timeout-- && !(*status & I2C_IF)) { 104 udelay (1000); 105 *status = mpc_reg_in (®s->msr); 106 }
arch/powerpc/cpu/mpc512x/pci.c:
87 /* We need to wait at least a 1sec based on PCI specs */ 88 for (i = 0; i < 1000; i++) 89 udelay(1000);
arch/powerpc/cpu/mpc5xx/spi.c:
258 for (i = 0; i < 1000; i++) { ... 265 udelay(1000); 266 }
390 for (tm=0; tm<1000; ++tm) { ... 394 udelay (1000); 395 }
arch/powerpc/cpu/mpc5xxx/i2c.c:
102 while (timeout-- && (status & I2C_BB)) { ... 111 udelay(15); 112 status = mpc_reg_in(®s->msr); 113 }
125 while (timeout-- && !(*status & I2C_IF)) { 126 udelay(15); 127 *status = mpc_reg_in(®s->msr); 128 }
And just that you don't think this is in a single CPU only:
arch/powerpc/cpu/mpc8260/pci.c:
343 for (i = 0; i < 1000; ++i) ... 345 udelay (1000);
Or in board code:
board/altera/common/cfide.c:
29 /* wait 500 ms for power to stabilize */ 30 for (i = 0; i < 500; i++) 31 udelay(1000);
board/amcc/bamboo/bamboo.c:
1019 for (i=0; i<500; i++) 1020 udelay(1000);
or common code:
common/cmd_fdc.c:
213 while((read_fdc_reg(FDC_SRA)&0x80)==0) { 214 timeout--; 215 udelay(10); 216 if(timeout==0) /* timeout occured */ 217 return FALSE; 218 }
228 while((read_fdc_reg(FDC_MSR)&0xC0)!=0xC0) { 229 /* direction out and ready */ 230 udelay(10); 231 timeout--; 232 if(timeout==0) /* timeout occured */ 233 return -1; 234 } etc.etc.
375 for(val=0;val<255;val++) 376 udelay(500); /* wait some time to start motor */
418 for(i=0;i<100;i++) 419 udelay(500); /* wait 500usec for fifo overrun */
600 for(i=0; i<255; i++) /* then we wait some time */ 601 udelay(500);
common/usb.c:
93 inline void wait_ms(unsigned long ms) 94 { 95 while (ms-- > 0) 96 udelay(1000); 97 }
etc. etc. Note this last example which "spreads" the effect in a not so nice way.
Note that there are even places where udelay() is part of the protocol timing implementation - like in the soft-I2C and soft-SPI drivers.
equivalent operation can be produced by a pretty simple re-coding of the loop. In any case, NIOS does not have the problem at present, so the suggested new work-around would be no worse than the present situation.
I think it is not correct to state that "NIOS does not have the problem at present" - it does, only this is not a blatant problem at the moment. Which in turn might result from the fact that all presently supported NIOS boards has any support enabled for I2C or SPI or USB or MMC or watchdogs or ... you name it.
The first user who adds any of the currently unused (and thus untested) standard features that work just fine on all other architectures might run into issue...
It is also true that the hardware timer cannot be used in a
reasonable version of udelay, as most of the desired delays may be very short relative to the timebase. A calibrated timing loop would be the best approach to the udelay problem.
Just try using Soft-I2C on a NIOS board and you will immediately realize how crucial a working version of udelay() is.
In general, that is true. There may be a few cases where a delay of less than the resolution is essential to make something work. There are
These are not just "a few cases". There are tons of it, all over the place - from protocol implementations like soft-I2C or soft-I2C to timing requirements for RAM initializations etc. etc. And there are enough places that mandate that the timing is at least in the requested oder, and not off by factors of tens or hundrets or worse.
probably lots of other cases where we can easily remove the restriction on the resolution. We cannot fix the first kind, no matter what we do, to work on a lower resolution timer. The second kind we can and probably should fix, because they are coded in an overly-restrictive manner. In any case, we don't absolutely have to fix them until somebody decides to use the code on a CPU with a low resolution timer. Practically speaking, the suggested solution will therefore work on all extant cases.
It will work by chance, at best. See above - any attempt to enable one of the currently not yet used standard features in U-Boot may break your system. I don't consider this a sound base - to me it feels like building on qicksand.
Best regards,
Wolfgang Denk

On 7/15/2011 12:17 AM, Wolfgang Denk wrote:
Dear "J. William Campbell",
In message4E1F8127.8030008@comcast.net you wrote:
I am pretty sure that is long enough for someone to notice. . I would be interested in seeing an example of such code as you refer to. Could you point me to one, because it seems to me that the only reason to code such a delay is that for some reason the user didn't want to keep looking at the termination condition so often. I think that that
arch/powerpc/cpu/mpc512x/i2c.c:
80 while (timeout--&& (status& I2C_BB)) { ... 88 udelay (1000); 89 status = mpc_reg_in (®s->msr); 90 }
103 while (timeout--&& !(*status& I2C_IF)) { 104 udelay (1000); 105 *status = mpc_reg_in (®s->msr); 106 } arch/powerpc/cpu/mpc512x/pci.c:
87 /* We need to wait at least a 1sec based on PCI specs */ 88 for (i = 0; i< 1000; i++) 89 udelay(1000);
arch/powerpc/cpu/mpc5xx/spi.c:
258 for (i = 0; i< 1000; i++) { ... 265 udelay(1000); 266 }
390 for (tm=0; tm<1000; ++tm) { ... 394 udelay (1000); 395 }
arch/powerpc/cpu/mpc5xxx/i2c.c:
102 while (timeout--&& (status& I2C_BB)) { ... 111 udelay(15); 112 status = mpc_reg_in(®s->msr); 113 }
125 while (timeout--&& !(*status& I2C_IF)) { 126 udelay(15); 127 *status = mpc_reg_in(®s->msr); 128 }
And just that you don't think this is in a single CPU only:
arch/powerpc/cpu/mpc8260/pci.c:
343 for (i = 0; i< 1000; ++i) ... 345 udelay (1000);
Or in board code:
board/altera/common/cfide.c:
29 /* wait 500 ms for power to stabilize */ 30 for (i = 0; i< 500; i++) 31 udelay(1000);
board/amcc/bamboo/bamboo.c:
1019 for (i=0; i<500; i++) 1020 udelay(1000);
or common code:
common/cmd_fdc.c:
213 while((read_fdc_reg(FDC_SRA)&0x80)==0) { 214 timeout--; 215 udelay(10); 216 if(timeout==0) /* timeout occured */ 217 return FALSE; 218 }
228 while((read_fdc_reg(FDC_MSR)&0xC0)!=0xC0) { 229 /* direction out and ready */ 230 udelay(10); 231 timeout--; 232 if(timeout==0) /* timeout occured */ 233 return -1; 234 } etc.etc.
375 for(val=0;val<255;val++) 376 udelay(500); /* wait some time to start motor */
418 for(i=0;i<100;i++) 419 udelay(500); /* wait 500usec for fifo overrun */
600 for(i=0; i<255; i++) /* then we wait some time */ 601 udelay(500);
common/usb.c:
93 inline void wait_ms(unsigned long ms) 94 { 95 while (ms--> 0) 96 udelay(1000); 97 }
etc. etc. Note this last example which "spreads" the effect in a not so nice way.
Note that there are even places where udelay() is part of the protocol timing implementation - like in the soft-I2C and soft-SPI drivers.
Hi All, Thanks for the pointers Wolfgang. From your examples, it seems we are talking exclusively about udelay. As I said in my previous post, on NIOS2, udelay needs to be mechanized on NIOS2 by a timed loop, not by using the same mechanism as the timer, as there is no way one can approximate microsecond resolution by the hardware timer. It is my opinion that there are many CPUs on which the udelay implementation must not be/should not be based on the same timer code as the get_time() operation, because in many cases the get_time() operation requires interrupts to be functional. As you have also pointed out, udelay needs to be available "early", before interrupts are available. Therefore, the udelay and get_timer must use the hardware at least somewhat differently. The must also not interfere with each other, which on some existing boards they did. If the I2C protocol must be available before interrupts are available, then udelay must be used. In the above examples, there are some loops in i2c and spi that appear to be waiting a full second. I assume they are using udelay because the get_timer feature is not yet available to them. I also assume that the example in common/usb.c uses udelay to wait for millisecond sized values for the same reason, i.e. that it may run before get_time() is available. However, if you examine the timer code on of the existing CPUs, you will find that udelay is NOT available early ( before interrupts are enabled) on quite a few of them. Therefore, none of the above code would work on these CPUs at present either. These CPUs must not have I2C or spi busses on them that are accessed "early".
equivalent operation can be produced by a pretty simple re-coding of the loop. In any case, NIOS does not have the problem at present, so the suggested new work-around would be no worse than the present situation.
I think it is not correct to state that "NIOS does not have the problem at present" - it does, only this is not a blatant problem at the moment. Which in turn might result from the fact that all presently supported NIOS boards has any support enabled for I2C or SPI or USB or MMC or watchdogs or ... you name it.
The first user who adds any of the currently unused (and thus untested) standard features that work just fine on all other architectures might run into issue...
True, although I expect you will find the statement "on all the other architectures" to be false. Many other architectures, yes, all, no. These other architectures just don't have spi or I2C yet, or if they do, they don't use it "early".
It is also true that the hardware timer cannot be used in a
reasonable version of udelay, as most of the desired delays may be very short relative to the timebase. A calibrated timing loop would be the best approach to the udelay problem.
Just try using Soft-I2C on a NIOS board and you will immediately realize how crucial a working version of udelay() is.
Agreed. The definition of "working" would need to include that the routine is available "early" and that it is accurate to within say +/-5% (other numbers welcome) of the specified delay, unless the delay is "small" relative to the CPU speed (not an issue on most CPUs, but is on some). On these existing NIOS2 processors, that will require a udelay based on a timing loop, as there is no microsecond level timer available. The timing loop can be calibrated using the 10 ms timer, so it can be accurate enough. It may need re-calibration if icache is turned on, but this is also doable.
In general, that is true. There may be a few cases where a delay of less than the resolution is essential to make something work. There are
These are not just "a few cases". There are tons of it, all over the place - from protocol implementations like soft-I2C or soft-I2C to timing requirements for RAM initializations etc. etc. And there are enough places that mandate that the timing is at least in the requested oder, and not off by factors of tens or hundrets or worse.
probably lots of other cases where we can easily remove the restriction on the resolution. We cannot fix the first kind, no matter what we do, to work on a lower resolution timer. The second kind we can and probably should fix, because they are coded in an overly-restrictive manner. In any case, we don't absolutely have to fix them until somebody decides to use the code on a CPU with a low resolution timer. Practically speaking, the suggested solution will therefore work on all extant cases.
It will work by chance, at best. See above - any attempt to enable one of the currently not yet used standard features in U-Boot may break your system. I don't consider this a sound base - to me it feels like building on qicksand.
In a perfect world, I would agree with you. Unfortunately (or maybe inevitably), large software projects are iterative. There are quite a few u-boot versions in the current code that do not meet all the requirements that exits for a fully compliant udelay. There were also quite a few board ports whose timers did not meet the implicit requirements to be fully "compliant". Full compliance is required for "plug and play" with u-boot code that has been written assuming this full compliance. Quite a few people have just made a port that works for them without worrying about this compliance. One could argue that compliance was not well enough documented, or that non-compliant boards should not have been accepted. All perhaps true (or not, because u-boot was still feeling its way forward), but we are where we are. We can't retro-actively change the NIOS2 boards that are out there already. However, we can require that if any of the boards are to be upgraded to include I2C or SPI devices, they must be supplied with a compliant udelay, either by a timed loop or increasing the hardware timer resolution. The get_timer design is sound for all existing designs if the resolution compensation is added. It preserves all working boards as working . If you modify the configuration of existing boards that currently are non-compliant in some way, they may quit working. That is true now, and it will be true if the change to include the resolution is made. If udelay doesn't have compliant resolution and accuracy, newly enabled code may fail. If you aren't using such code, you may not be motivated to fix the problem. It still should be fixed, but often will not be until it breaks something. So I think we are building on solid, backwards compatible ground. Yes, non-compliant boards need to be "fixed", but we need a way to move forward with minimum pain to the current users.
Best Regards, Bill Campbell
Best regards,
Wolfgang Denk

Dear "J. William Campbell",
In message 4E208227.6010903@comcast.net you wrote:
If the I2C protocol must be available before interrupts are
available, then udelay must be used. In the above examples, there are some loops in i2c and spi that appear to be waiting a full second. I assume they are using udelay because the get_timer feature is not yet available to them. I also assume that the example in common/usb.c uses
No, this is usually not the case. This long delay is the error case, which most probably will never happen. For the normal case, you want a tight spinning loop that introduces as little additional delay as possible.
True, although I expect you will find the statement "on all the other architectures" to be false. Many other architectures, yes, all, no. These other architectures just don't have spi or I2C yet, or if they do, they don't use it "early".
Are you aware of another architecture that cannot provide sub-microsecond timer resolution? Which is it?
Best regards,
Wolfgang Denk

On 7/15/2011 11:34 AM, Wolfgang Denk wrote:
Dear "J. William Campbell",
In message4E208227.6010903@comcast.net you wrote:
If the I2C protocol must be available before interrupts are
available, then udelay must be used. In the above examples, there are some loops in i2c and spi that appear to be waiting a full second. I assume they are using udelay because the get_timer feature is not yet available to them. I also assume that the example in common/usb.c uses
No, this is usually not the case. This long delay is the error case, which most probably will never happen. For the normal case, you want a tight spinning loop that introduces as little additional delay as possible.
Hi All, I understand why one would want to use udelay in those cases where there are other conditions that should cause the loop to exit. However, in the 16 examples you cited, 7 of those usages are for delays of multiple milliseconds with no tests or escape conditions included. I therefore pointed out that I assume that it was being done that way (as opposed to using get_timer) because this code would be executed "early", before get_timer was available.
True, although I expect you will find the statement "on all the other architectures" to be false. Many other architectures, yes, all, no. These other architectures just don't have spi or I2C yet, or if they do, they don't use it "early".
Are you aware of another architecture that cannot provide sub-microsecond timer resolution? Which is it?
No, but I am aware of some that do not provide udelay at all until after interrupts are enabled and the get_timer interface is available. Several ARM implementations have this property. There are one or two others (SPARC) that are similar as I recall. There were also some that called reset_timer, which would mess up nested timing loops, but this has already been fixed. There also quite a few udelay implementations that do not actually provide 1 µs resolution. For instance, the first thing that happens in arm720t/interrupts.c __udelay is that the input microseconds is divided by 1000 and the remainder discarded. A udelay(10) won't work so well here. The lh7a40x/timer.c uses a 508 kHz clock, so delays are accurate to at best 2 µs. There are other examples. For instance, I am pretty sure some u-boot based CPUs use a 32kHz clock as the timebase for udelay. The resolution in that case is 30 µs, which would be a problem for your example code. I am sure further digging will reveal other resolution issues.
These udelay issues would need fixing if all u-boot options are to work "out of the box". In some cases of low resolution, the fix is not easy, or maybe not even possible. However, this problem has not prevented the use of u-boot on these CPUs. It does mean that some things do not work "out of the box", and these non-compliant udelays should be fixed wherever practical. In any case, this shouldn't stop progress on get_timer and the delay_at_least (or whatever it ends up being called) function being adopted. That is independent of the udelay issues. udelay must be implemented in a "compliant" manner, which may or may not use the same hardware as get_timer() does. It certainly can't use the same code (although some ARM version in effect do, resulting in a non-compliant, low resolution udelay).
It might be interesting to utilize something like "jiffies" for the loop delays that are looking for error exits. In those cases, the error case should be infrequent. It may not matter that the total delay is quite a bit longer than the user requested, as long as it isn't vastly shorter. If a 10 µsec delay became a 30 µsec delay inside the loop examples where we expect to exit due to another cause, it probably wouldn't matter much. It would matter a lot though if the delay were setting a baud rate on a "bit-banged" output, so jiffies may not be worth it. I put it out there for consideration, as it is easier to produce than a udelay that has a guaranteed low absolute error.
Best Regards, Bill Campbell
Best regards,
Wolfgang Denk

Wolfgang, Bill
This thread was getting a little long so I took the liberty to snip the lot ;)
Now, the way I see things we are looking at two entirely different issues - udelay() and the Timer API. Unfortunately, they are somewhat intertwined because:
a) Some Architectures/SoCs/Boards etc do not implement udelay() in a manner that is either 'available early' or 'inaccurate' (or in some cases both) and b) There is a not insignificant amount of code that uses a counter/udelay combination to implement timeout detection
I think for the moment I would like to concentrate solely on the Timer API and leave udelay out of it. I know some architectures use the existing Timer API for udelay, but if you look at my patch series, I never actually touched the existing architecture timer implementations. To date, the series has mostly been a rename and tidy-up of the Timer API and it's usage.
So, I think it will be easier to progress if we forget about udelay for the moment. We can identify where it is broken/being abused as a separate task.
I can expand the scope of this patch series to look at those instances where an incrementing loop counter with a udelay in the loop is being used where get_time() and friend(s) should be used instead.
So in future, any architecture that can both initialise the timer sub-system 'early' and has a timer resolution of <= 1us can use the Timer API for udelay, otherwise, udelay will need an implementation (for that architecture) which is independent of the timer sub-system. As an aside, the x86 code _used_ to have a conditional udelay. If the timer sub-system was not initialised yet, udelay would be implemented as a NOP loop. After timers were available, they were used as they are more accurate.
Regards,
Graeme

This patch series is the first 'logical' half of the previous series titled '(WIP) [Timer]API Rewrite' which was a 16 part series
This half (the first half) of the original series is a simplification of the existing API designed to correct a few 'implementation errors' and prepare the U-Boot tree for the new Timer API (which is still under active discussion).
Changes since v1 ((WIP) [Timer]API Rewrite): - Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6 - Tweaks to some patch titles - Changed title prefix from '[Timer]' to 'Timer:' (git eats [..]) - Introduce new #define CONFIG_SYS_LOW_RES_TIMER - Dropping of the entire second half of the series (the new Timer API)
Graeme Russ (7): Timer: Fix misuse of ARM *timer_masked() functions outside arch/arm Timer: Remove calls to set_timer outside arch/ Timer: Remove set_timer completely Timer: Allow reset_timer() only for systems with low resolution timers Timer: Remove reset_timer() for non-Nios2 arches Timer: Fix at91rm9200/spi.c timer usage Timer: Remove reset_timer_masked()
arch/arm/cpu/arm1136/mx31/timer.c | 17 ----------------- arch/arm/cpu/arm1136/mx35/timer.c | 9 --------- arch/arm/cpu/arm1136/omap24xx/timer.c | 24 +++++++----------------- arch/arm/cpu/arm1176/s3c64xx/timer.c | 17 ----------------- arch/arm/cpu/arm1176/tnetv107x/timer.c | 14 -------------- arch/arm/cpu/arm720t/interrupts.c | 17 ----------------- arch/arm/cpu/arm920t/a320/timer.c | 12 ------------ arch/arm/cpu/arm920t/at91/timer.c | 19 ------------------- arch/arm/cpu/arm920t/at91rm9200/spi.c | 5 +++-- arch/arm/cpu/arm920t/at91rm9200/timer.c | 18 ------------------ arch/arm/cpu/arm920t/ep93xx/timer.c | 15 +++------------ arch/arm/cpu/arm920t/imx/timer.c | 21 +++------------------ arch/arm/cpu/arm920t/ks8695/timer.c | 25 +++++-------------------- arch/arm/cpu/arm920t/s3c24x0/timer.c | 18 ------------------ arch/arm/cpu/arm925t/timer.c | 23 +++-------------------- arch/arm/cpu/arm926ejs/armada100/timer.c | 20 ++------------------ arch/arm/cpu/arm926ejs/davinci/timer.c | 5 ----- arch/arm/cpu/arm926ejs/kirkwood/timer.c | 20 ++------------------ arch/arm/cpu/arm926ejs/mb86r0x/timer.c | 19 +++---------------- arch/arm/cpu/arm926ejs/mx25/timer.c | 19 ------------------- arch/arm/cpu/arm926ejs/mx27/timer.c | 19 ------------------- arch/arm/cpu/arm926ejs/nomadik/timer.c | 12 +++++------- arch/arm/cpu/arm926ejs/omap/timer.c | 11 ----------- arch/arm/cpu/arm926ejs/orion5x/timer.c | 20 ++------------------ arch/arm/cpu/arm926ejs/pantheon/timer.c | 20 ++------------------ arch/arm/cpu/arm926ejs/spear/timer.c | 22 +++------------------- arch/arm/cpu/arm926ejs/versatile/timer.c | 11 ----------- arch/arm/cpu/armv7/mx5/timer.c | 20 ++++---------------- arch/arm/cpu/armv7/omap-common/timer.c | 21 +++------------------ arch/arm/cpu/armv7/s5p-common/timer.c | 10 ---------- arch/arm/cpu/armv7/tegra2/timer.c | 17 ----------------- arch/arm/cpu/armv7/u8500/timer.c | 5 ----- arch/arm/cpu/ixp/timer.c | 10 ---------- arch/arm/cpu/lh7a40x/timer.c | 11 ----------- arch/arm/cpu/pxa/timer.c | 18 +----------------- arch/arm/cpu/s3c44b0/timer.c | 18 ------------------ arch/arm/cpu/sa1100/timer.c | 16 ---------------- arch/avr32/cpu/interrupts.c | 23 ----------------------- arch/blackfin/cpu/interrupts.c | 5 ----- arch/m68k/cpu/mcf547x_8x/slicetimer.c | 9 --------- arch/m68k/lib/board.c | 2 -- arch/m68k/lib/time.c | 21 ++------------------- arch/microblaze/cpu/timer.c | 12 +----------- arch/mips/cpu/mips32/time.c | 12 ------------ arch/nios2/cpu/interrupts.c | 6 ------ arch/powerpc/lib/board.c | 2 -- arch/powerpc/lib/interrupts.c | 10 ---------- arch/sh/lib/time.c | 12 ------------ arch/sh/lib/time_sh2.c | 15 +-------------- arch/sparc/lib/board.c | 2 -- arch/sparc/lib/interrupts.c | 12 +----------- arch/x86/lib/board.c | 2 -- arch/x86/lib/timer.c | 10 ---------- board/BuS/EB+MCF-EV123/flash.c | 10 ++++++---- board/armadillo/flash.c | 6 ++++-- board/armltd/integrator/timer.c | 24 ++++-------------------- board/armltd/vexpress/ca9x4_ct_vxp.c | 5 ----- board/atmel/at91rm9200dk/flash.c | 10 ++++++---- board/cerf250/flash.c | 14 ++++++-------- board/cm4008/flash.c | 10 ++++++---- board/cm41xx/flash.c | 10 ++++++---- board/cmc_pu2/flash.c | 11 ++++++----- board/cobra5272/flash.c | 10 ++++++---- board/cradle/flash.c | 10 ++++++---- board/csb226/flash.c | 10 ++++++---- board/dnp1110/flash.c | 14 ++++++-------- board/ep7312/flash.c | 10 ++++++---- board/gcplus/flash.c | 14 ++++++-------- board/idmr/flash.c | 10 ++++++---- board/impa7/flash.c | 10 ++++++---- board/innokom/flash.c | 10 ++++++---- board/lart/flash.c | 10 ++++++---- board/lpd7a40x/flash.c | 10 ++++++---- board/lubbock/flash.c | 14 ++++++-------- board/modnet50/flash.c | 14 ++++++++------ board/mx1ads/syncflash.c | 2 +- board/ns9750dev/flash.c | 15 ++++++--------- board/nvidia/common/board.c | 1 - board/pleb2/flash.c | 18 +++++++++--------- board/samsung/smdk2400/flash.c | 10 ++++++---- board/sbc2410x/flash.c | 10 ++++++---- board/scb9328/flash.c | 5 +++-- board/shannon/flash.c | 10 ++++++---- board/ti/omap1610inn/flash.c | 15 ++++++--------- board/ti/omap730p2/flash.c | 15 ++++++--------- board/xaeniax/flash.c | 14 ++++++-------- board/xm250/flash.c | 23 +++++++++++------------ board/zylonite/flash.c | 14 ++++++-------- drivers/block/mg_disk.c | 2 ++ drivers/mtd/cfi_flash.c | 4 ++++ drivers/mtd/spi/eeprom_m95xxx.c | 5 +++-- drivers/net/fec_mxc.c | 6 +++--- drivers/net/netarm_eth.c | 12 +++++++----- include/common.h | 1 - include/configs/PCI5441.h | 1 + include/configs/PK1C20.h | 1 + include/configs/nios2-generic.h | 1 + 97 files changed, 274 insertions(+), 910 deletions(-)
-- 1.7.5.2.317.g391b14

Hi Wolfgang,
On 15/07/11 22:15, Graeme Russ wrote:
This patch series is the first 'logical' half of the previous series titled '(WIP) [Timer]API Rewrite' which was a 16 part series
This half (the first half) of the original series is a simplification of the existing API designed to correct a few 'implementation errors' and prepare the U-Boot tree for the new Timer API (which is still under active discussion).
Changes since v1 ((WIP) [Timer]API Rewrite):
- Rebased to 68d4230c3ccce96a72c5b99e48399bf1796fe3c6
- Tweaks to some patch titles
- Changed title prefix from '[Timer]' to 'Timer:' (git eats [..])
- Introduce new #define CONFIG_SYS_LOW_RES_TIMER
- Dropping of the entire second half of the series (the new Timer API)
Graeme Russ (7): Timer: Fix misuse of ARM *timer_masked() functions outside arch/arm Timer: Remove calls to set_timer outside arch/ Timer: Remove set_timer completely Timer: Allow reset_timer() only for systems with low resolution timers Timer: Remove reset_timer() for non-Nios2 arches Timer: Fix at91rm9200/spi.c timer usage Timer: Remove reset_timer_masked()
Oh dear, it looks like Patchwork does not honour 'in-reply-to'. It has created new patches rather than updating the existing ones :(
I've marked the old ones 'Superseded' in Patchwork
Regards,
Graeme

Hi Greame,
Le 15/07/2011 15:08, Graeme Russ a écrit :
Oh dear, it looks like Patchwork does not honour 'in-reply-to'. It has created new patches rather than updating the existing ones :(
I'm not sure patchwork is supposed to honor the in-reply between patch versions. BTBW, is there a rationale or other documentation on the behavior of patchwork somewhere?
I've marked the old ones 'Superseded' in Patchwork
Thanks!
Amicalement,

Hi Albert,
On 16/07/11 18:36, Albert ARIBAUD wrote:
Hi Greame,
Le 15/07/2011 15:08, Graeme Russ a écrit :
Oh dear, it looks like Patchwork does not honour 'in-reply-to'. It has created new patches rather than updating the existing ones :(
I'm not sure patchwork is supposed to honor the in-reply between patch versions. BTBW, is there a rationale or other documentation on the behavior of patchwork somewhere?
I should! - The whole point of me painstakingly getting the in-reply-to correct for each individual patch was so they would track correctly everywhere (inbox, list archive, patchwork). Oh Well
Regards,
Graeme

Le 16/07/2011 11:01, Graeme Russ a écrit :
Hi Albert,
On 16/07/11 18:36, Albert ARIBAUD wrote:
Hi Greame,
Le 15/07/2011 15:08, Graeme Russ a écrit :
Oh dear, it looks like Patchwork does not honour 'in-reply-to'. It has created new patches rather than updating the existing ones :(
I'm not sure patchwork is supposed to honor the in-reply between patch versions. BTBW, is there a rationale or other documentation on the behavior of patchwork somewhere?
I should! - The whole point of me painstakingly getting the in-reply-to correct for each individual patch was so they would track correctly everywhere (inbox, list archive, patchwork). Oh Well
Two out of three ain't bad. :)
Regards,
Graeme
Amicalement,

Dear Graeme Russ,
In message 4E215370.2090203@gmail.com you wrote:
I'm not sure patchwork is supposed to honor the in-reply between patch versions. BTBW, is there a rationale or other documentation on the behavior of patchwork somewhere?
I should! - The whole point of me painstakingly getting the in-reply-to correct for each individual patch was so they would track correctly everywhere (inbox, list archive, patchwork). Oh Well
As far as I understand the threading is only given in the mailing list. Patchwork is not clever enough to recognize a reposting. Old, superseded patches have to be manually marked as such (as long as they are not already set to "Changes Requested").
Best regards,
Wolfgang Denk
participants (10)
-
Albert ARIBAUD
-
Andreas Bießmann
-
Graeme Russ
-
J. William Campbell
-
Mike Frysinger
-
Reinhard Meyer
-
Scott McNutt
-
Simon Glass
-
Vitaly Kuzmichev
-
Wolfgang Denk