blob: c48baad9a106ab9ec0cdfc1e1544cbd437231ff8 [file] [log] [blame]
Anton Staaf53fdc7e2012-12-05 14:46:29 +00001/*
2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
3 *
4 * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
5 *
6 * (C) Copyright 2001
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Anton Staaf53fdc7e2012-12-05 14:46:29 +000010 */
11
12/*
13 * Get Timer overflows after 2^32 / CONFIG_SYS_HZ (32Khz) = 131072 sec
14 */
15#include <common.h>
16#include <command.h>
17
18static int do_gettime(cmd_tbl_t *cmdtp, int flag, int argc,
19 char * const argv[])
20{
21 unsigned long int val = get_timer(0);
22
23#ifdef CONFIG_SYS_HZ
24 printf("Timer val: %lu\n", val);
25 printf("Seconds : %lu\n", val / CONFIG_SYS_HZ);
26 printf("Remainder : %lu\n", val % CONFIG_SYS_HZ);
27 printf("sys_hz = %lu\n", (unsigned long int)CONFIG_SYS_HZ);
28#else
29 printf("CONFIG_SYS_HZ not defined");
30 printf("Timer Val %lu", val);
31#endif
32
33 return 0;
34}
35
36U_BOOT_CMD(
37 gettime, 1, 1, do_gettime,
Bin Meng89fc8bb2015-01-19 21:32:00 +080038 "get timer val elapsed",
39 "get time elapsed from uboot start"
Anton Staaf53fdc7e2012-12-05 14:46:29 +000040);