diff options
Diffstat (limited to 'arch/arm/mach-omap2/timer.c')
-rw-r--r-- | arch/arm/mach-omap2/timer.c | 52 |
1 files changed, 14 insertions, 38 deletions
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c index 06e141543623..2bdd4cf17a8f 100644 --- a/arch/arm/mach-omap2/timer.c +++ b/arch/arm/mach-omap2/timer.c | |||
@@ -131,7 +131,6 @@ static void omap2_gp_timer_set_mode(enum clock_event_mode mode, | |||
131 | static struct clock_event_device clockevent_gpt = { | 131 | static struct clock_event_device clockevent_gpt = { |
132 | .name = "gp_timer", | 132 | .name = "gp_timer", |
133 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, | 133 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, |
134 | .shift = 32, | ||
135 | .rating = 300, | 134 | .rating = 300, |
136 | .set_next_event = omap2_gp_timer_set_next_event, | 135 | .set_next_event = omap2_gp_timer_set_next_event, |
137 | .set_mode = omap2_gp_timer_set_mode, | 136 | .set_mode = omap2_gp_timer_set_mode, |
@@ -165,17 +164,13 @@ static struct device_node * __init omap_get_timer_dt(struct of_device_id *match, | |||
165 | struct device_node *np; | 164 | struct device_node *np; |
166 | 165 | ||
167 | for_each_matching_node(np, match) { | 166 | for_each_matching_node(np, match) { |
168 | if (!of_device_is_available(np)) { | 167 | if (!of_device_is_available(np)) |
169 | of_node_put(np); | ||
170 | continue; | 168 | continue; |
171 | } | ||
172 | 169 | ||
173 | if (property && !of_get_property(np, property, NULL)) { | 170 | if (property && !of_get_property(np, property, NULL)) |
174 | of_node_put(np); | ||
175 | continue; | 171 | continue; |
176 | } | ||
177 | 172 | ||
178 | prom_add_property(np, &device_disabled); | 173 | of_add_property(np, &device_disabled); |
179 | return np; | 174 | return np; |
180 | } | 175 | } |
181 | 176 | ||
@@ -232,7 +227,7 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer, | |||
232 | int r = 0; | 227 | int r = 0; |
233 | 228 | ||
234 | if (of_have_populated_dt()) { | 229 | if (of_have_populated_dt()) { |
235 | np = omap_get_timer_dt(omap_timer_match, NULL); | 230 | np = omap_get_timer_dt(omap_timer_match, property); |
236 | if (!np) | 231 | if (!np) |
237 | return -ENODEV; | 232 | return -ENODEV; |
238 | 233 | ||
@@ -340,17 +335,11 @@ static void __init omap2_gp_clockevent_init(int gptimer_id, | |||
340 | 335 | ||
341 | __omap_dm_timer_int_enable(&clkev, OMAP_TIMER_INT_OVERFLOW); | 336 | __omap_dm_timer_int_enable(&clkev, OMAP_TIMER_INT_OVERFLOW); |
342 | 337 | ||
343 | clockevent_gpt.mult = div_sc(clkev.rate, NSEC_PER_SEC, | ||
344 | clockevent_gpt.shift); | ||
345 | clockevent_gpt.max_delta_ns = | ||
346 | clockevent_delta2ns(0xffffffff, &clockevent_gpt); | ||
347 | clockevent_gpt.min_delta_ns = | ||
348 | clockevent_delta2ns(3, &clockevent_gpt); | ||
349 | /* Timer internal resynch latency. */ | ||
350 | |||
351 | clockevent_gpt.cpumask = cpu_possible_mask; | 338 | clockevent_gpt.cpumask = cpu_possible_mask; |
352 | clockevent_gpt.irq = omap_dm_timer_get_irq(&clkev); | 339 | clockevent_gpt.irq = omap_dm_timer_get_irq(&clkev); |
353 | clockevents_register_device(&clockevent_gpt); | 340 | clockevents_config_and_register(&clockevent_gpt, clkev.rate, |
341 | 3, /* Timer internal resynch latency */ | ||
342 | 0xffffffff); | ||
354 | 343 | ||
355 | pr_info("OMAP clockevent source: GPTIMER%d at %lu Hz\n", | 344 | pr_info("OMAP clockevent source: GPTIMER%d at %lu Hz\n", |
356 | gptimer_id, clkev.rate); | 345 | gptimer_id, clkev.rate); |
@@ -556,7 +545,7 @@ static inline void __init realtime_counter_init(void) | |||
556 | 545 | ||
557 | #define OMAP_SYS_GP_TIMER_INIT(name, clkev_nr, clkev_src, clkev_prop, \ | 546 | #define OMAP_SYS_GP_TIMER_INIT(name, clkev_nr, clkev_src, clkev_prop, \ |
558 | clksrc_nr, clksrc_src) \ | 547 | clksrc_nr, clksrc_src) \ |
559 | static void __init omap##name##_gptimer_timer_init(void) \ | 548 | void __init omap##name##_gptimer_timer_init(void) \ |
560 | { \ | 549 | { \ |
561 | omap_dmtimer_init(); \ | 550 | omap_dmtimer_init(); \ |
562 | omap2_gp_clockevent_init((clkev_nr), clkev_src, clkev_prop); \ | 551 | omap2_gp_clockevent_init((clkev_nr), clkev_src, clkev_prop); \ |
@@ -565,7 +554,7 @@ static void __init omap##name##_gptimer_timer_init(void) \ | |||
565 | 554 | ||
566 | #define OMAP_SYS_32K_TIMER_INIT(name, clkev_nr, clkev_src, clkev_prop, \ | 555 | #define OMAP_SYS_32K_TIMER_INIT(name, clkev_nr, clkev_src, clkev_prop, \ |
567 | clksrc_nr, clksrc_src) \ | 556 | clksrc_nr, clksrc_src) \ |
568 | static void __init omap##name##_sync32k_timer_init(void) \ | 557 | void __init omap##name##_sync32k_timer_init(void) \ |
569 | { \ | 558 | { \ |
570 | omap_dmtimer_init(); \ | 559 | omap_dmtimer_init(); \ |
571 | omap2_gp_clockevent_init((clkev_nr), clkev_src, clkev_prop); \ | 560 | omap2_gp_clockevent_init((clkev_nr), clkev_src, clkev_prop); \ |
@@ -576,33 +565,23 @@ static void __init omap##name##_sync32k_timer_init(void) \ | |||
576 | omap2_sync32k_clocksource_init(); \ | 565 | omap2_sync32k_clocksource_init(); \ |
577 | } | 566 | } |
578 | 567 | ||
579 | #define OMAP_SYS_TIMER(name, clksrc) \ | ||
580 | struct sys_timer omap##name##_timer = { \ | ||
581 | .init = omap##name##_##clksrc##_timer_init, \ | ||
582 | }; | ||
583 | |||
584 | #ifdef CONFIG_ARCH_OMAP2 | 568 | #ifdef CONFIG_ARCH_OMAP2 |
585 | OMAP_SYS_32K_TIMER_INIT(2, 1, OMAP2_32K_SOURCE, "ti,timer-alwon", | 569 | OMAP_SYS_32K_TIMER_INIT(2, 1, OMAP2_32K_SOURCE, "ti,timer-alwon", |
586 | 2, OMAP2_MPU_SOURCE); | 570 | 2, OMAP2_MPU_SOURCE); |
587 | OMAP_SYS_TIMER(2, sync32k); | ||
588 | #endif /* CONFIG_ARCH_OMAP2 */ | 571 | #endif /* CONFIG_ARCH_OMAP2 */ |
589 | 572 | ||
590 | #ifdef CONFIG_ARCH_OMAP3 | 573 | #ifdef CONFIG_ARCH_OMAP3 |
591 | OMAP_SYS_32K_TIMER_INIT(3, 1, OMAP3_32K_SOURCE, "ti,timer-alwon", | 574 | OMAP_SYS_32K_TIMER_INIT(3, 1, OMAP3_32K_SOURCE, "ti,timer-alwon", |
592 | 2, OMAP3_MPU_SOURCE); | 575 | 2, OMAP3_MPU_SOURCE); |
593 | OMAP_SYS_TIMER(3, sync32k); | ||
594 | OMAP_SYS_32K_TIMER_INIT(3_secure, 12, OMAP3_32K_SOURCE, "ti,timer-secure", | 576 | OMAP_SYS_32K_TIMER_INIT(3_secure, 12, OMAP3_32K_SOURCE, "ti,timer-secure", |
595 | 2, OMAP3_MPU_SOURCE); | 577 | 2, OMAP3_MPU_SOURCE); |
596 | OMAP_SYS_TIMER(3_secure, sync32k); | ||
597 | OMAP_SYS_GP_TIMER_INIT(3_gp, 1, OMAP3_MPU_SOURCE, "ti,timer-alwon", | 578 | OMAP_SYS_GP_TIMER_INIT(3_gp, 1, OMAP3_MPU_SOURCE, "ti,timer-alwon", |
598 | 2, OMAP3_MPU_SOURCE); | 579 | 2, OMAP3_MPU_SOURCE); |
599 | OMAP_SYS_TIMER(3_gp, gptimer); | ||
600 | #endif /* CONFIG_ARCH_OMAP3 */ | 580 | #endif /* CONFIG_ARCH_OMAP3 */ |
601 | 581 | ||
602 | #ifdef CONFIG_SOC_AM33XX | 582 | #ifdef CONFIG_SOC_AM33XX |
603 | OMAP_SYS_GP_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, "ti,timer-alwon", | 583 | OMAP_SYS_GP_TIMER_INIT(3_am33xx, 1, OMAP4_MPU_SOURCE, "ti,timer-alwon", |
604 | 2, OMAP4_MPU_SOURCE); | 584 | 2, OMAP4_MPU_SOURCE); |
605 | OMAP_SYS_TIMER(3_am33xx, gptimer); | ||
606 | #endif /* CONFIG_SOC_AM33XX */ | 585 | #endif /* CONFIG_SOC_AM33XX */ |
607 | 586 | ||
608 | #ifdef CONFIG_ARCH_OMAP4 | 587 | #ifdef CONFIG_ARCH_OMAP4 |
@@ -610,7 +589,7 @@ OMAP_SYS_32K_TIMER_INIT(4, 1, OMAP4_32K_SOURCE, "ti,timer-alwon", | |||
610 | 2, OMAP4_MPU_SOURCE); | 589 | 2, OMAP4_MPU_SOURCE); |
611 | #ifdef CONFIG_LOCAL_TIMERS | 590 | #ifdef CONFIG_LOCAL_TIMERS |
612 | static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, OMAP44XX_LOCAL_TWD_BASE, 29); | 591 | static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, OMAP44XX_LOCAL_TWD_BASE, 29); |
613 | static void __init omap4_local_timer_init(void) | 592 | void __init omap4_local_timer_init(void) |
614 | { | 593 | { |
615 | omap4_sync32k_timer_init(); | 594 | omap4_sync32k_timer_init(); |
616 | /* Local timers are not supprted on OMAP4430 ES1.0 */ | 595 | /* Local timers are not supprted on OMAP4430 ES1.0 */ |
@@ -628,18 +607,17 @@ static void __init omap4_local_timer_init(void) | |||
628 | } | 607 | } |
629 | } | 608 | } |
630 | #else /* CONFIG_LOCAL_TIMERS */ | 609 | #else /* CONFIG_LOCAL_TIMERS */ |
631 | static void __init omap4_local_timer_init(void) | 610 | void __init omap4_local_timer_init(void) |
632 | { | 611 | { |
633 | omap4_sync32k_timer_init(); | 612 | omap4_sync32k_timer_init(); |
634 | } | 613 | } |
635 | #endif /* CONFIG_LOCAL_TIMERS */ | 614 | #endif /* CONFIG_LOCAL_TIMERS */ |
636 | OMAP_SYS_TIMER(4, local); | ||
637 | #endif /* CONFIG_ARCH_OMAP4 */ | 615 | #endif /* CONFIG_ARCH_OMAP4 */ |
638 | 616 | ||
639 | #ifdef CONFIG_SOC_OMAP5 | 617 | #ifdef CONFIG_SOC_OMAP5 |
640 | OMAP_SYS_32K_TIMER_INIT(5, 1, OMAP4_32K_SOURCE, "ti,timer-alwon", | 618 | OMAP_SYS_32K_TIMER_INIT(5, 1, OMAP4_32K_SOURCE, "ti,timer-alwon", |
641 | 2, OMAP4_MPU_SOURCE); | 619 | 2, OMAP4_MPU_SOURCE); |
642 | static void __init omap5_realtime_timer_init(void) | 620 | void __init omap5_realtime_timer_init(void) |
643 | { | 621 | { |
644 | int err; | 622 | int err; |
645 | 623 | ||
@@ -650,7 +628,6 @@ static void __init omap5_realtime_timer_init(void) | |||
650 | if (err) | 628 | if (err) |
651 | pr_err("%s: arch_timer_register failed %d\n", __func__, err); | 629 | pr_err("%s: arch_timer_register failed %d\n", __func__, err); |
652 | } | 630 | } |
653 | OMAP_SYS_TIMER(5, realtime); | ||
654 | #endif /* CONFIG_SOC_OMAP5 */ | 631 | #endif /* CONFIG_SOC_OMAP5 */ |
655 | 632 | ||
656 | /** | 633 | /** |
@@ -706,8 +683,7 @@ static int __init omap_timer_init(struct omap_hwmod *oh, void *unused) | |||
706 | pdata->timer_errata = omap_dm_timer_get_errata(); | 683 | pdata->timer_errata = omap_dm_timer_get_errata(); |
707 | pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count; | 684 | pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count; |
708 | 685 | ||
709 | pdev = omap_device_build(name, id, oh, pdata, sizeof(*pdata), | 686 | pdev = omap_device_build(name, id, oh, pdata, sizeof(*pdata)); |
710 | NULL, 0, 0); | ||
711 | 687 | ||
712 | if (IS_ERR(pdev)) { | 688 | if (IS_ERR(pdev)) { |
713 | pr_err("%s: Can't build omap_device for %s: %s.\n", | 689 | pr_err("%s: Can't build omap_device for %s: %s.\n", |
@@ -742,7 +718,7 @@ static int __init omap2_dm_timer_init(void) | |||
742 | 718 | ||
743 | return 0; | 719 | return 0; |
744 | } | 720 | } |
745 | arch_initcall(omap2_dm_timer_init); | 721 | omap_arch_initcall(omap2_dm_timer_init); |
746 | 722 | ||
747 | /** | 723 | /** |
748 | * omap2_override_clocksource - clocksource override with user configuration | 724 | * omap2_override_clocksource - clocksource override with user configuration |