Skip to content
Snippets Groups Projects
Commit 9868a36d authored by Nick Thompson's avatar Nick Thompson Committed by Tom Rix
Browse files

TI Davinci timer.c: Remove volatiles and memory mapped structures


Remove volatiles and memory mapped structure accesses and replace with
readl and writel macro usage.

Signed-off-by: default avatarNick Thompson <nick.thompson@gefanuc.com>
parent c90b3273
No related branches found
No related tags found
No related merge requests found
...@@ -38,8 +38,9 @@ ...@@ -38,8 +38,9 @@
*/ */
#include <common.h> #include <common.h>
#include <asm/io.h>
typedef volatile struct { struct davinci_timer {
u_int32_t pid12; u_int32_t pid12;
u_int32_t emumgt; u_int32_t emumgt;
u_int32_t na1; u_int32_t na1;
...@@ -51,9 +52,10 @@ typedef volatile struct { ...@@ -51,9 +52,10 @@ typedef volatile struct {
u_int32_t tcr; u_int32_t tcr;
u_int32_t tgcr; u_int32_t tgcr;
u_int32_t wdtcr; u_int32_t wdtcr;
} davinci_timer; };
davinci_timer *timer = (davinci_timer *)CONFIG_SYS_TIMERBASE; static struct davinci_timer * const timer =
(struct davinci_timer *)CONFIG_SYS_TIMERBASE;
#define TIMER_LOAD_VAL (CONFIG_SYS_HZ_CLOCK / CONFIG_SYS_HZ) #define TIMER_LOAD_VAL (CONFIG_SYS_HZ_CLOCK / CONFIG_SYS_HZ)
#define TIM_CLK_DIV 16 #define TIM_CLK_DIV 16
...@@ -64,30 +66,30 @@ static ulong lastinc; ...@@ -64,30 +66,30 @@ static ulong lastinc;
int timer_init(void) int timer_init(void)
{ {
/* We are using timer34 in unchained 32-bit mode, full speed */ /* We are using timer34 in unchained 32-bit mode, full speed */
timer->tcr = 0x0; writel(0x0, &timer->tcr);
timer->tgcr = 0x0; writel(0x0, &timer->tgcr);
timer->tgcr = 0x06 | ((TIM_CLK_DIV - 1) << 8); writel(0x06 | ((TIM_CLK_DIV - 1) << 8), &timer->tgcr);
timer->tim34 = 0x0; writel(0x0, &timer->tim34);
timer->prd34 = TIMER_LOAD_VAL; writel(TIMER_LOAD_VAL, &timer->prd34);
lastinc = 0; lastinc = 0;
timestamp = 0; timestamp = 0;
timer->tcr = 2 << 22; writel(2 << 22, &timer->tcr);
return(0); return(0);
} }
void reset_timer(void) void reset_timer(void)
{ {
timer->tcr = 0x0; writel(0x0, &timer->tcr);
timer->tim34 = 0; writel(0x0, &timer->tim34);
lastinc = 0; lastinc = 0;
timestamp = 0; timestamp = 0;
timer->tcr = 2 << 22; writel(2 << 22, &timer->tcr);
} }
static ulong get_timer_raw(void) static ulong get_timer_raw(void)
{ {
ulong now = timer->tim34; ulong now = readl(&timer->tim34);
if (now >= lastinc) { if (now >= lastinc) {
/* normal mode */ /* normal mode */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment