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