summaryrefslogtreecommitdiff
path: root/cpu/at32ap/interrupts.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2008-06-03 00:19:57 +0200
committerWolfgang Denk <wd@denx.de>2008-06-03 00:19:57 +0200
commit7a68389a231ac061ba2ffd628f86e15ed0545a7b (patch)
tree723fd35290b988810be6d417c21fa1949f25aae8 /cpu/at32ap/interrupts.c
parent7feb4d38ff1fdf8877f39447001ff9f6e93fa6bc (diff)
parenta8092c021d27f27f4b323b7d49979ca01b3fc19d (diff)
downloadu-boot-imx-7a68389a231ac061ba2ffd628f86e15ed0545a7b.zip
u-boot-imx-7a68389a231ac061ba2ffd628f86e15ed0545a7b.tar.gz
u-boot-imx-7a68389a231ac061ba2ffd628f86e15ed0545a7b.tar.bz2
Merge remote branch 'u-boot-avr32/master'
Diffstat (limited to 'cpu/at32ap/interrupts.c')
-rw-r--r--cpu/at32ap/interrupts.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/cpu/at32ap/interrupts.c b/cpu/at32ap/interrupts.c
index bef1f30..160838e 100644
--- a/cpu/at32ap/interrupts.c
+++ b/cpu/at32ap/interrupts.c
@@ -98,18 +98,16 @@ void set_timer(unsigned long t)
*/
void udelay(unsigned long usec)
{
- unsigned long now, end;
+ unsigned long cycles;
+ unsigned long base;
+ unsigned long now;
- now = sysreg_read(COUNT);
+ base = sysreg_read(COUNT);
+ cycles = ((usec * (get_tbclk() / 10000)) + 50) / 100;
- end = ((usec * (get_tbclk() / 10000)) + 50) / 100;
- end += now;
-
- while (now > end)
- now = sysreg_read(COUNT);
-
- while (now < end)
+ do {
now = sysreg_read(COUNT);
+ } while ((now - base) < cycles);
}
static int set_interrupt_handler(unsigned int nr, void (*handler)(void),