[U-Boot-Users] [PATCH] adds ndelay function (just like udelay)

eran.liberty at gmail.com eran.liberty at gmail.com
Tue Jul 3 18:40:36 CEST 2007


Though most cpu's do not support delay of such resolution it is prudent 
to insert this delay where the hardware specs demands it.

Signed-off-by: Eran Liberty <eran.liberty at gmail.com>

Index: lib_ppc/time.c
===================================================================
--- lib_ppc/time.c	(.../tags/trunk/20070620_2_merge_to_exsw6000)	(revision 69)
+++ lib_ppc/time.c	(.../branches/exsw6000)	(revision 69)
@@ -53,8 +53,17 @@
  */
 void udelay(unsigned long usec)
 {
-	ulong ticks = usec2ticks (usec);
+	ulong ticks = usec2ticks(usec);
 
+	wait_ticks(ticks);
+}
+
+/* ------------------------------------------------------------------------- */
+
+void ndelay (unsigned long nsec)
+{
+	ulong ticks = usec2ticks (1) * nsec / 1000 + 1;
+
 	wait_ticks (ticks);
 }
 
Index: include/exports.h
===================================================================
--- include/exports.h	(.../tags/trunk/20070620_2_merge_to_exsw6000)	(revision 69)
+++ include/exports.h	(.../branches/exsw6000)	(revision 69)
@@ -17,6 +17,7 @@
 void *malloc(size_t);
 void free(void*);
 void udelay(unsigned long);
+void ndelay(unsigned long);
 unsigned long get_timer(unsigned long);
 void vprintf(const char *, va_list);
 void do_reset (void);
Index: include/common.h
===================================================================
--- include/common.h	(.../tags/trunk/20070620_2_merge_to_exsw6000)	(revision 69)
+++ include/common.h	(.../branches/exsw6000)	(revision 69)
@@ -559,6 +559,7 @@
 
 /* lib_$(ARCH)/time.c */
 void	udelay	      (unsigned long);
+void ndelay(unsigned long);
 ulong	usec2ticks    (unsigned long usec);
 ulong	ticks2usec    (unsigned long ticks);
 int	init_timebase (void);





More information about the U-Boot mailing list