aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/time.c
diff options
context:
space:
mode:
authorKevin Hilman <khilman@deeprootsystems.com>2009-04-14 08:04:16 -0400
committerKevin Hilman <khilman@deeprootsystems.com>2009-04-23 12:31:09 -0400
commitf5c122da543ebf98a5ccb3166768e38eea3120dd (patch)
tree0275d0646aab07c8e3bf9ef5a22572bcf668f400 /arch/arm/mach-davinci/time.c
parentc5b736d093217890245a33e9a98fe92d6f3529bf (diff)
davinci: add arch_ioremap() which uses existing static mappings
Add arch-specific ioremap() which uses any existing static mappings in place of doing a new mapping. From now on, drivers should always use ioremap() instead of IO_ADDRESS(). In addition, remove the davinci_[read|write]* macros in favor of using ioremap. Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-davinci/time.c')
-rw-r--r--arch/arm/mach-davinci/time.c79
1 files changed, 44 insertions, 35 deletions
diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c
index 6c227d4ba998..88864ae067b8 100644
--- a/arch/arm/mach-davinci/time.c
+++ b/arch/arm/mach-davinci/time.c
@@ -16,6 +16,9 @@
16#include <linux/clockchips.h> 16#include <linux/clockchips.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/clk.h>
20#include <linux/err.h>
21#include <linux/device.h>
19 22
20#include <mach/hardware.h> 23#include <mach/hardware.h>
21#include <asm/system.h> 24#include <asm/system.h>
@@ -24,6 +27,8 @@
24#include <asm/mach/time.h> 27#include <asm/mach/time.h>
25#include <asm/errno.h> 28#include <asm/errno.h>
26#include <mach/io.h> 29#include <mach/io.h>
30#include <mach/cputype.h>
31#include "clock.h"
27 32
28static struct clock_event_device clockevent_davinci; 33static struct clock_event_device clockevent_davinci;
29 34
@@ -99,9 +104,9 @@ struct timer_s {
99 unsigned int id; 104 unsigned int id;
100 unsigned long period; 105 unsigned long period;
101 unsigned long opts; 106 unsigned long opts;
102 unsigned long reg_base; 107 void __iomem *base;
103 unsigned long tim_reg; 108 unsigned long tim_off;
104 unsigned long prd_reg; 109 unsigned long prd_off;
105 unsigned long enamode_shift; 110 unsigned long enamode_shift;
106 struct irqaction irqaction; 111 struct irqaction irqaction;
107}; 112};
@@ -114,15 +119,15 @@ static struct timer_s timers[];
114 119
115static int timer32_config(struct timer_s *t) 120static int timer32_config(struct timer_s *t)
116{ 121{
117 u32 tcr = davinci_readl(t->reg_base + TCR); 122 u32 tcr = __raw_readl(t->base + TCR);
118 123
119 /* disable timer */ 124 /* disable timer */
120 tcr &= ~(TCR_ENAMODE_MASK << t->enamode_shift); 125 tcr &= ~(TCR_ENAMODE_MASK << t->enamode_shift);
121 davinci_writel(tcr, t->reg_base + TCR); 126 __raw_writel(tcr, t->base + TCR);
122 127
123 /* reset counter to zero, set new period */ 128 /* reset counter to zero, set new period */
124 davinci_writel(0, t->tim_reg); 129 __raw_writel(0, t->base + t->tim_off);
125 davinci_writel(t->period, t->prd_reg); 130 __raw_writel(t->period, t->base + t->prd_off);
126 131
127 /* Set enable mode */ 132 /* Set enable mode */
128 if (t->opts & TIMER_OPTS_ONESHOT) { 133 if (t->opts & TIMER_OPTS_ONESHOT) {
@@ -131,13 +136,13 @@ static int timer32_config(struct timer_s *t)
131 tcr |= TCR_ENAMODE_PERIODIC << t->enamode_shift; 136 tcr |= TCR_ENAMODE_PERIODIC << t->enamode_shift;
132 } 137 }
133 138
134 davinci_writel(tcr, t->reg_base + TCR); 139 __raw_writel(tcr, t->base + TCR);
135 return 0; 140 return 0;
136} 141}
137 142
138static inline u32 timer32_read(struct timer_s *t) 143static inline u32 timer32_read(struct timer_s *t)
139{ 144{
140 return davinci_readl(t->tim_reg); 145 return __raw_readl(t->base + t->tim_off);
141} 146}
142 147
143static irqreturn_t timer_interrupt(int irq, void *dev_id) 148static irqreturn_t timer_interrupt(int irq, void *dev_id)
@@ -176,51 +181,54 @@ static struct timer_s timers[] = {
176 181
177static void __init timer_init(void) 182static void __init timer_init(void)
178{ 183{
179 u32 bases[] = {DAVINCI_TIMER0_BASE, DAVINCI_TIMER1_BASE}; 184 u32 phys_bases[] = {DAVINCI_TIMER0_BASE, DAVINCI_TIMER1_BASE};
180 int i; 185 int i;
181 186
182 /* Global init of each 64-bit timer as a whole */ 187 /* Global init of each 64-bit timer as a whole */
183 for(i=0; i<2; i++) { 188 for(i=0; i<2; i++) {
184 u32 tgcr, base = bases[i]; 189 u32 tgcr;
190 void __iomem *base = IO_ADDRESS(phys_bases[i]);
185 191
186 /* Disabled, Internal clock source */ 192 /* Disabled, Internal clock source */
187 davinci_writel(0, base + TCR); 193 __raw_writel(0, base + TCR);
188 194
189 /* reset both timers, no pre-scaler for timer34 */ 195 /* reset both timers, no pre-scaler for timer34 */
190 tgcr = 0; 196 tgcr = 0;
191 davinci_writel(tgcr, base + TGCR); 197 __raw_writel(tgcr, base + TGCR);
192 198
193 /* Set both timers to unchained 32-bit */ 199 /* Set both timers to unchained 32-bit */
194 tgcr = TGCR_TIMMODE_32BIT_UNCHAINED << TGCR_TIMMODE_SHIFT; 200 tgcr = TGCR_TIMMODE_32BIT_UNCHAINED << TGCR_TIMMODE_SHIFT;
195 davinci_writel(tgcr, base + TGCR); 201 __raw_writel(tgcr, base + TGCR);
196 202
197 /* Unreset timers */ 203 /* Unreset timers */
198 tgcr |= (TGCR_UNRESET << TGCR_TIM12RS_SHIFT) | 204 tgcr |= (TGCR_UNRESET << TGCR_TIM12RS_SHIFT) |
199 (TGCR_UNRESET << TGCR_TIM34RS_SHIFT); 205 (TGCR_UNRESET << TGCR_TIM34RS_SHIFT);
200 davinci_writel(tgcr, base + TGCR); 206 __raw_writel(tgcr, base + TGCR);
201 207
202 /* Init both counters to zero */ 208 /* Init both counters to zero */
203 davinci_writel(0, base + TIM12); 209 __raw_writel(0, base + TIM12);
204 davinci_writel(0, base + TIM34); 210 __raw_writel(0, base + TIM34);
205 } 211 }
206 212
207 /* Init of each timer as a 32-bit timer */ 213 /* Init of each timer as a 32-bit timer */
208 for (i=0; i< ARRAY_SIZE(timers); i++) { 214 for (i=0; i< ARRAY_SIZE(timers); i++) {
209 struct timer_s *t = &timers[i]; 215 struct timer_s *t = &timers[i];
216 u32 phys_base;
210 217
211 if (t->name) { 218 if (t->name) {
212 t->id = i; 219 t->id = i;
213 t->reg_base = (IS_TIMER1(t->id) ? 220 phys_base = (IS_TIMER1(t->id) ?
214 DAVINCI_TIMER1_BASE : DAVINCI_TIMER0_BASE); 221 DAVINCI_TIMER1_BASE : DAVINCI_TIMER0_BASE);
222 t->base = IO_ADDRESS(phys_base);
215 223
216 if (IS_TIMER_BOT(t->id)) { 224 if (IS_TIMER_BOT(t->id)) {
217 t->enamode_shift = 6; 225 t->enamode_shift = 6;
218 t->tim_reg = t->reg_base + TIM12; 226 t->tim_off = TIM12;
219 t->prd_reg = t->reg_base + PRD12; 227 t->prd_off = PRD12;
220 } else { 228 } else {
221 t->enamode_shift = 22; 229 t->enamode_shift = 22;
222 t->tim_reg = t->reg_base + TIM34; 230 t->tim_off = TIM34;
223 t->prd_reg = t->reg_base + PRD34; 231 t->prd_off = PRD34;
224 } 232 }
225 233
226 /* Register interrupt */ 234 /* Register interrupt */
@@ -333,42 +341,43 @@ struct sys_timer davinci_timer = {
333 341
334/* reset board using watchdog timer */ 342/* reset board using watchdog timer */
335void davinci_watchdog_reset(void) { 343void davinci_watchdog_reset(void) {
336 u32 tgcr, wdtcr, base = DAVINCI_WDOG_BASE; 344 u32 tgcr, wdtcr;
345 void __iomem *base = IO_ADDRESS(DAVINCI_WDOG_BASE);
337 346
338 /* disable, internal clock source */ 347 /* disable, internal clock source */
339 davinci_writel(0, base + TCR); 348 __raw_writel(0, base + TCR);
340 349
341 /* reset timer, set mode to 64-bit watchdog, and unreset */ 350 /* reset timer, set mode to 64-bit watchdog, and unreset */
342 tgcr = 0; 351 tgcr = 0;
343 davinci_writel(tgcr, base + TCR); 352 __raw_writel(tgcr, base + TCR);
344 tgcr = TGCR_TIMMODE_64BIT_WDOG << TGCR_TIMMODE_SHIFT; 353 tgcr = TGCR_TIMMODE_64BIT_WDOG << TGCR_TIMMODE_SHIFT;
345 tgcr |= (TGCR_UNRESET << TGCR_TIM12RS_SHIFT) | 354 tgcr |= (TGCR_UNRESET << TGCR_TIM12RS_SHIFT) |
346 (TGCR_UNRESET << TGCR_TIM34RS_SHIFT); 355 (TGCR_UNRESET << TGCR_TIM34RS_SHIFT);
347 davinci_writel(tgcr, base + TCR); 356 __raw_writel(tgcr, base + TCR);
348 357
349 /* clear counter and period regs */ 358 /* clear counter and period regs */
350 davinci_writel(0, base + TIM12); 359 __raw_writel(0, base + TIM12);
351 davinci_writel(0, base + TIM34); 360 __raw_writel(0, base + TIM34);
352 davinci_writel(0, base + PRD12); 361 __raw_writel(0, base + PRD12);
353 davinci_writel(0, base + PRD34); 362 __raw_writel(0, base + PRD34);
354 363
355 /* enable */ 364 /* enable */
356 wdtcr = davinci_readl(base + WDTCR); 365 wdtcr = __raw_readl(base + WDTCR);
357 wdtcr |= WDTCR_WDEN_ENABLE << WDTCR_WDEN_SHIFT; 366 wdtcr |= WDTCR_WDEN_ENABLE << WDTCR_WDEN_SHIFT;
358 davinci_writel(wdtcr, base + WDTCR); 367 __raw_writel(wdtcr, base + WDTCR);
359 368
360 /* put watchdog in pre-active state */ 369 /* put watchdog in pre-active state */
361 wdtcr = (WDTCR_WDKEY_SEQ0 << WDTCR_WDKEY_SHIFT) | 370 wdtcr = (WDTCR_WDKEY_SEQ0 << WDTCR_WDKEY_SHIFT) |
362 (WDTCR_WDEN_ENABLE << WDTCR_WDEN_SHIFT); 371 (WDTCR_WDEN_ENABLE << WDTCR_WDEN_SHIFT);
363 davinci_writel(wdtcr, base + WDTCR); 372 __raw_writel(wdtcr, base + WDTCR);
364 373
365 /* put watchdog in active state */ 374 /* put watchdog in active state */
366 wdtcr = (WDTCR_WDKEY_SEQ1 << WDTCR_WDKEY_SHIFT) | 375 wdtcr = (WDTCR_WDKEY_SEQ1 << WDTCR_WDKEY_SHIFT) |
367 (WDTCR_WDEN_ENABLE << WDTCR_WDEN_SHIFT); 376 (WDTCR_WDEN_ENABLE << WDTCR_WDEN_SHIFT);
368 davinci_writel(wdtcr, base + WDTCR); 377 __raw_writel(wdtcr, base + WDTCR);
369 378
370 /* write an invalid value to the WDKEY field to trigger 379 /* write an invalid value to the WDKEY field to trigger
371 * a watchdog reset */ 380 * a watchdog reset */
372 wdtcr = 0x00004000; 381 wdtcr = 0x00004000;
373 davinci_writel(wdtcr, base + WDTCR); 382 __raw_writel(wdtcr, base + WDTCR);
374} 383}