public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Andreas Bießmann" <andreas.devel@googlemail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 4/4] arm920t/at91/timer: replace bss variables by gd
Date: Tue, 30 Nov 2010 20:45:06 +0100	[thread overview]
Message-ID: <1291146306-15103-5-git-send-email-andreas.devel@googlemail.com> (raw)
In-Reply-To: <1291146306-15103-1-git-send-email-andreas.devel@googlemail.com>

Reuse the gd->tbl value for timestamp and add gd->lastinc for 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 <andreas.devel@googlemail.com>
---
changes since v1:
 * use gd->tbl as timestamp
 * add gd->lastinc for CONFIG_AT91FAMILY and use in favor of lastinc bss

 arch/arm/cpu/arm920t/at91/timer.c  |   29 ++++++++++++++---------------
 arch/arm/include/asm/global_data.h |    1 +
 include/configs/at91rm9200ek.h     |    2 ++
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/arch/arm/cpu/arm920t/at91/timer.c b/arch/arm/cpu/arm920t/at91/timer.c
index 91377d4..d9a024f 100644
--- a/arch/arm/cpu/arm920t/at91/timer.c
+++ b/arch/arm/cpu/arm920t/at91/timer.c
@@ -32,17 +32,16 @@
 
 #include <common.h>
 
-#include <asm/io.h>
-#include <asm/hardware.h>
+#include <asm/arch/io.h>
+#include <asm/arch/hardware.h>
 #include <asm/arch/at91_tc.h>
 #include <asm/arch/at91_pmc.h>
 
+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->lastinc = 0;
+	gd->tbl = 0;
 
 	return 0;
 }
@@ -86,7 +85,7 @@ ulong get_timer(ulong base)
 
 void set_timer(ulong t)
 {
-	timestamp = t;
+	gd->tbl = 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->lastinc = readl(&tc->tc[0].cv) & 0x0000ffff;
+	gd->tbl = 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->lastinc) {
 		/* normal mode */
-		timestamp += now - lastinc;
+		gd->tbl += now - gd->lastinc;
 	} else {
 		/* we have an overflow ... */
-		timestamp += now + TIMER_LOAD_VAL - lastinc;
+		gd->tbl += now + TIMER_LOAD_VAL - gd->lastinc;
 	}
-	lastinc = now;
+	gd->lastinc = now;
 
-	return timestamp;
+	return gd->tbl;
 }
 
 ulong get_timer_masked(void)
diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
index ada3fbb..e459a5d 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -60,6 +60,7 @@ typedef	struct	global_data {
 	unsigned long	tbl;
 	unsigned long	tbu;
 	unsigned long long	timer_reset_value;
+	unsigned long	lastinc;
 #endif
 	unsigned long	relocaddr;	/* Start address of U-Boot in RAM */
 	phys_size_t	ram_size;	/* RAM size */
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
  */
-- 
1.7.3.2

  parent reply	other threads:[~2010-11-30 19:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-30 19:45 [U-Boot] [PATCH v2 0/4] get at91rm9200ek working with ARM relocation Andreas Bießmann
2010-11-30 19:45 ` [U-Boot] [PATCH v2 1/4] at91rm9200ek: add configure target for RAM boot Andreas Bießmann
2010-11-30 19:45 ` [U-Boot] [PATCH v2 2/4] MAKEALL: fix AT91 Andreas Bießmann
2010-11-30 19:45 ` [U-Boot] [PATCH v2 3/4] arm920t/at91/reset: board_reset: define weak symbol Andreas Bießmann
2010-12-02 19:00   ` Jens Scharsig
2010-11-30 19:45 ` Andreas Bießmann [this message]
2010-11-30 19:58 ` [U-Boot] [PATCH v2 0/4] get at91rm9200ek working with ARM relocation Reinhard Meyer
2010-11-30 22:20   ` Andreas Bießmann
2010-12-05  9:53 ` Reinhard Meyer
2010-12-05 17:43   ` Andreas Bießmann
2010-12-05 17:56     ` Albert ARIBAUD
2010-12-05 18:05       ` Andreas Bießmann
2010-12-05 19:14         ` Reinhard Meyer
2010-12-05 20:00           ` Albert ARIBAUD
2010-12-05 22:05             ` Reinhard Meyer
2010-12-05 21:04           ` Wolfgang Denk
2010-12-05 21:24             ` Reinhard Meyer
2010-12-05 21:42               ` Wolfgang Denk
2010-12-05 21:51                 ` Reinhard Meyer
2010-12-06  5:37                   ` Wolfgang Denk
2010-12-06  5:56                     ` Reinhard Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1291146306-15103-5-git-send-email-andreas.devel@googlemail.com \
    --to=andreas.devel@googlemail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox