]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
arm926ejs: timer: Replace bss variable by gdr
authorHeiko Schocher <hs@denx.de>
Thu, 20 Jan 2011 22:56:39 +0000 (22:56 +0000)
committerAlbert Aribaud <albert.aribaud@free.fr>
Tue, 1 Feb 2011 23:54:45 +0000 (00:54 +0100)
Reuse the gd->tbl value for timestamp and add gd->lastinc for lastinc bss
values in the arm926ejs timers implementation.

The usage of bss values in drivers before initialisation of bss is forbidden.
In that special case some data in .rel.dyn gets corrupted.

This patch is similiar to the patch Dirk Behme posted
for the armv7/omap-common/timer.c and added suggestions
from Reinhard Meyer.

Tested on the arm926ejs mx27 based magnesium board
Tested on the arm926ejs kirkwood based suen3 board

Signed-off-by: Heiko Schocher <hs@denx.de>
cc: Albert ARIBAUD <albert.aribaud@free.fr>
cc: Prafulla Wadaskar <prafulla@marvell.com>
cc: Stefano Babic <sbabic@denx.de>
cc: Reinhard Meyer <u-boot@emk-elektronik.de>

arch/arm/cpu/arm926ejs/kirkwood/timer.c
arch/arm/cpu/arm926ejs/mb86r0x/timer.c
arch/arm/cpu/arm926ejs/mx25/timer.c
arch/arm/cpu/arm926ejs/mx27/timer.c
arch/arm/cpu/arm926ejs/omap/timer.c
arch/arm/cpu/arm926ejs/orion5x/timer.c
arch/arm/cpu/arm926ejs/spear/timer.c
arch/arm/cpu/arm926ejs/versatile/timer.c

index 2ec6a93807e9775856c3d42ac42ad8442ef7e7d8..3e8032960842e7c935daa34d189b9b441b9fe99a 100644 (file)
@@ -83,8 +83,10 @@ struct kwtmr_registers *kwtmr_regs = (struct kwtmr_registers *)KW_TIMER_BASE;
 #define READ_TIMER                     (readl(CNTMR_VAL_REG(UBOOT_CNTR)) /     \
                                         (CONFIG_SYS_TCLK / 1000))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 void reset_timer_masked(void)
 {
index 9175b71d16aa17e5c75e442defb5ea4ae1625a6b..6966b0d190d641c6255c7dde30aa0b2a6384c1e9 100644 (file)
 #define TIMER_LOAD_VAL 0xffffffff
 #define TIMER_FREQ     (CONFIG_MB86R0x_IOCLK  / 256)
 
-static unsigned long long timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 static inline unsigned long long tick_to_time(unsigned long long tick)
 {
index 11d41a8bf9f5b44ec098c18e4b62911f66cc1115..14f0c2dc73b923f28480abeccdba42a3675f2c12 100644 (file)
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastinc gd->lastinc
 
 /*
  * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
index 8f1d47bba775716ec21afd2a5e662c617b7a24d4..5c1cf014f05a46565515db626e7e425a84f66126 100644 (file)
 #define GPTCR_CLKSOURCE_32     (4 << 1)        /* Clock source         */
 #define GPTCR_TEN              1               /* Timer enable         */
 
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastinc gd->lastinc
 
 /*
  * "time" is measured in 1 / CONFIG_SYS_HZ seconds,
index 7d4b6e602e4e99b7ceca0d00e6ca504c5f50a957..88a0ee677eacec1776f29955092a839e7693ac7a 100644 (file)
 /* macro to read the 32 bit timer */
 #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+8))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 int timer_init (void)
 {
index 089ef47b371f672f85fd1c016e27b67b11327f0f..bbab2269ddab85ecd83fd3729708731d01d5929e 100644 (file)
@@ -90,8 +90,10 @@ static inline ulong read_timer(void)
              / (CONFIG_SYS_TCLK / 1000);
 }
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 void reset_timer_masked(void)
 {
index 06858b4a13bacf4fcaad376eff0a7aed407cd7d1..66cf4de81713205d24e1b3d94f862f01badf62a4 100644 (file)
@@ -36,8 +36,10 @@ static struct gpt_regs *const gpt_regs_p =
 static struct misc_regs *const misc_regs_p =
     (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 int timer_init(void)
 {
index 81d67490db87cadb9bba2d7bd63d9bcb91048ea7..2e243b196eb7c46e90d198b9a51431d092dc6ce6 100644 (file)
 /* macro to read the 32 bit timer */
 #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+4))
 
-static ulong timestamp;
-static ulong lastdec;
+DECLARE_GLOBAL_DATA_PTR;
+
+#define timestamp gd->tbl
+#define lastdec gd->lastinc
 
 #define TIMER_ENABLE   (1 << 7)
 #define TIMER_MODE_MSK (1 << 6)