From patchwork Wed Apr 3 19:35:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunter, Jon" X-Patchwork-Id: 233578 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 C33262C00E9 for ; Thu, 4 Apr 2013 06:36:23 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 351D74A2F1; Wed, 3 Apr 2013 21:36:17 +0200 (CEST) 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 ZE0qNkPYOnY4; Wed, 3 Apr 2013 21:36:16 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 220CB4A312; Wed, 3 Apr 2013 21:36:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9B0F04A2D0 for ; Wed, 3 Apr 2013 21:35:58 +0200 (CEST) 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 1XESwK4emtbO for ; Wed, 3 Apr 2013 21:35:57 +0200 (CEST) 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 comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by theia.denx.de (Postfix) with ESMTPS id D659B4A304 for ; Wed, 3 Apr 2013 21:35:51 +0200 (CEST) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r33JZoL8015267 for ; Wed, 3 Apr 2013 14:35:50 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r33JZoWo001248 for ; Wed, 3 Apr 2013 14:35:50 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Wed, 3 Apr 2013 14:35:49 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id r33JZnu5025939; Wed, 3 Apr 2013 14:35:49 -0500 Received: from localhost (h113-251.vpn.ti.com [172.24.113.251]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r33JZnV23950; Wed, 3 Apr 2013 14:35:49 -0500 (CDT) From: Jon Hunter To: Tom Rini Date: Wed, 3 Apr 2013 14:35:36 -0500 Message-ID: <1365017737-5926-5-git-send-email-jon-hunter@ti.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1365017737-5926-1-git-send-email-jon-hunter@ti.com> References: <1365017737-5926-1-git-send-email-jon-hunter@ti.com> MIME-Version: 1.0 Cc: u-boot Subject: [U-Boot] [PATCH 4/4] omap2420-h4: Fix get_timer() and CONFIG_SYS_HZ 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The function get_timer() should return time in ms and CONFIG_SYS_HZ should be set to 1000 by default. Fix both of these items. Signed-off-by: Jon Hunter --- arch/arm/cpu/arm1136/omap24xx/timer.c | 8 ++++++-- include/configs/omap2420h4.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/arm/cpu/arm1136/omap24xx/timer.c b/arch/arm/cpu/arm1136/omap24xx/timer.c index 53015cb..3b6666b 100644 --- a/arch/arm/cpu/arm1136/omap24xx/timer.c +++ b/arch/arm/cpu/arm1136/omap24xx/timer.c @@ -31,13 +31,16 @@ */ #include +#include #include #include +#define TIMER_CLOCK (CONFIG_SYS_CLK_FREQ / (2 << CONFIG_SYS_PTV)) #define TIMER_LOAD_VAL 0 /* macro to read the 32 bit timer */ -#define READ_TIMER (*((volatile ulong *)(CONFIG_SYS_TIMERBASE+TCRR))) +#define READ_TIMER readl(CONFIG_SYS_TIMERBASE+TCRR) \ + / (TIMER_CLOCK / CONFIG_SYS_HZ) DECLARE_GLOBAL_DATA_PTR; @@ -99,7 +102,8 @@ ulong get_timer_masked (void) gd->arch.tbl += (now - gd->arch.lastinc); } else { /* we have rollover of incrementer */ - gd->arch.tbl += (0xFFFFFFFF - gd->arch.lastinc) + now; + gd->arch.tbl += ((0xFFFFFFFF / (TIMER_CLOCK / CONFIG_SYS_HZ)) + - gd->arch.lastinc) + now; } gd->arch.lastinc = now; return gd->arch.tbl; diff --git a/include/configs/omap2420h4.h b/include/configs/omap2420h4.h index e144ae9d..04e8d3a 100644 --- a/include/configs/omap2420h4.h +++ b/include/configs/omap2420h4.h @@ -190,7 +190,7 @@ #define CONFIG_SYS_TIMERBASE OMAP2420_GPT2 #define CONFIG_SYS_PTV V_PTV /* 2^(PTV+1) */ -#define CONFIG_SYS_HZ ((CONFIG_SYS_CLK_FREQ)/(2 << CONFIG_SYS_PTV)) +#define CONFIG_SYS_HZ 1000 /*----------------------------------------------------------------------- * Physical Memory Map