From patchwork Tue Nov 30 06:37:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 73564 X-Patchwork-Delegate: info@emk-elektronik.de 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 35B6C1007D5 for ; Tue, 30 Nov 2010 17:38:41 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1BF90281D5; Tue, 30 Nov 2010 07:38:06 +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 Kc-0DgXO9Gly; Tue, 30 Nov 2010 07:38:05 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9F41028264; Tue, 30 Nov 2010 07:37:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2DABD281C9 for ; Tue, 30 Nov 2010 07:37:43 +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 fTCvumPxJhIe for ; Tue, 30 Nov 2010 07:37:42 +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-bw0-f44.google.com (mail-bw0-f44.google.com [209.85.214.44]) by theia.denx.de (Postfix) with ESMTP id 87DAC281D1 for ; Tue, 30 Nov 2010 07:37:38 +0100 (CET) Received: by mail-bw0-f44.google.com with SMTP id 12so4796071bwz.3 for ; Mon, 29 Nov 2010 22:37:38 -0800 (PST) Received: by 10.204.75.194 with SMTP id z2mr6110307bkj.132.1291099058365; Mon, 29 Nov 2010 22:37:38 -0800 (PST) Received: from andreas-mbp.erlangen.biessmann.tld (dslb-092-075-127-153.pools.arcor-ip.net [92.75.127.153]) by mx.google.com with ESMTPS id d27sm2477415bkw.2.2010.11.29.22.37.37 (version=SSLv3 cipher=RC4-MD5); Mon, 29 Nov 2010 22:37:37 -0800 (PST) From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= To: u-boot@lists.denx.de Date: Tue, 30 Nov 2010 07:37:19 +0100 Message-Id: <1291099039-49672-5-git-send-email-andreas.devel@googlemail.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1291099039-49672-1-git-send-email-andreas.devel@googlemail.com> References: <1291099039-49672-1-git-send-email-andreas.devel@googlemail.com> MIME-Version: 1.0 Cc: Albert ARIBAUD Subject: [U-Boot] [PATCH 4/4] arm920t/at91/timer: replace bss variables 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Reuse the gd->tbl/tbu values for timestamp/lastinc bss values in arm920t/at91/timer driver. The usage of bss values in driver before initialisation of bss is forbidden. In that special case some data in .rel.dyn gets corrupted by the arm920t/at91/timer driver. Signed-off-by: Andreas Bießmann --- arch/arm/cpu/arm920t/at91/timer.c | 29 ++++++++++++++--------------- include/configs/at91rm9200ek.h | 2 ++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/arch/arm/cpu/arm920t/at91/timer.c b/arch/arm/cpu/arm920t/at91/timer.c index 91377d4..2a7cd9b 100644 --- a/arch/arm/cpu/arm920t/at91/timer.c +++ b/arch/arm/cpu/arm920t/at91/timer.c @@ -32,17 +32,16 @@ #include -#include -#include +#include +#include #include #include +DECLARE_GLOBAL_DATA_PTR; + /* the number of clocks per CONFIG_SYS_HZ */ #define TIMER_LOAD_VAL (CONFIG_SYS_HZ_CLOCK/CONFIG_SYS_HZ) -static u32 timestamp; -static u32 lastinc; - int timer_init(void) { at91_tc_t *tc = (at91_tc_t *) AT91_TC_BASE; @@ -64,8 +63,8 @@ int timer_init(void) writel(TIMER_LOAD_VAL, &tc->tc[0].rc); writel(AT91_TC_CCR_SWTRG | AT91_TC_CCR_CLKEN, &tc->tc[0].ccr); - lastinc = 0; - timestamp = 0; + gd->tbu = 0; + gd->tbl = 0; return 0; } @@ -86,7 +85,7 @@ ulong get_timer(ulong base) void set_timer(ulong t) { - timestamp = t; + gd->tbu = t; } void __udelay(unsigned long usec) @@ -98,8 +97,8 @@ void reset_timer_masked(void) { /* reset time */ at91_tc_t *tc = (at91_tc_t *) AT91_TC_BASE; - lastinc = readl(&tc->tc[0].cv) & 0x0000ffff; - timestamp = 0; + gd->tbl = readl(&tc->tc[0].cv) & 0x0000ffff; + gd->tbu = 0; } ulong get_timer_raw(void) @@ -109,16 +108,16 @@ ulong get_timer_raw(void) now = readl(&tc->tc[0].cv) & 0x0000ffff; - if (now >= lastinc) { + if (now >= gd->tbl) { /* normal mode */ - timestamp += now - lastinc; + gd->tbu += now - gd->tbl; } else { /* we have an overflow ... */ - timestamp += now + TIMER_LOAD_VAL - lastinc; + gd->tbu += now + TIMER_LOAD_VAL - gd->tbl; } - lastinc = now; + gd->tbl = now; - return timestamp; + return gd->tbu; } ulong get_timer_masked(void) diff --git a/include/configs/at91rm9200ek.h b/include/configs/at91rm9200ek.h index ba2e9d3..57e17e9 100644 --- a/include/configs/at91rm9200ek.h +++ b/include/configs/at91rm9200ek.h @@ -71,6 +71,8 @@ #define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_INITRD_TAG +#define CONFIG_AT91FAMILY + /* * Memory Configuration */