arm926ejs: timer: Replace bss variable by gdr

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>
This commit is contained in:
Heiko Schocher 2011-01-20 22:56:39 +00:00 committed by Albert Aribaud
parent 009b54079e
commit c9ac3ba129
8 changed files with 32 additions and 16 deletions

View 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)) / \ #define READ_TIMER (readl(CNTMR_VAL_REG(UBOOT_CNTR)) / \
(CONFIG_SYS_TCLK / 1000)) (CONFIG_SYS_TCLK / 1000))
static ulong timestamp; DECLARE_GLOBAL_DATA_PTR;
static ulong lastdec;
#define timestamp gd->tbl
#define lastdec gd->lastinc
void reset_timer_masked(void) void reset_timer_masked(void)
{ {

View file

@ -33,8 +33,10 @@
#define TIMER_LOAD_VAL 0xffffffff #define TIMER_LOAD_VAL 0xffffffff
#define TIMER_FREQ (CONFIG_MB86R0x_IOCLK / 256) #define TIMER_FREQ (CONFIG_MB86R0x_IOCLK / 256)
static unsigned long long timestamp; DECLARE_GLOBAL_DATA_PTR;
static ulong lastdec;
#define timestamp gd->tbl
#define lastdec gd->lastinc
static inline unsigned long long tick_to_time(unsigned long long tick) static inline unsigned long long tick_to_time(unsigned long long tick)
{ {

View file

@ -41,8 +41,10 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/arch/imx-regs.h> #include <asm/arch/imx-regs.h>
static ulong timestamp; DECLARE_GLOBAL_DATA_PTR;
static ulong lastinc;
#define timestamp gd->tbl
#define lastinc gd->lastinc
/* /*
* "time" is measured in 1 / CONFIG_SYS_HZ seconds, * "time" is measured in 1 / CONFIG_SYS_HZ seconds,

View file

@ -43,8 +43,10 @@
#define GPTCR_CLKSOURCE_32 (4 << 1) /* Clock source */ #define GPTCR_CLKSOURCE_32 (4 << 1) /* Clock source */
#define GPTCR_TEN 1 /* Timer enable */ #define GPTCR_TEN 1 /* Timer enable */
static ulong timestamp; DECLARE_GLOBAL_DATA_PTR;
static ulong lastinc;
#define timestamp gd->tbl
#define lastinc gd->lastinc
/* /*
* "time" is measured in 1 / CONFIG_SYS_HZ seconds, * "time" is measured in 1 / CONFIG_SYS_HZ seconds,

View file

@ -42,8 +42,10 @@
/* macro to read the 32 bit timer */ /* macro to read the 32 bit timer */
#define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+8)) #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+8))
static ulong timestamp; DECLARE_GLOBAL_DATA_PTR;
static ulong lastdec;
#define timestamp gd->tbl
#define lastdec gd->lastinc
int timer_init (void) int timer_init (void)
{ {

View file

@ -90,8 +90,10 @@ static inline ulong read_timer(void)
/ (CONFIG_SYS_TCLK / 1000); / (CONFIG_SYS_TCLK / 1000);
} }
static ulong timestamp; DECLARE_GLOBAL_DATA_PTR;
static ulong lastdec;
#define timestamp gd->tbl
#define lastdec gd->lastinc
void reset_timer_masked(void) void reset_timer_masked(void)
{ {

View file

@ -36,8 +36,10 @@ static struct gpt_regs *const gpt_regs_p =
static struct misc_regs *const misc_regs_p = static struct misc_regs *const misc_regs_p =
(struct misc_regs *)CONFIG_SPEAR_MISCBASE; (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
static ulong timestamp; DECLARE_GLOBAL_DATA_PTR;
static ulong lastdec;
#define timestamp gd->tbl
#define lastdec gd->lastinc
int timer_init(void) int timer_init(void)
{ {

View file

@ -42,8 +42,10 @@
/* macro to read the 32 bit timer */ /* macro to read the 32 bit timer */
#define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+4)) #define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+4))
static ulong timestamp; DECLARE_GLOBAL_DATA_PTR;
static ulong lastdec;
#define timestamp gd->tbl
#define lastdec gd->lastinc
#define TIMER_ENABLE (1 << 7) #define TIMER_ENABLE (1 << 7)
#define TIMER_MODE_MSK (1 << 6) #define TIMER_MODE_MSK (1 << 6)