From patchwork Thu Dec 9 16:31:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 74932 X-Patchwork-Delegate: s-paulraj@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 3FC67B70B8 for ; Fri, 10 Dec 2010 03:31:58 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A9B132810E; Thu, 9 Dec 2010 17:31:56 +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 LOWHsyaIXbdU; Thu, 9 Dec 2010 17:31:56 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D449C28104; Thu, 9 Dec 2010 17:31:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1915728104 for ; Thu, 9 Dec 2010 17:31:53 +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 f8kI9hGhcPtc for ; Thu, 9 Dec 2010 17:31:51 +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-fx0-f51.google.com (mail-fx0-f51.google.com [209.85.161.51]) by theia.denx.de (Postfix) with ESMTP id 0810428101 for ; Thu, 9 Dec 2010 17:31:49 +0100 (CET) Received: by fxm5 with SMTP id 5so2331577fxm.10 for ; Thu, 09 Dec 2010 08:31:49 -0800 (PST) Received: by 10.223.123.195 with SMTP id q3mr8538719far.35.1291912309282; Thu, 09 Dec 2010 08:31:49 -0800 (PST) Received: from linux.local (p5B042457.dip0.t-ipconnect.de [91.4.36.87]) by mx.google.com with ESMTPS id 17sm595636far.43.2010.12.09.08.31.48 (version=SSLv3 cipher=RC4-MD5); Thu, 09 Dec 2010 08:31:48 -0800 (PST) From: Dirk Behme To: u-boot@lists.denx.de Date: Thu, 9 Dec 2010 17:31:28 +0100 Message-Id: <1291912288-27536-1-git-send-email-dirk.behme@gmail.com> X-Mailer: git-send-email 1.7.3.2 Cc: Dirk Behme Subject: [U-Boot] [RFC PATCH] OMAP: Timer: Replace bss variable by gd X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss values in the OMAP timer driver. The usage of bss values in drivers before initialisation of bss is forbidden. In that special case some data in .rel.dyn gets corrupted. Signed-off-by: Dirk Behme Tested-by: John Rigby Tested-by: Nishanth Menon Acked-by: Nishanth Menon Tested-by: Nishanth Menon Acked-by: Nishanth Menon Tested-by: Steve Sakoman --- Note: This is compile tested only (therefore the RFC). Please *test* on real OMAP HW, e.g. Beagle. This is change is inspired by http://git.denx.de/u-boot.git/?p=u-boot.git;a=commitdiff;h=a429db7e3ce6136f80f22584588247926ba60b05 arch/arm/cpu/armv7/omap-common/timer.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) Index: u-boot.git/arch/arm/cpu/armv7/omap-common/timer.c =================================================================== --- u-boot.git.orig/arch/arm/cpu/armv7/omap-common/timer.c +++ u-boot.git/arch/arm/cpu/armv7/omap-common/timer.c @@ -35,8 +35,8 @@ #include #include -static ulong timestamp; -static ulong lastinc; +DECLARE_GLOBAL_DATA_PTR; + static struct gptimer *timer_base = (struct gptimer *)CONFIG_SYS_TIMERBASE; /* @@ -74,7 +74,7 @@ ulong get_timer(ulong base) void set_timer(ulong t) { - timestamp = t; + gd->tbl = t; } /* delay x useconds */ @@ -96,8 +96,8 @@ void __udelay(unsigned long usec) void reset_timer_masked(void) { /* reset time, capture current incrementer value time */ - lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ); - timestamp = 0; /* start "advancing" time stamp from 0 */ + gd->lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ); + gd->tbl = 0; /* start "advancing" time stamp from 0 */ } ulong get_timer_masked(void) @@ -105,14 +105,14 @@ ulong get_timer_masked(void) /* current tick value */ ulong now = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ); - if (now >= lastinc) /* normal mode (non roll) */ + if (now >= gd->lastinc) /* normal mode (non roll) */ /* move stamp fordward with absoulte diff ticks */ - timestamp += (now - lastinc); + gd->tbl += (now - gd->lastinc); else /* we have rollover of incrementer */ - timestamp += ((TIMER_LOAD_VAL / (TIMER_CLOCK / CONFIG_SYS_HZ)) - - lastinc) + now; - lastinc = now; - return timestamp; + gd->tbl += ((TIMER_LOAD_VAL / (TIMER_CLOCK / CONFIG_SYS_HZ)) + - gd->lastinc) + now; + gd->lastinc = now; + return gd->tbl; } /*