diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2009-06-01 19:35:26 +0200 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-06-01 19:35:26 +0200 |
commit | c7f7ff179cb9f2f1e0244ef2c80afbb93c74ce2a (patch) | |
tree | 717656ebdba1fea6c763b2c57076c4c6996dfba3 /arch/arm/mach-realview | |
parent | [ARM] Kconfig: remove 'default n' (diff) | |
parent | [ARM] smp: use new cpumask functions (diff) | |
download | linux-c7f7ff179cb9f2f1e0244ef2c80afbb93c74ce2a.tar.xz linux-c7f7ff179cb9f2f1e0244ef2c80afbb93c74ce2a.zip |
Merge branch 'smp' into devel
Diffstat (limited to 'arch/arm/mach-realview')
-rw-r--r-- | arch/arm/mach-realview/Makefile | 3 | ||||
-rw-r--r-- | arch/arm/mach-realview/core.h | 3 | ||||
-rw-r--r-- | arch/arm/mach-realview/include/mach/scu.h | 13 | ||||
-rw-r--r-- | arch/arm/mach-realview/localtimer.c | 188 | ||||
-rw-r--r-- | arch/arm/mach-realview/platsmp.c | 49 | ||||
-rw-r--r-- | arch/arm/mach-realview/realview_eb.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-realview/realview_pb11mp.c | 1 |
7 files changed, 24 insertions, 234 deletions
diff --git a/arch/arm/mach-realview/Makefile b/arch/arm/mach-realview/Makefile index 7bea8ffc4b59..e13d0947ad0b 100644 --- a/arch/arm/mach-realview/Makefile +++ b/arch/arm/mach-realview/Makefile @@ -7,5 +7,6 @@ obj-$(CONFIG_MACH_REALVIEW_EB) += realview_eb.o obj-$(CONFIG_MACH_REALVIEW_PB11MP) += realview_pb11mp.o obj-$(CONFIG_MACH_REALVIEW_PB1176) += realview_pb1176.o obj-$(CONFIG_MACH_REALVIEW_PBA8) += realview_pba8.o -obj-$(CONFIG_SMP) += platsmp.o headsmp.o localtimer.o +obj-$(CONFIG_SMP) += platsmp.o headsmp.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o +obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h index 21c08637683b..59a337ba4be7 100644 --- a/arch/arm/mach-realview/core.h +++ b/arch/arm/mach-realview/core.h @@ -51,9 +51,6 @@ extern struct mmc_platform_data realview_mmc0_plat_data; extern struct mmc_platform_data realview_mmc1_plat_data; extern struct clcd_board clcd_plat_data; extern void __iomem *gic_cpu_base_addr; -#ifdef CONFIG_LOCAL_TIMERS -extern void __iomem *twd_base; -#endif extern void __iomem *timer0_va_base; extern void __iomem *timer1_va_base; extern void __iomem *timer2_va_base; diff --git a/arch/arm/mach-realview/include/mach/scu.h b/arch/arm/mach-realview/include/mach/scu.h deleted file mode 100644 index d55802d645af..000000000000 --- a/arch/arm/mach-realview/include/mach/scu.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __ASMARM_ARCH_SCU_H -#define __ASMARM_ARCH_SCU_H - -/* - * SCU registers - */ -#define SCU_CTRL 0x00 -#define SCU_CONFIG 0x04 -#define SCU_CPU_STATUS 0x08 -#define SCU_INVALIDATE 0x0c -#define SCU_FPGA_REVISION 0x10 - -#endif diff --git a/arch/arm/mach-realview/localtimer.c b/arch/arm/mach-realview/localtimer.c index 1c01d13460f0..60b4e111f459 100644 --- a/arch/arm/mach-realview/localtimer.c +++ b/arch/arm/mach-realview/localtimer.c @@ -9,196 +9,18 @@ * published by the Free Software Foundation. */ #include <linux/init.h> -#include <linux/kernel.h> -#include <linux/delay.h> -#include <linux/device.h> #include <linux/smp.h> -#include <linux/jiffies.h> -#include <linux/percpu.h> #include <linux/clockchips.h> -#include <linux/irq.h> -#include <linux/io.h> -#include <asm/hardware/arm_twd.h> -#include <asm/hardware/gic.h> -#include <mach/hardware.h> #include <asm/irq.h> - -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 */ -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) -{ - unsigned long ctrl; - - switch(mode) { - case CLOCK_EVT_MODE_PERIODIC: - /* timer load already set up */ - ctrl = TWD_TIMER_CONTROL_ENABLE | TWD_TIMER_CONTROL_IT_ENABLE - | TWD_TIMER_CONTROL_PERIODIC; - break; - case CLOCK_EVT_MODE_ONESHOT: - /* period set, and timer enabled in 'next_event' hook */ - ctrl = TWD_TIMER_CONTROL_IT_ENABLE | TWD_TIMER_CONTROL_ONESHOT; - break; - case CLOCK_EVT_MODE_UNUSED: - case CLOCK_EVT_MODE_SHUTDOWN: - default: - ctrl = 0; - } - - __raw_writel(ctrl, twd_base + TWD_TIMER_CONTROL); -} - -static int local_timer_set_next_event(unsigned long evt, - struct clock_event_device *unused) -{ - unsigned long ctrl = __raw_readl(twd_base + TWD_TIMER_CONTROL); - - __raw_writel(evt, twd_base + TWD_TIMER_COUNTER); - __raw_writel(ctrl | TWD_TIMER_CONTROL_ENABLE, twd_base + TWD_TIMER_CONTROL); - - return 0; -} - -/* - * local_timer_ack: checks for a local timer interrupt. - * - * If a local timer interrupt has occurred, acknowledge and return 1. - * Otherwise, return 0. - */ -int local_timer_ack(void) -{ - if (__raw_readl(twd_base + TWD_TIMER_INTSTAT)) { - __raw_writel(1, twd_base + TWD_TIMER_INTSTAT); - return 1; - } - - return 0; -} - -static void __cpuinit twd_calibrate_rate(void) -{ - unsigned long load, count; - u64 waitjiffies; - - /* - * If this is the first time round, we need to work out how fast - * the timer ticks - */ - if (mpcore_timer_rate == 0) { - printk("Calibrating local timer... "); - - /* Wait for a tick to start */ - waitjiffies = get_jiffies_64() + 1; - - while (get_jiffies_64() < waitjiffies) - udelay(10); - - /* OK, now the tick has started, let's get the timer going */ - waitjiffies += 5; - - /* enable, no interrupt or reload */ - __raw_writel(0x1, twd_base + TWD_TIMER_CONTROL); - - /* maximum value */ - __raw_writel(0xFFFFFFFFU, twd_base + TWD_TIMER_COUNTER); - - while (get_jiffies_64() < waitjiffies) - udelay(10); - - count = __raw_readl(twd_base + TWD_TIMER_COUNTER); - - mpcore_timer_rate = (0xFFFFFFFFU - count) * (HZ / 5); - - printk("%lu.%02luMHz.\n", mpcore_timer_rate / 1000000, - (mpcore_timer_rate / 100000) % 100); - } - - load = mpcore_timer_rate / HZ; - - __raw_writel(load, twd_base + TWD_TIMER_LOAD); -} +#include <asm/smp_twd.h> +#include <asm/localtimer.h> /* * Setup the local clock events for a CPU. */ -void __cpuinit local_timer_setup(void) -{ - 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); - - /* 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); -} - -/* - * take a local timer down - */ -void __cpuexit local_timer_stop(void) +void __cpuinit local_timer_setup(struct clock_event_device *evt) { - __raw_writel(0, twd_base + TWD_TIMER_CONTROL); + evt->irq = IRQ_LOCALTIMER; + twd_timer_setup(evt); } - -#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 */ diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c index 30a9c68591f6..ca742172ea78 100644 --- a/arch/arm/mach-realview/platsmp.c +++ b/arch/arm/mach-realview/platsmp.c @@ -19,10 +19,11 @@ #include <asm/cacheflush.h> #include <mach/hardware.h> #include <asm/mach-types.h> +#include <asm/localtimer.h> #include <mach/board-eb.h> #include <mach/board-pb11mp.h> -#include <mach/scu.h> +#include <asm/smp_scu.h> #include "core.h" @@ -44,31 +45,12 @@ static void __iomem *scu_base_addr(void) return (void __iomem *)0; } -static unsigned int __init get_core_count(void) +static inline unsigned int get_core_count(void) { - unsigned int ncores; void __iomem *scu_base = scu_base_addr(); - - if (scu_base) { - ncores = __raw_readl(scu_base + SCU_CONFIG); - ncores = (ncores & 0x03) + 1; - } else - ncores = 1; - - return ncores; -} - -/* - * Setup the SCU - */ -static void scu_enable(void) -{ - u32 scu_ctrl; - void __iomem *scu_base = scu_base_addr(); - - scu_ctrl = __raw_readl(scu_base + SCU_CTRL); - scu_ctrl |= 1; - __raw_writel(scu_ctrl, scu_base + SCU_CTRL); + if (scu_base) + return scu_get_core_count(scu_base); + return 1; } static DEFINE_SPINLOCK(boot_lock); @@ -184,7 +166,7 @@ void __init smp_init_cpus(void) unsigned int i, ncores = get_core_count(); for (i = 0; i < ncores; i++) - cpu_set(i, cpu_possible_map); + set_cpu_possible(i, true); } void __init smp_prepare_cpus(unsigned int max_cpus) @@ -217,19 +199,12 @@ 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. */ for (i = 0; i < max_cpus; i++) - cpu_set(i, cpu_present_map); + set_cpu_present(i, true); /* * Initialise the SCU if there are more than one CPU and let @@ -239,7 +214,13 @@ void __init smp_prepare_cpus(unsigned int max_cpus) * WFI */ if (max_cpus > 1) { - scu_enable(); + /* + * 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(scu_base_addr()); poke_milo(); } } diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c index c20fbef122b3..8dfa44e08a94 100644 --- a/arch/arm/mach-realview/realview_eb.c +++ b/arch/arm/mach-realview/realview_eb.c @@ -32,6 +32,7 @@ #include <asm/hardware/gic.h> #include <asm/hardware/icst307.h> #include <asm/hardware/cache-l2x0.h> +#include <asm/localtimer.h> #include <asm/mach/arch.h> #include <asm/mach/map.h> diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c index ea1e60eca359..dc4b16943907 100644 --- a/arch/arm/mach-realview/realview_pb11mp.c +++ b/arch/arm/mach-realview/realview_pb11mp.c @@ -32,6 +32,7 @@ #include <asm/hardware/gic.h> #include <asm/hardware/icst307.h> #include <asm/hardware/cache-l2x0.h> +#include <asm/localtimer.h> #include <asm/mach/arch.h> #include <asm/mach/flash.h> |