1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
10 #include <linux/delay.h>
12 static int do_sleep(struct cmd_tbl *cmdtp, int flag, int argc,
15 ulong start = get_timer(0);
23 delay = simple_strtoul(argv[1], NULL, 10) * CONFIG_SYS_HZ;
25 frpart = strchr(argv[1], '.');
28 uint mult = CONFIG_SYS_HZ / 10;
29 for (frpart++; *frpart != '\0' && mult > 0; frpart++) {
30 if (*frpart < '0' || *frpart > '9') {
34 mdelay += (*frpart - '0') * mult;
41 while (get_timer(start) < delay) {
52 sleep , 2, 1, do_sleep,
53 "delay execution for some time",
55 " - delay execution for N seconds (N is _decimal_ and can be\n"
59 #ifdef CONFIG_CMD_TIMER
60 static int do_timer(struct cmd_tbl *cmdtp, int flag, int argc,
68 if (!strcmp(argv[1], "start"))
71 if (!strcmp(argv[1], "get")) {
72 ulong msecs = get_timer(start) * 1000 / CONFIG_SYS_HZ;
73 printf("%ld.%03d\n", msecs / 1000, (int)(msecs % 1000));
80 timer, 2, 1, do_timer,
81 "access the system timer",
82 "start - Reset the timer reference.\n"
83 "timer get - Print the time since 'start'."