summaryrefslogtreecommitdiffstats
path: root/lib_generic
diff options
context:
space:
mode:
authorIngo van Lil <inguin@gmx.de>2009-11-24 14:09:21 +0100
committerWolfgang Denk <wd@denx.de>2009-12-05 01:08:53 +0100
commit3eb90bad651fab39cffba750ec4421a9c01d60e7 (patch)
tree63b21148a041603db252203a422dc465e862e016 /lib_generic
parent1c409bc7101a24ecd47a13a4e851845d66dc23ce (diff)
downloadu-boot-3eb90bad651fab39cffba750ec4421a9c01d60e7.tar.gz
u-boot-3eb90bad651fab39cffba750ec4421a9c01d60e7.tar.xz
u-boot-3eb90bad651fab39cffba750ec4421a9c01d60e7.zip
Generic udelay() with watchdog support
According to the PPC reference implementation the udelay() function is responsible for resetting the watchdog timer as frequently as needed. Most other architectures do not meet that requirement, so long-running operations might result in a watchdog reset. This patch adds a generic udelay() function which takes care of resetting the watchdog before calling an architecture-specific __udelay(). Signed-off-by: Ingo van Lil <inguin@gmx.de>
Diffstat (limited to 'lib_generic')
-rw-r--r--lib_generic/Makefile1
-rw-r--r--lib_generic/time.c43
2 files changed, 44 insertions, 0 deletions
diff --git a/lib_generic/Makefile b/lib_generic/Makefile
index 686601cc18..7291fa3963 100644
--- a/lib_generic/Makefile
+++ b/lib_generic/Makefile
@@ -44,6 +44,7 @@ COBJS-y += sha1.o
COBJS-$(CONFIG_SHA256) += sha256.o
COBJS-y += string.o
COBJS-y += strmhz.o
+COBJS-y += time.o
COBJS-y += vsprintf.o
COBJS-y += zlib.o
COBJS-$(CONFIG_RBTREE) += rbtree.o
diff --git a/lib_generic/time.c b/lib_generic/time.c
new file mode 100644
index 0000000000..a309c2613a
--- /dev/null
+++ b/lib_generic/time.c
@@ -0,0 +1,43 @@
+/*
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <watchdog.h>
+
+#ifndef CONFIG_WD_PERIOD
+# define CONFIG_WD_PERIOD (10 * 1000 * 1000) /* 10 seconds default*/
+#endif
+
+/* ------------------------------------------------------------------------- */
+
+void udelay(unsigned long usec)
+{
+ ulong kv;
+
+ do {
+ WATCHDOG_RESET();
+ kv = usec > CONFIG_WD_PERIOD ? CONFIG_WD_PERIOD : usec;
+ __udelay (kv);
+ usec -= kv;
+ } while(usec);
+}