From patchwork Thu Dec 6 00:46:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 204072 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id C79642C0134 for ; Thu, 6 Dec 2012 11:50:36 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6CB024A12B; Thu, 6 Dec 2012 01:50:35 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 92tn5HIQb-QX; Thu, 6 Dec 2012 01:50:35 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5C1F04A143; Thu, 6 Dec 2012 01:50:20 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6D2214A12B for ; Thu, 6 Dec 2012 01:50:18 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V5Wucmgn8D3Q for ; Thu, 6 Dec 2012 01:50:17 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-lb0-f202.google.com (mail-lb0-f202.google.com [209.85.217.202]) by theia.denx.de (Postfix) with ESMTPS id 153DA4A11C for ; Thu, 6 Dec 2012 01:50:15 +0100 (CET) Received: by mail-lb0-f202.google.com with SMTP id s4so273349lbc.3 for ; Wed, 05 Dec 2012 16:50:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=RLOF4TVamN+bVtrqG8ECUE1mddk128MQJvlVl169Zjw=; b=Tx/UhykuYCUIiKuq8PhTqgtv6kkxjeMzU9jTf9/xJnt9FeLZfzyd1zURns/sNR264E EjGNa15GsAbrdbklOhpCT5pKW6xAZzy/x003PQ8snK+oydnPRfVAD91Z0HDl43fTy1a9 3p8zklFrF/NkyR49C6DhBrp8NJCyUtsTnPwEtCCOXgLoa6YrL8ViyE2KyfzoZQ+Sbq2l pzrntApzcLZh+SRTd7s58WVKvFiqyXDw7bmuaQqyu3iv4q+RUQE66FH+haTqTjzdQ55x tD708vmONwzqUhxCeJva/9uHv93s0DH+EdeUVJKeudzupYO9eEWOvB3Oq1jViM4OlgYb t2NA== Received: by 10.14.214.197 with SMTP id c45mr19824302eep.7.1354755015172; Wed, 05 Dec 2012 16:50:15 -0800 (PST) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id g9si896998eeo.1.2012.12.05.16.50.15 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 05 Dec 2012 16:50:15 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id 902F7200059; Wed, 5 Dec 2012 16:50:14 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id F0E23160862; Wed, 5 Dec 2012 16:50:13 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Wed, 5 Dec 2012 16:46:29 -0800 Message-Id: <1354754807-21449-3-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1354754807-21449-1-git-send-email-sjg@chromium.org> References: <1354754807-21449-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmjgBXzISVyyAisaXbZahWSuImCcwHdKIJrsX5QFZSuYYEKd9P/HL/1CEqe7ZVZl6QT2ouA+wP1rsCbwfExw7F/UO5aM+SwtoDZGA77WCYGuS7bNwcOml4BIIOQyU89MCThqxL7HA7fPQ2v2hnKF0Dh8g/b8Ie1WMInjM1imboVDPDId7FZ7kfwRw0GdGR79ZTqARC1 Cc: Tom Rini , Anton Staaf Subject: [U-Boot] [PATCH v3 02/20] Add gettime command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Anton Staaf Gettime returns the current timer value. If CONFIG_SYS_HZ is defined then the timer value is also converted to seconds. Tegra20 (SeaBoard) # gettime Timer val: 7754 Seconds : 7 Remainder : 754 sys_hz = 1000 There has been some discussion about whether this is useful enough to be included in U-Boot. The following boards do not have CONFIG_SYS_HZ defined: M52277EVB M52277EVB_stmicro M53017EVB M54418TWR M54418TWR_nand_mii M54418TWR_nand_rmii M54418TWR_nand_rmii_lowfreq M54418TWR_serial_mii M54418TWR_serial_rmii Signed-off-by: Anton Staaf Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: - Convert space to tab in README - Update gettime commit message to include boards without CONFIG_SYS_HZ README | 1 + common/Makefile | 1 + common/cmd_gettime.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ include/config_cmd_all.h | 1 + 4 files changed, 59 insertions(+), 0 deletions(-) create mode 100644 common/cmd_gettime.c diff --git a/README b/README index ed7d270..089d7a4 100644 --- a/README +++ b/README @@ -819,6 +819,7 @@ The following options need to be configured: CONFIG_CMD_FDOS * Dos diskette Support CONFIG_CMD_FLASH flinfo, erase, protect CONFIG_CMD_FPGA FPGA device initialization support + CONFIG_CMD_GETTIME * Get time since boot CONFIG_CMD_GO * the 'go' command (exec code) CONFIG_CMD_GREPENV * search environment CONFIG_CMD_HWFLOW * RTS/CTS hw flow control diff --git a/common/Makefile b/common/Makefile index 9e43322..0fb79ed 100644 --- a/common/Makefile +++ b/common/Makefile @@ -100,6 +100,7 @@ ifdef CONFIG_FPGA COBJS-$(CONFIG_CMD_FPGA) += cmd_fpga.o endif COBJS-$(CONFIG_CMD_FS_GENERIC) += cmd_fs.o +COBJS-$(CONFIG_CMD_GETTIME) += cmd_gettime.o COBJS-$(CONFIG_CMD_GPIO) += cmd_gpio.o COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o COBJS-$(CONFIG_CMD_IDE) += cmd_ide.o diff --git a/common/cmd_gettime.c b/common/cmd_gettime.c new file mode 100644 index 0000000..d7d36a9 --- /dev/null +++ b/common/cmd_gettime.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. + * + * Copyright (c) 2009, Code Aurora Forum. All rights reserved. + * + * (C) Copyright 2001 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * Get Timer overflows after 2^32 / CONFIG_SYS_HZ (32Khz) = 131072 sec + */ +#include +#include + +static int do_gettime(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + unsigned long int val = get_timer(0); + +#ifdef CONFIG_SYS_HZ + printf("Timer val: %lu\n", val); + printf("Seconds : %lu\n", val / CONFIG_SYS_HZ); + printf("Remainder : %lu\n", val % CONFIG_SYS_HZ); + printf("sys_hz = %lu\n", (unsigned long int)CONFIG_SYS_HZ); +#else + printf("CONFIG_SYS_HZ not defined"); + printf("Timer Val %lu", val); +#endif + + return 0; +} + +U_BOOT_CMD( + gettime, 1, 1, do_gettime, + "get timer val elapsed,\n", + "get time elapsed from uboot start\n" +); diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index f434cd0..b87967e 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -40,6 +40,7 @@ #define CONFIG_CMD_FDOS /* Floppy DOS support */ #define CONFIG_CMD_FLASH /* flinfo, erase, protect */ #define CONFIG_CMD_FPGA /* FPGA configuration Support */ +#define CONFIG_CMD_GETTIME /* Get time since boot */ #define CONFIG_CMD_HWFLOW /* RTS/CTS hw flow control */ #define CONFIG_CMD_I2C /* I2C serial bus support */ #define CONFIG_CMD_IDE /* IDE harddisk support */