Move this field into arch_global_data and tidy up.
Signed-off-by: Simon Glass <sjg@chromium.org>
if (now >= gd->lastinc) /* normal mode (non roll) */
/* move stamp forward with absolut diff ticks */
- gd->tbl += (now - gd->lastinc);
+ gd->arch.tbl += (now - gd->lastinc);
else /* we have rollover of incrementer */
- gd->tbl += (0xFFFFFFFF - gd->lastinc) + now;
+ gd->arch.tbl += (0xFFFFFFFF - gd->lastinc) + now;
gd->lastinc = now;
- return gd->tbl;
+ return gd->arch.tbl;
}
ulong get_timer_masked(void)
DECLARE_GLOBAL_DATA_PTR;
-#define timestamp (gd->tbl)
+#define timestamp (gd->arch.tbl)
#define lastinc (gd->lastinc)
/* General purpose timers bitfields */
/* reset time */
gd->lastinc = READ_TIMER; /* capture current incrementer value */
- gd->tbl = 0; /* start "advancing" time stamp */
+ gd->arch.tbl = 0; /* start "advancing" time stamp */
return(0);
}
if ((tmo + tmp + 1) < tmp) { /* if setting this forward will roll */
/* time stamp, then reset time */
gd->lastinc = READ_TIMER; /* capture incrementer value */
- gd->tbl = 0; /* start time stamp */
+ gd->arch.tbl = 0; /* start time stamp */
} else {
tmo += tmp; /* else, set advancing stamp wake up time */
}
{
ulong now = READ_TIMER; /* current tick value */
- if (now >= gd->lastinc) /* normal mode (non roll) */
- gd->tbl += (now - gd->lastinc); /* move stamp fordward with absoulte diff ticks */
- else /* we have rollover of incrementer */
- gd->tbl += (0xFFFFFFFF - gd->lastinc) + now;
+ if (now >= gd->lastinc) { /* normal mode (non roll) */
+ /* move stamp fordward with absoulte diff ticks */
+ gd->arch.tbl += (now - gd->lastinc);
+ } else {
+ /* we have rollover of incrementer */
+ gd->arch.tbl += (0xFFFFFFFF - gd->lastinc) + now;
+ }
gd->lastinc = now;
- return gd->tbl;
+ return gd->arch.tbl;
}
/* waits specified delay value and resets timestamp */
writel(cr, &tmr->cr);
gd->arch.timer_rate_hz = TIMER_CLOCK;
- gd->arch.tbu = gd->tbl = 0;
+ gd->arch.tbu = gd->arch.tbl = 0;
return 0;
}
ulong now = TIMER_LOAD_VAL - readl(&tmr->timer3_counter);
/* increment tbu if tbl has rolled over */
- if (now < gd->tbl)
+ if (now < gd->arch.tbl)
gd->arch.tbu++;
- gd->tbl = now;
- return (((unsigned long long)gd->arch.tbu) << 32) | gd->tbl;
+ gd->arch.tbl = now;
+ return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
}
void __udelay(unsigned long usec)
writel(AT91_TC_CCR_SWTRG | AT91_TC_CCR_CLKEN, &tc->tc[0].ccr);
gd->lastinc = 0;
- gd->tbl = 0;
+ gd->arch.tbl = 0;
return 0;
}
if (now >= gd->lastinc) {
/* normal mode */
- gd->tbl += now - gd->lastinc;
+ gd->arch.tbl += now - gd->lastinc;
} else {
/* we have an overflow ... */
- gd->tbl += now + TIMER_LOAD_VAL - gd->lastinc;
+ gd->arch.tbl += now + TIMER_LOAD_VAL - gd->lastinc;
}
gd->lastinc = now;
- return gd->tbl;
+ return gd->arch.tbl;
}
ulong get_timer_masked(void)
tmr = (tmr & ~0x0700000) | 0x0500000;
writel(tmr, &timers->tcon);
gd->lastinc = 0;
- gd->tbl = 0;
+ gd->arch.tbl = 0;
return 0;
}
if (gd->lastinc >= now) {
/* normal mode */
- gd->tbl += gd->lastinc - now;
+ gd->arch.tbl += gd->lastinc - now;
} else {
/* we have an overflow ... */
- gd->tbl += gd->lastinc + gd->arch.tbu - now;
+ gd->arch.tbl += gd->lastinc + gd->arch.tbu - now;
}
gd->lastinc = now;
- return gd->tbl;
+ return gd->arch.tbl;
}
/*
#define COUNT_RD_REQ 0x1
DECLARE_GLOBAL_DATA_PTR;
-/* Using gd->arch.tbu from timestamp and gd->tbl for lastdec */
+/* Using gd->arch.tbu from timestamp and gd->arch.tbl for lastdec */
/* For preventing risk of instability in reading counter value,
* first set read request to register cvwr and then read same
{
ulong now = read_timer();
- if (now >= gd->tbl) {
+ if (now >= gd->arch.tbl) {
/* normal mode */
- gd->arch.tbu += now - gd->tbl;
+ gd->arch.tbu += now - gd->arch.tbl;
} else {
/* we have an overflow ... */
- gd->arch.tbu += now + TIMER_LOAD_VAL - gd->tbl;
+ gd->arch.tbu += now + TIMER_LOAD_VAL - gd->arch.tbl;
}
- gd->tbl = now;
+ gd->arch.tbl = now;
return gd->arch.tbu;
}
/* Enable timer 0 */
writel(0x1, &armd1timers->cer);
- /* init the gd->arch.tbu and gd->tbl value */
- gd->tbl = read_timer();
+ /* init the gd->arch.tbu and gd->arch.tbl value */
+ gd->arch.tbl = read_timer();
gd->arch.tbu = 0;
return 0;
writel(TIMER_LOAD_VAL | AT91_PIT_MR_EN , &pit->mr);
gd->arch.timer_rate_hz = gd->arch.mck_rate_hz / 16;
- gd->arch.tbu = gd->tbl = 0;
+ gd->arch.tbu = gd->arch.tbl = 0;
return 0;
}
ulong now = readl(&pit->piir);
/* increment tbu if tbl has rolled over */
- if (now < gd->tbl)
+ if (now < gd->arch.tbl)
gd->arch.tbu++;
- gd->tbl = now;
- return (((unsigned long long)gd->arch.tbu) << 32) | gd->tbl;
+ gd->arch.tbl = now;
+ return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
}
void __udelay(unsigned long usec)
unsigned long now = readl(&timer->tim34);
/* increment tbu if tbl has rolled over */
- if (now < gd->tbl)
+ if (now < gd->arch.tbl)
gd->arch.tbu++;
- gd->tbl = now;
+ gd->arch.tbl = now;
- return (((unsigned long long)gd->arch.tbu) << 32) | gd->tbl;
+ return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl;
}
ulong get_timer(ulong base)
DECLARE_GLOBAL_DATA_PTR;
-#define timestamp gd->tbl
+#define timestamp gd->arch.tbl
#define lastdec gd->lastinc
ulong get_timer_masked(void)
DECLARE_GLOBAL_DATA_PTR;
-#define timestamp gd->tbl
+#define timestamp gd->arch.tbl
#define lastdec gd->lastinc
static inline unsigned long long tick_to_time(unsigned long long tick)
DECLARE_GLOBAL_DATA_PTR;
-#define timestamp (gd->tbl)
+#define timestamp (gd->arch.tbl)
#define lastinc (gd->lastinc)
/*
DECLARE_GLOBAL_DATA_PTR;
-#define timestamp (gd->tbl)
+#define timestamp (gd->arch.tbl)
#define lastinc (gd->lastinc)
/*
DECLARE_GLOBAL_DATA_PTR;
-#define timestamp (gd->tbl)
+#define timestamp (gd->arch.tbl)
#define lastdec (gd->lastinc)
/*
DECLARE_GLOBAL_DATA_PTR;
-#define timestamp gd->tbl
+#define timestamp gd->arch.tbl
#define lastdec gd->lastinc
int timer_init (void)
DECLARE_GLOBAL_DATA_PTR;
-#define timestamp gd->tbl
+#define timestamp gd->arch.tbl
#define lastdec gd->lastinc
ulong get_timer_masked(void)
#define COUNT_RD_REQ 0x1
DECLARE_GLOBAL_DATA_PTR;
-/* Using gd->arch.tbu from timestamp and gd->tbl for lastdec */
+/* Using gd->arch.tbu from timestamp and gd->arch.tbl for lastdec */
/*
* For preventing risk of instability in reading counter value,
{
ulong now = read_timer();
- if (now >= gd->tbl) {
+ if (now >= gd->arch.tbl) {
/* normal mode */
- gd->arch.tbu += now - gd->tbl;
+ gd->arch.tbu += now - gd->arch.tbl;
} else {
/* we have an overflow ... */
- gd->arch.tbu += now + TIMER_LOAD_VAL - gd->tbl;
+ gd->arch.tbu += now + TIMER_LOAD_VAL - gd->arch.tbl;
}
- gd->tbl = now;
+ gd->arch.tbl = now;
return gd->arch.tbu;
}
/* Enable timer 0 */
writel(0x1, &panthtimers->cer);
- /* init the gd->arch.tbu and gd->tbl value */
- gd->tbl = read_timer();
+ /* init the gd->arch.tbu and gd->arch.tbl value */
+ gd->arch.tbl = read_timer();
gd->arch.tbu = 0;
return 0;
DECLARE_GLOBAL_DATA_PTR;
-#define timestamp gd->tbl
+#define timestamp gd->arch.tbl
#define lastdec gd->lastinc
int timer_init(void)
DECLARE_GLOBAL_DATA_PTR;
-#define timestamp gd->tbl
+#define timestamp gd->arch.tbl
#define lastdec gd->lastinc
#define TIMER_ENABLE (1 << 7)
/* 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 */
+ gd->arch.tbl = 0; /* start "advancing" time stamp from 0 */
return 0;
}
/* current tick value */
ulong now = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
- if (now >= gd->lastinc) /* normal mode (non roll) */
+ if (now >= gd->lastinc) { /* normal mode (non roll) */
/* move stamp fordward with absoulte diff ticks */
- gd->tbl += (now - gd->lastinc);
- else /* we have rollover of incrementer */
- gd->tbl += ((TIMER_LOAD_VAL / (TIMER_CLOCK / CONFIG_SYS_HZ))
- - gd->lastinc) + now;
+ gd->arch.tbl += (now - gd->lastinc);
+ } else { /* we have rollover of incrementer */
+ gd->arch.tbl += ((TIMER_LOAD_VAL / (TIMER_CLOCK /
+ CONFIG_SYS_HZ)) - gd->lastinc) + now;
+ }
gd->lastinc = now;
- return gd->tbl;
+ return gd->arch.tbl;
}
/*
/* reset time */
gd->lastinc = readl(&timer->tcnto4);
- gd->tbl = 0;
+ gd->arch.tbl = 0;
}
unsigned long get_timer_masked(void)
unsigned long count_value = readl(&timer->tcntb4);
if (gd->lastinc >= now)
- gd->tbl += gd->lastinc - now;
+ gd->arch.tbl += gd->lastinc - now;
else
- gd->tbl += gd->lastinc + count_value - now;
+ gd->arch.tbl += gd->lastinc + count_value - now;
gd->lastinc = now;
- return gd->tbl;
+ return gd->arch.tbl;
}
/*
if (gd->lastinc >= now) {
/* normal mode (non roll) */
/* move stamp forward with absolute diff ticks */
- gd->tbl += gd->lastinc - now;
+ gd->arch.tbl += gd->lastinc - now;
} else {
/* we have overflow of the count down timer */
- gd->tbl += TIMER_LOAD_VAL - gd->lastinc + now;
+ gd->arch.tbl += TIMER_LOAD_VAL - gd->lastinc + now;
}
gd->lastinc = now;
- return gd->tbl;
+ return gd->arch.tbl;
}
/*
/* capture current decrementer value time */
gd->lastinc = read_timer() / (CONFIG_TIMER_CLOCK_KHZ/CONFIG_SYS_HZ);
/* start "advancing" time stamp from 0 */
- gd->tbl = 0;
+ gd->arch.tbl = 0;
}
/* current tick value */
ulong now = TICKS_TO_HZ(READ_TIMER());
- if (now >= gd->lastinc) /* normal (non rollover) */
- gd->tbl += (now - gd->lastinc);
- else /* rollover */
- gd->tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL) - gd->lastinc) + now;
+ if (now >= gd->lastinc) { /* normal (non rollover) */
+ gd->arch.tbl += (now - gd->lastinc);
+ } else { /* rollover */
+ gd->arch.tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL) - gd->lastinc)
+ + now;
+ }
gd->lastinc = now;
- return gd->tbl;
+ return gd->arch.tbl;
}
/* Delay x useconds */
/* Reset time */
gd->lastinc = readl(&timer_base->counter) /
(TIMER_TICK_HZ / CONFIG_SYS_HZ);
- gd->tbl = 0;
+ gd->arch.tbl = 0;
return 0;
}
if (gd->lastinc >= now) {
/* Normal mode */
- gd->tbl += gd->lastinc - now;
+ gd->arch.tbl += gd->lastinc - now;
} else {
/* We have an overflow ... */
- gd->tbl += gd->lastinc + TIMER_LOAD_VAL - now;
+ gd->arch.tbl += gd->lastinc + TIMER_LOAD_VAL - now;
}
gd->lastinc = now;
- return gd->tbl;
+ return gd->arch.tbl;
}
void __udelay(unsigned long usec)
#define TIMER_LOAD_VAL 0xffffffff
-#define timestamp (gd->tbl)
+#define timestamp (gd->arch.tbl)
#define lastinc (gd->lastinc)
#if defined(CONFIG_CPU_PXA27X) || defined(CONFIG_CPU_MONAHANS)
if (now >= gd->lastinc) /* normal mode (non roll) */
/* move stamp forward with absolute diff ticks */
- gd->tbl += (now - gd->lastinc);
+ gd->arch.tbl += (now - gd->lastinc);
else /* we have rollover of incrementer */
- gd->tbl += ((TIMER_LOAD_VAL / (TIMER_CLK / CONFIG_SYS_HZ))
+ gd->arch.tbl += ((TIMER_LOAD_VAL / (TIMER_CLK / CONFIG_SYS_HZ))
- gd->lastinc) + now;
gd->lastinc = now;
- return gd->tbl;
+ return gd->arch.tbl;
}
/*
DECLARE_GLOBAL_DATA_PTR;
-#define timestamp (gd->tbl)
+#define timestamp (gd->arch.tbl)
#define lastinc (gd->lastinc)
static inline unsigned long long tick_to_time(unsigned long long tick)
/* "static data" needed by most of timer.c on ARM platforms */
unsigned long timer_rate_hz;
unsigned long tbu;
+ unsigned long tbl;
};
/*
#endif
#ifdef CONFIG_ARM
/* "static data" needed by most of timer.c on ARM platforms */
- unsigned long tbl;
unsigned long long timer_reset_value;
unsigned long lastinc;
#endif
{
/* reset time */
gd->lastinc = readl(&tcu->tcnt0);
- gd->tbl = 0;
+ gd->arch.tbl = 0;
}
ulong get_timer_masked(void)
ulong now = readl(&tcu->tcnt0);
if (gd->lastinc <= now)
- gd->tbl += now - gd->lastinc; /* normal mode */
+ gd->arch.tbl += now - gd->lastinc; /* normal mode */
else {
/* we have an overflow ... */
- gd->tbl += TIMER_FDATA + now - gd->lastinc;
+ gd->arch.tbl += TIMER_FDATA + now - gd->lastinc;
}
gd->lastinc = now;
- return gd->tbl;
+ return gd->arch.tbl;
}
void udelay_masked(unsigned long usec)
writeb(1 << TIMER_CHAN, &tcu->tesr); /* start counting up */
gd->lastinc = 0;
- gd->tbl = 0;
+ gd->arch.tbl = 0;
return 0;
}
void set_timer(ulong t)
{
- gd->tbl = t;
+ gd->arch.tbl = t;
}
void __udelay(unsigned long usec)