mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-13 14:06:07 -04:00
i.MX31: Add reset_timer() and modify get_timer_masked().
This patch adds the reset_timer() function (needed by nand_base.c) and modifies the get_timer_masked() to work in the same way as the omap24xx function. Signed-off-by: Magnus Lilja <lilja.magnus@gmail.com>
This commit is contained in:
parent
0b7c563989
commit
8c4ebec25b
@ -38,6 +38,9 @@
|
|||||||
#define GPTCR_CLKSOURCE_32 (4<<6) /* Clock source */
|
#define GPTCR_CLKSOURCE_32 (4<<6) /* Clock source */
|
||||||
#define GPTCR_TEN (1) /* Timer enable */
|
#define GPTCR_TEN (1) /* Timer enable */
|
||||||
|
|
||||||
|
static ulong timestamp;
|
||||||
|
static ulong lastinc;
|
||||||
|
|
||||||
/* nothing really to do with interrupts, just starts up a counter. */
|
/* nothing really to do with interrupts, just starts up a counter. */
|
||||||
int interrupt_init (void)
|
int interrupt_init (void)
|
||||||
{
|
{
|
||||||
@ -54,14 +57,27 @@ int interrupt_init (void)
|
|||||||
|
|
||||||
void reset_timer_masked (void)
|
void reset_timer_masked (void)
|
||||||
{
|
{
|
||||||
GPTCR = 0;
|
/* reset time */
|
||||||
GPTCR = GPTCR_CLKSOURCE_32 | GPTCR_TEN; /* Freerun Mode, PERCLK1 input */
|
lastinc = GPTCNT; /* capture current incrementer value time */
|
||||||
|
timestamp = 0; /* start "advancing" time stamp from 0 */
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset_timer(void)
|
||||||
|
{
|
||||||
|
reset_timer_masked();
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong get_timer_masked (void)
|
ulong get_timer_masked (void)
|
||||||
{
|
{
|
||||||
ulong val = GPTCNT;
|
ulong now = GPTCNT; /* current tick value */
|
||||||
return val;
|
|
||||||
|
if (now >= lastinc) /* normal mode (non roll) */
|
||||||
|
/* move stamp forward with absolut diff ticks */
|
||||||
|
timestamp += (now - lastinc);
|
||||||
|
else /* we have rollover of incrementer */
|
||||||
|
timestamp += (0xFFFFFFFF - lastinc) + now;
|
||||||
|
lastinc = now;
|
||||||
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong get_timer (ulong base)
|
ulong get_timer (ulong base)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user