aboutsummaryrefslogtreecommitdiffstats
path: root/udelay.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2002-04-29 11:00:28 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2002-04-29 11:00:28 +0000
commite0bc8f47b964169bcbec3ce14d1aca38bc024cee (patch)
treef8b0a611d773d5bd691d9156392ee3704d79d2fc /udelay.c
parentc9a403a8364c906a54c24a9465299bb7e45e53f6 (diff)
downloadlcd4linux-e0bc8f47b964169bcbec3ce14d1aca38bc024cee.tar.gz
[lcd4linux @ 2002-04-29 11:00:25 by reinelt]
added Toshiba T6963 driver added ndelay() with nanosecond resolution git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@152 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'udelay.c')
-rw-r--r--udelay.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/udelay.c b/udelay.c
index 079f986..d1ce790 100644
--- a/udelay.c
+++ b/udelay.c
@@ -1,4 +1,4 @@
-/* $Id: udelay.c,v 1.6 2001/08/08 05:40:24 reinelt Exp $
+/* $Id: udelay.c,v 1.7 2002/04/29 11:00:28 reinelt Exp $
*
* short delays
*
@@ -20,6 +20,11 @@
*
*
* $Log: udelay.c,v $
+ * Revision 1.7 2002/04/29 11:00:28 reinelt
+ *
+ * added Toshiba T6963 driver
+ * added ndelay() with nanosecond resolution
+ *
* Revision 1.6 2001/08/08 05:40:24 reinelt
*
* renamed CLK_TCK to CLOCKS_PER_SEC
@@ -102,9 +107,9 @@
unsigned long loops_per_usec;
-void udelay (unsigned long usec)
+void ndelay (unsigned long nsec)
{
- unsigned long loop=usec*loops_per_usec;
+ unsigned long loop=(nsec*loops_per_usec+999)/1000;
__asm__ (".align 16\n"
"1:\tdecl %0\n"
@@ -113,7 +118,6 @@ void udelay (unsigned long usec)
:"a" (loop));
}
-
/* adopted from /usr/src/linux/init/main.c */
void udelay_calibrate (void)
@@ -126,7 +130,7 @@ void udelay_calibrate (void)
tick=clock();
while (clock()==tick);
tick=clock();
- udelay(1000000/CLOCKS_PER_SEC);
+ ndelay(1000000000/CLOCKS_PER_SEC);
if (clock()>tick)
break;
}
@@ -138,7 +142,7 @@ void udelay_calibrate (void)
tick=clock();
while (clock()==tick);
tick=clock();
- udelay(1000000/CLOCKS_PER_SEC);
+ ndelay(1000000000/CLOCKS_PER_SEC);
if (clock()>tick)
loops_per_usec&=~bit;
}
@@ -223,31 +227,33 @@ void udelay_init (void)
}
-void udelay (unsigned long usec)
+void ndelay (unsigned long nsec)
{
if (ticks_per_usec) {
unsigned int t1, t2;
- usec*=ticks_per_usec;
+ nsec=(nsec*ticks_per_usec+999)/1000;
rdtscl(t1);
do {
+ rep_nop();
rdtscl(t2);
- } while ((t2-t1)<usec);
+ } while ((t2-t1)<nsec);
} else {
struct timeval now, end;
gettimeofday (&end, NULL);
- end.tv_usec+=usec;
+ end.tv_usec+=(nsec+999)/1000;
while (end.tv_usec>1000000) {
end.tv_usec-=1000000;
end.tv_sec++;
}
do {
+ rep_nop();
gettimeofday(&now, NULL);
} while (now.tv_sec==end.tv_sec?now.tv_usec<end.tv_usec:now.tv_sec<end.tv_sec);
}