Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Anton Staaf | d1390c8 | 2012-12-05 14:46:29 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 4 | * |
| 5 | * Copyright (c) 2009, Code Aurora Forum. All rights reserved. |
| 6 | * |
| 7 | * (C) Copyright 2001 |
| 8 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Anton Staaf | d1390c8 | 2012-12-05 14:46:29 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * Get Timer overflows after 2^32 / CONFIG_SYS_HZ (32Khz) = 131072 sec |
| 13 | */ |
Anton Staaf | d1390c8 | 2012-12-05 14:46:29 +0000 | [diff] [blame] | 14 | #include <command.h> |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 15 | #include <time.h> |
Anton Staaf | d1390c8 | 2012-12-05 14:46:29 +0000 | [diff] [blame] | 16 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 17 | static int do_gettime(struct cmd_tbl *cmdtp, int flag, int argc, |
| 18 | char *const argv[]) |
Anton Staaf | d1390c8 | 2012-12-05 14:46:29 +0000 | [diff] [blame] | 19 | { |
| 20 | unsigned long int val = get_timer(0); |
| 21 | |
| 22 | #ifdef CONFIG_SYS_HZ |
| 23 | printf("Timer val: %lu\n", val); |
| 24 | printf("Seconds : %lu\n", val / CONFIG_SYS_HZ); |
| 25 | printf("Remainder : %lu\n", val % CONFIG_SYS_HZ); |
| 26 | printf("sys_hz = %lu\n", (unsigned long int)CONFIG_SYS_HZ); |
| 27 | #else |
| 28 | printf("CONFIG_SYS_HZ not defined"); |
| 29 | printf("Timer Val %lu", val); |
| 30 | #endif |
| 31 | |
| 32 | return 0; |
| 33 | } |
| 34 | |
| 35 | U_BOOT_CMD( |
| 36 | gettime, 1, 1, do_gettime, |
Bin Meng | 1f9cb00 | 2015-01-19 21:32:00 +0800 | [diff] [blame] | 37 | "get timer val elapsed", |
| 38 | "get time elapsed from uboot start" |
Anton Staaf | d1390c8 | 2012-12-05 14:46:29 +0000 | [diff] [blame] | 39 | ); |