projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of git://git.denx.de/u-boot-avr32
[oweals/u-boot.git]
/
cpu
/
at32ap
/
interrupts.c
diff --git
a/cpu/at32ap/interrupts.c
b/cpu/at32ap/interrupts.c
index 85420a4248a89c5a3d6074031b346cec6854c98d..75cc39e94c33eb02684efd845500df0458d98c0e 100644
(file)
--- a/
cpu/at32ap/interrupts.c
+++ b/
cpu/at32ap/interrupts.c
@@
-20,8
+20,8
@@
* MA 02111-1307 USA
*/
#include <common.h>
* MA 02111-1307 USA
*/
#include <common.h>
+#include <div64.h>
-#include <asm/div64.h>
#include <asm/errno.h>
#include <asm/io.h>
#include <asm/processor.h>
#include <asm/errno.h>
#include <asm/io.h>
#include <asm/processor.h>
@@
-82,7
+82,7
@@
void set_timer(unsigned long t)
unsigned long long ticks = t;
unsigned long lo, hi, hi_new;
unsigned long long ticks = t;
unsigned long lo, hi, hi_new;
- ticks = (ticks * get_tbclk()) / C
FG
_HZ;
+ ticks = (ticks * get_tbclk()) / C
ONFIG_SYS
_HZ;
hi = ticks >> 32;
lo = ticks & 0xffffffffUL;
hi = ticks >> 32;
lo = ticks & 0xffffffffUL;
@@
-98,26
+98,27
@@
void set_timer(unsigned long t)
*/
void udelay(unsigned long usec)
{
*/
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);
now = sysreg_read(COUNT);
+ } while ((now - base) < cycles);
}
static int set_interrupt_handler(unsigned int nr, void (*handler)(void),
unsigned int priority)
{
}
static int set_interrupt_handler(unsigned int nr, void (*handler)(void),
unsigned int priority)
{
+ extern void _evba(void);
unsigned long intpr;
unsigned long handler_addr = (unsigned long)handler;
unsigned long intpr;
unsigned long handler_addr = (unsigned long)handler;
+ handler_addr -= (unsigned long)&_evba;
+
if ((handler_addr & HANDLER_MASK) != handler_addr
|| (priority & INTLEV_MASK) != priority)
return -EINVAL;
if ((handler_addr & HANDLER_MASK) != handler_addr
|| (priority & INTLEV_MASK) != priority)
return -EINVAL;
@@
-136,7
+137,7
@@
void timer_init(void)
sysreg_write(COUNT, 0);
sysreg_write(COUNT, 0);
- tmp = (u64)C
FG
_HZ << 32;
+ tmp = (u64)C
ONFIG_SYS
_HZ << 32;
tmp += gd->cpu_hz / 2;
do_div(tmp, gd->cpu_hz);
tb_factor = (u32)tmp;
tmp += gd->cpu_hz / 2;
do_div(tmp, gd->cpu_hz);
tb_factor = (u32)tmp;