xref: /openbmc/u-boot/lib/time.c (revision e32a268b6f96b5b4818e9c33d18cee98c0c31f7c)
1 /*
2  * (C) Copyright 2000-2009
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #include <common.h>
9 #include <watchdog.h>
10 
11 #if CONFIG_SYS_HZ != 1000
12 #warning "CONFIG_SYS_HZ must be 1000 and should not be defined by platforms"
13 #endif
14 
15 #ifndef CONFIG_WD_PERIOD
16 # define CONFIG_WD_PERIOD	(10 * 1000 * 1000)	/* 10 seconds default*/
17 #endif
18 
19 /* ------------------------------------------------------------------------- */
20 
21 void udelay(unsigned long usec)
22 {
23 	ulong kv;
24 
25 	do {
26 		WATCHDOG_RESET();
27 		kv = usec > CONFIG_WD_PERIOD ? CONFIG_WD_PERIOD : usec;
28 		__udelay (kv);
29 		usec -= kv;
30 	} while(usec);
31 }
32 
33 void mdelay(unsigned long msec)
34 {
35 	while (msec--)
36 		udelay(1000);
37 }
38