[mcs814x] nuport-mac: properly protect the phy interrupt handler
[openwrt.git] / target / linux / lantiq / patches-3.3 / 0033-MIPS-lantiq-add-ipi-handlers-to-make-vsmp-work.patch
1 From ec3b7d909fcc78e12625a4dd7ca27f63dddb3fa3 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Tue, 21 Feb 2012 21:09:01 +0100
4 Subject: [PATCH 33/70] MIPS: lantiq: add ipi handlers to make vsmp work
5
6 Add IPI handlers to the interrupt code. This patch makes MIPS_MT_SMP work
7 on lantiq SoCs.
8
9 Signed-off-by: John Crispin <blogic@openwrt.org>
10 ---
11  arch/mips/lantiq/irq.c  |   61 +++++++++++++++++++++++++++++++++++++++++++++++
12  arch/mips/lantiq/prom.c |    5 ++++
13  2 files changed, 66 insertions(+), 0 deletions(-)
14
15 --- a/arch/mips/lantiq/irq.c
16 +++ b/arch/mips/lantiq/irq.c
17 @@ -9,6 +9,7 @@
18  
19  #include <linux/interrupt.h>
20  #include <linux/ioport.h>
21 +#include <linux/sched.h>
22  
23  #include <asm/bootinfo.h>
24  #include <asm/irq_cpu.h>
25 @@ -54,6 +55,14 @@
26  #define ltq_eiu_w32(x, y)      ltq_w32((x), ltq_eiu_membase + (y))
27  #define ltq_eiu_r32(x)         ltq_r32(ltq_eiu_membase + (x))
28  
29 +/* our 2 ipi interrupts for VSMP */
30 +#define MIPS_CPU_IPI_RESCHED_IRQ       0
31 +#define MIPS_CPU_IPI_CALL_IRQ          1
32 +
33 +#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_MIPS_MT_SMTC)
34 +int gic_present;
35 +#endif
36 +
37  static unsigned short ltq_eiu_irq[MAX_EIU] = {
38         LTQ_EIU_IR0,
39         LTQ_EIU_IR1,
40 @@ -219,6 +228,47 @@ static void ltq_hw5_irqdispatch(void)
41         do_IRQ(MIPS_CPU_TIMER_IRQ);
42  }
43  
44 +#ifdef CONFIG_MIPS_MT_SMP
45 +void __init arch_init_ipiirq(int irq, struct irqaction *action)
46 +{
47 +       setup_irq(irq, action);
48 +       irq_set_handler(irq, handle_percpu_irq);
49 +}
50 +
51 +static void ltq_sw0_irqdispatch(void)
52 +{
53 +       do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_RESCHED_IRQ);
54 +}
55 +
56 +static void ltq_sw1_irqdispatch(void)
57 +{
58 +       do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_CALL_IRQ);
59 +}
60 +static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id)
61 +{
62 +       scheduler_ipi();
63 +       return IRQ_HANDLED;
64 +}
65 +
66 +static irqreturn_t ipi_call_interrupt(int irq, void *dev_id)
67 +{
68 +       smp_call_function_interrupt();
69 +       return IRQ_HANDLED;
70 +}
71 +
72 +static struct irqaction irq_resched = {
73 +       .handler        = ipi_resched_interrupt,
74 +       .flags          = IRQF_PERCPU,
75 +       .name           = "IPI_resched"
76 +};
77 +
78 +static struct irqaction irq_call = {
79 +       .handler        = ipi_call_interrupt,
80 +       .flags          = IRQF_PERCPU,
81 +       .name           = "IPI_call"
82 +};
83 +#endif
84 +
85  asmlinkage void plat_irq_dispatch(void)
86  {
87         unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM;
88 @@ -313,6 +363,17 @@ void __init arch_init_irq(void)
89                         irq_set_chip_and_handler(i, &ltq_irq_type,
90                                 handle_level_irq);
91  
92 +#if defined(CONFIG_MIPS_MT_SMP)
93 +       if (cpu_has_vint) {
94 +               pr_info("Setting up IPI vectored interrupts\n");
95 +               set_vi_handler(MIPS_CPU_IPI_RESCHED_IRQ, ltq_sw0_irqdispatch);
96 +               set_vi_handler(MIPS_CPU_IPI_CALL_IRQ, ltq_sw1_irqdispatch);
97 +       }
98 +       arch_init_ipiirq(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_RESCHED_IRQ,
99 +               &irq_resched);
100 +       arch_init_ipiirq(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_CALL_IRQ, &irq_call);
101 +#endif
102 +
103  #if !defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_MIPS_MT_SMTC)
104         set_c0_status(IE_IRQ0 | IE_IRQ1 | IE_IRQ2 |
105                 IE_IRQ3 | IE_IRQ4 | IE_IRQ5);
106 --- a/arch/mips/lantiq/prom.c
107 +++ b/arch/mips/lantiq/prom.c
108 @@ -108,4 +108,9 @@ void __init prom_init(void)
109         soc_info.sys_type[LTQ_SYS_TYPE_LEN - 1] = '\0';
110         pr_info("SoC: %s\n", soc_info.sys_type);
111         prom_init_cmdline();
112 +
113 +#if defined(CONFIG_MIPS_MT_SMP)
114 +       if (register_vsmp_smp_ops())
115 +               panic("failed to register_vsmp_smp_ops()");
116 +#endif
117  }