diff options
author | Wolfgang Denk <wd@denx.de> | 2008-09-12 15:24:54 +0200 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2008-09-12 15:24:54 +0200 |
commit | 6b8be3e58e9cc1badb7a709b0f3568d4d8eca4b7 (patch) | |
tree | a7468c1a17feaf28d8ef3443fe5b6f544ecddb72 /cpu/arm1136/mx31/interrupts.c | |
parent | 7238ada313057a85409485b8ee21515dc10c07a5 (diff) | |
parent | b476b032562aae5a09985f7e22232a5ee7042746 (diff) | |
download | u-boot-imx-6b8be3e58e9cc1badb7a709b0f3568d4d8eca4b7.zip u-boot-imx-6b8be3e58e9cc1badb7a709b0f3568d4d8eca4b7.tar.gz u-boot-imx-6b8be3e58e9cc1badb7a709b0f3568d4d8eca4b7.tar.bz2 |
Merge branch 'master' of /home/wd/git/u-boot/custodians
Diffstat (limited to 'cpu/arm1136/mx31/interrupts.c')
-rw-r--r-- | cpu/arm1136/mx31/interrupts.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/cpu/arm1136/mx31/interrupts.c b/cpu/arm1136/mx31/interrupts.c index 21b77a5..6e08c71 100644 --- a/cpu/arm1136/mx31/interrupts.c +++ b/cpu/arm1136/mx31/interrupts.c @@ -38,6 +38,9 @@ #define GPTCR_CLKSOURCE_32 (4<<6) /* Clock source */ #define GPTCR_TEN (1) /* Timer enable */ +static ulong timestamp; +static ulong lastinc; + /* nothing really to do with interrupts, just starts up a counter. */ int interrupt_init (void) { @@ -54,14 +57,27 @@ int interrupt_init (void) void reset_timer_masked (void) { - GPTCR = 0; - GPTCR = GPTCR_CLKSOURCE_32 | GPTCR_TEN; /* Freerun Mode, PERCLK1 input */ + /* reset time */ + 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 val = GPTCNT; - return val; + ulong now = GPTCNT; /* current tick value */ + + 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) |