From: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH 1/3][MIPS] lib_mips/time.c: Replace CP0 access functions with existing macros
Date: Sat, 24 May 2008 21:58:10 +0900 [thread overview]
Message-ID: <483810E2.7020105@ruby.dti.ne.jp> (raw)
In-Reply-To: <20080521153255.GD13959@ld0162-tx32.am.freescale.net>
Scott Wood wrote:
> On Wed, May 21, 2008 at 12:53:01PM +0900, Shinya Kuribayashi wrote:
>> I disagree with having this structure. Basic strategy for MIPS COUNT/
>> COMPARE handling is, let them overflow (os should I say wrap-around) as
>> they are. All we need is the Delta, not the numbers of overflows.
>
> You *do* need the full, non-overflowing counter if you want to provide
> the 32-bit millisecond clock that u-boot wants. Read the recent
> discussion on CFG_HZ that led to this patch.
Ok, here's my proposal. Conceptual patches for MIPS timer routines.
There might be still room for improvement, but I'd like to see something
like thease.
Just build tested. Any comments are appriciated.
Shinya
---
[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>
---
lib_mips/time.c | 35 ++++++++---------------------------
1 files changed, 8 insertions(+), 27 deletions(-)
diff --git a/lib_mips/time.c b/lib_mips/time.c
index cd8dc72..f03f023 100644
--- a/lib_mips/time.c
+++ b/lib_mips/time.c
@@ -22,26 +22,7 @@
*/
#include <common.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;
-}
+#include <asm/mipsregs.h>
/*
* timer without interrupts
@@ -49,25 +30,25 @@ static inline u32 mips_count_get(void)
int timer_init(void)
{
- mips_compare_set(0);
- mips_count_set(0);
+ write_32bit_cp0_register(CP0_COMPARE, 0);
+ write_32bit_cp0_register(CP0_COUNT, 0);
return 0;
}
void reset_timer(void)
{
- mips_count_set(0);
+ write_32bit_cp0_register(CP0_COUNT, 0);
}
ulong get_timer(ulong base)
{
- return mips_count_get() - base;
+ return read_32bit_cp0_register(CP0_COUNT) - base;
}
void set_timer(ulong t)
{
- mips_count_set(t);
+ write_32bit_cp0_register(CP0_COUNT, t);
}
void udelay (unsigned long usec)
@@ -76,7 +57,7 @@ void udelay (unsigned long usec)
ulong start = get_timer(0);
tmo = usec * (CFG_HZ / 1000000);
- while ((ulong)((mips_count_get() - start)) < tmo)
+ while ((ulong)((read_32bit_cp0_register(CP0_COUNT) - start)) < tmo)
/*NOP*/;
}
@@ -86,7 +67,7 @@ void udelay (unsigned long usec)
*/
unsigned long long get_ticks(void)
{
- return mips_count_get();
+ return read_32bit_cp0_register(CP0_COUNT);
}
/*
next prev parent reply other threads:[~2008-05-24 12:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-20 16:24 [U-Boot-Users] [PATCH] [resend] mips: Support to set CFG_HZ to 1000, consistent with other architectures Jason McMullan
2008-05-21 3:53 ` Shinya Kuribayashi
2008-05-21 15:32 ` Scott Wood
2008-05-24 12:58 ` Shinya Kuribayashi [this message]
2008-05-24 12:59 ` [U-Boot-Users] [PATCH 2/3][MIPS] lib_mips/time.c: Fix udelay Shinya Kuribayashi
2008-05-24 13:02 ` [U-Boot-Users] [PATCH 3/3][MIPS] lib_mips/time.c: Fix improper use of CFG_HZ and timer routines Shinya Kuribayashi
2008-05-24 19:59 ` Wolfgang Denk
2008-05-25 2:04 ` Shinya Kuribayashi
2008-05-25 8:15 ` Wolfgang Denk
2008-05-25 13:45 ` Shinya Kuribayashi
2008-05-25 15:18 ` Wolfgang Denk
2008-05-31 6:12 ` Shinya Kuribayashi
2008-05-31 6:17 ` Shinya Kuribayashi
2008-05-31 14:40 ` [U-Boot-Users] [PATCH 3/3 v2][MIPS] lib_mips/time.c: Fix CP0 count register usage " Shinya Kuribayashi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=483810E2.7020105@ruby.dti.ne.jp \
--to=skuribay@ruby.dti.ne.jp \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox