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/ptrace.h>
24 extern void integrator_secondary_startup(void);
27 * control for which core is the next to come out of the secondary
30 volatile int __cpuinitdata pen_release
= -1;
31 unsigned long __cpuinitdata phys_pen_release
= 0;
33 static DEFINE_SPINLOCK(boot_lock
);
35 void __cpuinit
platform_secondary_init(unsigned int cpu
)
38 * the primary core may have used a "cross call" soft interrupt
39 * to get this processor out of WFI in the BootMonitor - make
40 * sure that we are no longer being sent this soft interrupt
42 smp_cross_call_done(cpumask_of_cpu(cpu
));
45 * if any interrupts are already enabled for the primary
46 * core (e.g. timer irq), then they will not have been enabled
49 secondary_scan_irqs();
52 * let the primary processor know we're out of the
53 * pen, then head off into the C entry point
58 * Synchronise with the boot thread.
60 spin_lock(&boot_lock
);
61 spin_unlock(&boot_lock
);
64 int __cpuinit
boot_secondary(unsigned int cpu
, struct task_struct
*idle
)
66 unsigned long timeout
;
69 * set synchronisation state between this boot processor
70 * and the secondary one
72 spin_lock(&boot_lock
);
75 * The secondary processor is waiting to be released from
76 * the holding pen - release it, then wait for it to flag
77 * that it has been released by resetting pen_release.
79 * Note that "pen_release" is the hardware CPU ID, whereas
80 * "cpu" is Linux's internal ID.
88 * This is a later addition to the booting protocol: the
89 * bootMonitor now puts secondary cores into WFI, so
90 * poke_milo() no longer gets the cores moving; we need
91 * to send a soft interrupt to wake the secondary core.
92 * Use smp_cross_call() for this, since there's little
93 * point duplicating the code here
95 smp_cross_call(cpumask_of_cpu(cpu
));
97 timeout
= jiffies
+ (1 * HZ
);
98 while (time_before(jiffies
, timeout
)) {
99 if (pen_release
== -1)
106 * now the secondary core is starting up let it run its
107 * calibrations, then wait for it to finish
109 spin_unlock(&boot_lock
);
111 return pen_release
!= -1 ? -ENOSYS
: 0;
114 static void __init
poke_milo(void)
116 extern void secondary_startup(void);
118 /* nobody is to be released from the pen yet */
121 phys_pen_release
= virt_to_phys(&pen_release
);
124 * write the address of secondary startup into the system-wide
125 * flags register, then clear the bottom two bits, which is what
126 * BootMonitor is waiting for
129 #define CINTEGRATOR_HDR_FLAGSS_OFFSET 0x30
130 __raw_writel(virt_to_phys(integrator_secondary_startup
),
131 (IO_ADDRESS(INTEGRATOR_HDR_BASE
) +
132 CINTEGRATOR_HDR_FLAGSS_OFFSET
));
133 #define CINTEGRATOR_HDR_FLAGSC_OFFSET 0x34
135 (IO_ADDRESS(INTEGRATOR_HDR_BASE
) +
136 CINTEGRATOR_HDR_FLAGSC_OFFSET
));
143 * Initialise the CPU possible map early - this describes the CPUs
144 * which may be present or become present in the system.
146 void __init
smp_init_cpus(void)
148 unsigned int i
, ncores
= get_core_count();
150 for (i
= 0; i
< ncores
; i
++)
151 cpu_set(i
, cpu_possible_map
);
154 void __init
smp_prepare_cpus(unsigned int max_cpus
)
156 unsigned int ncores
= get_core_count();
157 unsigned int cpu
= smp_processor_id();
163 "Integrator/CP: strange CM count of 0? Default to 1\n");
168 if (ncores
> NR_CPUS
) {
170 "Integrator/CP: no. of cores (%d) greater than configured "
171 "maximum of %d - clipping\n",
177 * start with some more config for the Boot CPU, now that
178 * the world is a bit more alive (which was not the case
179 * when smp_prepare_boot_cpu() was called)
181 smp_store_cpu_info(cpu
);
184 * are we trying to boot more cores than exist?
186 if (max_cpus
> ncores
)
190 * Initialise the present map, which describes the set of CPUs
191 * actually populated at the present time.
193 for (i
= 0; i
< max_cpus
; i
++)
194 cpu_set(i
, cpu_present_map
);
197 * Do we need any more CPUs? If so, then let them know where
198 * to start. Note that, on modern versions of MILO, the "poke"
199 * doesn't actually do anything until each individual core is
200 * sent a soft interrupt to get it out of WFI