diff options
Diffstat (limited to 'arch/ppc64/kernel/iSeries_irq.c')
-rw-r--r-- | arch/ppc64/kernel/iSeries_irq.c | 312 |
1 files changed, 228 insertions, 84 deletions
diff --git a/arch/ppc64/kernel/iSeries_irq.c b/arch/ppc64/kernel/iSeries_irq.c index f831d259dbb7..77376c1bd611 100644 --- a/arch/ppc64/kernel/iSeries_irq.c +++ b/arch/ppc64/kernel/iSeries_irq.c | |||
@@ -1,27 +1,29 @@ | |||
1 | /************************************************************************/ | 1 | /* |
2 | /* This module supports the iSeries PCI bus interrupt handling */ | 2 | * This module supports the iSeries PCI bus interrupt handling |
3 | /* Copyright (C) 20yy <Robert L Holtorf> <IBM Corp> */ | 3 | * Copyright (C) 20yy <Robert L Holtorf> <IBM Corp> |
4 | /* */ | 4 | * Copyright (C) 2004-2005 IBM Corporation |
5 | /* This program is free software; you can redistribute it and/or modify */ | 5 | * |
6 | /* it under the terms of the GNU General Public License as published by */ | 6 | * This program is free software; you can redistribute it and/or modify |
7 | /* the Free Software Foundation; either version 2 of the License, or */ | 7 | * it under the terms of the GNU General Public License as published by |
8 | /* (at your option) any later version. */ | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | /* */ | 9 | * (at your option) any later version. |
10 | /* This program is distributed in the hope that it will be useful, */ | 10 | * |
11 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | 11 | * This program is distributed in the hope that it will be useful, |
12 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | /* GNU General Public License for more details. */ | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | /* */ | 14 | * GNU General Public License for more details. |
15 | /* You should have received a copy of the GNU General Public License */ | 15 | * |
16 | /* along with this program; if not, write to the: */ | 16 | * You should have received a copy of the GNU General Public License |
17 | /* Free Software Foundation, Inc., */ | 17 | * along with this program; if not, write to the: |
18 | /* 59 Temple Place, Suite 330, */ | 18 | * Free Software Foundation, Inc., |
19 | /* Boston, MA 02111-1307 USA */ | 19 | * 59 Temple Place, Suite 330, |
20 | /************************************************************************/ | 20 | * Boston, MA 02111-1307 USA |
21 | /* Change Activity: */ | 21 | * |
22 | /* Created, December 13, 2000 by Wayne Holm */ | 22 | * Change Activity: |
23 | /* End Change Activity */ | 23 | * Created, December 13, 2000 by Wayne Holm |
24 | /************************************************************************/ | 24 | * End Change Activity |
25 | */ | ||
26 | #include <linux/config.h> | ||
25 | #include <linux/pci.h> | 27 | #include <linux/pci.h> |
26 | #include <linux/init.h> | 28 | #include <linux/init.h> |
27 | #include <linux/threads.h> | 29 | #include <linux/threads.h> |
@@ -30,30 +32,15 @@ | |||
30 | #include <linux/string.h> | 32 | #include <linux/string.h> |
31 | #include <linux/bootmem.h> | 33 | #include <linux/bootmem.h> |
32 | #include <linux/ide.h> | 34 | #include <linux/ide.h> |
33 | |||
34 | #include <linux/irq.h> | 35 | #include <linux/irq.h> |
35 | #include <linux/spinlock.h> | 36 | #include <linux/spinlock.h> |
36 | #include <asm/ppcdebug.h> | ||
37 | 37 | ||
38 | #include <asm/ppcdebug.h> | ||
39 | #include <asm/iSeries/HvTypes.h> | ||
40 | #include <asm/iSeries/HvLpEvent.h> | ||
38 | #include <asm/iSeries/HvCallPci.h> | 41 | #include <asm/iSeries/HvCallPci.h> |
39 | #include <asm/iSeries/HvCallXm.h> | 42 | #include <asm/iSeries/HvCallXm.h> |
40 | #include <asm/iSeries/iSeries_irq.h> | 43 | #include <asm/iSeries/iSeries_irq.h> |
41 | #include <asm/iSeries/XmPciLpEvent.h> | ||
42 | |||
43 | static unsigned int iSeries_startup_IRQ(unsigned int irq); | ||
44 | static void iSeries_shutdown_IRQ(unsigned int irq); | ||
45 | static void iSeries_enable_IRQ(unsigned int irq); | ||
46 | static void iSeries_disable_IRQ(unsigned int irq); | ||
47 | static void iSeries_end_IRQ(unsigned int irq); | ||
48 | |||
49 | static hw_irq_controller iSeries_IRQ_handler = { | ||
50 | .typename = "iSeries irq controller", | ||
51 | .startup = iSeries_startup_IRQ, | ||
52 | .shutdown = iSeries_shutdown_IRQ, | ||
53 | .enable = iSeries_enable_IRQ, | ||
54 | .disable = iSeries_disable_IRQ, | ||
55 | .end = iSeries_end_IRQ | ||
56 | }; | ||
57 | 44 | ||
58 | /* This maps virtual irq numbers to real irqs */ | 45 | /* This maps virtual irq numbers to real irqs */ |
59 | unsigned int virt_irq_to_real_map[NR_IRQS]; | 46 | unsigned int virt_irq_to_real_map[NR_IRQS]; |
@@ -62,37 +49,187 @@ unsigned int virt_irq_to_real_map[NR_IRQS]; | |||
62 | /* Note: the pcnet32 driver assumes irq numbers < 2 aren't valid. :( */ | 49 | /* Note: the pcnet32 driver assumes irq numbers < 2 aren't valid. :( */ |
63 | static int next_virtual_irq = 2; | 50 | static int next_virtual_irq = 2; |
64 | 51 | ||
65 | /* This is called by init_IRQ. set in ppc_md.init_IRQ by iSeries_setup.c */ | 52 | static long Pci_Interrupt_Count; |
66 | void __init iSeries_init_IRQ(void) | 53 | static long Pci_Event_Count; |
54 | |||
55 | enum XmPciLpEvent_Subtype { | ||
56 | XmPciLpEvent_BusCreated = 0, // PHB has been created | ||
57 | XmPciLpEvent_BusError = 1, // PHB has failed | ||
58 | XmPciLpEvent_BusFailed = 2, // Msg to Secondary, Primary failed bus | ||
59 | XmPciLpEvent_NodeFailed = 4, // Multi-adapter bridge has failed | ||
60 | XmPciLpEvent_NodeRecovered = 5, // Multi-adapter bridge has recovered | ||
61 | XmPciLpEvent_BusRecovered = 12, // PHB has been recovered | ||
62 | XmPciLpEvent_UnQuiesceBus = 18, // Secondary bus unqiescing | ||
63 | XmPciLpEvent_BridgeError = 21, // Bridge Error | ||
64 | XmPciLpEvent_SlotInterrupt = 22 // Slot interrupt | ||
65 | }; | ||
66 | |||
67 | struct XmPciLpEvent_BusInterrupt { | ||
68 | HvBusNumber busNumber; | ||
69 | HvSubBusNumber subBusNumber; | ||
70 | }; | ||
71 | |||
72 | struct XmPciLpEvent_NodeInterrupt { | ||
73 | HvBusNumber busNumber; | ||
74 | HvSubBusNumber subBusNumber; | ||
75 | HvAgentId deviceId; | ||
76 | }; | ||
77 | |||
78 | struct XmPciLpEvent { | ||
79 | struct HvLpEvent hvLpEvent; | ||
80 | |||
81 | union { | ||
82 | u64 alignData; // Align on an 8-byte boundary | ||
83 | |||
84 | struct { | ||
85 | u32 fisr; | ||
86 | HvBusNumber busNumber; | ||
87 | HvSubBusNumber subBusNumber; | ||
88 | HvAgentId deviceId; | ||
89 | } slotInterrupt; | ||
90 | |||
91 | struct XmPciLpEvent_BusInterrupt busFailed; | ||
92 | struct XmPciLpEvent_BusInterrupt busRecovered; | ||
93 | struct XmPciLpEvent_BusInterrupt busCreated; | ||
94 | |||
95 | struct XmPciLpEvent_NodeInterrupt nodeFailed; | ||
96 | struct XmPciLpEvent_NodeInterrupt nodeRecovered; | ||
97 | |||
98 | } eventData; | ||
99 | |||
100 | }; | ||
101 | |||
102 | static void intReceived(struct XmPciLpEvent *eventParm, | ||
103 | struct pt_regs *regsParm) | ||
67 | { | 104 | { |
68 | /* Register PCI event handler and open an event path */ | 105 | int irq; |
69 | XmPciLpEvent_init(); | 106 | |
107 | ++Pci_Interrupt_Count; | ||
108 | |||
109 | switch (eventParm->hvLpEvent.xSubtype) { | ||
110 | case XmPciLpEvent_SlotInterrupt: | ||
111 | irq = eventParm->hvLpEvent.xCorrelationToken; | ||
112 | /* Dispatch the interrupt handlers for this irq */ | ||
113 | ppc_irq_dispatch_handler(regsParm, irq); | ||
114 | HvCallPci_eoi(eventParm->eventData.slotInterrupt.busNumber, | ||
115 | eventParm->eventData.slotInterrupt.subBusNumber, | ||
116 | eventParm->eventData.slotInterrupt.deviceId); | ||
117 | break; | ||
118 | /* Ignore error recovery events for now */ | ||
119 | case XmPciLpEvent_BusCreated: | ||
120 | printk(KERN_INFO "intReceived: system bus %d created\n", | ||
121 | eventParm->eventData.busCreated.busNumber); | ||
122 | break; | ||
123 | case XmPciLpEvent_BusError: | ||
124 | case XmPciLpEvent_BusFailed: | ||
125 | printk(KERN_INFO "intReceived: system bus %d failed\n", | ||
126 | eventParm->eventData.busFailed.busNumber); | ||
127 | break; | ||
128 | case XmPciLpEvent_BusRecovered: | ||
129 | case XmPciLpEvent_UnQuiesceBus: | ||
130 | printk(KERN_INFO "intReceived: system bus %d recovered\n", | ||
131 | eventParm->eventData.busRecovered.busNumber); | ||
132 | break; | ||
133 | case XmPciLpEvent_NodeFailed: | ||
134 | case XmPciLpEvent_BridgeError: | ||
135 | printk(KERN_INFO | ||
136 | "intReceived: multi-adapter bridge %d/%d/%d failed\n", | ||
137 | eventParm->eventData.nodeFailed.busNumber, | ||
138 | eventParm->eventData.nodeFailed.subBusNumber, | ||
139 | eventParm->eventData.nodeFailed.deviceId); | ||
140 | break; | ||
141 | case XmPciLpEvent_NodeRecovered: | ||
142 | printk(KERN_INFO | ||
143 | "intReceived: multi-adapter bridge %d/%d/%d recovered\n", | ||
144 | eventParm->eventData.nodeRecovered.busNumber, | ||
145 | eventParm->eventData.nodeRecovered.subBusNumber, | ||
146 | eventParm->eventData.nodeRecovered.deviceId); | ||
147 | break; | ||
148 | default: | ||
149 | printk(KERN_ERR | ||
150 | "intReceived: unrecognized event subtype 0x%x\n", | ||
151 | eventParm->hvLpEvent.xSubtype); | ||
152 | break; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | static void XmPciLpEvent_handler(struct HvLpEvent *eventParm, | ||
157 | struct pt_regs *regsParm) | ||
158 | { | ||
159 | #ifdef CONFIG_PCI | ||
160 | ++Pci_Event_Count; | ||
161 | |||
162 | if (eventParm && (eventParm->xType == HvLpEvent_Type_PciIo)) { | ||
163 | switch (eventParm->xFlags.xFunction) { | ||
164 | case HvLpEvent_Function_Int: | ||
165 | intReceived((struct XmPciLpEvent *)eventParm, regsParm); | ||
166 | break; | ||
167 | case HvLpEvent_Function_Ack: | ||
168 | printk(KERN_ERR | ||
169 | "XmPciLpEvent_handler: unexpected ack received\n"); | ||
170 | break; | ||
171 | default: | ||
172 | printk(KERN_ERR | ||
173 | "XmPciLpEvent_handler: unexpected event function %d\n", | ||
174 | (int)eventParm->xFlags.xFunction); | ||
175 | break; | ||
176 | } | ||
177 | } else if (eventParm) | ||
178 | printk(KERN_ERR | ||
179 | "XmPciLpEvent_handler: Unrecognized PCI event type 0x%x\n", | ||
180 | (int)eventParm->xType); | ||
181 | else | ||
182 | printk(KERN_ERR "XmPciLpEvent_handler: NULL event received\n"); | ||
183 | #endif | ||
70 | } | 184 | } |
71 | 185 | ||
72 | /* | 186 | /* |
73 | * This is called out of iSeries_scan_slot to allocate an IRQ for an EADS slot | 187 | * This is called by init_IRQ. set in ppc_md.init_IRQ by iSeries_setup.c |
74 | * It calculates the irq value for the slot. | 188 | * It must be called before the bus walk. |
75 | * Note that subBusNumber is always 0 (at the moment at least). | ||
76 | */ | 189 | */ |
77 | int __init iSeries_allocate_IRQ(HvBusNumber busNumber, | 190 | void __init iSeries_init_IRQ(void) |
78 | HvSubBusNumber subBusNumber, HvAgentId deviceId) | ||
79 | { | 191 | { |
80 | unsigned int realirq, virtirq; | 192 | /* Register PCI event handler and open an event path */ |
81 | u8 idsel = (deviceId >> 4); | 193 | int xRc; |
82 | u8 function = deviceId & 7; | ||
83 | |||
84 | virtirq = next_virtual_irq++; | ||
85 | realirq = ((busNumber - 1) << 6) + ((idsel - 1) << 3) + function; | ||
86 | virt_irq_to_real_map[virtirq] = realirq; | ||
87 | 194 | ||
88 | irq_desc[virtirq].handler = &iSeries_IRQ_handler; | 195 | xRc = HvLpEvent_registerHandler(HvLpEvent_Type_PciIo, |
89 | return virtirq; | 196 | &XmPciLpEvent_handler); |
197 | if (xRc == 0) { | ||
198 | xRc = HvLpEvent_openPath(HvLpEvent_Type_PciIo, 0); | ||
199 | if (xRc != 0) | ||
200 | printk(KERN_ERR "iSeries_init_IRQ: open event path " | ||
201 | "failed with rc 0x%x\n", xRc); | ||
202 | } else | ||
203 | printk(KERN_ERR "iSeries_init_IRQ: register handler " | ||
204 | "failed with rc 0x%x\n", xRc); | ||
90 | } | 205 | } |
91 | 206 | ||
92 | #define REAL_IRQ_TO_BUS(irq) ((((irq) >> 6) & 0xff) + 1) | 207 | #define REAL_IRQ_TO_BUS(irq) ((((irq) >> 6) & 0xff) + 1) |
93 | #define REAL_IRQ_TO_IDSEL(irq) ((((irq) >> 3) & 7) + 1) | 208 | #define REAL_IRQ_TO_IDSEL(irq) ((((irq) >> 3) & 7) + 1) |
94 | #define REAL_IRQ_TO_FUNC(irq) ((irq) & 7) | 209 | #define REAL_IRQ_TO_FUNC(irq) ((irq) & 7) |
95 | 210 | ||
211 | /* | ||
212 | * This will be called by device drivers (via enable_IRQ) | ||
213 | * to enable INTA in the bridge interrupt status register. | ||
214 | */ | ||
215 | static void iSeries_enable_IRQ(unsigned int irq) | ||
216 | { | ||
217 | u32 bus, deviceId, function, mask; | ||
218 | const u32 subBus = 0; | ||
219 | unsigned int rirq = virt_irq_to_real_map[irq]; | ||
220 | |||
221 | /* The IRQ has already been locked by the caller */ | ||
222 | bus = REAL_IRQ_TO_BUS(rirq); | ||
223 | function = REAL_IRQ_TO_FUNC(rirq); | ||
224 | deviceId = (REAL_IRQ_TO_IDSEL(rirq) << 4) + function; | ||
225 | |||
226 | /* Unmask secondary INTA */ | ||
227 | mask = 0x80000000; | ||
228 | HvCallPci_unmaskInterrupts(bus, subBus, deviceId, mask); | ||
229 | PPCDBG(PPCDBG_BUSWALK, "iSeries_enable_IRQ 0x%02X.%02X.%02X 0x%04X\n", | ||
230 | bus, subBus, deviceId, irq); | ||
231 | } | ||
232 | |||
96 | /* This is called by iSeries_activate_IRQs */ | 233 | /* This is called by iSeries_activate_IRQs */ |
97 | static unsigned int iSeries_startup_IRQ(unsigned int irq) | 234 | static unsigned int iSeries_startup_IRQ(unsigned int irq) |
98 | { | 235 | { |
@@ -131,7 +268,7 @@ void __init iSeries_activate_IRQs() | |||
131 | desc->handler->startup(irq); | 268 | desc->handler->startup(irq); |
132 | spin_unlock_irqrestore(&desc->lock, flags); | 269 | spin_unlock_irqrestore(&desc->lock, flags); |
133 | } | 270 | } |
134 | } | 271 | } |
135 | } | 272 | } |
136 | 273 | ||
137 | /* this is not called anywhere currently */ | 274 | /* this is not called anywhere currently */ |
@@ -173,29 +310,7 @@ static void iSeries_disable_IRQ(unsigned int irq) | |||
173 | mask = 0x80000000; | 310 | mask = 0x80000000; |
174 | HvCallPci_maskInterrupts(bus, subBus, deviceId, mask); | 311 | HvCallPci_maskInterrupts(bus, subBus, deviceId, mask); |
175 | PPCDBG(PPCDBG_BUSWALK, "iSeries_disable_IRQ 0x%02X.%02X.%02X 0x%04X\n", | 312 | PPCDBG(PPCDBG_BUSWALK, "iSeries_disable_IRQ 0x%02X.%02X.%02X 0x%04X\n", |
176 | bus, subBus, deviceId, irq); | 313 | bus, subBus, deviceId, irq); |
177 | } | ||
178 | |||
179 | /* | ||
180 | * This will be called by device drivers (via enable_IRQ) | ||
181 | * to enable INTA in the bridge interrupt status register. | ||
182 | */ | ||
183 | static void iSeries_enable_IRQ(unsigned int irq) | ||
184 | { | ||
185 | u32 bus, deviceId, function, mask; | ||
186 | const u32 subBus = 0; | ||
187 | unsigned int rirq = virt_irq_to_real_map[irq]; | ||
188 | |||
189 | /* The IRQ has already been locked by the caller */ | ||
190 | bus = REAL_IRQ_TO_BUS(rirq); | ||
191 | function = REAL_IRQ_TO_FUNC(rirq); | ||
192 | deviceId = (REAL_IRQ_TO_IDSEL(rirq) << 4) + function; | ||
193 | |||
194 | /* Unmask secondary INTA */ | ||
195 | mask = 0x80000000; | ||
196 | HvCallPci_unmaskInterrupts(bus, subBus, deviceId, mask); | ||
197 | PPCDBG(PPCDBG_BUSWALK, "iSeries_enable_IRQ 0x%02X.%02X.%02X 0x%04X\n", | ||
198 | bus, subBus, deviceId, irq); | ||
199 | } | 314 | } |
200 | 315 | ||
201 | /* | 316 | /* |
@@ -207,3 +322,32 @@ static void iSeries_enable_IRQ(unsigned int irq) | |||
207 | static void iSeries_end_IRQ(unsigned int irq) | 322 | static void iSeries_end_IRQ(unsigned int irq) |
208 | { | 323 | { |
209 | } | 324 | } |
325 | |||
326 | static hw_irq_controller iSeries_IRQ_handler = { | ||
327 | .typename = "iSeries irq controller", | ||
328 | .startup = iSeries_startup_IRQ, | ||
329 | .shutdown = iSeries_shutdown_IRQ, | ||
330 | .enable = iSeries_enable_IRQ, | ||
331 | .disable = iSeries_disable_IRQ, | ||
332 | .end = iSeries_end_IRQ | ||
333 | }; | ||
334 | |||
335 | /* | ||
336 | * This is called out of iSeries_scan_slot to allocate an IRQ for an EADS slot | ||
337 | * It calculates the irq value for the slot. | ||
338 | * Note that subBusNumber is always 0 (at the moment at least). | ||
339 | */ | ||
340 | int __init iSeries_allocate_IRQ(HvBusNumber busNumber, | ||
341 | HvSubBusNumber subBusNumber, HvAgentId deviceId) | ||
342 | { | ||
343 | unsigned int realirq, virtirq; | ||
344 | u8 idsel = (deviceId >> 4); | ||
345 | u8 function = deviceId & 7; | ||
346 | |||
347 | virtirq = next_virtual_irq++; | ||
348 | realirq = ((busNumber - 1) << 6) + ((idsel - 1) << 3) + function; | ||
349 | virt_irq_to_real_map[virtirq] = realirq; | ||
350 | |||
351 | irq_desc[virtirq].handler = &iSeries_IRQ_handler; | ||
352 | return virtirq; | ||
353 | } | ||