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