aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/ddb5xxx/ddb5477/irq.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/mips/ddb5xxx/ddb5477/irq.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/mips/ddb5xxx/ddb5477/irq.c')
-rw-r--r--arch/mips/ddb5xxx/ddb5477/irq.c199
1 files changed, 199 insertions, 0 deletions
diff --git a/arch/mips/ddb5xxx/ddb5477/irq.c b/arch/mips/ddb5xxx/ddb5477/irq.c
new file mode 100644
index 000000000000..5f027bfa4af8
--- /dev/null
+++ b/arch/mips/ddb5xxx/ddb5477/irq.c
@@ -0,0 +1,199 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
4 *
5 * arch/mips/ddb5xxx/ddb5477/irq.c
6 * The irq setup and misc routines for DDB5476.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13#include <linux/config.h>
14#include <linux/init.h>
15#include <linux/interrupt.h>
16#include <linux/irq.h>
17#include <linux/types.h>
18#include <linux/ptrace.h>
19
20#include <asm/i8259.h>
21#include <asm/system.h>
22#include <asm/mipsregs.h>
23#include <asm/debug.h>
24#include <asm/addrspace.h>
25#include <asm/bootinfo.h>
26
27#include <asm/ddb5xxx/ddb5xxx.h>
28
29
30/*
31 * IRQ mapping
32 *
33 * 0-7: 8 CPU interrupts
34 * 0 - software interrupt 0
35 * 1 - software interrupt 1
36 * 2 - most Vrc5477 interrupts are routed to this pin
37 * 3 - (optional) some other interrupts routed to this pin for debugg
38 * 4 - not used
39 * 5 - not used
40 * 6 - not used
41 * 7 - cpu timer (used by default)
42 *
43 * 8-39: 32 Vrc5477 interrupt sources
44 * (refer to the Vrc5477 manual)
45 */
46
47#define PCI0 DDB_INTPPES0
48#define PCI1 DDB_INTPPES1
49
50#define ACTIVE_LOW 1
51#define ACTIVE_HIGH 0
52
53#define LEVEL_SENSE 2
54#define EDGE_TRIGGER 0
55
56#define INTA 0
57#define INTB 1
58#define INTC 2
59#define INTD 3
60#define INTE 4
61
62static inline void
63set_pci_int_attr(u32 pci, u32 intn, u32 active, u32 trigger)
64{
65 u32 reg_value;
66 u32 reg_bitmask;
67
68 reg_value = ddb_in32(pci);
69 reg_bitmask = 0x3 << (intn * 2);
70
71 reg_value &= ~reg_bitmask;
72 reg_value |= (active | trigger) << (intn * 2);
73 ddb_out32(pci, reg_value);
74}
75
76extern void vrc5477_irq_init(u32 base);
77extern void mips_cpu_irq_init(u32 base);
78extern asmlinkage void ddb5477_handle_int(void);
79extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
80static struct irqaction irq_cascade = { no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL };
81
82void __init arch_init_irq(void)
83{
84 /* by default, we disable all interrupts and route all vrc5477
85 * interrupts to pin 0 (irq 2) */
86 ddb_out32(DDB_INTCTRL0, 0);
87 ddb_out32(DDB_INTCTRL1, 0);
88 ddb_out32(DDB_INTCTRL2, 0);
89 ddb_out32(DDB_INTCTRL3, 0);
90
91 clear_c0_status(0xff00);
92 set_c0_status(0x0400);
93
94 /* setup PCI interrupt attributes */
95 set_pci_int_attr(PCI0, INTA, ACTIVE_LOW, LEVEL_SENSE);
96 set_pci_int_attr(PCI0, INTB, ACTIVE_LOW, LEVEL_SENSE);
97 if (mips_machtype == MACH_NEC_ROCKHOPPERII)
98 set_pci_int_attr(PCI0, INTC, ACTIVE_HIGH, LEVEL_SENSE);
99 else
100 set_pci_int_attr(PCI0, INTC, ACTIVE_LOW, LEVEL_SENSE);
101 set_pci_int_attr(PCI0, INTD, ACTIVE_LOW, LEVEL_SENSE);
102 set_pci_int_attr(PCI0, INTE, ACTIVE_LOW, LEVEL_SENSE);
103
104 set_pci_int_attr(PCI1, INTA, ACTIVE_LOW, LEVEL_SENSE);
105 set_pci_int_attr(PCI1, INTB, ACTIVE_LOW, LEVEL_SENSE);
106 set_pci_int_attr(PCI1, INTC, ACTIVE_LOW, LEVEL_SENSE);
107 set_pci_int_attr(PCI1, INTD, ACTIVE_LOW, LEVEL_SENSE);
108 set_pci_int_attr(PCI1, INTE, ACTIVE_LOW, LEVEL_SENSE);
109
110 /*
111 * for debugging purpose, we enable several error interrupts
112 * and route them to pin 1. (IP3)
113 */
114 /* cpu parity check - 0 */
115 ll_vrc5477_irq_route(0, 1); ll_vrc5477_irq_enable(0);
116 /* cpu no-target decode - 1 */
117 ll_vrc5477_irq_route(1, 1); ll_vrc5477_irq_enable(1);
118 /* local bus read time-out - 7 */
119 ll_vrc5477_irq_route(7, 1); ll_vrc5477_irq_enable(7);
120 /* PCI SERR# - 14 */
121 ll_vrc5477_irq_route(14, 1); ll_vrc5477_irq_enable(14);
122 /* PCI internal error - 15 */
123 ll_vrc5477_irq_route(15, 1); ll_vrc5477_irq_enable(15);
124 /* IOPCI SERR# - 30 */
125 ll_vrc5477_irq_route(30, 1); ll_vrc5477_irq_enable(30);
126 /* IOPCI internal error - 31 */
127 ll_vrc5477_irq_route(31, 1); ll_vrc5477_irq_enable(31);
128
129 /* init all controllers */
130 init_i8259_irqs();
131 mips_cpu_irq_init(CPU_IRQ_BASE);
132 vrc5477_irq_init(VRC5477_IRQ_BASE);
133
134
135 /* setup cascade interrupts */
136 setup_irq(VRC5477_IRQ_BASE + VRC5477_I8259_CASCADE, &irq_cascade);
137 setup_irq(CPU_IRQ_BASE + CPU_VRC5477_CASCADE, &irq_cascade);
138
139 /* hook up the first-level interrupt handler */
140 set_except_vector(0, ddb5477_handle_int);
141}
142
143u8 i8259_interrupt_ack(void)
144{
145 u8 irq;
146 u32 reg;
147
148 /* Set window 0 for interrupt acknowledge */
149 reg = ddb_in32(DDB_PCIINIT10);
150
151 ddb_set_pmr(DDB_PCIINIT10, DDB_PCICMD_IACK, 0, DDB_PCI_ACCESS_32);
152 irq = *(volatile u8 *) KSEG1ADDR(DDB_PCI_IACK_BASE);
153 ddb_out32(DDB_PCIINIT10, reg);
154
155 /* i8259.c set the base vector to be 0x0 */
156 return irq + I8259_IRQ_BASE;
157}
158/*
159 * the first level int-handler will jump here if it is a vrc5477 irq
160 */
161#define NUM_5477_IRQS 32
162asmlinkage void
163vrc5477_irq_dispatch(struct pt_regs *regs)
164{
165 u32 intStatus;
166 u32 bitmask;
167 u32 i;
168
169 db_assert(ddb_in32(DDB_INT2STAT) == 0);
170 db_assert(ddb_in32(DDB_INT3STAT) == 0);
171 db_assert(ddb_in32(DDB_INT4STAT) == 0);
172 db_assert(ddb_in32(DDB_NMISTAT) == 0);
173
174 if (ddb_in32(DDB_INT1STAT) != 0) {
175#if defined(CONFIG_RUNTIME_DEBUG)
176 vrc5477_show_int_regs();
177#endif
178 panic("error interrupt has happened.");
179 }
180
181 intStatus = ddb_in32(DDB_INT0STAT);
182
183 if (mips_machtype == MACH_NEC_ROCKHOPPERII) {
184 /* check for i8259 interrupts */
185 if (intStatus & (1 << VRC5477_I8259_CASCADE)) {
186 int i8259_irq = i8259_interrupt_ack();
187 do_IRQ(I8259_IRQ_BASE + i8259_irq, regs);
188 return;
189 }
190 }
191
192 for (i=0, bitmask=1; i<= NUM_5477_IRQS; bitmask <<=1, i++) {
193 /* do we need to "and" with the int mask? */
194 if (intStatus & bitmask) {
195 do_IRQ(VRC5477_IRQ_BASE + i, regs);
196 return;
197 }
198 }
199}