Skip to contentSkip to conversation

davinci timer.c: Remove volatiles and memory mapped structures

PATCH Superseded Nick Thompson 3 participants 3 messages Oct 26, 2009

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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

Remove volatiles and memory mapped structure accesses from the davinci cpu timer.c functions 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 |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)
cpu/arm926ejs/davinci/timer.c +17 -12
index 80751ad..2b22eef 100644
@@ -1,4 +1,8 @@
 /*
+ * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <[email protected]>
+ *
+ * Coding style changes. Use writel and readl for hardware accesses.
+ *
  * (C) Copyright 2003
  * Texas Instruments <www.ti.com>
  *
@@ -38,8 +42,9 @@
  */
 
 #include <common.h>
+#include <asm/io.h>
 
-typedef volatile struct {
+typedef struct {
 	u_int32_t	pid12;
 	u_int32_t	emumgt;
 	u_int32_t	na1;
@@ -53,7 +58,7 @@ typedef volatile struct {
 	u_int32_t	wdtcr;
 } davinci_timer;
 
-davinci_timer		*timer = (davinci_timer *)CONFIG_SYS_TIMERBASE;
+static davinci_timer * const timer = (davinci_timer *)CONFIG_SYS_TIMERBASE;
 
 #define TIMER_LOAD_VAL	(CONFIG_SYS_HZ_CLOCK / CONFIG_SYS_HZ)
 #define TIM_CLK_DIV	16
@@ -64,30 +69,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 1/1 davinci timer.c: Remove volatiles and memory mapped structures

Hi Nick,

cpu/arm926ejs/davinci/timer.c line 8

Quoted 11 lines
cpu/arm926ejs/davinci/timer.c +4 -0
@@ -1,4 +1,8 @@
 /*
+ * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <[email protected]>
+ *
+ * Coding style changes. Use writel and readl for hardware accesses.
+ *
  * (C) Copyright 2003
  * Texas Instruments <www.ti.com>
  *

The change looks good to me, but I don't think your copyright should be added for such a trivial change. There are already 6 separate copyrights for a relatively simple 100 lines of code:)

Best,
Peter

#2 lore raw

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

Quoted 6 lines · On Monday 26 October 2009 15:42:56 Peter Tyser wrote:
Quoted 6 lines

+++ b/cpu/arm926ejs/davinci/timer.c

(quoted diff) +1 -0
@@ -1,4 +1,8 @@
 /*
+ * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd.

<[email protected]> + *
+ * Coding style changes. Use writel and readl for hardware accesses.

Quoted 8 lines
Quoted 4 lines

+ *
* (C) Copyright 2003
* Texas Instruments <www.ti.com>
*

The change looks good to me, but I don't think your copyright should be added for such a trivial change. There are already 6 separate copyrights for a relatively simple 100 lines of code:)

And you shouldn't add such comments about what you changed into the file itself. git will handle those comments.

Cheers,
Stefan

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de