Skip to contentSkip to conversation

davinci timer.c: Remove volatiles and memory mapped structures

PATCH New Nick Thompson 2 participants 2 messages Oct 26, 2009 – Nov 12, 2009

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 davinci timer.c: Remove volatiles and memory mapped structures

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

---
This patch was originally part of the da830 support patch, but this effort is now being integrated into davinci. As a result, these changes would be have been lost, as no change is required for da830. The changes where request to be kept available however, so here they are.

 cpu/arm926ejs/davinci/timer.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)
cpu/arm926ejs/davinci/timer.c +15 -13
index 80751ad..7c2c208 100644
@@ -38,8 +38,9 @@
  */
 
 #include <common.h>
+#include <asm/io.h>
 
-typedef volatile struct {
+struct davinci_timer {
 	u_int32_t	pid12;
 	u_int32_t	emumgt;
 	u_int32_t	na1;
@@ -51,9 +52,10 @@ typedef volatile struct {
 	u_int32_t	tcr;
 	u_int32_t	tgcr;
 	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 TIM_CLK_DIV	16
@@ -64,30 +66,30 @@ static ulong lastinc;
 int timer_init(void)
 {
 	/* We are using timer34 in unchained 32-bit mode, full speed */
-	timer->tcr = 0x0;
-	timer->tgcr = 0x0;
-	timer->tgcr = 0x06 | ((TIM_CLK_DIV - 1) << 8);
-	timer->tim34 = 0x0;
-	timer->prd34 = TIMER_LOAD_VAL;
+	writel(0x0, &timer->tcr);
+	writel(0x0, &timer->tgcr);
+	writel(0x06 | ((TIM_CLK_DIV - 1) << 8), &timer->tgcr);
+	writel(0x0, &timer->tim34);
+	writel(TIMER_LOAD_VAL, &timer->prd34);
 	lastinc = 0;
 	timestamp = 0;
-	timer->tcr = 2 << 22;
+	writel(2 << 22, &timer->tcr);
 
 	return(0);
 }
 
 void reset_timer(void)
 {
-	timer->tcr = 0x0;
-	timer->tim34 = 0;
+	writel(0x0, &timer->tcr);
+	writel(0x0, &timer->tim34);
 	lastinc = 0;
 	timestamp = 0;
-	timer->tcr = 2 << 22;
+	writel(2 << 22, &timer->tcr);
 }
 
 static ulong get_timer_raw(void)
 {
-	ulong now = timer->tim34;
+	ulong now = readl(&timer->tim34);
 
 	if (now >= lastinc) {
 		/* normal mode */
#1 lore raw

PATCH v3 1/1 davinci timer.c: Remove volatiles and memory mapped structures

Quoted 22 lines

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

---
This patch was originally part of the da830 support patch, but this effort is now being integrated into davinci. As a result, these changes would be have been lost, as no change is required for da830. The changes where request to be kept available however, so here they are.

 cpu/arm926ejs/davinci/timer.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)
cpu/arm926ejs/davinci/timer.c +0 -0
index 80751ad..7c2c208 100644

cpu/arm926ejs/davinci/timer.c line 38

Quoted 1 line
cpu/arm926ejs/davinci/timer.c +0 -0
@@ -38,8 +38,9 @@
  */

Pushed to u-boot-ti/master

Minor modification to patch header

http://git.denx.de/?p=u-boot/u-boot-ti.git;a=commit;h=5e9253f5857df4d52629778617a4104784afb0c0

Thanks,
Sandeep