xref: /OK3568_Linux_fs/u-boot/cmd/gettime.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * (C) Copyright 2001
7*4882a593Smuzhiyun  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * SPDX-License-Identifier:	GPL-2.0+
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun /*
13*4882a593Smuzhiyun  * Get Timer overflows after 2^32 / CONFIG_SYS_HZ (32Khz) = 131072 sec
14*4882a593Smuzhiyun  */
15*4882a593Smuzhiyun #include <common.h>
16*4882a593Smuzhiyun #include <command.h>
17*4882a593Smuzhiyun 
do_gettime(cmd_tbl_t * cmdtp,int flag,int argc,char * const argv[])18*4882a593Smuzhiyun static int do_gettime(cmd_tbl_t *cmdtp, int flag, int argc,
19*4882a593Smuzhiyun 		      char * const argv[])
20*4882a593Smuzhiyun {
21*4882a593Smuzhiyun 	unsigned long int val = get_timer(0);
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun #ifdef CONFIG_SYS_HZ
24*4882a593Smuzhiyun 	printf("Timer val: %lu\n", val);
25*4882a593Smuzhiyun 	printf("Seconds : %lu\n", val / CONFIG_SYS_HZ);
26*4882a593Smuzhiyun 	printf("Remainder : %lu\n", val % CONFIG_SYS_HZ);
27*4882a593Smuzhiyun 	printf("sys_hz = %lu\n", (unsigned long int)CONFIG_SYS_HZ);
28*4882a593Smuzhiyun #else
29*4882a593Smuzhiyun 	printf("CONFIG_SYS_HZ not defined");
30*4882a593Smuzhiyun 	printf("Timer Val %lu", val);
31*4882a593Smuzhiyun #endif
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun 	return 0;
34*4882a593Smuzhiyun }
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun U_BOOT_CMD(
37*4882a593Smuzhiyun 	gettime,	1,	1,	do_gettime,
38*4882a593Smuzhiyun 	"get timer val elapsed",
39*4882a593Smuzhiyun 	"get time elapsed from uboot start"
40*4882a593Smuzhiyun );
41