2 * linux/arch/arm/plat-versatile/platsmp.c
4 * Copyright (C) 2002 ARM Ltd.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 #include <linux/init.h>
12 #include <linux/errno.h>
13 #include <linux/delay.h>
14 #include <linux/device.h>
15 #include <linux/jiffies.h>
16 #include <linux/smp.h>
18 #include <asm/cacheflush.h>
21 * control for which core is the next to come out of the secondary
24 volatile int __cpuinitdata pen_release
= -1;
27 * Write pen_release in a way that is guaranteed to be visible to all
28 * observers, irrespective of whether they're taking part in coherency
29 * or not. This is necessary for the hotplug code to work reliably.
31 static void __cpuinit
write_pen_release(int val
)
35 __cpuc_flush_dcache_area((void *)&pen_release
, sizeof(pen_release
));
36 outer_clean_range(__pa(&pen_release
), __pa(&pen_release
+ 1));
39 static DEFINE_SPINLOCK(boot_lock
);
41 void __cpuinit
platform_secondary_init(unsigned int cpu
)
44 * if any interrupts are already enabled for the primary
45 * core (e.g. timer irq), then they will not have been enabled
48 gic_secondary_init(0);
51 * let the primary processor know we're out of the
52 * pen, then head off into the C entry point
54 write_pen_release(-1);
57 * Synchronise with the boot thread.
59 spin_lock(&boot_lock
);
60 spin_unlock(&boot_lock
);
63 int __cpuinit
boot_secondary(unsigned int cpu
, struct task_struct
*idle
)
65 unsigned long timeout
;
68 * Set synchronisation state between this boot processor
69 * and the secondary one
71 spin_lock(&boot_lock
);
74 * This is really belt and braces; we hold unintended secondary
75 * CPUs in the holding pen until we're ready for them. However,
76 * since we haven't sent them a soft interrupt, they shouldn't
79 write_pen_release(cpu
);
82 * Send the secondary CPU a soft interrupt, thereby causing
83 * the boot monitor to read the system wide flags register,
84 * and branch to the address found there.
86 smp_cross_call(cpumask_of(cpu
), 1);
88 timeout
= jiffies
+ (1 * HZ
);
89 while (time_before(jiffies
, timeout
)) {
91 if (pen_release
== -1)
98 * now the secondary core is starting up let it run its
99 * calibrations, then wait for it to finish
101 spin_unlock(&boot_lock
);
103 return pen_release
!= -1 ? -ENOSYS
: 0;