Linux-libre 5.4.47-gnu
[librecmc/linux-libre.git] / arch / mips / pmcs-msp71xx / msp_smp.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2000, 2001, 2004 MIPS Technologies, Inc.
4  * Copyright (C) 2001 Ralf Baechle
5  * Copyright (C) 2010 PMC-Sierra, Inc.
6  *
7  *  VSMP support for MSP platforms . Derived from malta vsmp support.
8  */
9 #include <linux/smp.h>
10 #include <linux/interrupt.h>
11
12 #include <asm/setup.h>
13
14 #ifdef CONFIG_MIPS_MT_SMP
15 #define MIPS_CPU_IPI_RESCHED_IRQ 0      /* SW int 0 for resched */
16 #define MIPS_CPU_IPI_CALL_IRQ 1         /* SW int 1 for call */
17
18
19 static void ipi_resched_dispatch(void)
20 {
21         do_IRQ(MIPS_CPU_IPI_RESCHED_IRQ);
22 }
23
24 static void ipi_call_dispatch(void)
25 {
26         do_IRQ(MIPS_CPU_IPI_CALL_IRQ);
27 }
28
29 static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id)
30 {
31         return IRQ_HANDLED;
32 }
33
34 static irqreturn_t ipi_call_interrupt(int irq, void *dev_id)
35 {
36         generic_smp_call_function_interrupt();
37
38         return IRQ_HANDLED;
39 }
40
41 static struct irqaction irq_resched = {
42         .handler        = ipi_resched_interrupt,
43         .flags          = IRQF_PERCPU,
44         .name           = "IPI_resched"
45 };
46
47 static struct irqaction irq_call = {
48         .handler        = ipi_call_interrupt,
49         .flags          = IRQF_PERCPU,
50         .name           = "IPI_call"
51 };
52
53 void __init arch_init_ipiirq(int irq, struct irqaction *action)
54 {
55         setup_irq(irq, action);
56         irq_set_handler(irq, handle_percpu_irq);
57 }
58
59 void __init msp_vsmp_int_init(void)
60 {
61         set_vi_handler(MIPS_CPU_IPI_RESCHED_IRQ, ipi_resched_dispatch);
62         set_vi_handler(MIPS_CPU_IPI_CALL_IRQ, ipi_call_dispatch);
63         arch_init_ipiirq(MIPS_CPU_IPI_RESCHED_IRQ, &irq_resched);
64         arch_init_ipiirq(MIPS_CPU_IPI_CALL_IRQ, &irq_call);
65 }
66 #endif /* CONFIG_MIPS_MT_SMP */