1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
13 #include <linux/delay.h>
15 static int do_sleep(struct cmd_tbl *cmdtp, int flag, int argc,
18 ulong start = get_timer(0);
26 delay = simple_strtoul(argv[1], NULL, 10) * CONFIG_SYS_HZ;
28 frpart = strchr(argv[1], '.');
31 uint mult = CONFIG_SYS_HZ / 10;
32 for (frpart++; *frpart != '\0' && mult > 0; frpart++) {
33 if (*frpart < '0' || *frpart > '9') {
37 mdelay += (*frpart - '0') * mult;
44 while (get_timer(start) < delay) {
55 sleep , 2, 1, do_sleep,
56 "delay execution for some time",
58 " - delay execution for N seconds (N is _decimal_ and can be\n"
62 #ifdef CONFIG_CMD_TIMER
63 static int do_timer(struct cmd_tbl *cmdtp, int flag, int argc,
71 if (!strcmp(argv[1], "start"))
74 if (!strcmp(argv[1], "get")) {
75 ulong msecs = get_timer(start) * 1000 / CONFIG_SYS_HZ;
76 printf("%ld.%03d\n", msecs / 1000, (int)(msecs % 1000));
83 timer, 2, 1, do_timer,
84 "access the system timer",
85 "start - Reset the timer reference.\n"
86 "timer get - Print the time since 'start'."