1 #include <linux/linkage.h>
2 #include <linux/sched.h>
5 #include <asm/titan_dep.h>
7 extern unsigned int (*mips_hpt_read)(void);
8 extern void (*mips_hpt_init)(unsigned int);
10 #define LAUNCHSTACK_SIZE 256
12 static __initdata DEFINE_SPINLOCK(launch_lock);
14 static unsigned long secondary_sp __initdata;
15 static unsigned long secondary_gp __initdata;
17 static unsigned char launchstack[LAUNCHSTACK_SIZE] __initdata
18 __attribute__((aligned(2 * sizeof(long))));
20 static void __init prom_smp_bootstrap(void)
24 while (spin_is_locked(&launch_lock));
31 : "r" (secondary_sp), "r" (secondary_gp));
35 * PMON is a fragile beast. It'll blow up once the mappings it's littering
36 * right into the middle of KSEG3 are blown away so we have to grab the slave
37 * core early and keep it in a waiting loop.
39 void __init prom_grab_secondary(void)
41 spin_lock(&launch_lock);
43 pmon_cpustart(1, &prom_smp_bootstrap,
44 launchstack + LAUNCHSTACK_SIZE, 0);
48 * Detect available CPUs, populate phys_cpu_present_map before smp_init
50 * We don't want to start the secondary CPU yet nor do we have a nice probing
51 * feature in PMON so we just assume presence of the secondary core.
53 void __init plat_smp_setup(void)
57 cpus_clear(phys_cpu_present_map);
59 for (i = 0; i < 2; i++) {
60 cpu_set(i, phys_cpu_present_map);
61 __cpu_number_map[i] = i;
62 __cpu_logical_map[i] = i;
66 void __init plat_prepare_cpus(unsigned int max_cpus)
69 * Be paranoid. Enable the IPI only if we're really about to go SMP.
71 if (cpus_weight(cpu_possible_map))
72 set_c0_status(STATUSF_IP5);
76 * Firmware CPU startup hook
77 * Complicated by PMON's weird interface which tries to minimic the UNIX fork.
78 * It launches the next * available CPU and copies some information on the
79 * stack so the first thing we do is throw away that stuff and load useful
80 * values into the registers ...
82 void prom_boot_secondary(int cpu, struct task_struct *idle)
84 unsigned long gp = (unsigned long) task_thread_info(idle);
85 unsigned long sp = __KSTK_TOS(idle);
90 spin_unlock(&launch_lock);
93 /* Hook for after all CPUs are online */
94 void prom_cpus_done(void)
99 * After we've done initial boot, this function is called to allow the
100 * board code to clean up state, if needed
102 void prom_init_secondary(void)
104 mips_hpt_init(mips_hpt_read());
106 set_c0_status(ST0_CO | ST0_IE | ST0_IM);
109 void prom_smp_finish(void)
113 asmlinkage void titan_mailbox_irq(struct pt_regs *regs)
115 int cpu = smp_processor_id();
116 unsigned long status;
119 status = OCD_READ(RM9000x2_OCD_INTP0STATUS3);
120 OCD_WRITE(RM9000x2_OCD_INTP0CLEAR3, status);
124 status = OCD_READ(RM9000x2_OCD_INTP1STATUS3);
125 OCD_WRITE(RM9000x2_OCD_INTP1CLEAR3, status);
129 smp_call_function_interrupt();
133 * Send inter-processor interrupt
135 void core_send_ipi(int cpu, unsigned int action)
138 * Generate an INTMSG so that it can be sent over to the
139 * destination CPU. The INTMSG will put the STATUS bits
140 * based on the action desired. An alternative strategy
141 * is to write to the Interrupt Set register, read the
142 * Interrupt Status register and clear the Interrupt
143 * Clear register. The latter is preffered.
146 case SMP_RESCHEDULE_YOURSELF:
148 OCD_WRITE(RM9000x2_OCD_INTP1SET3, 4);
150 OCD_WRITE(RM9000x2_OCD_INTP0SET3, 4);
153 case SMP_CALL_FUNCTION:
155 OCD_WRITE(RM9000x2_OCD_INTP1SET3, 2);
157 OCD_WRITE(RM9000x2_OCD_INTP0SET3, 2);