mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-04-01 03:51:31 +00:00
PXA: timer use do_div and simplify it
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
This commit is contained in:
parent
014c595f12
commit
a922fdb87a
1 changed files with 21 additions and 19 deletions
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <asm/arch/pxa-regs.h>
|
#include <asm/arch/pxa-regs.h>
|
||||||
|
#include <div64.h>
|
||||||
|
|
||||||
#ifdef CONFIG_USE_IRQ
|
#ifdef CONFIG_USE_IRQ
|
||||||
#error: interrupts not implemented yet
|
#error: interrupts not implemented yet
|
||||||
|
@ -41,6 +42,20 @@
|
||||||
#error "Timer frequency unknown - please config PXA CPU type"
|
#error "Timer frequency unknown - please config PXA CPU type"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline unsigned long long tick_to_time(unsigned long long tick)
|
||||||
|
{
|
||||||
|
tick *= CONFIG_SYS_HZ;
|
||||||
|
do_div(tick, TIMER_FREQ_HZ);
|
||||||
|
return tick;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long long us_to_tick(unsigned long long us)
|
||||||
|
{
|
||||||
|
us = us * TIMER_FREQ_HZ + 999999;
|
||||||
|
do_div(us, 1000000);
|
||||||
|
return us;
|
||||||
|
}
|
||||||
|
|
||||||
int interrupt_init (void)
|
int interrupt_init (void)
|
||||||
{
|
{
|
||||||
/* nothing happens here - we don't setup any IRQs */
|
/* nothing happens here - we don't setup any IRQs */
|
||||||
|
@ -75,33 +90,20 @@ void reset_timer_masked (void)
|
||||||
|
|
||||||
ulong get_timer_masked (void)
|
ulong get_timer_masked (void)
|
||||||
{
|
{
|
||||||
unsigned long long ticks = get_ticks();
|
return tick_to_time(get_ticks());
|
||||||
|
|
||||||
return (((ticks / TIMER_FREQ_HZ) * 1000) +
|
|
||||||
((ticks % TIMER_FREQ_HZ) * 1000) / TIMER_FREQ_HZ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void udelay_masked (unsigned long usec)
|
void udelay_masked (unsigned long usec)
|
||||||
{
|
{
|
||||||
|
unsigned long long tmp;
|
||||||
ulong tmo;
|
ulong tmo;
|
||||||
ulong endtime;
|
|
||||||
signed long diff;
|
|
||||||
|
|
||||||
if (usec >= 1000) {
|
tmo = us_to_tick(usec);
|
||||||
tmo = usec / 1000;
|
tmp = get_ticks() + tmo; /* get current timestamp */
|
||||||
tmo *= TIMER_FREQ_HZ;
|
|
||||||
tmo /= 1000;
|
|
||||||
} else {
|
|
||||||
tmo = usec * TIMER_FREQ_HZ;
|
|
||||||
tmo /= (1000*1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
endtime = get_ticks() + tmo;
|
while (get_ticks() < tmp) /* loop till event */
|
||||||
|
/*NOP*/;
|
||||||
|
|
||||||
do {
|
|
||||||
ulong now = get_ticks();
|
|
||||||
diff = endtime - now;
|
|
||||||
} while (diff >= 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue