12 #include <linux/sched.h>
20 #include <linux/reboot.h>
22 #include <linux/compiler.h>
23 #include <linux/linkage.h>
25 #include <linux/kernel.h>
28 #include <asm/pgtable.h>
29 #include <asm/processor.h>
30 #include <asm/bootinfo.h>
32 #include <asm/cacheflush.h>
33 #include <asm/tlbflush.h>
36 #include <asm/traps.h>
37 #include <asm/barrier.h>
49 unsigned long bmips_smp_boot_sp;
50 unsigned long bmips_smp_boot_gp;
52 static void bmips_send_ipi_single(
int cpu,
unsigned int action);
56 #define IPI0_IRQ (MIPS_CPU_IRQ_BASE + 0)
57 #define IPI1_IRQ (MIPS_CPU_IRQ_BASE + 1)
59 #define CPUNUM(cpu, shift) (((cpu) + bmips_cpu_offset) << (shift))
60 #define ACTION_CLR_IPI(cpu, ipi) (0x2000 | CPUNUM(cpu, 9) | ((ipi) << 8))
61 #define ACTION_SET_IPI(cpu, ipi) (0x3000 | CPUNUM(cpu, 9) | ((ipi) << 8))
62 #define ACTION_BOOT_THREAD(cpu) (0x08 | CPUNUM(cpu, 0))
64 static void __init bmips_smp_setup(
void)
68 #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
70 clear_c0_brcm_cmt_ctrl(0x30);
73 set_c0_brcm_config_0(0x30000);
80 change_c0_brcm_cmt_intr(0xf8018000,
81 (0x02 << 27) | (0x03 << 15));
85 #elif defined(CONFIG_CPU_BMIPS5000)
87 set_c0_brcm_config(0x03 << 22);
90 change_c0_brcm_mode(0x1f << 27, 0x02 << 27);
96 for (i = 0; i < max_cpus; i++) {
109 for (i = 0; i < max_cpus; i++) {
120 static void bmips_prepare_cpus(
unsigned int max_cpus)
124 panic(
"Can't request IPI0 interrupt\n");
127 panic(
"Can't request IPI1 interrupt\n");
154 pr_info(
"SMP: Booting CPU%d...\n", cpu);
157 bmips_send_ipi_single(cpu, 0);
159 #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
160 set_c0_brcm_cmt_ctrl(0x01);
161 #elif defined(CONFIG_CPU_BMIPS5000)
169 bmips_write_zscm_reg(0x210, 0xc0000000);
171 bmips_write_zscm_reg(0x210, 0x00);
174 cpumask_set_cpu(cpu, &bmips_booted_mask);
181 static void bmips_init_secondary(
void)
185 #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
187 unsigned long old_vec;
193 #elif defined(CONFIG_CPU_BMIPS5000)
204 static void bmips_smp_finish(
void)
219 static void bmips_cpus_done(
void)
223 #if defined(CONFIG_CPU_BMIPS5000)
233 static void bmips_send_ipi_single(
int cpu,
unsigned int action)
240 int action = irq - IPI0_IRQ;
267 static void bmips_send_ipi_single(
int cpu,
unsigned int action)
275 spin_unlock_irqrestore(&
ipi_lock, flags);
278 static irqreturn_t bmips_ipi_interrupt(
int irq,
void *dev_id)
281 int action, cpu = irq - IPI0_IRQ;
285 per_cpu(ipi_action_mask, cpu) = 0;
287 spin_unlock_irqrestore(&
ipi_lock, flags);
299 static void bmips_send_ipi_mask(
const struct cpumask *
mask,
305 bmips_send_ipi_single(i, action);
308 #ifdef CONFIG_HOTPLUG_CPU
310 static int bmips_cpu_disable(
void)
317 pr_info(
"SMP: CPU%d is offline\n", cpu);
328 static void bmips_cpu_die(
unsigned int cpu)
332 void __ref play_dead(
void)
337 _dma_cache_wback_inv(0, ~0);
347 irq_disable_hazard();
355 " j bmips_secondary_reentry\n"
362 .smp_setup = bmips_smp_setup,
363 .prepare_cpus = bmips_prepare_cpus,
364 .boot_secondary = bmips_boot_secondary,
365 .smp_finish = bmips_smp_finish,
366 .init_secondary = bmips_init_secondary,
367 .cpus_done = bmips_cpus_done,
368 .send_ipi_single = bmips_send_ipi_single,
369 .send_ipi_mask = bmips_send_ipi_mask,
370 #ifdef CONFIG_HOTPLUG_CPU
371 .cpu_disable = bmips_cpu_disable,
372 .cpu_die = bmips_cpu_die,
386 memcpy((
void *)dst, start, end - start);
392 static inline void __cpuinit bmips_nmi_handler_setup(
void)
395 &bmips_reset_nmi_vec_end);
397 &bmips_smp_int_vec_end);
402 unsigned long new_ebase =
ebase;
407 #if defined(CONFIG_CPU_BMIPS4350)
422 #elif defined(CONFIG_CPU_BMIPS4380)
427 new_ebase = 0x80000400;
431 #elif defined(CONFIG_CPU_BMIPS5000)
436 new_ebase = 0x80001000;
440 bmips_write_zscm_reg(0xa0, 0xa008a008);