1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
22e192b24SSimon Glass /*
32e192b24SSimon Glass * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
42e192b24SSimon Glass *
52e192b24SSimon Glass * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
62e192b24SSimon Glass *
72e192b24SSimon Glass * (C) Copyright 2001
82e192b24SSimon Glass * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
92e192b24SSimon Glass */
102e192b24SSimon Glass
112e192b24SSimon Glass /*
122e192b24SSimon Glass * Get Timer overflows after 2^32 / CONFIG_SYS_HZ (32Khz) = 131072 sec
132e192b24SSimon Glass */
142e192b24SSimon Glass #include <common.h>
152e192b24SSimon Glass #include <command.h>
162e192b24SSimon Glass
do_gettime(cmd_tbl_t * cmdtp,int flag,int argc,char * const argv[])172e192b24SSimon Glass static int do_gettime(cmd_tbl_t *cmdtp, int flag, int argc,
182e192b24SSimon Glass char * const argv[])
192e192b24SSimon Glass {
202e192b24SSimon Glass unsigned long int val = get_timer(0);
212e192b24SSimon Glass
222e192b24SSimon Glass #ifdef CONFIG_SYS_HZ
232e192b24SSimon Glass printf("Timer val: %lu\n", val);
242e192b24SSimon Glass printf("Seconds : %lu\n", val / CONFIG_SYS_HZ);
252e192b24SSimon Glass printf("Remainder : %lu\n", val % CONFIG_SYS_HZ);
262e192b24SSimon Glass printf("sys_hz = %lu\n", (unsigned long int)CONFIG_SYS_HZ);
272e192b24SSimon Glass #else
282e192b24SSimon Glass printf("CONFIG_SYS_HZ not defined");
292e192b24SSimon Glass printf("Timer Val %lu", val);
302e192b24SSimon Glass #endif
312e192b24SSimon Glass
322e192b24SSimon Glass return 0;
332e192b24SSimon Glass }
342e192b24SSimon Glass
352e192b24SSimon Glass U_BOOT_CMD(
362e192b24SSimon Glass gettime, 1, 1, do_gettime,
372e192b24SSimon Glass "get timer val elapsed",
382e192b24SSimon Glass "get time elapsed from uboot start"
392e192b24SSimon Glass );
40