2 * linux/arch/arm/mach-cintegrator/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/kernel.h>
13 #include <linux/sched.h>
14 #include <linux/errno.h>
17 #include <asm/atomic.h>
18 #include <asm/cacheflush.h>
19 #include <asm/delay.h>
20 #include <asm/mmu_context.h>
21 #include <asm/procinfo.h>
22 #include <asm/ptrace.h>
25 extern void integrator_secondary_startup(void);
28 * control for which core is the next to come out of the secondary
31 volatile int __cpuinitdata pen_release = -1;
32 unsigned long __cpuinitdata phys_pen_release = 0;
34 static DEFINE_SPINLOCK(boot_lock);
36 void __cpuinit platform_secondary_init(unsigned int cpu)
39 * the primary core may have used a "cross call" soft interrupt
40 * to get this processor out of WFI in the BootMonitor - make
41 * sure that we are no longer being sent this soft interrupt
43 smp_cross_call_done(cpumask_of_cpu(cpu));
46 * if any interrupts are already enabled for the primary
47 * core (e.g. timer irq), then they will not have been enabled
50 secondary_scan_irqs();
53 * let the primary processor know we're out of the
54 * pen, then head off into the C entry point
59 * Synchronise with the boot thread.
61 spin_lock(&boot_lock);
62 spin_unlock(&boot_lock);
65 int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
67 unsigned long timeout;
70 * set synchronisation state between this boot processor
71 * and the secondary one
73 spin_lock(&boot_lock);
76 * The secondary processor is waiting to be released from
77 * the holding pen - release it, then wait for it to flag
78 * that it has been released by resetting pen_release.
80 * Note that "pen_release" is the hardware CPU ID, whereas
81 * "cpu" is Linux's internal ID.
89 * This is a later addition to the booting protocol: the
90 * bootMonitor now puts secondary cores into WFI, so
91 * poke_milo() no longer gets the cores moving; we need
92 * to send a soft interrupt to wake the secondary core.
93 * Use smp_cross_call() for this, since there's little
94 * point duplicating the code here
96 smp_cross_call(cpumask_of_cpu(cpu));
98 timeout = jiffies + (1 * HZ);
99 while (time_before(jiffies, timeout)) {
100 if (pen_release == -1)
107 * now the secondary core is starting up let it run its
108 * calibrations, then wait for it to finish
110 spin_unlock(&boot_lock);
112 return pen_release != -1 ? -ENOSYS : 0;
115 static void __init poke_milo(void)
117 extern void secondary_startup(void);
119 /* nobody is to be released from the pen yet */
122 phys_pen_release = virt_to_phys(&pen_release);
125 * write the address of secondary startup into the system-wide
126 * flags register, then clear the bottom two bits, which is what
127 * BootMonitor is waiting for
130 #define CINTEGRATOR_HDR_FLAGSS_OFFSET 0x30
131 __raw_writel(virt_to_phys(integrator_secondary_startup),
132 (IO_ADDRESS(INTEGRATOR_HDR_BASE) +
133 CINTEGRATOR_HDR_FLAGSS_OFFSET));
134 #define CINTEGRATOR_HDR_FLAGSC_OFFSET 0x34
136 (IO_ADDRESS(INTEGRATOR_HDR_BASE) +
137 CINTEGRATOR_HDR_FLAGSC_OFFSET));
143 void __init smp_prepare_cpus(unsigned int max_cpus)
145 unsigned int ncores = get_core_count();
146 unsigned int cpu = smp_processor_id();
152 "Integrator/CP: strange CM count of 0? Default to 1\n");
157 if (ncores > NR_CPUS) {
159 "Integrator/CP: no. of cores (%d) greater than configured "
160 "maximum of %d - clipping\n",
166 * start with some more config for the Boot CPU, now that
167 * the world is a bit more alive (which was not the case
168 * when smp_prepare_boot_cpu() was called)
170 smp_store_cpu_info(cpu);
173 * are we trying to boot more cores than exist?
175 if (max_cpus > ncores)
179 * Initialise the possible/present maps.
180 * cpu_possible_map describes the set of CPUs which may be present
181 * cpu_present_map describes the set of CPUs populated
183 for (i = 0; i < max_cpus; i++) {
184 cpu_set(i, cpu_possible_map);
185 cpu_set(i, cpu_present_map);
189 * Do we need any more CPUs? If so, then let them know where
190 * to start. Note that, on modern versions of MILO, the "poke"
191 * doesn't actually do anything until each individual core is
192 * sent a soft interrupt to get it out of WFI