From bc28248ee25e5c239cbe6afca35a100b08401de5 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 17 May 2009 18:58:34 +0100 Subject: [ARM] smp: move core localtimer support out of platform specific files Signed-off-by: Russell King --- arch/arm/mach-realview/localtimer.c | 70 ++++++++----------------------------- arch/arm/mach-realview/platsmp.c | 14 ++++---- 2 files changed, 21 insertions(+), 63 deletions(-) (limited to 'arch/arm/mach-realview') diff --git a/arch/arm/mach-realview/localtimer.c b/arch/arm/mach-realview/localtimer.c index 1c01d13460f0..cd98e7acd94d 100644 --- a/arch/arm/mach-realview/localtimer.c +++ b/arch/arm/mach-realview/localtimer.c @@ -11,10 +11,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -24,18 +22,6 @@ #include #include -static DEFINE_PER_CPU(struct clock_event_device, local_clockevent); - -/* - * Used on SMP for either the local timer or IPI_TIMER - */ -void local_timer_interrupt(void) -{ - struct clock_event_device *clk = &__get_cpu_var(local_clockevent); - - clk->event_handler(clk); -} - #ifdef CONFIG_LOCAL_TIMERS /* set up by the platform code */ @@ -44,7 +30,7 @@ void __iomem *twd_base; static unsigned long mpcore_timer_rate; static void local_timer_set_mode(enum clock_event_mode mode, - struct clock_event_device *clk) + struct clock_event_device *evt) { unsigned long ctrl; @@ -140,32 +126,29 @@ static void __cpuinit twd_calibrate_rate(void) /* * Setup the local clock events for a CPU. */ -void __cpuinit local_timer_setup(void) +void __cpuinit local_timer_setup(struct clock_event_device *evt) { - unsigned int cpu = smp_processor_id(); - struct clock_event_device *clk = &per_cpu(local_clockevent, cpu); unsigned long flags; twd_calibrate_rate(); - clk->name = "local_timer"; - clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; - clk->rating = 350; - clk->set_mode = local_timer_set_mode; - clk->set_next_event = local_timer_set_next_event; - clk->irq = IRQ_LOCALTIMER; - clk->cpumask = cpumask_of(cpu); - clk->shift = 20; - clk->mult = div_sc(mpcore_timer_rate, NSEC_PER_SEC, clk->shift); - clk->max_delta_ns = clockevent_delta2ns(0xffffffff, clk); - clk->min_delta_ns = clockevent_delta2ns(0xf, clk); + evt->name = "local_timer"; + evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; + evt->rating = 350; + evt->set_mode = local_timer_set_mode; + evt->set_next_event = local_timer_set_next_event; + evt->irq = IRQ_LOCALTIMER; + evt->shift = 20; + evt->mult = div_sc(mpcore_timer_rate, NSEC_PER_SEC, evt->shift); + evt->max_delta_ns = clockevent_delta2ns(0xffffffff, evt); + evt->min_delta_ns = clockevent_delta2ns(0xf, evt); /* Make sure our local interrupt controller has this enabled */ local_irq_save(flags); get_irq_chip(IRQ_LOCALTIMER)->unmask(IRQ_LOCALTIMER); local_irq_restore(flags); - clockevents_register_device(clk); + clockevents_register_device(evt); } /* @@ -176,29 +159,4 @@ void __cpuexit local_timer_stop(void) __raw_writel(0, twd_base + TWD_TIMER_CONTROL); } -#else /* CONFIG_LOCAL_TIMERS */ - -static void dummy_timer_set_mode(enum clock_event_mode mode, - struct clock_event_device *clk) -{ -} - -void __cpuinit local_timer_setup(void) -{ - unsigned int cpu = smp_processor_id(); - struct clock_event_device *clk = &per_cpu(local_clockevent, cpu); - - clk->name = "dummy_timer"; - clk->features = CLOCK_EVT_FEAT_ONESHOT | - CLOCK_EVT_FEAT_PERIODIC | - CLOCK_EVT_FEAT_DUMMY; - clk->rating = 400; - clk->mult = 1; - clk->set_mode = dummy_timer_set_mode; - clk->broadcast = smp_timer_broadcast; - clk->cpumask = cpumask_of(cpu); - - clockevents_register_device(clk); -} - -#endif /* !CONFIG_LOCAL_TIMERS */ +#endif /* CONFIG_LOCAL_TIMERS */ diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c index 30a9c68591f6..b34d3a57ce93 100644 --- a/arch/arm/mach-realview/platsmp.c +++ b/arch/arm/mach-realview/platsmp.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -217,13 +218,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus) if (max_cpus > ncores) max_cpus = ncores; -#if defined(CONFIG_LOCAL_TIMERS) || defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) - /* - * Enable the local timer or broadcast device for the boot CPU. - */ - local_timer_setup(); -#endif - /* * Initialise the present map, which describes the set of CPUs * actually populated at the present time. @@ -239,6 +233,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus) * WFI */ if (max_cpus > 1) { + /* + * Enable the local timer or broadcast device for the + * boot CPU, but only if we have more than one CPU. + */ + percpu_timer_setup(); + scu_enable(); poke_milo(); } -- cgit v1.2.3