]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * pci_irq.c - ACPI PCI Interrupt Routing ($Revision: 11 $) | |
3 | * | |
4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | |
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | |
6 | * Copyright (C) 2002 Dominik Brodowski <devel@brodo.de> | |
7 | * | |
8 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; either version 2 of the License, or (at | |
13 | * your option) any later version. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, but | |
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | * General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License along | |
21 | * with this program; if not, write to the Free Software Foundation, Inc., | |
22 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
23 | * | |
24 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
25 | */ | |
26 | ||
1da177e4 LT |
27 | |
28 | #include <linux/kernel.h> | |
29 | #include <linux/module.h> | |
30 | #include <linux/init.h> | |
31 | #include <linux/types.h> | |
32 | #include <linux/proc_fs.h> | |
33 | #include <linux/spinlock.h> | |
34 | #include <linux/pm.h> | |
35 | #include <linux/pci.h> | |
36 | #include <linux/acpi.h> | |
37 | #include <acpi/acpi_bus.h> | |
38 | #include <acpi/acpi_drivers.h> | |
39 | ||
1da177e4 | 40 | #define _COMPONENT ACPI_PCI_COMPONENT |
f52fd66d | 41 | ACPI_MODULE_NAME("pci_irq"); |
1da177e4 | 42 | |
4be44fcd | 43 | static struct acpi_prt_list acpi_prt; |
1da177e4 LT |
44 | static DEFINE_SPINLOCK(acpi_prt_lock); |
45 | ||
46 | /* -------------------------------------------------------------------------- | |
47 | PCI IRQ Routing Table (PRT) Support | |
48 | -------------------------------------------------------------------------- */ | |
49 | ||
4be44fcd LB |
50 | static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment, |
51 | int bus, | |
52 | int device, int pin) | |
1da177e4 | 53 | { |
4be44fcd | 54 | struct acpi_prt_entry *entry = NULL; |
1da177e4 | 55 | |
1da177e4 | 56 | if (!acpi_prt.count) |
d550d98d | 57 | return NULL; |
1da177e4 LT |
58 | |
59 | /* | |
60 | * Parse through all PRT entries looking for a match on the specified | |
61 | * PCI device's segment, bus, device, and pin (don't care about func). | |
62 | * | |
63 | */ | |
64 | spin_lock(&acpi_prt_lock); | |
1a3b77ae | 65 | list_for_each_entry(entry, &acpi_prt.entries, node) { |
4be44fcd LB |
66 | if ((segment == entry->id.segment) |
67 | && (bus == entry->id.bus) | |
68 | && (device == entry->id.device) | |
69 | && (pin == entry->pin)) { | |
1da177e4 | 70 | spin_unlock(&acpi_prt_lock); |
d550d98d | 71 | return entry; |
1da177e4 LT |
72 | } |
73 | } | |
74 | ||
75 | spin_unlock(&acpi_prt_lock); | |
d550d98d | 76 | return NULL; |
1da177e4 LT |
77 | } |
78 | ||
1da177e4 | 79 | static int |
4be44fcd LB |
80 | acpi_pci_irq_add_entry(acpi_handle handle, |
81 | int segment, int bus, struct acpi_pci_routing_table *prt) | |
1da177e4 | 82 | { |
4be44fcd | 83 | struct acpi_prt_entry *entry = NULL; |
1da177e4 | 84 | |
1da177e4 LT |
85 | |
86 | if (!prt) | |
d550d98d | 87 | return -EINVAL; |
1da177e4 | 88 | |
36bcbec7 | 89 | entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); |
1da177e4 | 90 | if (!entry) |
d550d98d | 91 | return -ENOMEM; |
1da177e4 LT |
92 | |
93 | entry->id.segment = segment; | |
94 | entry->id.bus = bus; | |
95 | entry->id.device = (prt->address >> 16) & 0xFFFF; | |
96 | entry->id.function = prt->address & 0xFFFF; | |
97 | entry->pin = prt->pin; | |
98 | ||
99 | /* | |
100 | * Type 1: Dynamic | |
101 | * --------------- | |
102 | * The 'source' field specifies the PCI interrupt link device used to | |
103 | * configure the IRQ assigned to this slot|dev|pin. The 'source_index' | |
104 | * indicates which resource descriptor in the resource template (of | |
105 | * the link device) this interrupt is allocated from. | |
106 | * | |
107 | * NOTE: Don't query the Link Device for IRQ information at this time | |
108 | * because Link Device enumeration may not have occurred yet | |
109 | * (e.g. exists somewhere 'below' this _PRT entry in the ACPI | |
110 | * namespace). | |
111 | */ | |
112 | if (prt->source[0]) { | |
113 | acpi_get_handle(handle, prt->source, &entry->link.handle); | |
114 | entry->link.index = prt->source_index; | |
115 | } | |
116 | /* | |
117 | * Type 2: Static | |
118 | * -------------- | |
119 | * The 'source' field is NULL, and the 'source_index' field specifies | |
120 | * the IRQ value, which is hardwired to specific interrupt inputs on | |
121 | * the interrupt controller. | |
122 | */ | |
123 | else | |
124 | entry->link.index = prt->source_index; | |
125 | ||
126 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, | |
4be44fcd LB |
127 | " %02X:%02X:%02X[%c] -> %s[%d]\n", |
128 | entry->id.segment, entry->id.bus, | |
129 | entry->id.device, ('A' + entry->pin), prt->source, | |
130 | entry->link.index)); | |
1da177e4 LT |
131 | |
132 | spin_lock(&acpi_prt_lock); | |
133 | list_add_tail(&entry->node, &acpi_prt.entries); | |
134 | acpi_prt.count++; | |
135 | spin_unlock(&acpi_prt_lock); | |
136 | ||
d550d98d | 137 | return 0; |
1da177e4 LT |
138 | } |
139 | ||
1da177e4 | 140 | static void |
4be44fcd | 141 | acpi_pci_irq_del_entry(int segment, int bus, struct acpi_prt_entry *entry) |
1da177e4 | 142 | { |
4be44fcd | 143 | if (segment == entry->id.segment && bus == entry->id.bus) { |
1da177e4 LT |
144 | acpi_prt.count--; |
145 | list_del(&entry->node); | |
146 | kfree(entry); | |
147 | } | |
148 | } | |
149 | ||
4be44fcd | 150 | int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) |
1da177e4 | 151 | { |
4be44fcd LB |
152 | acpi_status status = AE_OK; |
153 | char *pathname = NULL; | |
154 | struct acpi_buffer buffer = { 0, NULL }; | |
155 | struct acpi_pci_routing_table *prt = NULL; | |
156 | struct acpi_pci_routing_table *entry = NULL; | |
157 | static int first_time = 1; | |
1da177e4 | 158 | |
1da177e4 | 159 | |
36bcbec7 | 160 | pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); |
4be44fcd | 161 | if (!pathname) |
d550d98d | 162 | return -ENOMEM; |
1da177e4 LT |
163 | |
164 | if (first_time) { | |
165 | acpi_prt.count = 0; | |
166 | INIT_LIST_HEAD(&acpi_prt.entries); | |
167 | first_time = 0; | |
168 | } | |
169 | ||
170 | /* | |
171 | * NOTE: We're given a 'handle' to the _PRT object's parent device | |
172 | * (either a PCI root bridge or PCI-PCI bridge). | |
173 | */ | |
174 | ||
175 | buffer.length = ACPI_PATHNAME_MAX; | |
176 | buffer.pointer = pathname; | |
177 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | |
178 | ||
179 | printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n", | |
4be44fcd | 180 | pathname); |
1da177e4 LT |
181 | |
182 | /* | |
183 | * Evaluate this _PRT and add its entries to our global list (acpi_prt). | |
184 | */ | |
185 | ||
186 | buffer.length = 0; | |
187 | buffer.pointer = NULL; | |
188 | kfree(pathname); | |
189 | status = acpi_get_irq_routing_table(handle, &buffer); | |
190 | if (status != AE_BUFFER_OVERFLOW) { | |
a6fc6720 TR |
191 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]", |
192 | acpi_format_exception(status))); | |
d550d98d | 193 | return -ENODEV; |
1da177e4 LT |
194 | } |
195 | ||
36bcbec7 | 196 | prt = kzalloc(buffer.length, GFP_KERNEL); |
4be44fcd | 197 | if (!prt) { |
d550d98d | 198 | return -ENOMEM; |
1da177e4 | 199 | } |
1da177e4 LT |
200 | buffer.pointer = prt; |
201 | ||
202 | status = acpi_get_irq_routing_table(handle, &buffer); | |
203 | if (ACPI_FAILURE(status)) { | |
a6fc6720 TR |
204 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]", |
205 | acpi_format_exception(status))); | |
1da177e4 | 206 | kfree(buffer.pointer); |
d550d98d | 207 | return -ENODEV; |
1da177e4 LT |
208 | } |
209 | ||
210 | entry = prt; | |
211 | ||
212 | while (entry && (entry->length > 0)) { | |
213 | acpi_pci_irq_add_entry(handle, segment, bus, entry); | |
214 | entry = (struct acpi_pci_routing_table *) | |
4be44fcd | 215 | ((unsigned long)entry + entry->length); |
1da177e4 LT |
216 | } |
217 | ||
218 | kfree(prt); | |
219 | ||
d550d98d | 220 | return 0; |
1da177e4 LT |
221 | } |
222 | ||
4be44fcd | 223 | void acpi_pci_irq_del_prt(int segment, int bus) |
1da177e4 | 224 | { |
4be44fcd LB |
225 | struct list_head *node = NULL, *n = NULL; |
226 | struct acpi_prt_entry *entry = NULL; | |
1da177e4 | 227 | |
4be44fcd | 228 | if (!acpi_prt.count) { |
1da177e4 LT |
229 | return; |
230 | } | |
231 | ||
4be44fcd LB |
232 | printk(KERN_DEBUG |
233 | "ACPI: Delete PCI Interrupt Routing Table for %x:%x\n", segment, | |
234 | bus); | |
1da177e4 LT |
235 | spin_lock(&acpi_prt_lock); |
236 | list_for_each_safe(node, n, &acpi_prt.entries) { | |
237 | entry = list_entry(node, struct acpi_prt_entry, node); | |
238 | ||
239 | acpi_pci_irq_del_entry(segment, bus, entry); | |
240 | } | |
241 | spin_unlock(&acpi_prt_lock); | |
242 | } | |
4be44fcd | 243 | |
1da177e4 LT |
244 | /* -------------------------------------------------------------------------- |
245 | PCI Interrupt Routing Support | |
246 | -------------------------------------------------------------------------- */ | |
4be44fcd | 247 | typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **); |
1da177e4 | 248 | |
87bec66b DSL |
249 | static int |
250 | acpi_pci_allocate_irq(struct acpi_prt_entry *entry, | |
50eca3eb | 251 | int *triggering, int *polarity, char **link) |
87bec66b | 252 | { |
4be44fcd | 253 | int irq; |
87bec66b | 254 | |
87bec66b DSL |
255 | |
256 | if (entry->link.handle) { | |
257 | irq = acpi_pci_link_allocate_irq(entry->link.handle, | |
50eca3eb BM |
258 | entry->link.index, triggering, |
259 | polarity, link); | |
87bec66b | 260 | if (irq < 0) { |
cece9296 LB |
261 | printk(KERN_WARNING PREFIX |
262 | "Invalid IRQ link routing entry\n"); | |
d550d98d | 263 | return -1; |
87bec66b DSL |
264 | } |
265 | } else { | |
266 | irq = entry->link.index; | |
50eca3eb BM |
267 | *triggering = ACPI_LEVEL_SENSITIVE; |
268 | *polarity = ACPI_ACTIVE_LOW; | |
87bec66b DSL |
269 | } |
270 | ||
271 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq)); | |
d550d98d | 272 | return irq; |
87bec66b DSL |
273 | } |
274 | ||
275 | static int | |
276 | acpi_pci_free_irq(struct acpi_prt_entry *entry, | |
50eca3eb | 277 | int *triggering, int *polarity, char **link) |
87bec66b | 278 | { |
4be44fcd | 279 | int irq; |
87bec66b | 280 | |
87bec66b DSL |
281 | if (entry->link.handle) { |
282 | irq = acpi_pci_link_free_irq(entry->link.handle); | |
283 | } else { | |
284 | irq = entry->link.index; | |
285 | } | |
d550d98d | 286 | return irq; |
87bec66b | 287 | } |
4be44fcd | 288 | |
1da177e4 LT |
289 | /* |
290 | * acpi_pci_irq_lookup | |
291 | * success: return IRQ >= 0 | |
292 | * failure: return -1 | |
293 | */ | |
294 | static int | |
4be44fcd LB |
295 | acpi_pci_irq_lookup(struct pci_bus *bus, |
296 | int device, | |
297 | int pin, | |
50eca3eb BM |
298 | int *triggering, |
299 | int *polarity, char **link, irq_lookup_func func) | |
1da177e4 | 300 | { |
4be44fcd | 301 | struct acpi_prt_entry *entry = NULL; |
1da177e4 LT |
302 | int segment = pci_domain_nr(bus); |
303 | int bus_nr = bus->number; | |
87bec66b | 304 | int ret; |
1da177e4 | 305 | |
1da177e4 | 306 | |
4be44fcd LB |
307 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
308 | "Searching for PRT entry for %02x:%02x:%02x[%c]\n", | |
309 | segment, bus_nr, device, ('A' + pin))); | |
1da177e4 | 310 | |
4be44fcd | 311 | entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin); |
1da177e4 LT |
312 | if (!entry) { |
313 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n")); | |
d550d98d | 314 | return -1; |
1da177e4 | 315 | } |
4be44fcd | 316 | |
50eca3eb | 317 | ret = func(entry, triggering, polarity, link); |
d550d98d | 318 | return ret; |
1da177e4 LT |
319 | } |
320 | ||
321 | /* | |
322 | * acpi_pci_irq_derive | |
323 | * success: return IRQ >= 0 | |
324 | * failure: return < 0 | |
325 | */ | |
326 | static int | |
4be44fcd LB |
327 | acpi_pci_irq_derive(struct pci_dev *dev, |
328 | int pin, | |
50eca3eb BM |
329 | int *triggering, |
330 | int *polarity, char **link, irq_lookup_func func) | |
1da177e4 | 331 | { |
4be44fcd LB |
332 | struct pci_dev *bridge = dev; |
333 | int irq = -1; | |
334 | u8 bridge_pin = 0; | |
1da177e4 | 335 | |
1da177e4 LT |
336 | |
337 | if (!dev) | |
d550d98d | 338 | return -EINVAL; |
1da177e4 LT |
339 | |
340 | /* | |
341 | * Attempt to derive an IRQ for this device from a parent bridge's | |
342 | * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge). | |
343 | */ | |
344 | while (irq < 0 && bridge->bus->self) { | |
345 | pin = (pin + PCI_SLOT(bridge->devfn)) % 4; | |
346 | bridge = bridge->bus->self; | |
347 | ||
348 | if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) { | |
349 | /* PC card has the same IRQ as its cardbridge */ | |
8015a014 | 350 | bridge_pin = bridge->pin; |
1da177e4 | 351 | if (!bridge_pin) { |
4be44fcd LB |
352 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
353 | "No interrupt pin configured for device %s\n", | |
354 | pci_name(bridge))); | |
d550d98d | 355 | return -1; |
1da177e4 LT |
356 | } |
357 | /* Pin is from 0 to 3 */ | |
4be44fcd | 358 | bridge_pin--; |
1da177e4 LT |
359 | pin = bridge_pin; |
360 | } | |
361 | ||
362 | irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), | |
50eca3eb | 363 | pin, triggering, polarity, |
4be44fcd | 364 | link, func); |
1da177e4 LT |
365 | } |
366 | ||
367 | if (irq < 0) { | |
cece9296 LB |
368 | printk(KERN_WARNING PREFIX "Unable to derive IRQ for device %s\n", |
369 | pci_name(dev)); | |
d550d98d | 370 | return -1; |
1da177e4 LT |
371 | } |
372 | ||
373 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n", | |
4be44fcd | 374 | irq, pci_name(dev), pci_name(bridge))); |
1da177e4 | 375 | |
d550d98d | 376 | return irq; |
1da177e4 LT |
377 | } |
378 | ||
379 | /* | |
380 | * acpi_pci_irq_enable | |
381 | * success: return 0 | |
382 | * failure: return < 0 | |
383 | */ | |
384 | ||
4be44fcd | 385 | int acpi_pci_irq_enable(struct pci_dev *dev) |
1da177e4 | 386 | { |
4be44fcd LB |
387 | int irq = 0; |
388 | u8 pin = 0; | |
50eca3eb BM |
389 | int triggering = ACPI_LEVEL_SENSITIVE; |
390 | int polarity = ACPI_ACTIVE_LOW; | |
4be44fcd LB |
391 | char *link = NULL; |
392 | int rc; | |
1da177e4 | 393 | |
1da177e4 LT |
394 | |
395 | if (!dev) | |
d550d98d | 396 | return -EINVAL; |
4be44fcd | 397 | |
8015a014 | 398 | pin = dev->pin; |
1da177e4 | 399 | if (!pin) { |
4be44fcd LB |
400 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
401 | "No interrupt pin configured for device %s\n", | |
402 | pci_name(dev))); | |
d550d98d | 403 | return 0; |
1da177e4 LT |
404 | } |
405 | pin--; | |
406 | ||
407 | if (!dev->bus) { | |
6468463a | 408 | printk(KERN_ERR PREFIX "Invalid (NULL) 'bus' field\n"); |
d550d98d | 409 | return -ENODEV; |
1da177e4 LT |
410 | } |
411 | ||
412 | /* | |
413 | * First we check the PCI IRQ routing table (PRT) for an IRQ. PRT | |
414 | * values override any BIOS-assigned IRQs set during boot. | |
415 | */ | |
4be44fcd | 416 | irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, |
50eca3eb | 417 | &triggering, &polarity, &link, |
4be44fcd | 418 | acpi_pci_allocate_irq); |
1da177e4 LT |
419 | |
420 | /* | |
421 | * If no PRT entry was found, we'll try to derive an IRQ from the | |
422 | * device's parent bridge. | |
423 | */ | |
424 | if (irq < 0) | |
50eca3eb BM |
425 | irq = acpi_pci_irq_derive(dev, pin, &triggering, |
426 | &polarity, &link, | |
4be44fcd LB |
427 | acpi_pci_allocate_irq); |
428 | ||
96c2a876 AC |
429 | if (irq < 0) { |
430 | /* | |
431 | * IDE legacy mode controller IRQs are magic. Why do compat | |
432 | * extensions always make such a nasty mess. | |
433 | */ | |
434 | if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE && | |
435 | (dev->class & 0x05) == 0) | |
436 | return 0; | |
437 | } | |
1da177e4 LT |
438 | /* |
439 | * No IRQ known to the ACPI subsystem - maybe the BIOS / | |
440 | * driver reported one, then use it. Exit in any case. | |
441 | */ | |
442 | if (irq < 0) { | |
443 | printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: no GSI", | |
4be44fcd | 444 | pci_name(dev), ('A' + pin)); |
1da177e4 | 445 | /* Interrupt Line values above 0xF are forbidden */ |
44f8e1a2 | 446 | if (dev->irq > 0 && (dev->irq <= 0xF)) { |
1da177e4 | 447 | printk(" - using IRQ %d\n", dev->irq); |
4be44fcd LB |
448 | acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, |
449 | ACPI_ACTIVE_LOW); | |
d550d98d | 450 | return 0; |
4be44fcd | 451 | } else { |
1da177e4 | 452 | printk("\n"); |
d550d98d | 453 | return 0; |
1da177e4 | 454 | } |
4be44fcd | 455 | } |
1da177e4 | 456 | |
50eca3eb | 457 | rc = acpi_register_gsi(irq, triggering, polarity); |
349f0d56 KK |
458 | if (rc < 0) { |
459 | printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " | |
460 | "to register GSI\n", pci_name(dev), ('A' + pin)); | |
d550d98d | 461 | return rc; |
349f0d56 KK |
462 | } |
463 | dev->irq = rc; | |
1da177e4 LT |
464 | |
465 | printk(KERN_INFO PREFIX "PCI Interrupt %s[%c] -> ", | |
4be44fcd | 466 | pci_name(dev), 'A' + pin); |
1da177e4 LT |
467 | |
468 | if (link) | |
469 | printk("Link [%s] -> ", link); | |
470 | ||
471 | printk("GSI %u (%s, %s) -> IRQ %d\n", irq, | |
50eca3eb BM |
472 | (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", |
473 | (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); | |
1da177e4 | 474 | |
d550d98d | 475 | return 0; |
1da177e4 | 476 | } |
1da177e4 | 477 | |
87bec66b | 478 | /* FIXME: implement x86/x86_64 version */ |
4be44fcd LB |
479 | void __attribute__ ((weak)) acpi_unregister_gsi(u32 i) |
480 | { | |
481 | } | |
87bec66b | 482 | |
4be44fcd | 483 | void acpi_pci_irq_disable(struct pci_dev *dev) |
1da177e4 | 484 | { |
4be44fcd LB |
485 | int gsi = 0; |
486 | u8 pin = 0; | |
50eca3eb BM |
487 | int triggering = ACPI_LEVEL_SENSITIVE; |
488 | int polarity = ACPI_ACTIVE_LOW; | |
1da177e4 | 489 | |
1da177e4 | 490 | |
5f0110f2 | 491 | if (!dev || !dev->bus) |
d550d98d | 492 | return; |
1da177e4 | 493 | |
8015a014 | 494 | pin = dev->pin; |
1da177e4 | 495 | if (!pin) |
d550d98d | 496 | return; |
1da177e4 LT |
497 | pin--; |
498 | ||
1da177e4 LT |
499 | /* |
500 | * First we check the PCI IRQ routing table (PRT) for an IRQ. | |
501 | */ | |
4be44fcd | 502 | gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, |
50eca3eb | 503 | &triggering, &polarity, NULL, |
4be44fcd | 504 | acpi_pci_free_irq); |
1da177e4 LT |
505 | /* |
506 | * If no PRT entry was found, we'll try to derive an IRQ from the | |
507 | * device's parent bridge. | |
508 | */ | |
509 | if (gsi < 0) | |
4be44fcd | 510 | gsi = acpi_pci_irq_derive(dev, pin, |
50eca3eb | 511 | &triggering, &polarity, NULL, |
4be44fcd | 512 | acpi_pci_free_irq); |
1da177e4 | 513 | if (gsi < 0) |
d550d98d | 514 | return; |
1da177e4 LT |
515 | |
516 | /* | |
517 | * TBD: It might be worth clearing dev->irq by magic constant | |
518 | * (e.g. PCI_UNDEFINED_IRQ). | |
519 | */ | |
520 | ||
521 | printk(KERN_INFO PREFIX "PCI interrupt for device %s disabled\n", | |
522 | pci_name(dev)); | |
523 | ||
524 | acpi_unregister_gsi(gsi); | |
525 | ||
d550d98d | 526 | return; |
1da177e4 | 527 | } |