blob: f914c753de21dcc9982a3f13ec007db9069d42a4 [file] [log] [blame]
Marc St-Jean35832e22007-06-14 15:54:47 -06001/*
2 * IRQ vector handles
3 *
4 * Copyright (C) 1995, 1996, 1997, 2003 by Ralf Baechle
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/irq.h>
14#include <linux/interrupt.h>
15#include <linux/ptrace.h>
16#include <linux/time.h>
17
18#include <asm/irq_cpu.h>
19
20#include <msp_int.h>
21
Marc St-Jean35832e22007-06-14 15:54:47 -060022/* SLP bases systems */
23extern void msp_slp_irq_init(void);
24extern void msp_slp_irq_dispatch(void);
25
26/* CIC based systems */
27extern void msp_cic_irq_init(void);
28extern void msp_cic_irq_dispatch(void);
29
Anoop P A92592c92011-01-25 13:50:10 +053030/* VSMP support init */
31extern void msp_vsmp_int_init(void);
32
33/* vectored interrupt implementation */
34
Ralf Baechleb633648c52014-05-23 16:29:44 +020035/* SW0/1 interrupts are used for SMP */
Anoop P A92592c92011-01-25 13:50:10 +053036static inline void mac0_int_dispatch(void) { do_IRQ(MSP_INT_MAC0); }
37static inline void mac1_int_dispatch(void) { do_IRQ(MSP_INT_MAC1); }
38static inline void mac2_int_dispatch(void) { do_IRQ(MSP_INT_SAR); }
39static inline void usb_int_dispatch(void) { do_IRQ(MSP_INT_USB); }
40static inline void sec_int_dispatch(void) { do_IRQ(MSP_INT_SEC); }
41
Marc St-Jean35832e22007-06-14 15:54:47 -060042/*
43 * The PMC-Sierra MSP interrupts are arranged in a 3 level cascaded
Ralf Baechle70342282013-01-22 12:59:30 +010044 * hierarchical system. The first level are the direct MIPS interrupts
Marc St-Jean35832e22007-06-14 15:54:47 -060045 * and are assigned the interrupt range 0-7. The second level is the SLM
Ralf Baechle70342282013-01-22 12:59:30 +010046 * interrupt controller and is assigned the range 8-39. The third level
Marc St-Jean35832e22007-06-14 15:54:47 -060047 * comprises the Peripherial block, the PCI block, the PCI MSI block and
48 * the SLP. The PCI interrupts and the SLP errors are handled by the
49 * relevant subsystems so the core interrupt code needs only concern
50 * itself with the Peripheral block. These are assigned interrupts in
51 * the range 40-71.
52 */
53
Sergey Ryazanovb3804d82014-08-14 02:09:35 +040054asmlinkage void plat_irq_dispatch(void)
Marc St-Jean35832e22007-06-14 15:54:47 -060055{
56 u32 pending;
57
58 pending = read_c0_status() & read_c0_cause();
59
60 /*
61 * jump to the correct interrupt routine
62 * These are arranged in priority order and the timer
63 * comes first!
64 */
65
66#ifdef CONFIG_IRQ_MSP_CIC /* break out the CIC stuff for now */
67 if (pending & C_IRQ4) /* do the peripherals first, that's the timer */
68 msp_cic_irq_dispatch();
69
70 else if (pending & C_IRQ0)
71 do_IRQ(MSP_INT_MAC0);
72
73 else if (pending & C_IRQ1)
74 do_IRQ(MSP_INT_MAC1);
75
76 else if (pending & C_IRQ2)
77 do_IRQ(MSP_INT_USB);
78
79 else if (pending & C_IRQ3)
80 do_IRQ(MSP_INT_SAR);
81
82 else if (pending & C_IRQ5)
83 do_IRQ(MSP_INT_SEC);
84
85#else
86 if (pending & C_IRQ5)
87 do_IRQ(MSP_INT_TIMER);
88
89 else if (pending & C_IRQ0)
90 do_IRQ(MSP_INT_MAC0);
91
92 else if (pending & C_IRQ1)
93 do_IRQ(MSP_INT_MAC1);
94
95 else if (pending & C_IRQ3)
96 do_IRQ(MSP_INT_VE);
97
98 else if (pending & C_IRQ4)
99 msp_slp_irq_dispatch();
100#endif
101
102 else if (pending & C_SW0) /* do software after hardware */
103 do_IRQ(MSP_INT_SW0);
104
105 else if (pending & C_SW1)
106 do_IRQ(MSP_INT_SW1);
107}
108
Anoop P A92592c92011-01-25 13:50:10 +0530109static struct irqaction cic_cascade_msp = {
Marc St-Jean35832e22007-06-14 15:54:47 -0600110 .handler = no_action,
Ralf Baechlea705dc72011-07-28 13:31:48 +0100111 .name = "MSP CIC cascade",
Wu Zhangjin5a4a4ad2011-07-23 12:41:24 +0000112 .flags = IRQF_NO_THREAD,
Marc St-Jean35832e22007-06-14 15:54:47 -0600113};
114
Anoop P A92592c92011-01-25 13:50:10 +0530115static struct irqaction per_cascade_msp = {
116 .handler = no_action,
Ralf Baechlea705dc72011-07-28 13:31:48 +0100117 .name = "MSP PER cascade",
Wu Zhangjin5a4a4ad2011-07-23 12:41:24 +0000118 .flags = IRQF_NO_THREAD,
Anoop P A92592c92011-01-25 13:50:10 +0530119};
Marc St-Jean35832e22007-06-14 15:54:47 -0600120
121void __init arch_init_irq(void)
122{
Anoop P A92592c92011-01-25 13:50:10 +0530123 /* assume we'll be using vectored interrupt mode except in UP mode*/
124#ifdef CONFIG_MIPS_MT
125 BUG_ON(!cpu_has_vint);
126#endif
Marc St-Jean35832e22007-06-14 15:54:47 -0600127 /* initialize the 1st-level CPU based interrupt controller */
128 mips_cpu_irq_init();
129
130#ifdef CONFIG_IRQ_MSP_CIC
131 msp_cic_irq_init();
Anoop P A92592c92011-01-25 13:50:10 +0530132#ifdef CONFIG_MIPS_MT
133 set_vi_handler(MSP_INT_CIC, msp_cic_irq_dispatch);
134 set_vi_handler(MSP_INT_MAC0, mac0_int_dispatch);
135 set_vi_handler(MSP_INT_MAC1, mac1_int_dispatch);
136 set_vi_handler(MSP_INT_SAR, mac2_int_dispatch);
137 set_vi_handler(MSP_INT_USB, usb_int_dispatch);
138 set_vi_handler(MSP_INT_SEC, sec_int_dispatch);
139#ifdef CONFIG_MIPS_MT_SMP
140 msp_vsmp_int_init();
Anoop P A92592c92011-01-25 13:50:10 +0530141#endif /* CONFIG_MIPS_MT_SMP */
142#endif /* CONFIG_MIPS_MT */
Marc St-Jean35832e22007-06-14 15:54:47 -0600143 /* setup the cascaded interrupts */
Anoop P A92592c92011-01-25 13:50:10 +0530144 setup_irq(MSP_INT_CIC, &cic_cascade_msp);
145 setup_irq(MSP_INT_PER, &per_cascade_msp);
146
Marc St-Jean35832e22007-06-14 15:54:47 -0600147#else
Ralf Baechleb633648c52014-05-23 16:29:44 +0200148 /*
149 * Setup the 2nd-level SLP register based interrupt controller.
150 * VSMP support support is not enabled for SLP.
151 */
Marc St-Jean35832e22007-06-14 15:54:47 -0600152 msp_slp_irq_init();
153
154 /* setup the cascaded SLP/PER interrupts */
Anoop P A92592c92011-01-25 13:50:10 +0530155 setup_irq(MSP_INT_SLP, &cic_cascade_msp);
156 setup_irq(MSP_INT_PER, &per_cascade_msp);
Marc St-Jean35832e22007-06-14 15:54:47 -0600157#endif
158}