mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-09 03:58:18 -04:00
arm920t/at91/timer: replace bss variables by gd
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>
This commit is contained in:
parent
305bf489d1
commit
a429db7e3c
@ -32,17 +32,16 @@
|
|||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
|
||||||
#include <asm/io.h>
|
#include <asm/arch/io.h>
|
||||||
#include <asm/hardware.h>
|
#include <asm/arch/hardware.h>
|
||||||
#include <asm/arch/at91_tc.h>
|
#include <asm/arch/at91_tc.h>
|
||||||
#include <asm/arch/at91_pmc.h>
|
#include <asm/arch/at91_pmc.h>
|
||||||
|
|
||||||
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
/* the number of clocks per CONFIG_SYS_HZ */
|
/* the number of clocks per CONFIG_SYS_HZ */
|
||||||
#define TIMER_LOAD_VAL (CONFIG_SYS_HZ_CLOCK/CONFIG_SYS_HZ)
|
#define TIMER_LOAD_VAL (CONFIG_SYS_HZ_CLOCK/CONFIG_SYS_HZ)
|
||||||
|
|
||||||
static u32 timestamp;
|
|
||||||
static u32 lastinc;
|
|
||||||
|
|
||||||
int timer_init(void)
|
int timer_init(void)
|
||||||
{
|
{
|
||||||
at91_tc_t *tc = (at91_tc_t *) AT91_TC_BASE;
|
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(TIMER_LOAD_VAL, &tc->tc[0].rc);
|
||||||
|
|
||||||
writel(AT91_TC_CCR_SWTRG | AT91_TC_CCR_CLKEN, &tc->tc[0].ccr);
|
writel(AT91_TC_CCR_SWTRG | AT91_TC_CCR_CLKEN, &tc->tc[0].ccr);
|
||||||
lastinc = 0;
|
gd->lastinc = 0;
|
||||||
timestamp = 0;
|
gd->tbl = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -86,7 +85,7 @@ ulong get_timer(ulong base)
|
|||||||
|
|
||||||
void set_timer(ulong t)
|
void set_timer(ulong t)
|
||||||
{
|
{
|
||||||
timestamp = t;
|
gd->tbl = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __udelay(unsigned long usec)
|
void __udelay(unsigned long usec)
|
||||||
@ -98,8 +97,8 @@ void reset_timer_masked(void)
|
|||||||
{
|
{
|
||||||
/* reset time */
|
/* reset time */
|
||||||
at91_tc_t *tc = (at91_tc_t *) AT91_TC_BASE;
|
at91_tc_t *tc = (at91_tc_t *) AT91_TC_BASE;
|
||||||
lastinc = readl(&tc->tc[0].cv) & 0x0000ffff;
|
gd->lastinc = readl(&tc->tc[0].cv) & 0x0000ffff;
|
||||||
timestamp = 0;
|
gd->tbl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong get_timer_raw(void)
|
ulong get_timer_raw(void)
|
||||||
@ -109,16 +108,16 @@ ulong get_timer_raw(void)
|
|||||||
|
|
||||||
now = readl(&tc->tc[0].cv) & 0x0000ffff;
|
now = readl(&tc->tc[0].cv) & 0x0000ffff;
|
||||||
|
|
||||||
if (now >= lastinc) {
|
if (now >= gd->lastinc) {
|
||||||
/* normal mode */
|
/* normal mode */
|
||||||
timestamp += now - lastinc;
|
gd->tbl += now - gd->lastinc;
|
||||||
} else {
|
} else {
|
||||||
/* we have an overflow ... */
|
/* 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)
|
ulong get_timer_masked(void)
|
||||||
|
@ -60,6 +60,7 @@ typedef struct global_data {
|
|||||||
unsigned long tbl;
|
unsigned long tbl;
|
||||||
unsigned long tbu;
|
unsigned long tbu;
|
||||||
unsigned long long timer_reset_value;
|
unsigned long long timer_reset_value;
|
||||||
|
unsigned long lastinc;
|
||||||
#endif
|
#endif
|
||||||
unsigned long relocaddr; /* Start address of U-Boot in RAM */
|
unsigned long relocaddr; /* Start address of U-Boot in RAM */
|
||||||
phys_size_t ram_size; /* RAM size */
|
phys_size_t ram_size; /* RAM size */
|
||||||
|
@ -71,6 +71,8 @@
|
|||||||
#define CONFIG_SETUP_MEMORY_TAGS
|
#define CONFIG_SETUP_MEMORY_TAGS
|
||||||
#define CONFIG_INITRD_TAG
|
#define CONFIG_INITRD_TAG
|
||||||
|
|
||||||
|
#define CONFIG_AT91FAMILY
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Memory Configuration
|
* Memory Configuration
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user