mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-09-27 16:51:34 +02:00
[MIPS] lib_mips/time.c: Replace CP0 access functions with existing macros
We already have many pre-defined CP0 access macros in <asm/mipsregs.h>. This patch replaces mips_{compare,count}_set and mips_count_get with existing macros. Signed-off-by: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
This commit is contained in:
parent
8155efbd7a
commit
c7e38e413a
@ -22,26 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <asm/mipsregs.h>
|
||||||
|
|
||||||
static inline void mips_compare_set(u32 v)
|
|
||||||
{
|
|
||||||
asm volatile ("mtc0 %0, $11" : : "r" (v));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void mips_count_set(u32 v)
|
|
||||||
{
|
|
||||||
asm volatile ("mtc0 %0, $9" : : "r" (v));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline u32 mips_count_get(void)
|
|
||||||
{
|
|
||||||
u32 count;
|
|
||||||
|
|
||||||
asm volatile ("mfc0 %0, $9" : "=r" (count) :);
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* timer without interrupts
|
* timer without interrupts
|
||||||
@ -49,25 +30,25 @@ static inline u32 mips_count_get(void)
|
|||||||
|
|
||||||
int timer_init(void)
|
int timer_init(void)
|
||||||
{
|
{
|
||||||
mips_compare_set(0);
|
write_c0_compare(0);
|
||||||
mips_count_set(0);
|
write_c0_count(0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_timer(void)
|
void reset_timer(void)
|
||||||
{
|
{
|
||||||
mips_count_set(0);
|
write_c0_count(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong get_timer(ulong base)
|
ulong get_timer(ulong base)
|
||||||
{
|
{
|
||||||
return mips_count_get() - base;
|
return read_c0_count() - base;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_timer(ulong t)
|
void set_timer(ulong t)
|
||||||
{
|
{
|
||||||
mips_count_set(t);
|
write_c0_count(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void udelay (unsigned long usec)
|
void udelay (unsigned long usec)
|
||||||
@ -76,7 +57,7 @@ void udelay (unsigned long usec)
|
|||||||
ulong start = get_timer(0);
|
ulong start = get_timer(0);
|
||||||
|
|
||||||
tmo = usec * (CFG_HZ / 1000000);
|
tmo = usec * (CFG_HZ / 1000000);
|
||||||
while ((ulong)((mips_count_get() - start)) < tmo)
|
while ((ulong)((read_c0_count() - start)) < tmo)
|
||||||
/*NOP*/;
|
/*NOP*/;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +67,7 @@ void udelay (unsigned long usec)
|
|||||||
*/
|
*/
|
||||||
unsigned long long get_ticks(void)
|
unsigned long long get_ticks(void)
|
||||||
{
|
{
|
||||||
return mips_count_get();
|
return read_c0_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user