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