Skip to contentSkip to conversation

Timer cleanup, new API, x86 HAL

RFC PATCH New Graeme Russ 1 participant 6 messages May 29, 2011

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

cover Timer cleanup, new API, x86 HAL

This is a preview patch series for the new timer API implemented for the x86 architecture. It provides a proof of concept for the API currently under discussion. Some of the details are yet to be finalised, but hopefully this patchset will give some insight into where we are going. Note in particular the implementation of sync_timers() - It works very well for systems with 1us tick sources, but is not at all generic for more obscure clock frequencies - Bill Campbell will (hopefully ;)) provide a more robust function.

Enjoy

Graeme Russ (5):
[Timer]Remove calls to [set,reset]_timer outside arch/ [Timer]Fix misuse of ARM *timer_masked() functions [x86]Fix Global Data usage in assembler files [Timer]Create new timer API
[Timer]Add x86 timer HAL

 arch/nios2/cpu/interrupts.c        |    4 +++
 arch/x86/cpu/sc520/sc520_timer.c   |   46 ++++++++++++++++++++++++++---------
 arch/x86/cpu/start.S               |    3 +-
 arch/x86/include/asm/global_data.h |   35 ++++++++++++---------------
 arch/x86/include/asm/ic/sc520.h    |    9 +-----
 arch/x86/lib/board.c               |   12 ++++++++-
 arch/x86/lib/timer.c               |   15 +-----------
 board/BuS/EB+MCF-EV123/flash.c     |   10 ++++---
 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/cobra5272/flash.c            |   10 ++++---
 board/cradle/flash.c               |   10 ++++---
 board/csb226/flash.c               |   10 ++++---
 board/dnp1110/flash.c              |   14 ++++------
 board/eNET/eNET.c                  |   11 ++++----
 board/eNET/eNET_start.S            |   13 +++++++++-
 board/eNET/eNET_start16.S          |    9 +++++++
 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/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/samsung/smdk2410/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/block/mg_disk.c            |    1 -
 drivers/mtd/cfi_flash.c            |    2 -
 drivers/mtd/spi/eeprom_m95xxx.c    |    5 ++-
 drivers/net/fec_mxc.c              |    6 ++--
 drivers/net/netarm_eth.c           |   12 +++++----
 drivers/spi/atmel_dataflash_spi.c  |    5 ++-
 include/common.h                   |    4 +++
 lib/asm-offsets.c                  |    3 ++
 lib/time.c                         |   45 +++++++++++++++++++++++++++++++++++
 56 files changed, 382 insertions(+), 272 deletions(-)

--
1.7.5.2.317.g391b14

#1 lore raw

RFC PATCH 1/5 Remove calls to [set, reset]_timer outside arch/

There is no need to use set_timer() and reset_timer() and there are build breakages occuring because of them (specifically cfi_flash). Remove any usage outside arch/ to fix build breakages and to prepare for complete removal

The Nios2 timer implentation updates every 10ms (increases in 10ms steps) and required a reset_timer() call before timing operations. For Nios2, call reset_timer() when get_timer() is called with a parameter value of 0

---
checkpatch complains about long lines and brace usage in the board specific flash.c files - They are deprecated and not worth fixing for style

NOTE: The Nios2 solution is not correct - a proper solution is currently under discussion

Changes since V1:
- Fix typo in commit message
- Add reset_timer() to Nios2 get_timer(0)

---
 arch/nios2/cpu/interrupts.c    |    4 ++++
 board/BuS/EB+MCF-EV123/flash.c |   10 ++++++----
 board/cobra5272/flash.c        |   10 ++++++----
 board/idmr/flash.c             |   10 ++++++----
 drivers/block/mg_disk.c        |    1 -
 drivers/mtd/cfi_flash.c        |    2 --
 6 files changed, 22 insertions(+), 15 deletions(-)
arch/nios2/cpu/interrupts.c +4 -0
index 63acfa9..4e027f1 100644
@@ -95,6 +95,10 @@ void reset_timer (void)
 ulong get_timer (ulong base)
 {
 	WATCHDOG_RESET ();
+
+	if (base == 0)
+		reset_timer();
+
 	return (timestamp - base);
 }
 
board/BuS/EB+MCF-EV123/flash.c +6 -4
index 3c36367..8b7f957 100644
@@ -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)))
board/cobra5272/flash.c +6 -4
index 33c9361..e8f02eb 100644
@@ -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;
 		}
board/idmr/flash.c +6 -4
index 57c9948..9f4ff2b 100644
@@ -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;
 		}
drivers/block/mg_disk.c +0 -1
index b74307a..7609557 100644
@@ -91,7 +91,6 @@ static unsigned int mg_wait (u32 expect, u32 msec)
 	u32 from, cur, err;
 
 	err = MG_ERR_NONE;
-	reset_timer();
 	from = get_timer(0);
 
 	status = readb(mg_base() + MG_REG_STATUS);
drivers/mtd/cfi_flash.c +0 -2
index 5788328..ea5e1f2 100644
@@ -573,7 +573,6 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector,
 #endif
 
 	/* Wait for command completion */
-	reset_timer();
 	start = get_timer (0);
 	while (flash_is_busy (info, sector)) {
 		if (get_timer (start) > tout) {
@@ -660,7 +659,6 @@ static int flash_status_poll(flash_info_t *info, void *src, void *dst,
 #endif
 
 	/* Wait for command completion */
-	reset_timer();
 	start = get_timer(0);
 	while (1) {
 		switch (info->portwidth) {

--
1.7.5.2.317.g391b14

#2 lore raw

RFC PATCH 2/5 Fix misuse of ARM *timer_masked() functions outside arch/arm

In reply to Graeme Russ
---
 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/samsung/smdk2410/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 +++++++-----
 drivers/spi/atmel_dataflash_spi.c |    5 +++--
 38 files changed, 217 insertions(+), 195 deletions(-)
board/armadillo/flash.c +4 -2
index cdbbfd0..cf7d7f6 100644
@@ -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;
board/atmel/at91rm9200dk/flash.c +6 -4
index 902c3c4..be22743 100644
@@ -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;
 		}
board/cerf250/flash.c +6 -8
index a4b201e..e1e7807 100644
@@ -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);
 		}
board/cm4008/flash.c +6 -4
index 2e66872..d6fd519 100644
@@ -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);
 		}
board/cm41xx/flash.c +6 -4
index 2e66872..d6fd519 100644
@@ -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);
 		}
board/cmc_pu2/flash.c +6 -5
index d832e62..d10faab 100644
@@ -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);
 		}
board/cradle/flash.c +6 -4
index b5635fb..1601782 100644
@@ -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;
board/csb226/flash.c +6 -4
index 02ded1c..e103470 100644
@@ -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;
board/dnp1110/flash.c +6 -8
index c81abc5..53f89ee 100644
@@ -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);
 		}
board/ep7312/flash.c +6 -4
index 0c2b3ae..2ed9c9a 100644
@@ -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;
board/gcplus/flash.c +6 -8
index 8511582..ab567e8 100644
@@ -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);
 		}
board/impa7/flash.c +6 -4
index d0c5880..6eae428 100644
@@ -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;
board/innokom/flash.c +6 -4
index 8c95341..ed4b987 100644
@@ -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;
board/ixdp425/flash.c +6 -4
index f1d9190..5e4e0e7 100644
@@ -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);
 		}
board/lart/flash.c +6 -4
index 29a331e..408c884 100644
@@ -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;
board/lpd7a40x/flash.c +6 -4
index a3ba75b..f5c0713 100644
@@ -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;
board/lubbock/flash.c +6 -8
index a4b201e..1ea2893 100644
@@ -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);
 		}
board/modnet50/flash.c +8 -6
index 4c31143..4834e21 100644
@@ -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 */
board/mpl/vcma9/flash.c +6 -4
index 7abf9cf..5d49204 100644
@@ -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;
 		}
board/mx1ads/syncflash.c +1 -1
index 47f613c..7331efa 100644
@@ -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();
board/ns9750dev/flash.c +6 -9
index 5b56b98..185bc2d 100644
@@ -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);
 		}
board/pleb2/flash.c +9 -9
index a8897dc..2406c5f 100644
@@ -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;
 		}
board/samsung/smdk2400/flash.c +6 -4
index fb69c21..47382fe 100644
@@ -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;
board/samsung/smdk2410/flash.c +6 -4
index 132d752..cef0cd2 100644
@@ -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
@@ -324,7 +326,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;
@@ -332,7 +334,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;
 		}
board/sbc2410x/flash.c +6 -4
index abb0935..d209a6f 100644
@@ -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;
 		}
board/scb9328/flash.c +3 -2
index c6f94ae..00c660a 100644
@@ -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;
 		}
board/shannon/flash.c +6 -4
index 0455afa..179ec5f 100644
@@ -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;
board/ti/omap1610inn/flash.c +6 -9
index 36200ad..1b67d08 100644
@@ -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);
 		}
board/ti/omap730p2/flash.c +6 -9
index 5b56b98..185bc2d 100644
@@ -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);
 		}
board/trab/cmd_trab.c +3 -3
index dec3c61..17890d9 100644
@@ -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);
 	}
 
board/trab/flash.c +6 -4
index 4e89c41..bde1f77 100644
@@ -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;
 		}
board/xaeniax/flash.c +6 -8
index b051c89..6cb0aca 100644
@@ -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);
 		}
board/xm250/flash.c +11 -12
index b02149c..e825aba 100644
@@ -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;
board/zylonite/flash.c +6 -8
index 5ba84c6..3ee0ab8 100644
@@ -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);
 		}
drivers/mtd/spi/eeprom_m95xxx.c +3 -2
index 632db4e..ef8ed6f 100644
@@ -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");
drivers/net/fec_mxc.c +3 -3
index 4e4cd27..ab90afa 100644
@@ -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);
drivers/net/netarm_eth.c +7 -5
index c9e324e..f54817e 100644
@@ -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 */
drivers/spi/atmel_dataflash_spi.c +3 -2
index 4a5c4aa..cc5a532 100644
@@ -134,6 +134,7 @@ unsigned int AT91F_SpiWrite1(AT91PS_DataflashDesc pDesc);
 unsigned int AT91F_SpiWrite(AT91PS_DataflashDesc pDesc)
 {
 	unsigned int timeout;
+	ulong start;
 
 	pDesc->state = BUSY;
 
@@ -158,12 +159,12 @@ unsigned int AT91F_SpiWrite(AT91PS_DataflashDesc pDesc)
 	}
 
 	/* arm simple, non interrupt dependent timer */
-	reset_timer_masked();
+	start = get_timer(0);
 	timeout = 0;
 
 	writel(AT91_SPI_TXTEN + AT91_SPI_RXTEN, AT91_BASE_SPI + AT91_SPI_PTCR);
 	while (!(readl(AT91_BASE_SPI + AT91_SPI_SR) & AT91_SPI_RXBUFF) &&
-		((timeout = get_timer_masked()) < CONFIG_SYS_SPI_WRITE_TOUT));
+		((timeout = get_timer(start)) < CONFIG_SYS_SPI_WRITE_TOUT));
 	writel(AT91_SPI_TXTDIS + AT91_SPI_RXTDIS, AT91_BASE_SPI + AT91_SPI_PTCR);
 	pDesc->state = IDLE;
 

--
1.7.5.2.317.g391b14

#3 lore raw

RFC PATCH 3/5 Fix Global Data usage in assembler files

In reply to Graeme Russ

---
This is a little fixup patch unrelated specifically to the timer rework I will send this as an independent patch later

 arch/x86/cpu/start.S               |    3 ++-
 arch/x86/include/asm/global_data.h |   19 -------------------
 arch/x86/include/asm/ic/sc520.h    |    8 --------
 lib/asm-offsets.c                  |    3 +++
 4 files changed, 5 insertions(+), 28 deletions(-)
arch/x86/cpu/start.S +2 -1
index 7ccc076..31de0f8 100644
@@ -30,6 +30,7 @@
 #include <version.h>
 #include <asm/global_data.h>
 #include <asm/processor-flags.h>
+#include <asm-offsets.h>
 
 .section .text
 .code32
@@ -114,7 +115,7 @@ relocate_code:
 
 	/* Setup call address of in-RAM copy of board_init_r() */
 	movl	$board_init_r, %ebp
-	addl	(GD_RELOC_OFF * 4)(%edx), %ebp
+	addl	(GENERATED_GD_RELOC_OFF)(%edx), %ebp
 
 	/* Setup parameters to board_init_r() */
 	movl	%edx, %eax
arch/x86/include/asm/global_data.h +0 -19
index f8a16d6..f977dbe 100644
@@ -58,25 +58,6 @@ extern gd_t *gd;
 
 #endif
 
-/* Word Offsets into Global Data - MUST match struct gd_t */
-#define GD_BD		0
-#define GD_FLAGS	1
-#define GD_BAUDRATE	2
-#define GD_HAVE_CONSOLE	3
-#define GD_RELOC_OFF	4
-#define GD_LOAD_OFF	5
-#define GD_ENV_ADDR	6
-#define GD_ENV_VALID	7
-#define GD_CPU_CLK	8
-#define GD_BUS_CLK	9
-#define GD_RELOC_ADDR	10
-#define GD_START_ADDR_SP	11
-#define GD_RAM_SIZE	12
-#define GD_RESET_STATUS	13
-#define GD_JT		14
-
-#define GD_SIZE		15
-
 /*
  * Global Data Flags
  */
arch/x86/include/asm/ic/sc520.h +0 -8
index 956c1c2..8b5f47c 100644
@@ -260,14 +260,6 @@ extern sc520_mmcr_t *sc520_mmcr;
 #define SC520_MMCR_BASE		0xfffef000
 
 /* MMCR Addresses (required for assembler code) */
-#define SC520_DRCCTL		(SC520_MMCR_BASE + 0x010)
-#define SC520_DRCTMCTL		(SC520_MMCR_BASE + 0x012)
-#define SC520_DRCCFG		(SC520_MMCR_BASE + 0x014)
-#define SC520_DRCBENDADR	(SC520_MMCR_BASE + 0x018)
-#define SC520_ECCCTL		(SC520_MMCR_BASE + 0x020)
-#define SC520_DBCTL		(SC520_MMCR_BASE + 0x040)
-#define SC520_ECCINT		(SC520_MMCR_BASE + 0xd18)
-
 #define SC520_PAR0		(SC520_MMCR_BASE + 0x088)
 #define SC520_PAR1		(SC520_PAR0 + (0x04 * 1))
 #define SC520_PAR2		(SC520_PAR0 + (0x04 * 2))
lib/asm-offsets.c +3 -0
index c88f5d4..6ae32dc 100644
@@ -28,5 +28,8 @@ int main(void)
 	DEFINE(GENERATED_BD_INFO_SIZE,
 		(sizeof(struct bd_info) + 15) & ~15);
 
+	DEFINE(GENERATED_GD_RELOC_OFF,
+		(offsetof(gd_t, reloc_off)));
+
 	return 0;
 }

--
1.7.5.2.317.g391b14

#4 lore raw

RFC PATCH 4/5 Create new timer API

In reply to Graeme Russ
---
 include/common.h |    4 ++++
 lib/time.c       |   45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 0 deletions(-)
include/common.h +4 -0
index 21c05db..ddb5c03 100644
@@ -622,6 +622,7 @@ void	__udelay      (unsigned long);
 ulong	usec2ticks    (unsigned long usec);
 ulong	ticks2usec    (unsigned long ticks);
 int	init_timebase (void);
+void	sync_ticks    (void);
 
 /* lib/gunzip.c */
 int gunzip(void *, int, unsigned char *, unsigned long *);
@@ -642,6 +643,9 @@ int strcmp_compar(const void *, const void *);
 
 /* lib/time.c */
 void	udelay        (unsigned long);
+void sync_timers(void);
+u32 get_us_timer(u32);
+u32 get_ms_timer(u32);
 
 /* lib/vsprintf.c */
 ulong	simple_strtoul(const char *cp,char **endp,unsigned int base);
lib/time.c +45 -0

54 lines not on this page · raw message

--
1.7.5.2.317.g391b14

#5 lore raw

RFC PATCH 5/5 Add x86 timer HAL

In reply to Graeme Russ
---
 arch/x86/cpu/sc520/sc520_timer.c   |   46 ++++++++++++++++++++++++++---------
 arch/x86/include/asm/global_data.h |   16 ++++++++++++
 arch/x86/include/asm/ic/sc520.h    |    3 ++
 arch/x86/lib/board.c               |   12 ++++++++-
 arch/x86/lib/timer.c               |   15 +-----------
 board/eNET/eNET.c                  |   11 ++++----
 board/eNET/eNET_start.S            |   13 +++++++++-
 board/eNET/eNET_start16.S          |    9 +++++++
 8 files changed, 90 insertions(+), 35 deletions(-)
arch/x86/cpu/sc520/sc520_timer.c +34 -12
index 1bcfe67..92e0954 100644
@@ -29,10 +29,13 @@
 #include <asm/interrupt.h>
 #include <asm/ic/sc520.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 void sc520_timer_isr(void)
 {
 	/* Ack the GP Timer Interrupt */
 	writeb(0x02, &sc520_mmcr->gptmrsta);
+	sync_timers();
 }
 
 int timer_init(void)
@@ -70,21 +73,40 @@ int timer_init(void)
 	return 0;
 }
 
-/* Allow boards to override udelay implementation */
 void __udelay(unsigned long usec)
-	__attribute__((weak, alias("sc520_udelay")));
+{
+	u32 start = get_us_timer(0);
+
+	while (get_us_timer(start) < usec)
+		;
+}
+
+void sync_ticks(void)
+{
+	u16 milli;
+	u16 micro;
+
+	milli = readw(&sc520_mmcr->swtmrmilli);
+	micro = readw(&sc520_mmcr->swtmrmicro);
+
+	gd->ticks += (milli * 1000) + micro - gd->last_micro;
+	gd->last_micro = micro;
+}
+
+ulong usec2ticks(unsigned long usecs)
+{
+	return usecs;
+}
 
-void sc520_udelay(unsigned long usec)
+ulong ticks2usec(unsigned long ticks)
 {
-	int m = 0;
-	long u;
-	long temp;
+	return ticks;
+}
 
-	temp = readw(&sc520_mmcr->swtmrmilli);
-	temp = readw(&sc520_mmcr->swtmrmicro);
+int init_timebase(void)
+{
+	sync_timers();
 
-	do {
-		m += readw(&sc520_mmcr->swtmrmilli);
-		u = readw(&sc520_mmcr->swtmrmicro) + (m * 1000);
-	} while (u < usec);
+	return 0;
 }
+
arch/x86/include/asm/global_data.h +16 -0
index f977dbe..6352f01 100644
@@ -50,8 +50,24 @@ typedef	struct global_data {
 	unsigned long	start_addr_sp;	/* start_addr_stackpointer */
 	phys_size_t	ram_size;	/* RAM size */
 	unsigned long	reset_status;	/* reset status register@boot */
+
+	/*
+	 * Used by the sc520 timer routine to keep track of free running
+	 * microsecond counter (which does not reset)
+	 */
+	u16		last_micro;	/* last value read from sc520 swtmrmicro */
+
+	/* Raw hardware tick counter maintained by sync_ticks() */
+	u64		ticks;
+
+	/* Timers maintained by sync_timers() */
+	u32		us_timer;	/* microsecond timer */
+	u32		ms_timer;	/* millisecond timer */
+	u32		us_accumulator;
+
 	void		**jt;		/* jump table */
 	char		env_buf[32];	/* buffer for getenv() before reloc. */
+
 } gd_t;
 
 extern gd_t *gd;
arch/x86/include/asm/ic/sc520.h +3 -0
index 8b5f47c..bcf46ca 100644
@@ -260,6 +260,9 @@ extern sc520_mmcr_t *sc520_mmcr;
 #define SC520_MMCR_BASE		0xfffef000
 
 /* MMCR Addresses (required for assembler code) */
+#define SC520_SWTMRMILLI	(SC520_MMCR_BASE + 0xc60)
+#define SC520_SWTMRCFG		(SC520_MMCR_BASE + 0xc64)
+
 #define SC520_PAR0		(SC520_MMCR_BASE + 0x088)
 #define SC520_PAR1		(SC520_PAR0 + (0x04 * 1))
 #define SC520_PAR2		(SC520_PAR0 + (0x04 * 2))
arch/x86/lib/board.c +10 -2
index df54222..6b57bd3 100644
@@ -159,6 +159,7 @@ static int do_elf_reloc_fixups(void);
 init_fnc_t *init_sequence_f[] = {
 	cpu_init_f,
 	board_early_init_f,
+	init_timebase,
 	env_init,
 	init_baudrate,
 	serial_init,
@@ -275,6 +276,9 @@ void board_init_r(gd_t *id, ulong dest_addr)
 	static gd_t gd_data;
 	init_fnc_t **init_fnc_ptr;
 
+	u32 start_us = get_us_timer(0);
+	u32 start_ms = get_ms_timer(0);
+
 	show_boot_progress(0x21);
 
 	/* Global data pointer is now writable */
@@ -363,8 +367,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);
@@ -432,6 +434,12 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
 	show_boot_progress(0x29);
 
+	printf("board_init_r () time = %u microseconds, %u milliseconds\n",
+			get_us_timer(start_us),
+			get_ms_timer(start_ms));
+
+	printf("Total Boot Time = %u microseconds\n", get_us_timer(0));
+
 	/* main_loop() can return to retry autoboot, if so just run it again. */
 	for (;;) {
 		main_loop();
arch/x86/lib/timer.c +1 -14
index 8fc68cd..e382aab 100644
@@ -36,7 +36,6 @@ struct timer_isr_function {
 };
 
 static struct timer_isr_function *first_timer_isr = NULL;
-static volatile unsigned long system_ticks = 0;
 
 /*
  * register_timer_isr() allows multiple architecture and board specific
@@ -85,8 +84,6 @@ void timer_isr(void *unused)
 {
 	struct timer_isr_function *temp = first_timer_isr;
 
-	system_ticks++;
-
 	/* Execute each registered function */
 	while (temp != NULL) {
 		temp->isr_func ();
@@ -94,17 +91,7 @@ void timer_isr(void *unused)
 	}
 }
 
-void reset_timer (void)
-{
-	system_ticks = 0;
-}
-
 ulong get_timer (ulong base)
 {
-	return (system_ticks - base);
-}
-
-void set_timer (ulong t)
-{
-	system_ticks = t;
+	return get_ms_timer(base);
 }
board/eNET/eNET.c +5 -6
index 2a5636c..226b68a 100644
@@ -48,6 +48,9 @@ int board_early_init_f(void)
 {
 	u16 pio_out_cfg = 0x0000;
 
+	/* 33.000 MHz xtal */
+	writeb(0x01, &sc520_mmcr->swtmrcfg);
+
 	/* Configure General Purpose Bus timing */
 	writeb(CONFIG_SYS_SC520_GPCSRT, &sc520_mmcr->gpcsrt);
 	writeb(CONFIG_SYS_SC520_GPCSPW, &sc520_mmcr->gpcspw);
@@ -252,16 +255,12 @@ void setup_pcat_compatibility()
 
 void enet_timer_isr(void)
 {
-	static long enet_ticks = 0;
-
-	enet_ticks++;
-
 	/* Toggle Watchdog every 100ms */
-	if ((enet_ticks % 100) == 0)
+	if ((get_ms_timer(0) % 100) == 0)
 		hw_watchdog_reset();
 
 	/* Toggle Run LED every 500ms */
-	if ((enet_ticks % 500) == 0)
+	if ((get_ms_timer(0) % 500) == 0)
 		enet_toggle_run_led();
 }
 
board/eNET/eNET_start.S +12 -1
index 0dec7ea..bd35d7d 100644
@@ -22,9 +22,20 @@
  */
 
 #include "hardware.h"
+#include <asm/ic/sc520.h>
 
 /* board early intialization */
 .globl early_board_init
 early_board_init:
-	/* No 32-bit board specific initialisation */
+
+	/* Set xtal frequency (33.000MHz) */
+	movl    $(SC520_SWTMRCFG), %edi
+	movb	$0x01, %al
+	movb	%al, (%di)
+
+	/* Reset millisecond software timer */
+	movl    $(SC520_SWTMRMILLI), %edi
+	movl	(%di), %eax
+
+	/* Done */
 	jmp	early_board_init_ret
board/eNET/eNET_start16.S +9 -0
index 77e5519..2fc032d 100644
@@ -47,6 +47,15 @@ board_init16:
 	movw	$0xdf00, %ax
 	movw	%ax, %ds
 
+	/* Set xtal frequency (33.000MHz) */
+	movl    $(SC520_SWTMRCFG - SC520_MMCR_BASE), %edi
+	movb	$0x01, %al
+	movb	%al, (%di)
+
+	/* Reset millisecond software timer */
+	movl    $(SC520_SWTMRMILLI - SC520_MMCR_BASE), %edi
+	movl	(%di), %eax
+
 	/* Map PAR for Boot Flash (BOOTCS, 512kB @ 0x380000000) */
 	movl    $(SC520_PAR14 - SC520_MMCR_BASE), %edi
 	movl	$CONFIG_SYS_SC520_BOOTCS_PAR, %eax

--
1.7.5.2.317.g391b14