1 --- a/arch/arm/mach-cns3xxx/Makefile
2 +++ b/arch/arm/mach-cns3xxx/Makefile
4 obj-$(CONFIG_ARCH_CNS3XXX) += core.o pm.o devices.o
5 obj-$(CONFIG_PCI) += pcie.o
6 obj-$(CONFIG_MACH_CNS3420VB) += cns3420vb.o
7 +obj-$(CONFIG_SMP) += platsmp.o headsmp.o
8 +obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
9 +obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
11 +++ b/arch/arm/mach-cns3xxx/headsmp.S
14 + * linux/arch/arm/mach-cns3xxx/headsmp.S
16 + * Cloned from linux/arch/arm/plat-versatile/headsmp.S
18 + * Copyright (c) 2003 ARM Limited
19 + * All Rights Reserved
21 + * This program is free software; you can redistribute it and/or modify
22 + * it under the terms of the GNU General Public License version 2 as
23 + * published by the Free Software Foundation.
25 +#include <linux/linkage.h>
26 +#include <linux/init.h>
31 + * CNS3XXX specific entry point for secondary CPUs. This provides
32 + * a "holding pen" into which all secondary cores are held until we're
33 + * ready for them to initialise.
35 +ENTRY(cns3xxx_secondary_startup)
36 + mrc p15, 0, r0, c0, c0, 5
47 + * we've been released from the holding pen: secondary_stack
48 + * should now contain the SVC stack for this core
56 +++ b/arch/arm/mach-cns3xxx/hotplug.c
58 +/* linux arch/arm/mach-cns3xxx/hotplug.c
60 + * Cloned from linux/arch/arm/mach-realview/hotplug.c
62 + * Copyright (C) 2002 ARM Ltd.
63 + * All Rights Reserved
65 + * This program is free software; you can redistribute it and/or modify
66 + * it under the terms of the GNU General Public License version 2 as
67 + * published by the Free Software Foundation.
70 +#include <linux/kernel.h>
71 +#include <linux/errno.h>
72 +#include <linux/smp.h>
74 +#include <asm/cacheflush.h>
76 +extern volatile int pen_release;
78 +static inline void cpu_enter_lowpower(void)
84 + " mcr p15, 0, %1, c7, c5, 0\n"
85 + " mcr p15, 0, %1, c7, c10, 4\n"
87 + * Turn off coherency
89 + " mrc p15, 0, %0, c1, c0, 1\n"
91 + " mcr p15, 0, %0, c1, c0, 1\n"
92 + " mrc p15, 0, %0, c1, c0, 0\n"
94 + " mcr p15, 0, %0, c1, c0, 0\n"
96 + : "r" (0), "Ir" (CR_C), "Ir" (0x40)
100 +static inline void cpu_leave_lowpower(void)
105 + "mrc p15, 0, %0, c1, c0, 0\n"
106 + " orr %0, %0, %1\n"
107 + " mcr p15, 0, %0, c1, c0, 0\n"
108 + " mrc p15, 0, %0, c1, c0, 1\n"
109 + " orr %0, %0, %2\n"
110 + " mcr p15, 0, %0, c1, c0, 1\n"
112 + : "Ir" (CR_C), "Ir" (0x40)
116 +static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
119 + * there is no power-control hardware on this platform, so all
120 + * we can do is put the core into WFI; this is safe as the calling
121 + * code will have already disabled interrupts
127 + asm(".word 0xe320f003\n"
132 + if (pen_release == cpu) {
134 + * OK, proper wakeup, we're done
140 + * Getting here, means that we have come out of WFI without
141 + * having been woken up - this shouldn't happen
143 + * Just note it happening - when we're woken, we can report
150 +int platform_cpu_kill(unsigned int cpu)
156 + * platform-specific code to shutdown a CPU
158 + * Called with IRQs disabled
160 +void platform_cpu_die(unsigned int cpu)
165 + * we're ready for shutdown now, so do it
167 + cpu_enter_lowpower();
168 + platform_do_lowpower(cpu, &spurious);
171 + * bring this CPU back into the world of cache
172 + * coherency, and then restore interrupts
174 + cpu_leave_lowpower();
177 + pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);
180 +int platform_cpu_disable(unsigned int cpu)
183 + * we don't allow CPU 0 to be shutdown (it is still too special
184 + * e.g. clock tick interrupts)
186 + return cpu == 0 ? -EPERM : 0;
188 --- a/arch/arm/mach-cns3xxx/Kconfig
189 +++ b/arch/arm/mach-cns3xxx/Kconfig
190 @@ -3,6 +3,7 @@ menu "CNS3XXX platform type"
192 config MACH_CNS3420VB
193 bool "Support for CNS3420 Validation Board"
194 + select HAVE_ARM_SCU if SMP
195 select MIGHT_HAVE_PCI
197 Include support for the Cavium Networks CNS3420 MPCore Platform
199 +++ b/arch/arm/mach-cns3xxx/localtimer.c
201 +/* linux/arch/arm/mach-cns3xxx/localtimer.c
203 + * Cloned from linux/arch/arm/mach-realview/localtimer.c
205 + * Copyright (C) 2002 ARM Ltd.
206 + * All Rights Reserved
208 + * This program is free software; you can redistribute it and/or modify
209 + * it under the terms of the GNU General Public License version 2 as
210 + * published by the Free Software Foundation.
213 +#include <linux/clockchips.h>
215 +#include <asm/irq.h>
216 +#include <asm/localtimer.h>
219 + * Setup the local clock events for a CPU.
221 +int __cpuinit local_timer_setup(struct clock_event_device *evt)
223 + evt->irq = IRQ_LOCALTIMER;
224 + twd_timer_setup(evt);
228 +++ b/arch/arm/mach-cns3xxx/platsmp.c
230 +/* linux/arch/arm/mach-cns3xxx/platsmp.c
232 + * Copyright 2011 Gateworks Corporation
233 + * Chris Lang <clang@gateworks.com>
234 + * Cloned from linux/arch/arm/mach-vexpress/platsmp.c
236 + * Copyright (C) 2002 ARM Ltd.
237 + * All Rights Reserved
239 + * This program is free software; you can redistribute it and/or modify
240 + * it under the terms of the GNU General Public License version 2 as
241 + * published by the Free Software Foundation.
244 +#include <linux/init.h>
245 +#include <linux/errno.h>
246 +#include <linux/delay.h>
247 +#include <linux/device.h>
248 +#include <linux/jiffies.h>
249 +#include <linux/smp.h>
250 +#include <linux/io.h>
252 +#include <asm/cacheflush.h>
253 +#include <asm/hardware/gic.h>
254 +#include <asm/smp_scu.h>
255 +#include <asm/unified.h>
257 +#include <mach/hardware.h>
258 +#include <mach/cns3xxx.h>
260 +extern void cns3xxx_secondary_startup(void);
263 + * control for which core is the next to come out of the secondary
264 + * boot "holding pen"
267 +volatile int __cpuinitdata pen_release = -1;
270 + * Write pen_release in a way that is guaranteed to be visible to all
271 + * observers, irrespective of whether they're taking part in coherency
272 + * or not. This is necessary for the hotplug code to work reliably.
274 +static void write_pen_release(int val)
278 + __cpuc_flush_dcache_area((void *)&pen_release, sizeof(pen_release));
279 + outer_clean_range(__pa(&pen_release), __pa(&pen_release + 1));
282 +static void __iomem *scu_base_addr(void)
284 + return (void __iomem *)(CNS3XXX_TC11MP_SCU_BASE_VIRT);
287 +static DEFINE_SPINLOCK(boot_lock);
289 +void __cpuinit platform_secondary_init(unsigned int cpu)
292 + * if any interrupts are already enabled for the primary
293 + * core (e.g. timer irq), then they will not have been enabled
296 + gic_secondary_init(0);
299 + * let the primary processor know we're out of the
300 + * pen, then head off into the C entry point
302 + write_pen_release(-1);
305 + * Synchronise with the boot thread.
307 + spin_lock(&boot_lock);
308 + spin_unlock(&boot_lock);
311 +int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
313 + unsigned long timeout;
316 + * Set synchronisation state between this boot processor
317 + * and the secondary one
319 + spin_lock(&boot_lock);
322 + * The secondary processor is waiting to be released from
323 + * the holding pen - release it, then wait for it to flag
324 + * that it has been released by resetting pen_release.
326 + * Note that "pen_release" is the hardware CPU ID, whereas
327 + * "cpu" is Linux's internal ID.
329 + write_pen_release(cpu);
332 + * Send the secondary CPU a soft interrupt, thereby causing
333 + * the boot monitor to read the system wide flags register,
334 + * and branch to the address found there.
336 + gic_raise_softirq(cpumask_of(cpu), 1);
338 + timeout = jiffies + (1 * HZ);
339 + while (time_before(jiffies, timeout)) {
341 + if (pen_release == -1)
348 + * now the secondary core is starting up let it run its
349 + * calibrations, then wait for it to finish
351 + spin_unlock(&boot_lock);
353 + return pen_release != -1 ? -ENOSYS : 0;
357 + * Initialise the CPU possible map early - this describes the CPUs
358 + * which may be present or become present in the system.
361 +void __init smp_init_cpus(void)
363 + void __iomem *scu_base = scu_base_addr();
364 + unsigned int i, ncores;
366 + ncores = scu_base ? scu_get_core_count(scu_base) : 1;
369 + if (ncores > NR_CPUS) {
370 + printk(KERN_WARNING
371 + "cns3xxx: no. of cores (%d) greater than configured "
372 + "maximum of %d - clipping\n",
377 + for (i = 0; i < ncores; i++)
378 + set_cpu_possible(i, true);
380 + set_smp_cross_call(gic_raise_softirq);
383 +void __init platform_smp_prepare_cpus(unsigned int max_cpus)
388 + * Initialise the present map, which describes the set of CPUs
389 + * actually populated at the present time.
391 + for (i = 0; i < max_cpus; i++)
392 + set_cpu_present(i, true);
394 + scu_enable(scu_base_addr());
397 + * Write the address of secondary startup into the
398 + * system-wide flags register. The boot monitor waits
399 + * until it receives a soft interrupt, and then the
400 + * secondary CPU branches to this address.
402 + __raw_writel(virt_to_phys(cns3xxx_secondary_startup),
403 + (void __iomem *)(CNS3XXX_MISC_BASE_VIRT + 0x0600));
405 --- a/arch/arm/Kconfig
406 +++ b/arch/arm/Kconfig
407 @@ -1313,7 +1313,7 @@ config SMP
408 depends on REALVIEW_EB_ARM11MP || REALVIEW_EB_A9MP || \
409 MACH_REALVIEW_PB11MP || MACH_REALVIEW_PBX || ARCH_OMAP4 || \
410 ARCH_EXYNOS4 || ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4 || \
411 - ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE
412 + ARCH_MSM_SCORPIONMP || ARCH_SHMOBILE || ARCH_CNS3XXX
413 select USE_GENERIC_SMP_HELPERS
414 select HAVE_ARM_SCU if !ARCH_MSM_SCORPIONMP