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 | 27 | |
391df5dc | 28 | #include <linux/dmi.h> |
1da177e4 LT |
29 | #include <linux/kernel.h> |
30 | #include <linux/module.h> | |
31 | #include <linux/init.h> | |
32 | #include <linux/types.h> | |
33 | #include <linux/proc_fs.h> | |
34 | #include <linux/spinlock.h> | |
35 | #include <linux/pm.h> | |
36 | #include <linux/pci.h> | |
37 | #include <linux/acpi.h> | |
38 | #include <acpi/acpi_bus.h> | |
39 | #include <acpi/acpi_drivers.h> | |
40 | ||
1da177e4 | 41 | #define _COMPONENT ACPI_PCI_COMPONENT |
f52fd66d | 42 | ACPI_MODULE_NAME("pci_irq"); |
1da177e4 | 43 | |
f748bafa BH |
44 | struct acpi_prt_entry { |
45 | struct list_head node; | |
46 | struct acpi_pci_id id; | |
47 | u8 pin; | |
48 | struct { | |
49 | acpi_handle handle; | |
50 | u32 index; | |
51 | } link; | |
52 | u32 irq; | |
53 | }; | |
54 | ||
55 | struct acpi_prt_list { | |
56 | int count; | |
57 | struct list_head entries; | |
58 | }; | |
59 | ||
4be44fcd | 60 | static struct acpi_prt_list acpi_prt; |
1da177e4 LT |
61 | static DEFINE_SPINLOCK(acpi_prt_lock); |
62 | ||
63 | /* -------------------------------------------------------------------------- | |
64 | PCI IRQ Routing Table (PRT) Support | |
65 | -------------------------------------------------------------------------- */ | |
66 | ||
4be44fcd LB |
67 | static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment, |
68 | int bus, | |
69 | int device, int pin) | |
1da177e4 | 70 | { |
4be44fcd | 71 | struct acpi_prt_entry *entry = NULL; |
1da177e4 | 72 | |
1da177e4 | 73 | if (!acpi_prt.count) |
d550d98d | 74 | return NULL; |
1da177e4 LT |
75 | |
76 | /* | |
77 | * Parse through all PRT entries looking for a match on the specified | |
78 | * PCI device's segment, bus, device, and pin (don't care about func). | |
79 | * | |
80 | */ | |
81 | spin_lock(&acpi_prt_lock); | |
1a3b77ae | 82 | list_for_each_entry(entry, &acpi_prt.entries, node) { |
4be44fcd LB |
83 | if ((segment == entry->id.segment) |
84 | && (bus == entry->id.bus) | |
85 | && (device == entry->id.device) | |
86 | && (pin == entry->pin)) { | |
1da177e4 | 87 | spin_unlock(&acpi_prt_lock); |
d550d98d | 88 | return entry; |
1da177e4 LT |
89 | } |
90 | } | |
91 | ||
92 | spin_unlock(&acpi_prt_lock); | |
d550d98d | 93 | return NULL; |
1da177e4 LT |
94 | } |
95 | ||
391df5dc BH |
96 | /* http://bugzilla.kernel.org/show_bug.cgi?id=4773 */ |
97 | static struct dmi_system_id medion_md9580[] = { | |
98 | { | |
99 | .ident = "Medion MD9580-F laptop", | |
100 | .matches = { | |
101 | DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"), | |
102 | DMI_MATCH(DMI_PRODUCT_NAME, "A555"), | |
103 | }, | |
104 | }, | |
105 | { } | |
106 | }; | |
107 | ||
108 | /* http://bugzilla.kernel.org/show_bug.cgi?id=5044 */ | |
109 | static struct dmi_system_id dell_optiplex[] = { | |
110 | { | |
111 | .ident = "Dell Optiplex GX1", | |
112 | .matches = { | |
113 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"), | |
114 | DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX1 600S+"), | |
115 | }, | |
116 | }, | |
117 | { } | |
118 | }; | |
119 | ||
120 | /* http://bugzilla.kernel.org/show_bug.cgi?id=10138 */ | |
121 | static struct dmi_system_id hp_t5710[] = { | |
122 | { | |
123 | .ident = "HP t5710", | |
124 | .matches = { | |
125 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | |
126 | DMI_MATCH(DMI_PRODUCT_NAME, "hp t5000 series"), | |
127 | DMI_MATCH(DMI_BOARD_NAME, "098Ch"), | |
128 | }, | |
129 | }, | |
130 | { } | |
131 | }; | |
132 | ||
133 | struct prt_quirk { | |
134 | struct dmi_system_id *system; | |
135 | unsigned int segment; | |
136 | unsigned int bus; | |
137 | unsigned int device; | |
138 | unsigned char pin; | |
139 | char *source; /* according to BIOS */ | |
140 | char *actual_source; | |
141 | }; | |
142 | ||
143 | /* | |
144 | * These systems have incorrect _PRT entries. The BIOS claims the PCI | |
145 | * interrupt at the listed segment/bus/device/pin is connected to the first | |
146 | * link device, but it is actually connected to the second. | |
147 | */ | |
148 | static struct prt_quirk prt_quirks[] = { | |
149 | { medion_md9580, 0, 0, 9, 'A', | |
b97d4803 BH |
150 | "\\_SB_.PCI0.ISA_.LNKA", |
151 | "\\_SB_.PCI0.ISA_.LNKB"}, | |
391df5dc BH |
152 | { dell_optiplex, 0, 0, 0xd, 'A', |
153 | "\\_SB_.LNKB", | |
154 | "\\_SB_.LNKA"}, | |
155 | { hp_t5710, 0, 0, 1, 'A', | |
156 | "\\_SB_.PCI0.LNK1", | |
157 | "\\_SB_.PCI0.LNK3"}, | |
158 | }; | |
159 | ||
160 | static void | |
161 | do_prt_fixups(struct acpi_prt_entry *entry, struct acpi_pci_routing_table *prt) | |
162 | { | |
163 | int i; | |
164 | struct prt_quirk *quirk; | |
165 | ||
166 | for (i = 0; i < ARRAY_SIZE(prt_quirks); i++) { | |
167 | quirk = &prt_quirks[i]; | |
168 | ||
169 | /* All current quirks involve link devices, not GSIs */ | |
170 | if (!prt->source) | |
171 | continue; | |
172 | ||
173 | if (dmi_check_system(quirk->system) && | |
174 | entry->id.segment == quirk->segment && | |
175 | entry->id.bus == quirk->bus && | |
176 | entry->id.device == quirk->device && | |
177 | entry->pin + 'A' == quirk->pin && | |
178 | !strcmp(prt->source, quirk->source) && | |
179 | strlen(prt->source) >= strlen(quirk->actual_source)) { | |
180 | printk(KERN_WARNING PREFIX "firmware reports " | |
c83642d5 | 181 | "%04x:%02x:%02x PCI INT %c connected to %s; " |
391df5dc BH |
182 | "changing to %s\n", |
183 | entry->id.segment, entry->id.bus, | |
184 | entry->id.device, 'A' + entry->pin, | |
185 | prt->source, quirk->actual_source); | |
186 | strcpy(prt->source, quirk->actual_source); | |
187 | } | |
188 | } | |
189 | } | |
190 | ||
1da177e4 | 191 | static int |
4be44fcd LB |
192 | acpi_pci_irq_add_entry(acpi_handle handle, |
193 | int segment, int bus, struct acpi_pci_routing_table *prt) | |
1da177e4 | 194 | { |
4be44fcd | 195 | struct acpi_prt_entry *entry = NULL; |
1da177e4 | 196 | |
36bcbec7 | 197 | entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); |
1da177e4 | 198 | if (!entry) |
d550d98d | 199 | return -ENOMEM; |
1da177e4 LT |
200 | |
201 | entry->id.segment = segment; | |
202 | entry->id.bus = bus; | |
203 | entry->id.device = (prt->address >> 16) & 0xFFFF; | |
1da177e4 LT |
204 | entry->pin = prt->pin; |
205 | ||
391df5dc BH |
206 | do_prt_fixups(entry, prt); |
207 | ||
1da177e4 LT |
208 | /* |
209 | * Type 1: Dynamic | |
210 | * --------------- | |
211 | * The 'source' field specifies the PCI interrupt link device used to | |
212 | * configure the IRQ assigned to this slot|dev|pin. The 'source_index' | |
213 | * indicates which resource descriptor in the resource template (of | |
214 | * the link device) this interrupt is allocated from. | |
215 | * | |
216 | * NOTE: Don't query the Link Device for IRQ information at this time | |
217 | * because Link Device enumeration may not have occurred yet | |
218 | * (e.g. exists somewhere 'below' this _PRT entry in the ACPI | |
219 | * namespace). | |
220 | */ | |
221 | if (prt->source[0]) { | |
222 | acpi_get_handle(handle, prt->source, &entry->link.handle); | |
223 | entry->link.index = prt->source_index; | |
224 | } | |
225 | /* | |
226 | * Type 2: Static | |
227 | * -------------- | |
228 | * The 'source' field is NULL, and the 'source_index' field specifies | |
229 | * the IRQ value, which is hardwired to specific interrupt inputs on | |
230 | * the interrupt controller. | |
231 | */ | |
232 | else | |
233 | entry->link.index = prt->source_index; | |
234 | ||
235 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, | |
21a53283 | 236 | " %04x:%02x:%02x[%c] -> %s[%d]\n", |
4be44fcd LB |
237 | entry->id.segment, entry->id.bus, |
238 | entry->id.device, ('A' + entry->pin), prt->source, | |
239 | entry->link.index)); | |
1da177e4 LT |
240 | |
241 | spin_lock(&acpi_prt_lock); | |
242 | list_add_tail(&entry->node, &acpi_prt.entries); | |
243 | acpi_prt.count++; | |
244 | spin_unlock(&acpi_prt_lock); | |
245 | ||
d550d98d | 246 | return 0; |
1da177e4 LT |
247 | } |
248 | ||
1da177e4 | 249 | static void |
4be44fcd | 250 | acpi_pci_irq_del_entry(int segment, int bus, struct acpi_prt_entry *entry) |
1da177e4 | 251 | { |
4be44fcd | 252 | if (segment == entry->id.segment && bus == entry->id.bus) { |
1da177e4 LT |
253 | acpi_prt.count--; |
254 | list_del(&entry->node); | |
255 | kfree(entry); | |
256 | } | |
257 | } | |
258 | ||
4be44fcd | 259 | int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) |
1da177e4 | 260 | { |
2320ac6c BH |
261 | acpi_status status; |
262 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | |
263 | struct acpi_pci_routing_table *entry; | |
4be44fcd | 264 | static int first_time = 1; |
1da177e4 | 265 | |
1da177e4 LT |
266 | if (first_time) { |
267 | acpi_prt.count = 0; | |
268 | INIT_LIST_HEAD(&acpi_prt.entries); | |
269 | first_time = 0; | |
270 | } | |
271 | ||
2320ac6c BH |
272 | /* 'handle' is the _PRT's parent (root bridge or PCI-PCI bridge) */ |
273 | status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | |
274 | if (ACPI_FAILURE(status)) | |
275 | return -ENODEV; | |
1da177e4 LT |
276 | |
277 | printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n", | |
2320ac6c | 278 | (char *) buffer.pointer); |
1da177e4 | 279 | |
2320ac6c | 280 | kfree(buffer.pointer); |
1da177e4 | 281 | |
2320ac6c | 282 | buffer.length = ACPI_ALLOCATE_BUFFER; |
1da177e4 | 283 | buffer.pointer = NULL; |
1da177e4 LT |
284 | |
285 | status = acpi_get_irq_routing_table(handle, &buffer); | |
286 | if (ACPI_FAILURE(status)) { | |
a6fc6720 TR |
287 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]", |
288 | acpi_format_exception(status))); | |
1da177e4 | 289 | kfree(buffer.pointer); |
d550d98d | 290 | return -ENODEV; |
1da177e4 LT |
291 | } |
292 | ||
2320ac6c | 293 | entry = buffer.pointer; |
1da177e4 LT |
294 | while (entry && (entry->length > 0)) { |
295 | acpi_pci_irq_add_entry(handle, segment, bus, entry); | |
296 | entry = (struct acpi_pci_routing_table *) | |
4be44fcd | 297 | ((unsigned long)entry + entry->length); |
1da177e4 LT |
298 | } |
299 | ||
2320ac6c | 300 | kfree(buffer.pointer); |
d550d98d | 301 | return 0; |
1da177e4 LT |
302 | } |
303 | ||
4be44fcd | 304 | void acpi_pci_irq_del_prt(int segment, int bus) |
1da177e4 | 305 | { |
4be44fcd LB |
306 | struct list_head *node = NULL, *n = NULL; |
307 | struct acpi_prt_entry *entry = NULL; | |
1da177e4 | 308 | |
4be44fcd | 309 | if (!acpi_prt.count) { |
1da177e4 LT |
310 | return; |
311 | } | |
312 | ||
4be44fcd | 313 | printk(KERN_DEBUG |
21a53283 BH |
314 | "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n", |
315 | segment, bus); | |
1da177e4 LT |
316 | spin_lock(&acpi_prt_lock); |
317 | list_for_each_safe(node, n, &acpi_prt.entries) { | |
318 | entry = list_entry(node, struct acpi_prt_entry, node); | |
319 | ||
320 | acpi_pci_irq_del_entry(segment, bus, entry); | |
321 | } | |
322 | spin_unlock(&acpi_prt_lock); | |
323 | } | |
4be44fcd | 324 | |
1da177e4 LT |
325 | /* -------------------------------------------------------------------------- |
326 | PCI Interrupt Routing Support | |
327 | -------------------------------------------------------------------------- */ | |
4be44fcd | 328 | typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **); |
1da177e4 | 329 | |
87bec66b DSL |
330 | static int |
331 | acpi_pci_allocate_irq(struct acpi_prt_entry *entry, | |
50eca3eb | 332 | int *triggering, int *polarity, char **link) |
87bec66b | 333 | { |
4be44fcd | 334 | int irq; |
87bec66b | 335 | |
87bec66b DSL |
336 | |
337 | if (entry->link.handle) { | |
338 | irq = acpi_pci_link_allocate_irq(entry->link.handle, | |
50eca3eb BM |
339 | entry->link.index, triggering, |
340 | polarity, link); | |
87bec66b | 341 | if (irq < 0) { |
cece9296 LB |
342 | printk(KERN_WARNING PREFIX |
343 | "Invalid IRQ link routing entry\n"); | |
d550d98d | 344 | return -1; |
87bec66b DSL |
345 | } |
346 | } else { | |
347 | irq = entry->link.index; | |
50eca3eb BM |
348 | *triggering = ACPI_LEVEL_SENSITIVE; |
349 | *polarity = ACPI_ACTIVE_LOW; | |
87bec66b DSL |
350 | } |
351 | ||
c13f889a | 352 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found GSI %d\n", irq)); |
d550d98d | 353 | return irq; |
87bec66b DSL |
354 | } |
355 | ||
356 | static int | |
357 | acpi_pci_free_irq(struct acpi_prt_entry *entry, | |
50eca3eb | 358 | int *triggering, int *polarity, char **link) |
87bec66b | 359 | { |
4be44fcd | 360 | int irq; |
87bec66b | 361 | |
87bec66b DSL |
362 | if (entry->link.handle) { |
363 | irq = acpi_pci_link_free_irq(entry->link.handle); | |
364 | } else { | |
365 | irq = entry->link.index; | |
366 | } | |
d550d98d | 367 | return irq; |
87bec66b | 368 | } |
4be44fcd | 369 | |
1da177e4 LT |
370 | /* |
371 | * acpi_pci_irq_lookup | |
372 | * success: return IRQ >= 0 | |
373 | * failure: return -1 | |
374 | */ | |
375 | static int | |
4be44fcd LB |
376 | acpi_pci_irq_lookup(struct pci_bus *bus, |
377 | int device, | |
378 | int pin, | |
50eca3eb BM |
379 | int *triggering, |
380 | int *polarity, char **link, irq_lookup_func func) | |
1da177e4 | 381 | { |
4be44fcd | 382 | struct acpi_prt_entry *entry = NULL; |
1da177e4 LT |
383 | int segment = pci_domain_nr(bus); |
384 | int bus_nr = bus->number; | |
87bec66b | 385 | int ret; |
1da177e4 | 386 | |
1da177e4 | 387 | |
4be44fcd | 388 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
21a53283 | 389 | "Searching for _PRT entry for %04x:%02x:%02x[%c]\n", |
4be44fcd | 390 | segment, bus_nr, device, ('A' + pin))); |
1da177e4 | 391 | |
4be44fcd | 392 | entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin); |
1da177e4 | 393 | if (!entry) { |
21a53283 | 394 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_PRT entry not found\n")); |
d550d98d | 395 | return -1; |
1da177e4 | 396 | } |
4be44fcd | 397 | |
50eca3eb | 398 | ret = func(entry, triggering, polarity, link); |
d550d98d | 399 | return ret; |
1da177e4 LT |
400 | } |
401 | ||
402 | /* | |
403 | * acpi_pci_irq_derive | |
404 | * success: return IRQ >= 0 | |
405 | * failure: return < 0 | |
406 | */ | |
407 | static int | |
4be44fcd LB |
408 | acpi_pci_irq_derive(struct pci_dev *dev, |
409 | int pin, | |
50eca3eb BM |
410 | int *triggering, |
411 | int *polarity, char **link, irq_lookup_func func) | |
1da177e4 | 412 | { |
4be44fcd LB |
413 | struct pci_dev *bridge = dev; |
414 | int irq = -1; | |
c83642d5 | 415 | u8 bridge_pin = 0, orig_pin = pin; |
1da177e4 | 416 | |
1da177e4 | 417 | |
1da177e4 LT |
418 | /* |
419 | * Attempt to derive an IRQ for this device from a parent bridge's | |
420 | * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge). | |
421 | */ | |
422 | while (irq < 0 && bridge->bus->self) { | |
423 | pin = (pin + PCI_SLOT(bridge->devfn)) % 4; | |
424 | bridge = bridge->bus->self; | |
425 | ||
426 | if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) { | |
427 | /* PC card has the same IRQ as its cardbridge */ | |
8015a014 | 428 | bridge_pin = bridge->pin; |
1da177e4 | 429 | if (!bridge_pin) { |
4be44fcd LB |
430 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
431 | "No interrupt pin configured for device %s\n", | |
432 | pci_name(bridge))); | |
d550d98d | 433 | return -1; |
1da177e4 LT |
434 | } |
435 | /* Pin is from 0 to 3 */ | |
4be44fcd | 436 | bridge_pin--; |
1da177e4 LT |
437 | pin = bridge_pin; |
438 | } | |
439 | ||
440 | irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), | |
50eca3eb | 441 | pin, triggering, polarity, |
4be44fcd | 442 | link, func); |
1da177e4 LT |
443 | } |
444 | ||
445 | if (irq < 0) { | |
c83642d5 BH |
446 | dev_warn(&dev->dev, "can't derive routing for PCI INT %c\n", |
447 | 'A' + orig_pin); | |
d550d98d | 448 | return -1; |
1da177e4 LT |
449 | } |
450 | ||
c13f889a | 451 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive GSI %d for device %s from %s\n", |
4be44fcd | 452 | irq, pci_name(dev), pci_name(bridge))); |
1da177e4 | 453 | |
d550d98d | 454 | return irq; |
1da177e4 LT |
455 | } |
456 | ||
457 | /* | |
458 | * acpi_pci_irq_enable | |
459 | * success: return 0 | |
460 | * failure: return < 0 | |
461 | */ | |
462 | ||
4be44fcd | 463 | int acpi_pci_irq_enable(struct pci_dev *dev) |
1da177e4 | 464 | { |
c13f889a | 465 | int gsi = 0; |
4be44fcd | 466 | u8 pin = 0; |
50eca3eb BM |
467 | int triggering = ACPI_LEVEL_SENSITIVE; |
468 | int polarity = ACPI_ACTIVE_LOW; | |
4be44fcd | 469 | char *link = NULL; |
c83642d5 | 470 | char link_desc[16]; |
4be44fcd | 471 | int rc; |
1da177e4 | 472 | |
1da177e4 | 473 | |
8015a014 | 474 | pin = dev->pin; |
1da177e4 | 475 | if (!pin) { |
4be44fcd LB |
476 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
477 | "No interrupt pin configured for device %s\n", | |
478 | pci_name(dev))); | |
d550d98d | 479 | return 0; |
1da177e4 LT |
480 | } |
481 | pin--; | |
482 | ||
1da177e4 LT |
483 | /* |
484 | * First we check the PCI IRQ routing table (PRT) for an IRQ. PRT | |
485 | * values override any BIOS-assigned IRQs set during boot. | |
486 | */ | |
c13f889a | 487 | gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, |
50eca3eb | 488 | &triggering, &polarity, &link, |
4be44fcd | 489 | acpi_pci_allocate_irq); |
1da177e4 LT |
490 | |
491 | /* | |
492 | * If no PRT entry was found, we'll try to derive an IRQ from the | |
493 | * device's parent bridge. | |
494 | */ | |
c13f889a BH |
495 | if (gsi < 0) |
496 | gsi = acpi_pci_irq_derive(dev, pin, &triggering, | |
50eca3eb | 497 | &polarity, &link, |
4be44fcd LB |
498 | acpi_pci_allocate_irq); |
499 | ||
c13f889a | 500 | if (gsi < 0) { |
96c2a876 AC |
501 | /* |
502 | * IDE legacy mode controller IRQs are magic. Why do compat | |
503 | * extensions always make such a nasty mess. | |
504 | */ | |
505 | if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE && | |
506 | (dev->class & 0x05) == 0) | |
507 | return 0; | |
508 | } | |
1da177e4 LT |
509 | /* |
510 | * No IRQ known to the ACPI subsystem - maybe the BIOS / | |
511 | * driver reported one, then use it. Exit in any case. | |
512 | */ | |
c13f889a | 513 | if (gsi < 0) { |
c83642d5 | 514 | dev_warn(&dev->dev, "PCI INT %c: no GSI", 'A' + pin); |
1da177e4 | 515 | /* Interrupt Line values above 0xF are forbidden */ |
44f8e1a2 | 516 | if (dev->irq > 0 && (dev->irq <= 0xF)) { |
1da177e4 | 517 | printk(" - using IRQ %d\n", dev->irq); |
4be44fcd LB |
518 | acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, |
519 | ACPI_ACTIVE_LOW); | |
d550d98d | 520 | return 0; |
4be44fcd | 521 | } else { |
1da177e4 | 522 | printk("\n"); |
d550d98d | 523 | return 0; |
1da177e4 | 524 | } |
4be44fcd | 525 | } |
1da177e4 | 526 | |
c13f889a | 527 | rc = acpi_register_gsi(gsi, triggering, polarity); |
349f0d56 | 528 | if (rc < 0) { |
c83642d5 BH |
529 | dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n", |
530 | 'A' + pin); | |
d550d98d | 531 | return rc; |
349f0d56 KK |
532 | } |
533 | dev->irq = rc; | |
1da177e4 | 534 | |
1da177e4 | 535 | if (link) |
c83642d5 BH |
536 | snprintf(link_desc, sizeof(link_desc), " -> Link[%s]", link); |
537 | else | |
538 | link_desc[0] = '\0'; | |
1da177e4 | 539 | |
c83642d5 | 540 | dev_info(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n", |
c13f889a | 541 | 'A' + pin, link_desc, gsi, |
c83642d5 BH |
542 | (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", |
543 | (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); | |
1da177e4 | 544 | |
d550d98d | 545 | return 0; |
1da177e4 | 546 | } |
1da177e4 | 547 | |
87bec66b | 548 | /* FIXME: implement x86/x86_64 version */ |
4be44fcd LB |
549 | void __attribute__ ((weak)) acpi_unregister_gsi(u32 i) |
550 | { | |
551 | } | |
87bec66b | 552 | |
4be44fcd | 553 | void acpi_pci_irq_disable(struct pci_dev *dev) |
1da177e4 | 554 | { |
4be44fcd LB |
555 | int gsi = 0; |
556 | u8 pin = 0; | |
50eca3eb BM |
557 | int triggering = ACPI_LEVEL_SENSITIVE; |
558 | int polarity = ACPI_ACTIVE_LOW; | |
1da177e4 | 559 | |
1da177e4 | 560 | |
8015a014 | 561 | pin = dev->pin; |
1da177e4 | 562 | if (!pin) |
d550d98d | 563 | return; |
1da177e4 LT |
564 | pin--; |
565 | ||
1da177e4 LT |
566 | /* |
567 | * First we check the PCI IRQ routing table (PRT) for an IRQ. | |
568 | */ | |
4be44fcd | 569 | gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, |
50eca3eb | 570 | &triggering, &polarity, NULL, |
4be44fcd | 571 | acpi_pci_free_irq); |
1da177e4 LT |
572 | /* |
573 | * If no PRT entry was found, we'll try to derive an IRQ from the | |
574 | * device's parent bridge. | |
575 | */ | |
576 | if (gsi < 0) | |
4be44fcd | 577 | gsi = acpi_pci_irq_derive(dev, pin, |
50eca3eb | 578 | &triggering, &polarity, NULL, |
4be44fcd | 579 | acpi_pci_free_irq); |
1da177e4 | 580 | if (gsi < 0) |
d550d98d | 581 | return; |
1da177e4 LT |
582 | |
583 | /* | |
584 | * TBD: It might be worth clearing dev->irq by magic constant | |
585 | * (e.g. PCI_UNDEFINED_IRQ). | |
586 | */ | |
587 | ||
c83642d5 | 588 | dev_info(&dev->dev, "PCI INT %c disabled\n", 'A' + pin); |
1da177e4 | 589 | acpi_unregister_gsi(gsi); |
1da177e4 | 590 | } |