diff options
Diffstat (limited to 'arch/arm/mach-davinci/time.c')
-rw-r--r-- | arch/arm/mach-davinci/time.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c index 9e0b106b4f5f..0f21c36e65dd 100644 --- a/arch/arm/mach-davinci/time.c +++ b/arch/arm/mach-davinci/time.c | |||
@@ -197,32 +197,36 @@ static void __init timer_init(void) | |||
197 | { | 197 | { |
198 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 198 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
199 | struct davinci_timer_instance *dtip = soc_info->timer_info->timers; | 199 | struct davinci_timer_instance *dtip = soc_info->timer_info->timers; |
200 | void __iomem *base[2]; | ||
200 | int i; | 201 | int i; |
201 | 202 | ||
202 | /* Global init of each 64-bit timer as a whole */ | 203 | /* Global init of each 64-bit timer as a whole */ |
203 | for(i=0; i<2; i++) { | 204 | for(i=0; i<2; i++) { |
204 | u32 tgcr; | 205 | u32 tgcr; |
205 | void __iomem *base = dtip[i].base; | 206 | |
207 | base[i] = ioremap(dtip[i].base, SZ_4K); | ||
208 | if (WARN_ON(!base[i])) | ||
209 | continue; | ||
206 | 210 | ||
207 | /* Disabled, Internal clock source */ | 211 | /* Disabled, Internal clock source */ |
208 | __raw_writel(0, base + TCR); | 212 | __raw_writel(0, base[i] + TCR); |
209 | 213 | ||
210 | /* reset both timers, no pre-scaler for timer34 */ | 214 | /* reset both timers, no pre-scaler for timer34 */ |
211 | tgcr = 0; | 215 | tgcr = 0; |
212 | __raw_writel(tgcr, base + TGCR); | 216 | __raw_writel(tgcr, base[i] + TGCR); |
213 | 217 | ||
214 | /* Set both timers to unchained 32-bit */ | 218 | /* Set both timers to unchained 32-bit */ |
215 | tgcr = TGCR_TIMMODE_32BIT_UNCHAINED << TGCR_TIMMODE_SHIFT; | 219 | tgcr = TGCR_TIMMODE_32BIT_UNCHAINED << TGCR_TIMMODE_SHIFT; |
216 | __raw_writel(tgcr, base + TGCR); | 220 | __raw_writel(tgcr, base[i] + TGCR); |
217 | 221 | ||
218 | /* Unreset timers */ | 222 | /* Unreset timers */ |
219 | tgcr |= (TGCR_UNRESET << TGCR_TIM12RS_SHIFT) | | 223 | tgcr |= (TGCR_UNRESET << TGCR_TIM12RS_SHIFT) | |
220 | (TGCR_UNRESET << TGCR_TIM34RS_SHIFT); | 224 | (TGCR_UNRESET << TGCR_TIM34RS_SHIFT); |
221 | __raw_writel(tgcr, base + TGCR); | 225 | __raw_writel(tgcr, base[i] + TGCR); |
222 | 226 | ||
223 | /* Init both counters to zero */ | 227 | /* Init both counters to zero */ |
224 | __raw_writel(0, base + TIM12); | 228 | __raw_writel(0, base[i] + TIM12); |
225 | __raw_writel(0, base + TIM34); | 229 | __raw_writel(0, base[i] + TIM34); |
226 | } | 230 | } |
227 | 231 | ||
228 | /* Init of each timer as a 32-bit timer */ | 232 | /* Init of each timer as a 32-bit timer */ |
@@ -231,7 +235,9 @@ static void __init timer_init(void) | |||
231 | int timer = ID_TO_TIMER(t->id); | 235 | int timer = ID_TO_TIMER(t->id); |
232 | u32 irq; | 236 | u32 irq; |
233 | 237 | ||
234 | t->base = dtip[timer].base; | 238 | t->base = base[timer]; |
239 | if (!t->base) | ||
240 | continue; | ||
235 | 241 | ||
236 | if (IS_TIMER_BOT(t->id)) { | 242 | if (IS_TIMER_BOT(t->id)) { |
237 | t->enamode_shift = 6; | 243 | t->enamode_shift = 6; |
@@ -361,13 +367,13 @@ static void __init davinci_timer_init(void) | |||
361 | } | 367 | } |
362 | } | 368 | } |
363 | 369 | ||
364 | /* init timer hw */ | ||
365 | timer_init(); | ||
366 | |||
367 | timer_clk = clk_get(NULL, "timer0"); | 370 | timer_clk = clk_get(NULL, "timer0"); |
368 | BUG_ON(IS_ERR(timer_clk)); | 371 | BUG_ON(IS_ERR(timer_clk)); |
369 | clk_enable(timer_clk); | 372 | clk_enable(timer_clk); |
370 | 373 | ||
374 | /* init timer hw */ | ||
375 | timer_init(); | ||
376 | |||
371 | davinci_clock_tick_rate = clk_get_rate(timer_clk); | 377 | davinci_clock_tick_rate = clk_get_rate(timer_clk); |
372 | 378 | ||
373 | /* setup clocksource */ | 379 | /* setup clocksource */ |
@@ -399,13 +405,16 @@ struct sys_timer davinci_timer = { | |||
399 | 405 | ||
400 | 406 | ||
401 | /* reset board using watchdog timer */ | 407 | /* reset board using watchdog timer */ |
402 | void davinci_watchdog_reset(void) | 408 | void davinci_watchdog_reset(struct platform_device *pdev) |
403 | { | 409 | { |
404 | u32 tgcr, wdtcr; | 410 | u32 tgcr, wdtcr; |
405 | struct platform_device *pdev = &davinci_wdt_device; | 411 | void __iomem *base; |
406 | void __iomem *base = IO_ADDRESS(pdev->resource[0].start); | ||
407 | struct clk *wd_clk; | 412 | struct clk *wd_clk; |
408 | 413 | ||
414 | base = ioremap(pdev->resource[0].start, SZ_4K); | ||
415 | if (WARN_ON(!base)) | ||
416 | return; | ||
417 | |||
409 | wd_clk = clk_get(&pdev->dev, NULL); | 418 | wd_clk = clk_get(&pdev->dev, NULL); |
410 | if (WARN_ON(IS_ERR(wd_clk))) | 419 | if (WARN_ON(IS_ERR(wd_clk))) |
411 | return; | 420 | return; |