xref: /openbmc/linux/arch/mips/kernel/smp-bmips.c (revision 62cac480)
1df0ac8a4SKevin Cernekee /*
2df0ac8a4SKevin Cernekee  * This file is subject to the terms and conditions of the GNU General Public
3df0ac8a4SKevin Cernekee  * License.  See the file "COPYING" in the main directory of this archive
4df0ac8a4SKevin Cernekee  * for more details.
5df0ac8a4SKevin Cernekee  *
6df0ac8a4SKevin Cernekee  * Copyright (C) 2011 by Kevin Cernekee (cernekee@gmail.com)
7df0ac8a4SKevin Cernekee  *
8df0ac8a4SKevin Cernekee  * SMP support for BMIPS
9df0ac8a4SKevin Cernekee  */
10df0ac8a4SKevin Cernekee 
11df0ac8a4SKevin Cernekee #include <linux/init.h>
12df0ac8a4SKevin Cernekee #include <linux/sched.h>
13ef8bd77fSIngo Molnar #include <linux/sched/hotplug.h>
14fc69910fSArnd Bergmann #include <linux/sched/task_stack.h>
15df0ac8a4SKevin Cernekee #include <linux/mm.h>
16df0ac8a4SKevin Cernekee #include <linux/delay.h>
17df0ac8a4SKevin Cernekee #include <linux/smp.h>
18df0ac8a4SKevin Cernekee #include <linux/interrupt.h>
19df0ac8a4SKevin Cernekee #include <linux/spinlock.h>
20df0ac8a4SKevin Cernekee #include <linux/cpu.h>
21df0ac8a4SKevin Cernekee #include <linux/cpumask.h>
22df0ac8a4SKevin Cernekee #include <linux/reboot.h>
23df0ac8a4SKevin Cernekee #include <linux/io.h>
24df0ac8a4SKevin Cernekee #include <linux/compiler.h>
25df0ac8a4SKevin Cernekee #include <linux/linkage.h>
26df0ac8a4SKevin Cernekee #include <linux/bug.h>
27df0ac8a4SKevin Cernekee #include <linux/kernel.h>
2862cac480SDengcheng Zhu #include <linux/kexec.h>
29df0ac8a4SKevin Cernekee 
30df0ac8a4SKevin Cernekee #include <asm/time.h>
31df0ac8a4SKevin Cernekee #include <asm/pgtable.h>
32df0ac8a4SKevin Cernekee #include <asm/processor.h>
33df0ac8a4SKevin Cernekee #include <asm/bootinfo.h>
34df0ac8a4SKevin Cernekee #include <asm/pmon.h>
35df0ac8a4SKevin Cernekee #include <asm/cacheflush.h>
36df0ac8a4SKevin Cernekee #include <asm/tlbflush.h>
37df0ac8a4SKevin Cernekee #include <asm/mipsregs.h>
38df0ac8a4SKevin Cernekee #include <asm/bmips.h>
39df0ac8a4SKevin Cernekee #include <asm/traps.h>
40df0ac8a4SKevin Cernekee #include <asm/barrier.h>
41fc455787SKevin Cernekee #include <asm/cpu-features.h>
42df0ac8a4SKevin Cernekee 
43df0ac8a4SKevin Cernekee static int __maybe_unused max_cpus = 1;
44df0ac8a4SKevin Cernekee 
45df0ac8a4SKevin Cernekee /* these may be configured by the platform code */
46df0ac8a4SKevin Cernekee int bmips_smp_enabled = 1;
47df0ac8a4SKevin Cernekee int bmips_cpu_offset;
48df0ac8a4SKevin Cernekee cpumask_t bmips_booted_mask;
49d8010cebSKevin Cernekee unsigned long bmips_tp1_irqs = IE_IRQ1;
50df0ac8a4SKevin Cernekee 
51fc455787SKevin Cernekee #define RESET_FROM_KSEG0		0x80080800
52fc455787SKevin Cernekee #define RESET_FROM_KSEG1		0xa0080800
53fc455787SKevin Cernekee 
543677a283SKevin Cernekee static void bmips_set_reset_vec(int cpu, u32 val);
553677a283SKevin Cernekee 
56df0ac8a4SKevin Cernekee #ifdef CONFIG_SMP
57df0ac8a4SKevin Cernekee 
58df0ac8a4SKevin Cernekee /* initial $sp, $gp - used by arch/mips/kernel/bmips_vec.S */
59df0ac8a4SKevin Cernekee unsigned long bmips_smp_boot_sp;
60df0ac8a4SKevin Cernekee unsigned long bmips_smp_boot_gp;
61df0ac8a4SKevin Cernekee 
626465460cSJonas Gorski static void bmips43xx_send_ipi_single(int cpu, unsigned int action);
636465460cSJonas Gorski static void bmips5000_send_ipi_single(int cpu, unsigned int action);
646465460cSJonas Gorski static irqreturn_t bmips43xx_ipi_interrupt(int irq, void *dev_id);
656465460cSJonas Gorski static irqreturn_t bmips5000_ipi_interrupt(int irq, void *dev_id);
66df0ac8a4SKevin Cernekee 
67df0ac8a4SKevin Cernekee /* SW interrupts 0,1 are used for interprocessor signaling */
68df0ac8a4SKevin Cernekee #define IPI0_IRQ			(MIPS_CPU_IRQ_BASE + 0)
69df0ac8a4SKevin Cernekee #define IPI1_IRQ			(MIPS_CPU_IRQ_BASE + 1)
70df0ac8a4SKevin Cernekee 
71df0ac8a4SKevin Cernekee #define CPUNUM(cpu, shift)		(((cpu) + bmips_cpu_offset) << (shift))
72df0ac8a4SKevin Cernekee #define ACTION_CLR_IPI(cpu, ipi)	(0x2000 | CPUNUM(cpu, 9) | ((ipi) << 8))
73df0ac8a4SKevin Cernekee #define ACTION_SET_IPI(cpu, ipi)	(0x3000 | CPUNUM(cpu, 9) | ((ipi) << 8))
74df0ac8a4SKevin Cernekee #define ACTION_BOOT_THREAD(cpu)		(0x08 | CPUNUM(cpu, 0))
75df0ac8a4SKevin Cernekee 
76df0ac8a4SKevin Cernekee static void __init bmips_smp_setup(void)
77df0ac8a4SKevin Cernekee {
784df715aaSFlorian Fainelli 	int i, cpu = 1, boot_cpu = 0;
79fcfa66deSFlorian Fainelli 	int cpu_hw_intr;
80fcfa66deSFlorian Fainelli 
816465460cSJonas Gorski 	switch (current_cpu_type()) {
826465460cSJonas Gorski 	case CPU_BMIPS4350:
836465460cSJonas Gorski 	case CPU_BMIPS4380:
84df0ac8a4SKevin Cernekee 		/* arbitration priority */
85df0ac8a4SKevin Cernekee 		clear_c0_brcm_cmt_ctrl(0x30);
86df0ac8a4SKevin Cernekee 
87df0ac8a4SKevin Cernekee 		/* NBK and weak order flags */
88df0ac8a4SKevin Cernekee 		set_c0_brcm_config_0(0x30000);
89df0ac8a4SKevin Cernekee 
904df715aaSFlorian Fainelli 		/* Find out if we are running on TP0 or TP1 */
914df715aaSFlorian Fainelli 		boot_cpu = !!(read_c0_brcm_cmt_local() & (1 << 31));
924df715aaSFlorian Fainelli 
93df0ac8a4SKevin Cernekee 		/*
946465460cSJonas Gorski 		 * MIPS interrupts 0,1 (SW INT 0,1) cross over to the other
956465460cSJonas Gorski 		 * thread
96df0ac8a4SKevin Cernekee 		 * MIPS interrupt 2 (HW INT 0) is the CPU0 L1 controller output
97df0ac8a4SKevin Cernekee 		 * MIPS interrupt 3 (HW INT 1) is the CPU1 L1 controller output
98df0ac8a4SKevin Cernekee 		 */
99fcfa66deSFlorian Fainelli 		if (boot_cpu == 0)
100fcfa66deSFlorian Fainelli 			cpu_hw_intr = 0x02;
101fcfa66deSFlorian Fainelli 		else
102fcfa66deSFlorian Fainelli 			cpu_hw_intr = 0x1d;
103fcfa66deSFlorian Fainelli 
1046465460cSJonas Gorski 		change_c0_brcm_cmt_intr(0xf8018000,
1056465460cSJonas Gorski 					(cpu_hw_intr << 27) | (0x03 << 15));
106df0ac8a4SKevin Cernekee 
107df0ac8a4SKevin Cernekee 		/* single core, 2 threads (2 pipelines) */
108df0ac8a4SKevin Cernekee 		max_cpus = 2;
1096465460cSJonas Gorski 
1106465460cSJonas Gorski 		break;
1116465460cSJonas Gorski 	case CPU_BMIPS5000:
112df0ac8a4SKevin Cernekee 		/* enable raceless SW interrupts */
113df0ac8a4SKevin Cernekee 		set_c0_brcm_config(0x03 << 22);
114df0ac8a4SKevin Cernekee 
115df0ac8a4SKevin Cernekee 		/* route HW interrupt 0 to CPU0, HW interrupt 1 to CPU1 */
116df0ac8a4SKevin Cernekee 		change_c0_brcm_mode(0x1f << 27, 0x02 << 27);
117df0ac8a4SKevin Cernekee 
118df0ac8a4SKevin Cernekee 		/* N cores, 2 threads per core */
119df0ac8a4SKevin Cernekee 		max_cpus = (((read_c0_brcm_config() >> 6) & 0x03) + 1) << 1;
120df0ac8a4SKevin Cernekee 
121df0ac8a4SKevin Cernekee 		/* clear any pending SW interrupts */
122df0ac8a4SKevin Cernekee 		for (i = 0; i < max_cpus; i++) {
123df0ac8a4SKevin Cernekee 			write_c0_brcm_action(ACTION_CLR_IPI(i, 0));
124df0ac8a4SKevin Cernekee 			write_c0_brcm_action(ACTION_CLR_IPI(i, 1));
125df0ac8a4SKevin Cernekee 		}
1266465460cSJonas Gorski 
1276465460cSJonas Gorski 		break;
1286465460cSJonas Gorski 	default:
1296465460cSJonas Gorski 		max_cpus = 1;
1306465460cSJonas Gorski 	}
131df0ac8a4SKevin Cernekee 
132df0ac8a4SKevin Cernekee 	if (!bmips_smp_enabled)
133df0ac8a4SKevin Cernekee 		max_cpus = 1;
134df0ac8a4SKevin Cernekee 
135df0ac8a4SKevin Cernekee 	/* this can be overridden by the BSP */
136df0ac8a4SKevin Cernekee 	if (!board_ebase_setup)
137df0ac8a4SKevin Cernekee 		board_ebase_setup = &bmips_ebase_setup;
138df0ac8a4SKevin Cernekee 
1394df715aaSFlorian Fainelli 	__cpu_number_map[boot_cpu] = 0;
1404df715aaSFlorian Fainelli 	__cpu_logical_map[0] = boot_cpu;
1414df715aaSFlorian Fainelli 
142df0ac8a4SKevin Cernekee 	for (i = 0; i < max_cpus; i++) {
1434df715aaSFlorian Fainelli 		if (i != boot_cpu) {
1444df715aaSFlorian Fainelli 			__cpu_number_map[i] = cpu;
1454df715aaSFlorian Fainelli 			__cpu_logical_map[cpu] = i;
1464df715aaSFlorian Fainelli 			cpu++;
1474df715aaSFlorian Fainelli 		}
148df0ac8a4SKevin Cernekee 		set_cpu_possible(i, 1);
149df0ac8a4SKevin Cernekee 		set_cpu_present(i, 1);
150df0ac8a4SKevin Cernekee 	}
151df0ac8a4SKevin Cernekee }
152df0ac8a4SKevin Cernekee 
153df0ac8a4SKevin Cernekee /*
154df0ac8a4SKevin Cernekee  * IPI IRQ setup - runs on CPU0
155df0ac8a4SKevin Cernekee  */
156df0ac8a4SKevin Cernekee static void bmips_prepare_cpus(unsigned int max_cpus)
157df0ac8a4SKevin Cernekee {
1586465460cSJonas Gorski 	irqreturn_t (*bmips_ipi_interrupt)(int irq, void *dev_id);
1596465460cSJonas Gorski 
1606465460cSJonas Gorski 	switch (current_cpu_type()) {
1616465460cSJonas Gorski 	case CPU_BMIPS4350:
1626465460cSJonas Gorski 	case CPU_BMIPS4380:
1636465460cSJonas Gorski 		bmips_ipi_interrupt = bmips43xx_ipi_interrupt;
1646465460cSJonas Gorski 		break;
1656465460cSJonas Gorski 	case CPU_BMIPS5000:
1666465460cSJonas Gorski 		bmips_ipi_interrupt = bmips5000_ipi_interrupt;
1676465460cSJonas Gorski 		break;
1686465460cSJonas Gorski 	default:
1696465460cSJonas Gorski 		return;
1706465460cSJonas Gorski 	}
1716465460cSJonas Gorski 
17206a3f0c9SJustin Chen 	if (request_irq(IPI0_IRQ, bmips_ipi_interrupt,
17306a3f0c9SJustin Chen 			IRQF_PERCPU | IRQF_NO_SUSPEND, "smp_ipi0", NULL))
174f7777dccSRalf Baechle 		panic("Can't request IPI0 interrupt");
17506a3f0c9SJustin Chen 	if (request_irq(IPI1_IRQ, bmips_ipi_interrupt,
17606a3f0c9SJustin Chen 			IRQF_PERCPU | IRQF_NO_SUSPEND, "smp_ipi1", NULL))
177f7777dccSRalf Baechle 		panic("Can't request IPI1 interrupt");
178df0ac8a4SKevin Cernekee }
179df0ac8a4SKevin Cernekee 
180df0ac8a4SKevin Cernekee /*
181df0ac8a4SKevin Cernekee  * Tell the hardware to boot CPUx - runs on CPU0
182df0ac8a4SKevin Cernekee  */
183d595d423SPaul Burton static int bmips_boot_secondary(int cpu, struct task_struct *idle)
184df0ac8a4SKevin Cernekee {
185df0ac8a4SKevin Cernekee 	bmips_smp_boot_sp = __KSTK_TOS(idle);
186df0ac8a4SKevin Cernekee 	bmips_smp_boot_gp = (unsigned long)task_thread_info(idle);
187df0ac8a4SKevin Cernekee 	mb();
188df0ac8a4SKevin Cernekee 
189df0ac8a4SKevin Cernekee 	/*
190df0ac8a4SKevin Cernekee 	 * Initial boot sequence for secondary CPU:
191df0ac8a4SKevin Cernekee 	 *   bmips_reset_nmi_vec @ a000_0000 ->
192df0ac8a4SKevin Cernekee 	 *   bmips_smp_entry ->
193df0ac8a4SKevin Cernekee 	 *   plat_wired_tlb_setup (cached function call; optional) ->
194df0ac8a4SKevin Cernekee 	 *   start_secondary (cached jump)
195df0ac8a4SKevin Cernekee 	 *
196df0ac8a4SKevin Cernekee 	 * Warm restart sequence:
197df0ac8a4SKevin Cernekee 	 *   play_dead WAIT loop ->
198df0ac8a4SKevin Cernekee 	 *   bmips_smp_int_vec @ BMIPS_WARM_RESTART_VEC ->
199df0ac8a4SKevin Cernekee 	 *   eret to play_dead ->
200df0ac8a4SKevin Cernekee 	 *   bmips_secondary_reentry ->
201df0ac8a4SKevin Cernekee 	 *   start_secondary
202df0ac8a4SKevin Cernekee 	 */
203df0ac8a4SKevin Cernekee 
204df0ac8a4SKevin Cernekee 	pr_info("SMP: Booting CPU%d...\n", cpu);
205df0ac8a4SKevin Cernekee 
2066465460cSJonas Gorski 	if (cpumask_test_cpu(cpu, &bmips_booted_mask)) {
2073677a283SKevin Cernekee 		/* kseg1 might not exist if this CPU enabled XKS01 */
2083677a283SKevin Cernekee 		bmips_set_reset_vec(cpu, RESET_FROM_KSEG0);
2093677a283SKevin Cernekee 
2106465460cSJonas Gorski 		switch (current_cpu_type()) {
2116465460cSJonas Gorski 		case CPU_BMIPS4350:
2126465460cSJonas Gorski 		case CPU_BMIPS4380:
2136465460cSJonas Gorski 			bmips43xx_send_ipi_single(cpu, 0);
2146465460cSJonas Gorski 			break;
2156465460cSJonas Gorski 		case CPU_BMIPS5000:
2166465460cSJonas Gorski 			bmips5000_send_ipi_single(cpu, 0);
2176465460cSJonas Gorski 			break;
2186465460cSJonas Gorski 		}
2193677a283SKevin Cernekee 	} else {
2203677a283SKevin Cernekee 		bmips_set_reset_vec(cpu, RESET_FROM_KSEG1);
2213677a283SKevin Cernekee 
2226465460cSJonas Gorski 		switch (current_cpu_type()) {
2236465460cSJonas Gorski 		case CPU_BMIPS4350:
2246465460cSJonas Gorski 		case CPU_BMIPS4380:
2254df715aaSFlorian Fainelli 			/* Reset slave TP1 if booting from TP0 */
226976f39b1SFlorian Fainelli 			if (cpu_logical_map(cpu) == 1)
227df0ac8a4SKevin Cernekee 				set_c0_brcm_cmt_ctrl(0x01);
2286465460cSJonas Gorski 			break;
2296465460cSJonas Gorski 		case CPU_BMIPS5000:
230df0ac8a4SKevin Cernekee 			write_c0_brcm_action(ACTION_BOOT_THREAD(cpu));
2316465460cSJonas Gorski 			break;
2326465460cSJonas Gorski 		}
233df0ac8a4SKevin Cernekee 		cpumask_set_cpu(cpu, &bmips_booted_mask);
234df0ac8a4SKevin Cernekee 	}
235d595d423SPaul Burton 
236d595d423SPaul Burton 	return 0;
237df0ac8a4SKevin Cernekee }
238df0ac8a4SKevin Cernekee 
239df0ac8a4SKevin Cernekee /*
240df0ac8a4SKevin Cernekee  * Early setup - runs on secondary CPU after cache probe
241df0ac8a4SKevin Cernekee  */
242df0ac8a4SKevin Cernekee static void bmips_init_secondary(void)
243df0ac8a4SKevin Cernekee {
2446465460cSJonas Gorski 	switch (current_cpu_type()) {
2456465460cSJonas Gorski 	case CPU_BMIPS4350:
2466465460cSJonas Gorski 	case CPU_BMIPS4380:
247df0ac8a4SKevin Cernekee 		clear_c0_cause(smp_processor_id() ? C_SW1 : C_SW0);
2486465460cSJonas Gorski 		break;
2496465460cSJonas Gorski 	case CPU_BMIPS5000:
250df0ac8a4SKevin Cernekee 		write_c0_brcm_action(ACTION_CLR_IPI(smp_processor_id(), 0));
251f875a832SPaul Burton 		cpu_set_core(&current_cpu_data, (read_c0_brcm_config() >> 25) & 3);
2526465460cSJonas Gorski 		break;
2536465460cSJonas Gorski 	}
254df0ac8a4SKevin Cernekee }
255df0ac8a4SKevin Cernekee 
256df0ac8a4SKevin Cernekee /*
257df0ac8a4SKevin Cernekee  * Late setup - runs on secondary CPU before entering the idle loop
258df0ac8a4SKevin Cernekee  */
259df0ac8a4SKevin Cernekee static void bmips_smp_finish(void)
260df0ac8a4SKevin Cernekee {
261df0ac8a4SKevin Cernekee 	pr_info("SMP: CPU%d is running\n", smp_processor_id());
262856ac3c6SYong Zhang 
263856ac3c6SYong Zhang 	/* make sure there won't be a timer interrupt for a little while */
264856ac3c6SYong Zhang 	write_c0_compare(read_c0_count() + mips_hpt_frequency / HZ);
265856ac3c6SYong Zhang 
266856ac3c6SYong Zhang 	irq_enable_hazard();
267d8010cebSKevin Cernekee 	set_c0_status(IE_SW0 | IE_SW1 | bmips_tp1_irqs | IE_IRQ5 | ST0_IE);
268856ac3c6SYong Zhang 	irq_enable_hazard();
269df0ac8a4SKevin Cernekee }
270df0ac8a4SKevin Cernekee 
271df0ac8a4SKevin Cernekee /*
272df0ac8a4SKevin Cernekee  * BMIPS5000 raceless IPIs
273df0ac8a4SKevin Cernekee  *
274df0ac8a4SKevin Cernekee  * Each CPU has two inbound SW IRQs which are independent of all other CPUs.
275df0ac8a4SKevin Cernekee  * IPI0 is used for SMP_RESCHEDULE_YOURSELF
276df0ac8a4SKevin Cernekee  * IPI1 is used for SMP_CALL_FUNCTION
277df0ac8a4SKevin Cernekee  */
278df0ac8a4SKevin Cernekee 
2796465460cSJonas Gorski static void bmips5000_send_ipi_single(int cpu, unsigned int action)
280df0ac8a4SKevin Cernekee {
281df0ac8a4SKevin Cernekee 	write_c0_brcm_action(ACTION_SET_IPI(cpu, action == SMP_CALL_FUNCTION));
282df0ac8a4SKevin Cernekee }
283df0ac8a4SKevin Cernekee 
2846465460cSJonas Gorski static irqreturn_t bmips5000_ipi_interrupt(int irq, void *dev_id)
285df0ac8a4SKevin Cernekee {
286df0ac8a4SKevin Cernekee 	int action = irq - IPI0_IRQ;
287df0ac8a4SKevin Cernekee 
288df0ac8a4SKevin Cernekee 	write_c0_brcm_action(ACTION_CLR_IPI(smp_processor_id(), action));
289df0ac8a4SKevin Cernekee 
290df0ac8a4SKevin Cernekee 	if (action == 0)
291df0ac8a4SKevin Cernekee 		scheduler_ipi();
292df0ac8a4SKevin Cernekee 	else
2934ace6139SAlex Smith 		generic_smp_call_function_interrupt();
294df0ac8a4SKevin Cernekee 
295df0ac8a4SKevin Cernekee 	return IRQ_HANDLED;
296df0ac8a4SKevin Cernekee }
297df0ac8a4SKevin Cernekee 
2986465460cSJonas Gorski static void bmips5000_send_ipi_mask(const struct cpumask *mask,
2996465460cSJonas Gorski 	unsigned int action)
3006465460cSJonas Gorski {
3016465460cSJonas Gorski 	unsigned int i;
3026465460cSJonas Gorski 
3036465460cSJonas Gorski 	for_each_cpu(i, mask)
3046465460cSJonas Gorski 		bmips5000_send_ipi_single(i, action);
3056465460cSJonas Gorski }
306df0ac8a4SKevin Cernekee 
307df0ac8a4SKevin Cernekee /*
308df0ac8a4SKevin Cernekee  * BMIPS43xx racey IPIs
309df0ac8a4SKevin Cernekee  *
310df0ac8a4SKevin Cernekee  * We use one inbound SW IRQ for each CPU.
311df0ac8a4SKevin Cernekee  *
312df0ac8a4SKevin Cernekee  * A spinlock must be held in order to keep CPUx from accidentally clearing
313df0ac8a4SKevin Cernekee  * an incoming IPI when it writes CP0 CAUSE to raise an IPI on CPUy.  The
314df0ac8a4SKevin Cernekee  * same spinlock is used to protect the action masks.
315df0ac8a4SKevin Cernekee  */
316df0ac8a4SKevin Cernekee 
317df0ac8a4SKevin Cernekee static DEFINE_SPINLOCK(ipi_lock);
318df0ac8a4SKevin Cernekee static DEFINE_PER_CPU(int, ipi_action_mask);
319df0ac8a4SKevin Cernekee 
3206465460cSJonas Gorski static void bmips43xx_send_ipi_single(int cpu, unsigned int action)
321df0ac8a4SKevin Cernekee {
322df0ac8a4SKevin Cernekee 	unsigned long flags;
323df0ac8a4SKevin Cernekee 
324df0ac8a4SKevin Cernekee 	spin_lock_irqsave(&ipi_lock, flags);
325df0ac8a4SKevin Cernekee 	set_c0_cause(cpu ? C_SW1 : C_SW0);
326df0ac8a4SKevin Cernekee 	per_cpu(ipi_action_mask, cpu) |= action;
327df0ac8a4SKevin Cernekee 	irq_enable_hazard();
328df0ac8a4SKevin Cernekee 	spin_unlock_irqrestore(&ipi_lock, flags);
329df0ac8a4SKevin Cernekee }
330df0ac8a4SKevin Cernekee 
3316465460cSJonas Gorski static irqreturn_t bmips43xx_ipi_interrupt(int irq, void *dev_id)
332df0ac8a4SKevin Cernekee {
333df0ac8a4SKevin Cernekee 	unsigned long flags;
334df0ac8a4SKevin Cernekee 	int action, cpu = irq - IPI0_IRQ;
335df0ac8a4SKevin Cernekee 
336df0ac8a4SKevin Cernekee 	spin_lock_irqsave(&ipi_lock, flags);
33735898716SChristoph Lameter 	action = __this_cpu_read(ipi_action_mask);
338df0ac8a4SKevin Cernekee 	per_cpu(ipi_action_mask, cpu) = 0;
339df0ac8a4SKevin Cernekee 	clear_c0_cause(cpu ? C_SW1 : C_SW0);
340df0ac8a4SKevin Cernekee 	spin_unlock_irqrestore(&ipi_lock, flags);
341df0ac8a4SKevin Cernekee 
342df0ac8a4SKevin Cernekee 	if (action & SMP_RESCHEDULE_YOURSELF)
343df0ac8a4SKevin Cernekee 		scheduler_ipi();
344df0ac8a4SKevin Cernekee 	if (action & SMP_CALL_FUNCTION)
3454ace6139SAlex Smith 		generic_smp_call_function_interrupt();
346df0ac8a4SKevin Cernekee 
347df0ac8a4SKevin Cernekee 	return IRQ_HANDLED;
348df0ac8a4SKevin Cernekee }
349df0ac8a4SKevin Cernekee 
3506465460cSJonas Gorski static void bmips43xx_send_ipi_mask(const struct cpumask *mask,
351df0ac8a4SKevin Cernekee 	unsigned int action)
352df0ac8a4SKevin Cernekee {
353df0ac8a4SKevin Cernekee 	unsigned int i;
354df0ac8a4SKevin Cernekee 
355df0ac8a4SKevin Cernekee 	for_each_cpu(i, mask)
3566465460cSJonas Gorski 		bmips43xx_send_ipi_single(i, action);
357df0ac8a4SKevin Cernekee }
358df0ac8a4SKevin Cernekee 
359df0ac8a4SKevin Cernekee #ifdef CONFIG_HOTPLUG_CPU
360df0ac8a4SKevin Cernekee 
361df0ac8a4SKevin Cernekee static int bmips_cpu_disable(void)
362df0ac8a4SKevin Cernekee {
363df0ac8a4SKevin Cernekee 	unsigned int cpu = smp_processor_id();
364df0ac8a4SKevin Cernekee 
365df0ac8a4SKevin Cernekee 	if (cpu == 0)
366df0ac8a4SKevin Cernekee 		return -EBUSY;
367df0ac8a4SKevin Cernekee 
368df0ac8a4SKevin Cernekee 	pr_info("SMP: CPU%d is offline\n", cpu);
369df0ac8a4SKevin Cernekee 
3700b5f9c00SRusty Russell 	set_cpu_online(cpu, false);
371826e99beSJames Hogan 	calculate_cpu_foreign_map();
37251ad4aceSFlorian Fainelli 	irq_cpu_offline();
373230b6ff5SJon Fraser 	clear_c0_status(IE_IRQ5);
374df0ac8a4SKevin Cernekee 
375df0ac8a4SKevin Cernekee 	local_flush_tlb_all();
376df0ac8a4SKevin Cernekee 	local_flush_icache_range(0, ~0);
377df0ac8a4SKevin Cernekee 
378df0ac8a4SKevin Cernekee 	return 0;
379df0ac8a4SKevin Cernekee }
380df0ac8a4SKevin Cernekee 
381df0ac8a4SKevin Cernekee static void bmips_cpu_die(unsigned int cpu)
382df0ac8a4SKevin Cernekee {
383df0ac8a4SKevin Cernekee }
384df0ac8a4SKevin Cernekee 
385df0ac8a4SKevin Cernekee void __ref play_dead(void)
386df0ac8a4SKevin Cernekee {
387df0ac8a4SKevin Cernekee 	idle_task_exit();
388df0ac8a4SKevin Cernekee 
389df0ac8a4SKevin Cernekee 	/* flush data cache */
390df0ac8a4SKevin Cernekee 	_dma_cache_wback_inv(0, ~0);
391df0ac8a4SKevin Cernekee 
392df0ac8a4SKevin Cernekee 	/*
393df0ac8a4SKevin Cernekee 	 * Wakeup is on SW0 or SW1; disable everything else
394df0ac8a4SKevin Cernekee 	 * Use BEV !IV (BMIPS_WARM_RESTART_VEC) to avoid the regular Linux
395df0ac8a4SKevin Cernekee 	 * IRQ handlers; this clears ST0_IE and returns immediately.
396df0ac8a4SKevin Cernekee 	 */
397df0ac8a4SKevin Cernekee 	clear_c0_cause(CAUSEF_IV | C_SW0 | C_SW1);
398d8010cebSKevin Cernekee 	change_c0_status(
399d8010cebSKevin Cernekee 		IE_IRQ5 | bmips_tp1_irqs | IE_SW0 | IE_SW1 | ST0_IE | ST0_BEV,
400df0ac8a4SKevin Cernekee 		IE_SW0 | IE_SW1 | ST0_IE | ST0_BEV);
401df0ac8a4SKevin Cernekee 	irq_disable_hazard();
402df0ac8a4SKevin Cernekee 
403df0ac8a4SKevin Cernekee 	/*
404df0ac8a4SKevin Cernekee 	 * wait for SW interrupt from bmips_boot_secondary(), then jump
405df0ac8a4SKevin Cernekee 	 * back to start_secondary()
406df0ac8a4SKevin Cernekee 	 */
407df0ac8a4SKevin Cernekee 	__asm__ __volatile__(
408df0ac8a4SKevin Cernekee 	"	wait\n"
409df0ac8a4SKevin Cernekee 	"	j	bmips_secondary_reentry\n"
410df0ac8a4SKevin Cernekee 	: : : "memory");
411df0ac8a4SKevin Cernekee }
412df0ac8a4SKevin Cernekee 
413df0ac8a4SKevin Cernekee #endif /* CONFIG_HOTPLUG_CPU */
414df0ac8a4SKevin Cernekee 
415ff2c8252SMatt Redfearn const struct plat_smp_ops bmips43xx_smp_ops = {
416df0ac8a4SKevin Cernekee 	.smp_setup		= bmips_smp_setup,
417df0ac8a4SKevin Cernekee 	.prepare_cpus		= bmips_prepare_cpus,
418df0ac8a4SKevin Cernekee 	.boot_secondary		= bmips_boot_secondary,
419df0ac8a4SKevin Cernekee 	.smp_finish		= bmips_smp_finish,
420df0ac8a4SKevin Cernekee 	.init_secondary		= bmips_init_secondary,
4216465460cSJonas Gorski 	.send_ipi_single	= bmips43xx_send_ipi_single,
4226465460cSJonas Gorski 	.send_ipi_mask		= bmips43xx_send_ipi_mask,
4236465460cSJonas Gorski #ifdef CONFIG_HOTPLUG_CPU
4246465460cSJonas Gorski 	.cpu_disable		= bmips_cpu_disable,
4256465460cSJonas Gorski 	.cpu_die		= bmips_cpu_die,
4266465460cSJonas Gorski #endif
42762cac480SDengcheng Zhu #ifdef CONFIG_KEXEC
42862cac480SDengcheng Zhu 	.kexec_nonboot_cpu	= kexec_nonboot_cpu_jump,
42962cac480SDengcheng Zhu #endif
4306465460cSJonas Gorski };
4316465460cSJonas Gorski 
432ff2c8252SMatt Redfearn const struct plat_smp_ops bmips5000_smp_ops = {
4336465460cSJonas Gorski 	.smp_setup		= bmips_smp_setup,
4346465460cSJonas Gorski 	.prepare_cpus		= bmips_prepare_cpus,
4356465460cSJonas Gorski 	.boot_secondary		= bmips_boot_secondary,
4366465460cSJonas Gorski 	.smp_finish		= bmips_smp_finish,
4376465460cSJonas Gorski 	.init_secondary		= bmips_init_secondary,
4386465460cSJonas Gorski 	.send_ipi_single	= bmips5000_send_ipi_single,
4396465460cSJonas Gorski 	.send_ipi_mask		= bmips5000_send_ipi_mask,
440df0ac8a4SKevin Cernekee #ifdef CONFIG_HOTPLUG_CPU
441df0ac8a4SKevin Cernekee 	.cpu_disable		= bmips_cpu_disable,
442df0ac8a4SKevin Cernekee 	.cpu_die		= bmips_cpu_die,
443df0ac8a4SKevin Cernekee #endif
44462cac480SDengcheng Zhu #ifdef CONFIG_KEXEC
44562cac480SDengcheng Zhu 	.kexec_nonboot_cpu	= kexec_nonboot_cpu_jump,
44662cac480SDengcheng Zhu #endif
447df0ac8a4SKevin Cernekee };
448df0ac8a4SKevin Cernekee 
449df0ac8a4SKevin Cernekee #endif /* CONFIG_SMP */
450df0ac8a4SKevin Cernekee 
451df0ac8a4SKevin Cernekee /***********************************************************************
452df0ac8a4SKevin Cernekee  * BMIPS vector relocation
453df0ac8a4SKevin Cernekee  * This is primarily used for SMP boot, but it is applicable to some
454df0ac8a4SKevin Cernekee  * UP BMIPS systems as well.
455df0ac8a4SKevin Cernekee  ***********************************************************************/
456df0ac8a4SKevin Cernekee 
457078a55fcSPaul Gortmaker static void bmips_wr_vec(unsigned long dst, char *start, char *end)
458df0ac8a4SKevin Cernekee {
459df0ac8a4SKevin Cernekee 	memcpy((void *)dst, start, end - start);
46057b41758SPetri Gynther 	dma_cache_wback(dst, end - start);
461df0ac8a4SKevin Cernekee 	local_flush_icache_range(dst, dst + (end - start));
462df0ac8a4SKevin Cernekee 	instruction_hazard();
463df0ac8a4SKevin Cernekee }
464df0ac8a4SKevin Cernekee 
465078a55fcSPaul Gortmaker static inline void bmips_nmi_handler_setup(void)
466df0ac8a4SKevin Cernekee {
467df0ac8a4SKevin Cernekee 	bmips_wr_vec(BMIPS_NMI_RESET_VEC, &bmips_reset_nmi_vec,
468df0ac8a4SKevin Cernekee 		&bmips_reset_nmi_vec_end);
469df0ac8a4SKevin Cernekee 	bmips_wr_vec(BMIPS_WARM_RESTART_VEC, &bmips_smp_int_vec,
470df0ac8a4SKevin Cernekee 		&bmips_smp_int_vec_end);
471df0ac8a4SKevin Cernekee }
472df0ac8a4SKevin Cernekee 
473fc455787SKevin Cernekee struct reset_vec_info {
474fc455787SKevin Cernekee 	int cpu;
475fc455787SKevin Cernekee 	u32 val;
476fc455787SKevin Cernekee };
477fc455787SKevin Cernekee 
478fc455787SKevin Cernekee static void bmips_set_reset_vec_remote(void *vinfo)
479fc455787SKevin Cernekee {
480fc455787SKevin Cernekee 	struct reset_vec_info *info = vinfo;
481fc455787SKevin Cernekee 	int shift = info->cpu & 0x01 ? 16 : 0;
482fc455787SKevin Cernekee 	u32 mask = ~(0xffff << shift), val = info->val >> 16;
483fc455787SKevin Cernekee 
484fc455787SKevin Cernekee 	preempt_disable();
485fc455787SKevin Cernekee 	if (smp_processor_id() > 0) {
486fc455787SKevin Cernekee 		smp_call_function_single(0, &bmips_set_reset_vec_remote,
487fc455787SKevin Cernekee 					 info, 1);
488fc455787SKevin Cernekee 	} else {
489fc455787SKevin Cernekee 		if (info->cpu & 0x02) {
490fc455787SKevin Cernekee 			/* BMIPS5200 "should" use mask/shift, but it's buggy */
491fc455787SKevin Cernekee 			bmips_write_zscm_reg(0xa0, (val << 16) | val);
492fc455787SKevin Cernekee 			bmips_read_zscm_reg(0xa0);
493fc455787SKevin Cernekee 		} else {
494fc455787SKevin Cernekee 			write_c0_brcm_bootvec((read_c0_brcm_bootvec() & mask) |
495fc455787SKevin Cernekee 					      (val << shift));
496fc455787SKevin Cernekee 		}
497fc455787SKevin Cernekee 	}
498fc455787SKevin Cernekee 	preempt_enable();
499fc455787SKevin Cernekee }
500fc455787SKevin Cernekee 
501fc455787SKevin Cernekee static void bmips_set_reset_vec(int cpu, u32 val)
502fc455787SKevin Cernekee {
503fc455787SKevin Cernekee 	struct reset_vec_info info;
504fc455787SKevin Cernekee 
505fc455787SKevin Cernekee 	if (current_cpu_type() == CPU_BMIPS5000) {
506fc455787SKevin Cernekee 		/* this needs to run from CPU0 (which is always online) */
507fc455787SKevin Cernekee 		info.cpu = cpu;
508fc455787SKevin Cernekee 		info.val = val;
509fc455787SKevin Cernekee 		bmips_set_reset_vec_remote(&info);
510fc455787SKevin Cernekee 	} else {
511fc455787SKevin Cernekee 		void __iomem *cbr = BMIPS_GET_CBR();
512fc455787SKevin Cernekee 
513fc455787SKevin Cernekee 		if (cpu == 0)
514fc455787SKevin Cernekee 			__raw_writel(val, cbr + BMIPS_RELO_VECTOR_CONTROL_0);
515fc455787SKevin Cernekee 		else {
516fc455787SKevin Cernekee 			if (current_cpu_type() != CPU_BMIPS4380)
517fc455787SKevin Cernekee 				return;
518fc455787SKevin Cernekee 			__raw_writel(val, cbr + BMIPS_RELO_VECTOR_CONTROL_1);
519fc455787SKevin Cernekee 		}
520fc455787SKevin Cernekee 	}
521fc455787SKevin Cernekee 	__sync();
522fc455787SKevin Cernekee 	back_to_back_c0_hazard();
523fc455787SKevin Cernekee }
524fc455787SKevin Cernekee 
525078a55fcSPaul Gortmaker void bmips_ebase_setup(void)
526df0ac8a4SKevin Cernekee {
527df0ac8a4SKevin Cernekee 	unsigned long new_ebase = ebase;
528df0ac8a4SKevin Cernekee 
529df0ac8a4SKevin Cernekee 	BUG_ON(ebase != CKSEG0);
530df0ac8a4SKevin Cernekee 
5316465460cSJonas Gorski 	switch (current_cpu_type()) {
5326465460cSJonas Gorski 	case CPU_BMIPS4350:
533df0ac8a4SKevin Cernekee 		/*
534df0ac8a4SKevin Cernekee 		 * BMIPS4350 cannot relocate the normal vectors, but it
535df0ac8a4SKevin Cernekee 		 * can relocate the BEV=1 vectors.  So CPU1 starts up at
536df0ac8a4SKevin Cernekee 		 * the relocated BEV=1, IV=0 general exception vector @
537df0ac8a4SKevin Cernekee 		 * 0xa000_0380.
538df0ac8a4SKevin Cernekee 		 *
539df0ac8a4SKevin Cernekee 		 * set_uncached_handler() is used here because:
540df0ac8a4SKevin Cernekee 		 *  - CPU1 will run this from uncached space
541df0ac8a4SKevin Cernekee 		 *  - None of the cacheflush functions are set up yet
542df0ac8a4SKevin Cernekee 		 */
543df0ac8a4SKevin Cernekee 		set_uncached_handler(BMIPS_WARM_RESTART_VEC - CKSEG0,
544df0ac8a4SKevin Cernekee 			&bmips_smp_int_vec, 0x80);
545df0ac8a4SKevin Cernekee 		__sync();
546df0ac8a4SKevin Cernekee 		return;
547fa010672SJon Fraser 	case CPU_BMIPS3300:
5486465460cSJonas Gorski 	case CPU_BMIPS4380:
549df0ac8a4SKevin Cernekee 		/*
550df0ac8a4SKevin Cernekee 		 * 0x8000_0000: reset/NMI (initially in kseg1)
551df0ac8a4SKevin Cernekee 		 * 0x8000_0400: normal vectors
552df0ac8a4SKevin Cernekee 		 */
553df0ac8a4SKevin Cernekee 		new_ebase = 0x80000400;
554fc455787SKevin Cernekee 		bmips_set_reset_vec(0, RESET_FROM_KSEG0);
5556465460cSJonas Gorski 		break;
5566465460cSJonas Gorski 	case CPU_BMIPS5000:
557df0ac8a4SKevin Cernekee 		/*
558df0ac8a4SKevin Cernekee 		 * 0x8000_0000: reset/NMI (initially in kseg1)
559df0ac8a4SKevin Cernekee 		 * 0x8000_1000: normal vectors
560df0ac8a4SKevin Cernekee 		 */
561df0ac8a4SKevin Cernekee 		new_ebase = 0x80001000;
562fc455787SKevin Cernekee 		bmips_set_reset_vec(0, RESET_FROM_KSEG0);
563df0ac8a4SKevin Cernekee 		write_c0_ebase(new_ebase);
5646465460cSJonas Gorski 		break;
5656465460cSJonas Gorski 	default:
566df0ac8a4SKevin Cernekee 		return;
5676465460cSJonas Gorski 	}
5686465460cSJonas Gorski 
569df0ac8a4SKevin Cernekee 	board_nmi_handler_setup = &bmips_nmi_handler_setup;
570df0ac8a4SKevin Cernekee 	ebase = new_ebase;
571df0ac8a4SKevin Cernekee }
572df0ac8a4SKevin Cernekee 
573df0ac8a4SKevin Cernekee asmlinkage void __weak plat_wired_tlb_setup(void)
574df0ac8a4SKevin Cernekee {
575df0ac8a4SKevin Cernekee 	/*
576df0ac8a4SKevin Cernekee 	 * Called when starting/restarting a secondary CPU.
577df0ac8a4SKevin Cernekee 	 * Kernel stacks and other important data might only be accessible
578df0ac8a4SKevin Cernekee 	 * once the wired entries are present.
579df0ac8a4SKevin Cernekee 	 */
580df0ac8a4SKevin Cernekee }
581738a3f79SFlorian Fainelli 
582627f4a2bSJaedon Shin void bmips_cpu_setup(void)
583738a3f79SFlorian Fainelli {
584738a3f79SFlorian Fainelli 	void __iomem __maybe_unused *cbr = BMIPS_GET_CBR();
585738a3f79SFlorian Fainelli 	u32 __maybe_unused cfg;
586738a3f79SFlorian Fainelli 
587738a3f79SFlorian Fainelli 	switch (current_cpu_type()) {
588738a3f79SFlorian Fainelli 	case CPU_BMIPS3300:
589738a3f79SFlorian Fainelli 		/* Set BIU to async mode */
590738a3f79SFlorian Fainelli 		set_c0_brcm_bus_pll(BIT(22));
591738a3f79SFlorian Fainelli 		__sync();
592738a3f79SFlorian Fainelli 
593738a3f79SFlorian Fainelli 		/* put the BIU back in sync mode */
594738a3f79SFlorian Fainelli 		clear_c0_brcm_bus_pll(BIT(22));
595738a3f79SFlorian Fainelli 
596738a3f79SFlorian Fainelli 		/* clear BHTD to enable branch history table */
597738a3f79SFlorian Fainelli 		clear_c0_brcm_reset(BIT(16));
598738a3f79SFlorian Fainelli 
599738a3f79SFlorian Fainelli 		/* Flush and enable RAC */
600738a3f79SFlorian Fainelli 		cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG);
601ea4b3afeSJaedon Shin 		__raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG);
602738a3f79SFlorian Fainelli 		__raw_readl(cbr + BMIPS_RAC_CONFIG);
603738a3f79SFlorian Fainelli 
604738a3f79SFlorian Fainelli 		cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG);
605ea4b3afeSJaedon Shin 		__raw_writel(cfg | 0xf, cbr + BMIPS_RAC_CONFIG);
606738a3f79SFlorian Fainelli 		__raw_readl(cbr + BMIPS_RAC_CONFIG);
607738a3f79SFlorian Fainelli 
608738a3f79SFlorian Fainelli 		cfg = __raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE);
609738a3f79SFlorian Fainelli 		__raw_writel(cfg | 0x0fff0000, cbr + BMIPS_RAC_ADDRESS_RANGE);
610738a3f79SFlorian Fainelli 		__raw_readl(cbr + BMIPS_RAC_ADDRESS_RANGE);
611738a3f79SFlorian Fainelli 		break;
612738a3f79SFlorian Fainelli 
613738a3f79SFlorian Fainelli 	case CPU_BMIPS4380:
614738a3f79SFlorian Fainelli 		/* CBG workaround for early BMIPS4380 CPUs */
615738a3f79SFlorian Fainelli 		switch (read_c0_prid()) {
616738a3f79SFlorian Fainelli 		case 0x2a040:
617738a3f79SFlorian Fainelli 		case 0x2a042:
618738a3f79SFlorian Fainelli 		case 0x2a044:
619738a3f79SFlorian Fainelli 		case 0x2a060:
620738a3f79SFlorian Fainelli 			cfg = __raw_readl(cbr + BMIPS_L2_CONFIG);
621738a3f79SFlorian Fainelli 			__raw_writel(cfg & ~0x07000000, cbr + BMIPS_L2_CONFIG);
622738a3f79SFlorian Fainelli 			__raw_readl(cbr + BMIPS_L2_CONFIG);
623738a3f79SFlorian Fainelli 		}
624738a3f79SFlorian Fainelli 
625738a3f79SFlorian Fainelli 		/* clear BHTD to enable branch history table */
626738a3f79SFlorian Fainelli 		clear_c0_brcm_config_0(BIT(21));
627738a3f79SFlorian Fainelli 
628738a3f79SFlorian Fainelli 		/* XI/ROTR enable */
629738a3f79SFlorian Fainelli 		set_c0_brcm_config_0(BIT(23));
630738a3f79SFlorian Fainelli 		set_c0_brcm_cmt_ctrl(BIT(15));
631738a3f79SFlorian Fainelli 		break;
632738a3f79SFlorian Fainelli 
633738a3f79SFlorian Fainelli 	case CPU_BMIPS5000:
634738a3f79SFlorian Fainelli 		/* enable RDHWR, BRDHWR */
635738a3f79SFlorian Fainelli 		set_c0_brcm_config(BIT(17) | BIT(21));
636738a3f79SFlorian Fainelli 
637738a3f79SFlorian Fainelli 		/* Disable JTB */
638738a3f79SFlorian Fainelli 		__asm__ __volatile__(
639738a3f79SFlorian Fainelli 		"	.set	noreorder\n"
640738a3f79SFlorian Fainelli 		"	li	$8, 0x5a455048\n"
641738a3f79SFlorian Fainelli 		"	.word	0x4088b00f\n"	/* mtc0	t0, $22, 15 */
642738a3f79SFlorian Fainelli 		"	.word	0x4008b008\n"	/* mfc0	t0, $22, 8 */
643738a3f79SFlorian Fainelli 		"	li	$9, 0x00008000\n"
644738a3f79SFlorian Fainelli 		"	or	$8, $8, $9\n"
645738a3f79SFlorian Fainelli 		"	.word	0x4088b008\n"	/* mtc0	t0, $22, 8 */
646738a3f79SFlorian Fainelli 		"	sync\n"
647738a3f79SFlorian Fainelli 		"	li	$8, 0x0\n"
648738a3f79SFlorian Fainelli 		"	.word	0x4088b00f\n"	/* mtc0	t0, $22, 15 */
649738a3f79SFlorian Fainelli 		"	.set	reorder\n"
650738a3f79SFlorian Fainelli 		: : : "$8", "$9");
651738a3f79SFlorian Fainelli 
652738a3f79SFlorian Fainelli 		/* XI enable */
653738a3f79SFlorian Fainelli 		set_c0_brcm_config(BIT(27));
654738a3f79SFlorian Fainelli 
655738a3f79SFlorian Fainelli 		/* enable MIPS32R2 ROR instruction for XI TLB handlers */
656738a3f79SFlorian Fainelli 		__asm__ __volatile__(
657738a3f79SFlorian Fainelli 		"	li	$8, 0x5a455048\n"
658738a3f79SFlorian Fainelli 		"	.word	0x4088b00f\n"	/* mtc0 $8, $22, 15 */
659738a3f79SFlorian Fainelli 		"	nop; nop; nop\n"
660738a3f79SFlorian Fainelli 		"	.word	0x4008b008\n"	/* mfc0 $8, $22, 8 */
661738a3f79SFlorian Fainelli 		"	lui	$9, 0x0100\n"
662738a3f79SFlorian Fainelli 		"	or	$8, $9\n"
663738a3f79SFlorian Fainelli 		"	.word	0x4088b008\n"	/* mtc0 $8, $22, 8 */
664738a3f79SFlorian Fainelli 		: : : "$8", "$9");
665738a3f79SFlorian Fainelli 		break;
666738a3f79SFlorian Fainelli 	}
667738a3f79SFlorian Fainelli }
668