Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * pci_link.c - ACPI PCI Interrupt Link Device Driver ($Revision: 34 $) |
| 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 | * TBD: |
| 27 | * 1. Support more than one IRQ resource entry per link device (index). |
| 28 | * 2. Implement start/stop mechanism and use ACPI Bus Driver facilities |
| 29 | * for IRQ management (e.g. start()->_SRS). |
| 30 | */ |
| 31 | |
| 32 | #include <linux/sysdev.h> |
| 33 | #include <linux/kernel.h> |
| 34 | #include <linux/module.h> |
| 35 | #include <linux/init.h> |
| 36 | #include <linux/types.h> |
| 37 | #include <linux/proc_fs.h> |
| 38 | #include <linux/spinlock.h> |
| 39 | #include <linux/pm.h> |
| 40 | #include <linux/pci.h> |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 41 | #include <linux/mutex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | #include <acpi/acpi_bus.h> |
| 44 | #include <acpi/acpi_drivers.h> |
| 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #define _COMPONENT ACPI_PCI_COMPONENT |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 47 | ACPI_MODULE_NAME("pci_link") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define ACPI_PCI_LINK_CLASS "pci_irq_routing" |
| 49 | #define ACPI_PCI_LINK_HID "PNP0C0F" |
| 50 | #define ACPI_PCI_LINK_DRIVER_NAME "ACPI PCI Interrupt Link Driver" |
| 51 | #define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link" |
| 52 | #define ACPI_PCI_LINK_FILE_INFO "info" |
| 53 | #define ACPI_PCI_LINK_FILE_STATUS "state" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | #define ACPI_PCI_LINK_MAX_POSSIBLE 16 |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 55 | static int acpi_pci_link_add(struct acpi_device *device); |
| 56 | static int acpi_pci_link_remove(struct acpi_device *device, int type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | static struct acpi_driver acpi_pci_link_driver = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 59 | .name = ACPI_PCI_LINK_DRIVER_NAME, |
| 60 | .class = ACPI_PCI_LINK_CLASS, |
| 61 | .ids = ACPI_PCI_LINK_HID, |
| 62 | .ops = { |
| 63 | .add = acpi_pci_link_add, |
| 64 | .remove = acpi_pci_link_remove, |
| 65 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 68 | /* |
| 69 | * If a link is initialized, we never change its active and initialized |
| 70 | * later even the link is disable. Instead, we just repick the active irq |
| 71 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | struct acpi_pci_link_irq { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 73 | u8 active; /* Current IRQ */ |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 74 | u8 triggering; /* All IRQs */ |
| 75 | u8 polarity; /* All IRQs */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 76 | u8 resource_type; |
| 77 | u8 possible_count; |
| 78 | u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; |
| 79 | u8 initialized:1; |
| 80 | u8 reserved:7; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | struct acpi_pci_link { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 84 | struct list_head node; |
| 85 | struct acpi_device *device; |
| 86 | acpi_handle handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | struct acpi_pci_link_irq irq; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 88 | int refcnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | static struct { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 92 | int count; |
| 93 | struct list_head entries; |
| 94 | } acpi_link; |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 95 | DEFINE_MUTEX(acpi_link_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | /* -------------------------------------------------------------------------- |
| 98 | PCI Link Device Management |
| 99 | -------------------------------------------------------------------------- */ |
| 100 | |
| 101 | /* |
| 102 | * set context (link) possible list from resource list |
| 103 | */ |
| 104 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 105 | acpi_pci_link_check_possible(struct acpi_resource *resource, void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 107 | struct acpi_pci_link *link = (struct acpi_pci_link *)context; |
| 108 | u32 i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
| 110 | ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible"); |
| 111 | |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 112 | switch (resource->type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 113 | case ACPI_RESOURCE_TYPE_START_DEPENDENT: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | return_ACPI_STATUS(AE_OK); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 115 | case ACPI_RESOURCE_TYPE_IRQ: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 116 | { |
| 117 | struct acpi_resource_irq *p = &resource->data.irq; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 118 | if (!p || !p->interrupt_count) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 119 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
| 120 | "Blank IRQ resource\n")); |
| 121 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 123 | for (i = 0; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 124 | (i < p->interrupt_count |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 125 | && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { |
| 126 | if (!p->interrupts[i]) { |
| 127 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
| 128 | "Invalid IRQ %d\n", |
| 129 | p->interrupts[i])); |
| 130 | continue; |
| 131 | } |
| 132 | link->irq.possible[i] = p->interrupts[i]; |
| 133 | link->irq.possible_count++; |
| 134 | } |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 135 | link->irq.triggering = p->triggering; |
| 136 | link->irq.polarity = p->polarity; |
| 137 | link->irq.resource_type = ACPI_RESOURCE_TYPE_IRQ; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 138 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | } |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 140 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 141 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 142 | struct acpi_resource_extended_irq *p = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 143 | &resource->data.extended_irq; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 144 | if (!p || !p->interrupt_count) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 145 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
| 146 | "Blank EXT IRQ resource\n")); |
| 147 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 149 | for (i = 0; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 150 | (i < p->interrupt_count |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 151 | && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { |
| 152 | if (!p->interrupts[i]) { |
| 153 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
| 154 | "Invalid IRQ %d\n", |
| 155 | p->interrupts[i])); |
| 156 | continue; |
| 157 | } |
| 158 | link->irq.possible[i] = p->interrupts[i]; |
| 159 | link->irq.possible_count++; |
| 160 | } |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 161 | link->irq.triggering = p->triggering; |
| 162 | link->irq.polarity = p->polarity; |
| 163 | link->irq.resource_type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 164 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | default: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 167 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 168 | "Resource is not an IRQ entry\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | return_ACPI_STATUS(AE_OK); |
| 170 | } |
| 171 | |
| 172 | return_ACPI_STATUS(AE_CTRL_TERMINATE); |
| 173 | } |
| 174 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 175 | static int acpi_pci_link_get_possible(struct acpi_pci_link *link) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 177 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
| 179 | ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible"); |
| 180 | |
| 181 | if (!link) |
| 182 | return_VALUE(-EINVAL); |
| 183 | |
| 184 | status = acpi_walk_resources(link->handle, METHOD_NAME__PRS, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 185 | acpi_pci_link_check_possible, link); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | if (ACPI_FAILURE(status)) { |
| 187 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n")); |
| 188 | return_VALUE(-ENODEV); |
| 189 | } |
| 190 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 191 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 192 | "Found %d possible IRQs\n", |
| 193 | link->irq.possible_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
| 195 | return_VALUE(0); |
| 196 | } |
| 197 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 199 | acpi_pci_link_check_current(struct acpi_resource *resource, void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 201 | int *irq = (int *)context; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
| 203 | ACPI_FUNCTION_TRACE("acpi_pci_link_check_current"); |
| 204 | |
Len Brown | eca008c | 2005-09-22 00:25:18 -0400 | [diff] [blame] | 205 | switch (resource->type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 206 | case ACPI_RESOURCE_TYPE_IRQ: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 207 | { |
| 208 | struct acpi_resource_irq *p = &resource->data.irq; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 209 | if (!p || !p->interrupt_count) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 210 | /* |
| 211 | * IRQ descriptors may have no IRQ# bits set, |
| 212 | * particularly those those w/ _STA disabled |
| 213 | */ |
| 214 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 215 | "Blank IRQ resource\n")); |
| 216 | return_ACPI_STATUS(AE_OK); |
| 217 | } |
| 218 | *irq = p->interrupts[0]; |
| 219 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | } |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 221 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 222 | { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 223 | struct acpi_resource_extended_irq *p = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 224 | &resource->data.extended_irq; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 225 | if (!p || !p->interrupt_count) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 226 | /* |
| 227 | * extended IRQ descriptors must |
| 228 | * return at least 1 IRQ |
| 229 | */ |
| 230 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, |
| 231 | "Blank EXT IRQ resource\n")); |
| 232 | return_ACPI_STATUS(AE_OK); |
| 233 | } |
| 234 | *irq = p->interrupts[0]; |
| 235 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | } |
Len Brown | d4ec6c7 | 2006-01-26 17:23:38 -0500 | [diff] [blame] | 237 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | default: |
Len Brown | d4ec6c7 | 2006-01-26 17:23:38 -0500 | [diff] [blame] | 239 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource %d isn't an IRQ\n", resource->type)); |
| 240 | case ACPI_RESOURCE_TYPE_END_TAG: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | return_ACPI_STATUS(AE_OK); |
| 242 | } |
| 243 | return_ACPI_STATUS(AE_CTRL_TERMINATE); |
| 244 | } |
| 245 | |
| 246 | /* |
| 247 | * Run _CRS and set link->irq.active |
| 248 | * |
| 249 | * return value: |
| 250 | * 0 - success |
| 251 | * !0 - failure |
| 252 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 253 | static int acpi_pci_link_get_current(struct acpi_pci_link *link) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 255 | int result = 0; |
| 256 | acpi_status status = AE_OK; |
| 257 | int irq = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | |
| 259 | ACPI_FUNCTION_TRACE("acpi_pci_link_get_current"); |
| 260 | |
| 261 | if (!link || !link->handle) |
| 262 | return_VALUE(-EINVAL); |
| 263 | |
| 264 | link->irq.active = 0; |
| 265 | |
| 266 | /* in practice, status disabled is meaningless, ignore it */ |
| 267 | if (acpi_strict) { |
| 268 | /* Query _STA, set link->device->status */ |
| 269 | result = acpi_bus_get_status(link->device); |
| 270 | if (result) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 271 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 272 | "Unable to read status\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | goto end; |
| 274 | } |
| 275 | |
| 276 | if (!link->device->status.enabled) { |
| 277 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n")); |
| 278 | return_VALUE(0); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | /* |
| 283 | * Query and parse _CRS to get the current IRQ assignment. |
| 284 | */ |
| 285 | |
| 286 | status = acpi_walk_resources(link->handle, METHOD_NAME__CRS, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 287 | acpi_pci_link_check_current, &irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | if (ACPI_FAILURE(status)) { |
| 289 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n")); |
| 290 | result = -ENODEV; |
| 291 | goto end; |
| 292 | } |
| 293 | |
| 294 | if (acpi_strict && !irq) { |
| 295 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_CRS returned 0\n")); |
| 296 | result = -ENODEV; |
| 297 | } |
| 298 | |
| 299 | link->irq.active = irq; |
| 300 | |
| 301 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active)); |
| 302 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 303 | end: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | return_VALUE(result); |
| 305 | } |
| 306 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 307 | static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 309 | int result = 0; |
| 310 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | struct { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 312 | struct acpi_resource res; |
| 313 | struct acpi_resource end; |
| 314 | } *resource; |
| 315 | struct acpi_buffer buffer = { 0, NULL }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | |
| 317 | ACPI_FUNCTION_TRACE("acpi_pci_link_set"); |
| 318 | |
| 319 | if (!link || !irq) |
| 320 | return_VALUE(-EINVAL); |
| 321 | |
Dave Jones | a64882e | 2005-12-12 00:37:40 -0800 | [diff] [blame] | 322 | resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 323 | if (!resource) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | return_VALUE(-ENOMEM); |
| 325 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 326 | memset(resource, 0, sizeof(*resource) + 1); |
| 327 | buffer.length = sizeof(*resource) + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | buffer.pointer = resource; |
| 329 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 330 | switch (link->irq.resource_type) { |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 331 | case ACPI_RESOURCE_TYPE_IRQ: |
| 332 | resource->res.type = ACPI_RESOURCE_TYPE_IRQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | resource->res.length = sizeof(struct acpi_resource); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 334 | resource->res.data.irq.triggering = link->irq.triggering; |
| 335 | resource->res.data.irq.polarity = |
| 336 | link->irq.polarity; |
| 337 | if (link->irq.triggering == ACPI_EDGE_SENSITIVE) |
| 338 | resource->res.data.irq.sharable = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 339 | ACPI_EXCLUSIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | else |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 341 | resource->res.data.irq.sharable = ACPI_SHARED; |
| 342 | resource->res.data.irq.interrupt_count = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | resource->res.data.irq.interrupts[0] = irq; |
| 344 | break; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 345 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 346 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
| 347 | resource->res.type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | resource->res.length = sizeof(struct acpi_resource); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 349 | resource->res.data.extended_irq.producer_consumer = |
| 350 | ACPI_CONSUMER; |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 351 | resource->res.data.extended_irq.triggering = |
| 352 | link->irq.triggering; |
| 353 | resource->res.data.extended_irq.polarity = |
| 354 | link->irq.polarity; |
| 355 | if (link->irq.triggering == ACPI_EDGE_SENSITIVE) |
| 356 | resource->res.data.irq.sharable = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 357 | ACPI_EXCLUSIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | else |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 359 | resource->res.data.irq.sharable = ACPI_SHARED; |
| 360 | resource->res.data.extended_irq.interrupt_count = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | resource->res.data.extended_irq.interrupts[0] = irq; |
| 362 | /* ignore resource_source, it's optional */ |
| 363 | break; |
| 364 | default: |
| 365 | printk("ACPI BUG: resource_type %d\n", link->irq.resource_type); |
| 366 | result = -EINVAL; |
| 367 | goto end; |
| 368 | |
| 369 | } |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 370 | resource->end.type = ACPI_RESOURCE_TYPE_END_TAG; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | |
| 372 | /* Attempt to set the resource */ |
| 373 | status = acpi_set_current_resources(link->handle, &buffer); |
| 374 | |
| 375 | /* check for total failure */ |
| 376 | if (ACPI_FAILURE(status)) { |
| 377 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SRS\n")); |
| 378 | result = -ENODEV; |
| 379 | goto end; |
| 380 | } |
| 381 | |
| 382 | /* Query _STA, set device->status */ |
| 383 | result = acpi_bus_get_status(link->device); |
| 384 | if (result) { |
| 385 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n")); |
| 386 | goto end; |
| 387 | } |
| 388 | if (!link->device->status.enabled) { |
| 389 | printk(KERN_WARNING PREFIX |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 390 | "%s [%s] disabled and referenced, BIOS bug.\n", |
| 391 | acpi_device_name(link->device), |
| 392 | acpi_device_bid(link->device)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | /* Query _CRS, set link->irq.active */ |
| 396 | result = acpi_pci_link_get_current(link); |
| 397 | if (result) { |
| 398 | goto end; |
| 399 | } |
| 400 | |
| 401 | /* |
| 402 | * Is current setting not what we set? |
| 403 | * set link->irq.active |
| 404 | */ |
| 405 | if (link->irq.active != irq) { |
| 406 | /* |
| 407 | * policy: when _CRS doesn't return what we just _SRS |
| 408 | * assume _SRS worked and override _CRS value. |
| 409 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 410 | printk(KERN_WARNING PREFIX |
| 411 | "%s [%s] BIOS reported IRQ %d, using IRQ %d\n", |
| 412 | acpi_device_name(link->device), |
| 413 | acpi_device_bid(link->device), link->irq.active, irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | link->irq.active = irq; |
| 415 | } |
| 416 | |
| 417 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Set IRQ %d\n", link->irq.active)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 418 | |
| 419 | end: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | kfree(resource); |
| 421 | return_VALUE(result); |
| 422 | } |
| 423 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | /* -------------------------------------------------------------------------- |
| 425 | PCI Link IRQ Management |
| 426 | -------------------------------------------------------------------------- */ |
| 427 | |
| 428 | /* |
| 429 | * "acpi_irq_balance" (default in APIC mode) enables ACPI to use PIC Interrupt |
| 430 | * Link Devices to move the PIRQs around to minimize sharing. |
| 431 | * |
| 432 | * "acpi_irq_nobalance" (default in PIC mode) tells ACPI not to move any PIC IRQs |
| 433 | * that the BIOS has already set to active. This is necessary because |
| 434 | * ACPI has no automatic means of knowing what ISA IRQs are used. Note that |
| 435 | * if the BIOS doesn't set a Link Device active, ACPI needs to program it |
| 436 | * even if acpi_irq_nobalance is set. |
| 437 | * |
| 438 | * A tables of penalties avoids directing PCI interrupts to well known |
| 439 | * ISA IRQs. Boot params are available to over-ride the default table: |
| 440 | * |
| 441 | * List interrupts that are free for PCI use. |
| 442 | * acpi_irq_pci=n[,m] |
| 443 | * |
| 444 | * List interrupts that should not be used for PCI: |
| 445 | * acpi_irq_isa=n[,m] |
| 446 | * |
| 447 | * Note that PCI IRQ routers have a list of possible IRQs, |
| 448 | * which may not include the IRQs this table says are available. |
| 449 | * |
| 450 | * Since this heuristic can't tell the difference between a link |
| 451 | * that no device will attach to, vs. a link which may be shared |
| 452 | * by multiple active devices -- it is not optimal. |
| 453 | * |
| 454 | * If interrupt performance is that important, get an IO-APIC system |
| 455 | * with a pin dedicated to each device. Or for that matter, an MSI |
| 456 | * enabled system. |
| 457 | */ |
| 458 | |
| 459 | #define ACPI_MAX_IRQS 256 |
| 460 | #define ACPI_MAX_ISA_IRQ 16 |
| 461 | |
| 462 | #define PIRQ_PENALTY_PCI_AVAILABLE (0) |
| 463 | #define PIRQ_PENALTY_PCI_POSSIBLE (16*16) |
| 464 | #define PIRQ_PENALTY_PCI_USING (16*16*16) |
| 465 | #define PIRQ_PENALTY_ISA_TYPICAL (16*16*16*16) |
| 466 | #define PIRQ_PENALTY_ISA_USED (16*16*16*16*16) |
| 467 | #define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16) |
| 468 | |
| 469 | static int acpi_irq_penalty[ACPI_MAX_IRQS] = { |
| 470 | PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */ |
| 471 | PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */ |
| 472 | PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 473 | PIRQ_PENALTY_ISA_TYPICAL, /* IRQ3 serial */ |
| 474 | PIRQ_PENALTY_ISA_TYPICAL, /* IRQ4 serial */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | PIRQ_PENALTY_ISA_TYPICAL, /* IRQ5 sometimes SoundBlaster */ |
| 476 | PIRQ_PENALTY_ISA_TYPICAL, /* IRQ6 */ |
| 477 | PIRQ_PENALTY_ISA_TYPICAL, /* IRQ7 parallel, spurious */ |
| 478 | PIRQ_PENALTY_ISA_TYPICAL, /* IRQ8 rtc, sometimes */ |
| 479 | PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ9 PCI, often acpi */ |
| 480 | PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ10 PCI */ |
| 481 | PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ11 PCI */ |
| 482 | PIRQ_PENALTY_ISA_USED, /* IRQ12 mouse */ |
| 483 | PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */ |
| 484 | PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */ |
| 485 | PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 486 | /* >IRQ15 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | }; |
| 488 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 489 | int __init acpi_irq_penalty_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 491 | struct list_head *node = NULL; |
| 492 | struct acpi_pci_link *link = NULL; |
| 493 | int i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | |
| 495 | ACPI_FUNCTION_TRACE("acpi_irq_penalty_init"); |
| 496 | |
| 497 | /* |
| 498 | * Update penalties to facilitate IRQ balancing. |
| 499 | */ |
| 500 | list_for_each(node, &acpi_link.entries) { |
| 501 | |
| 502 | link = list_entry(node, struct acpi_pci_link, node); |
| 503 | if (!link) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 504 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 505 | "Invalid link context\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | continue; |
| 507 | } |
| 508 | |
| 509 | /* |
| 510 | * reflect the possible and active irqs in the penalty table -- |
| 511 | * useful for breaking ties. |
| 512 | */ |
| 513 | if (link->irq.possible_count) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 514 | int penalty = |
| 515 | PIRQ_PENALTY_PCI_POSSIBLE / |
| 516 | link->irq.possible_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | |
| 518 | for (i = 0; i < link->irq.possible_count; i++) { |
| 519 | if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 520 | acpi_irq_penalty[link->irq. |
| 521 | possible[i]] += |
| 522 | penalty; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | } else if (link->irq.active) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 526 | acpi_irq_penalty[link->irq.active] += |
| 527 | PIRQ_PENALTY_PCI_POSSIBLE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | } |
| 529 | } |
| 530 | /* Add a penalty for the SCI */ |
| 531 | acpi_irq_penalty[acpi_fadt.sci_int] += PIRQ_PENALTY_PCI_USING; |
| 532 | |
| 533 | return_VALUE(0); |
| 534 | } |
| 535 | |
| 536 | static int acpi_irq_balance; /* 0: static, 1: balance */ |
| 537 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 538 | static int acpi_pci_link_allocate(struct acpi_pci_link *link) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 540 | int irq; |
| 541 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | |
| 543 | ACPI_FUNCTION_TRACE("acpi_pci_link_allocate"); |
| 544 | |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 545 | if (link->irq.initialized) { |
| 546 | if (link->refcnt == 0) |
| 547 | /* This means the link is disabled but initialized */ |
| 548 | acpi_pci_link_set(link, link->irq.active); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | return_VALUE(0); |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 550 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | |
| 552 | /* |
| 553 | * search for active IRQ in list of possible IRQs. |
| 554 | */ |
| 555 | for (i = 0; i < link->irq.possible_count; ++i) { |
| 556 | if (link->irq.active == link->irq.possible[i]) |
| 557 | break; |
| 558 | } |
| 559 | /* |
| 560 | * forget active IRQ that is not in possible list |
| 561 | */ |
| 562 | if (i == link->irq.possible_count) { |
| 563 | if (acpi_strict) |
| 564 | printk(KERN_WARNING PREFIX "_CRS %d not found" |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 565 | " in _PRS\n", link->irq.active); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | link->irq.active = 0; |
| 567 | } |
| 568 | |
| 569 | /* |
| 570 | * if active found, use it; else pick entry from end of possible list. |
| 571 | */ |
| 572 | if (link->irq.active) { |
| 573 | irq = link->irq.active; |
| 574 | } else { |
| 575 | irq = link->irq.possible[link->irq.possible_count - 1]; |
| 576 | } |
| 577 | |
| 578 | if (acpi_irq_balance || !link->irq.active) { |
| 579 | /* |
| 580 | * Select the best IRQ. This is done in reverse to promote |
| 581 | * the use of IRQs 9, 10, 11, and >15. |
| 582 | */ |
| 583 | for (i = (link->irq.possible_count - 1); i >= 0; i--) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 584 | if (acpi_irq_penalty[irq] > |
| 585 | acpi_irq_penalty[link->irq.possible[i]]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | irq = link->irq.possible[i]; |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | /* Attempt to enable the link device at this IRQ. */ |
| 591 | if (acpi_pci_link_set(link, irq)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 592 | printk(PREFIX |
| 593 | "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n" |
| 594 | "Try pci=noacpi or acpi=off\n", |
| 595 | acpi_device_name(link->device), |
| 596 | acpi_device_bid(link->device)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | return_VALUE(-ENODEV); |
| 598 | } else { |
| 599 | acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 600 | printk(PREFIX "%s [%s] enabled at IRQ %d\n", |
| 601 | acpi_device_name(link->device), |
| 602 | acpi_device_bid(link->device), link->irq.active); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | link->irq.initialized = 1; |
| 606 | |
| 607 | return_VALUE(0); |
| 608 | } |
| 609 | |
| 610 | /* |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 611 | * acpi_pci_link_allocate_irq |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | * success: return IRQ >= 0 |
| 613 | * failure: return -1 |
| 614 | */ |
| 615 | |
| 616 | int |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 617 | acpi_pci_link_allocate_irq(acpi_handle handle, |
| 618 | int index, |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 619 | int *triggering, int *polarity, char **name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 621 | int result = 0; |
| 622 | struct acpi_device *device = NULL; |
| 623 | struct acpi_pci_link *link = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 625 | ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | |
| 627 | result = acpi_bus_get_device(handle, &device); |
| 628 | if (result) { |
| 629 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n")); |
| 630 | return_VALUE(-1); |
| 631 | } |
| 632 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 633 | link = (struct acpi_pci_link *)acpi_driver_data(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | if (!link) { |
| 635 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); |
| 636 | return_VALUE(-1); |
| 637 | } |
| 638 | |
| 639 | /* TBD: Support multiple index (IRQ) entries per Link Device */ |
| 640 | if (index) { |
| 641 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid index %d\n", index)); |
| 642 | return_VALUE(-1); |
| 643 | } |
| 644 | |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 645 | mutex_lock(&acpi_link_lock); |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 646 | if (acpi_pci_link_allocate(link)) { |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 647 | mutex_unlock(&acpi_link_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | return_VALUE(-1); |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 649 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 650 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | if (!link->irq.active) { |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 652 | mutex_unlock(&acpi_link_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n")); |
| 654 | return_VALUE(-1); |
| 655 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 656 | link->refcnt++; |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 657 | mutex_unlock(&acpi_link_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 659 | if (triggering) |
| 660 | *triggering = link->irq.triggering; |
| 661 | if (polarity) |
| 662 | *polarity = link->irq.polarity; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 663 | if (name) |
| 664 | *name = acpi_device_bid(link->device); |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 665 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 666 | "Link %s is referenced\n", |
| 667 | acpi_device_bid(link->device))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | return_VALUE(link->irq.active); |
| 669 | } |
| 670 | |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 671 | /* |
| 672 | * We don't change link's irq information here. After it is reenabled, we |
| 673 | * continue use the info |
| 674 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 675 | int acpi_pci_link_free_irq(acpi_handle handle) |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 676 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 677 | struct acpi_device *device = NULL; |
| 678 | struct acpi_pci_link *link = NULL; |
| 679 | acpi_status result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 681 | ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq"); |
| 682 | |
| 683 | result = acpi_bus_get_device(handle, &device); |
| 684 | if (result) { |
| 685 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n")); |
| 686 | return_VALUE(-1); |
| 687 | } |
| 688 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 689 | link = (struct acpi_pci_link *)acpi_driver_data(device); |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 690 | if (!link) { |
| 691 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); |
| 692 | return_VALUE(-1); |
| 693 | } |
| 694 | |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 695 | mutex_lock(&acpi_link_lock); |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 696 | if (!link->irq.initialized) { |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 697 | mutex_unlock(&acpi_link_lock); |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 698 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n")); |
| 699 | return_VALUE(-1); |
| 700 | } |
David Shaohua Li | ecc21eb | 2005-08-03 11:00:11 -0400 | [diff] [blame] | 701 | #ifdef FUTURE_USE |
| 702 | /* |
| 703 | * The Link reference count allows us to _DISable an unused link |
| 704 | * and suspend time, and set it again on resume. |
| 705 | * However, 2.6.12 still has irq_router.resume |
| 706 | * which blindly restores the link state. |
| 707 | * So we disable the reference count method |
| 708 | * to prevent duplicate acpi_pci_link_set() |
| 709 | * which would harm some systems |
| 710 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 711 | link->refcnt--; |
David Shaohua Li | ecc21eb | 2005-08-03 11:00:11 -0400 | [diff] [blame] | 712 | #endif |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 713 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 714 | "Link %s is dereferenced\n", |
| 715 | acpi_device_bid(link->device))); |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 716 | |
| 717 | if (link->refcnt == 0) { |
| 718 | acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); |
| 719 | } |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 720 | mutex_unlock(&acpi_link_lock); |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 721 | return_VALUE(link->irq.active); |
| 722 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 723 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | /* -------------------------------------------------------------------------- |
| 725 | Driver Interface |
| 726 | -------------------------------------------------------------------------- */ |
| 727 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 728 | static int acpi_pci_link_add(struct acpi_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 730 | int result = 0; |
| 731 | struct acpi_pci_link *link = NULL; |
| 732 | int i = 0; |
| 733 | int found = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | |
| 735 | ACPI_FUNCTION_TRACE("acpi_pci_link_add"); |
| 736 | |
| 737 | if (!device) |
| 738 | return_VALUE(-EINVAL); |
| 739 | |
| 740 | link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL); |
| 741 | if (!link) |
| 742 | return_VALUE(-ENOMEM); |
| 743 | memset(link, 0, sizeof(struct acpi_pci_link)); |
| 744 | |
| 745 | link->device = device; |
| 746 | link->handle = device->handle; |
| 747 | strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME); |
| 748 | strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS); |
| 749 | acpi_driver_data(device) = link; |
| 750 | |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 751 | mutex_lock(&acpi_link_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | result = acpi_pci_link_get_possible(link); |
| 753 | if (result) |
| 754 | goto end; |
| 755 | |
| 756 | /* query and set link->irq.active */ |
| 757 | acpi_pci_link_get_current(link); |
| 758 | |
| 759 | printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device), |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 760 | acpi_device_bid(device)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | for (i = 0; i < link->irq.possible_count; i++) { |
| 762 | if (link->irq.active == link->irq.possible[i]) { |
| 763 | printk(" *%d", link->irq.possible[i]); |
| 764 | found = 1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 765 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | printk(" %d", link->irq.possible[i]); |
| 767 | } |
| 768 | |
| 769 | printk(")"); |
| 770 | |
| 771 | if (!found) |
| 772 | printk(" *%d", link->irq.active); |
| 773 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 774 | if (!link->device->status.enabled) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | printk(", disabled."); |
| 776 | |
| 777 | printk("\n"); |
| 778 | |
| 779 | /* TBD: Acquire/release lock */ |
| 780 | list_add_tail(&link->node, &acpi_link.entries); |
| 781 | acpi_link.count++; |
| 782 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 783 | end: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | /* disable all links -- to be activated on use */ |
| 785 | acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 786 | mutex_unlock(&acpi_link_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | |
| 788 | if (result) |
| 789 | kfree(link); |
| 790 | |
| 791 | return_VALUE(result); |
| 792 | } |
| 793 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 794 | static int acpi_pci_link_resume(struct acpi_pci_link *link) |
Linus Torvalds | 697a2d6 | 2005-08-01 12:37:54 -0700 | [diff] [blame] | 795 | { |
| 796 | ACPI_FUNCTION_TRACE("acpi_pci_link_resume"); |
| 797 | |
| 798 | if (link->refcnt && link->irq.active && link->irq.initialized) |
| 799 | return_VALUE(acpi_pci_link_set(link, link->irq.active)); |
| 800 | else |
| 801 | return_VALUE(0); |
| 802 | } |
| 803 | |
David Shaohua Li | 11e981f | 2005-08-03 23:46:33 -0400 | [diff] [blame] | 804 | /* |
| 805 | * FIXME: this is a workaround to avoid nasty warning. It will be removed |
| 806 | * after every device calls pci_disable_device in .resume. |
| 807 | */ |
| 808 | int acpi_in_resume; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 809 | static int irqrouter_resume(struct sys_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 811 | struct list_head *node = NULL; |
| 812 | struct acpi_pci_link *link = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | |
Linus Torvalds | 697a2d6 | 2005-08-01 12:37:54 -0700 | [diff] [blame] | 814 | ACPI_FUNCTION_TRACE("irqrouter_resume"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | |
Linus Torvalds | 5603509 | 2006-06-19 18:05:09 -0700 | [diff] [blame] | 816 | /* Make sure SCI is enabled again (Apple firmware bug?) */ |
| 817 | acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK); |
| 818 | |
David Shaohua Li | 11e981f | 2005-08-03 23:46:33 -0400 | [diff] [blame] | 819 | acpi_in_resume = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | list_for_each(node, &acpi_link.entries) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | link = list_entry(node, struct acpi_pci_link, node); |
| 822 | if (!link) { |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 823 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 824 | "Invalid link context\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | continue; |
| 826 | } |
Linus Torvalds | 697a2d6 | 2005-08-01 12:37:54 -0700 | [diff] [blame] | 827 | acpi_pci_link_resume(link); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | } |
David Shaohua Li | 11e981f | 2005-08-03 23:46:33 -0400 | [diff] [blame] | 829 | acpi_in_resume = 0; |
Linus Torvalds | 697a2d6 | 2005-08-01 12:37:54 -0700 | [diff] [blame] | 830 | return_VALUE(0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | } |
| 832 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 833 | static int acpi_pci_link_remove(struct acpi_device *device, int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | { |
| 835 | struct acpi_pci_link *link = NULL; |
| 836 | |
| 837 | ACPI_FUNCTION_TRACE("acpi_pci_link_remove"); |
| 838 | |
| 839 | if (!device || !acpi_driver_data(device)) |
| 840 | return_VALUE(-EINVAL); |
| 841 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 842 | link = (struct acpi_pci_link *)acpi_driver_data(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 844 | mutex_lock(&acpi_link_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | list_del(&link->node); |
Ingo Molnar | 36e4309 | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 846 | mutex_unlock(&acpi_link_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | |
| 848 | kfree(link); |
| 849 | |
| 850 | return_VALUE(0); |
| 851 | } |
| 852 | |
| 853 | /* |
| 854 | * modify acpi_irq_penalty[] from cmdline |
| 855 | */ |
| 856 | static int __init acpi_irq_penalty_update(char *str, int used) |
| 857 | { |
| 858 | int i; |
| 859 | |
| 860 | for (i = 0; i < 16; i++) { |
| 861 | int retval; |
| 862 | int irq; |
| 863 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 864 | retval = get_option(&str, &irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | |
| 866 | if (!retval) |
| 867 | break; /* no number found */ |
| 868 | |
| 869 | if (irq < 0) |
| 870 | continue; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 871 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | if (irq >= ACPI_MAX_IRQS) |
| 873 | continue; |
| 874 | |
| 875 | if (used) |
| 876 | acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED; |
| 877 | else |
| 878 | acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE; |
| 879 | |
| 880 | if (retval != 2) /* no next number */ |
| 881 | break; |
| 882 | } |
| 883 | return 1; |
| 884 | } |
| 885 | |
| 886 | /* |
| 887 | * We'd like PNP to call this routine for the |
| 888 | * single ISA_USED value for each legacy device. |
| 889 | * But instead it calls us with each POSSIBLE setting. |
| 890 | * There is no ISA_POSSIBLE weight, so we simply use |
| 891 | * the (small) PCI_USING penalty. |
| 892 | */ |
David Shaohua Li | c9c3e45 | 2005-04-01 00:07:31 -0500 | [diff] [blame] | 893 | void acpi_penalize_isa_irq(int irq, int active) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | { |
David Shaohua Li | c9c3e45 | 2005-04-01 00:07:31 -0500 | [diff] [blame] | 895 | if (active) |
| 896 | acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED; |
| 897 | else |
| 898 | acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | } |
| 900 | |
| 901 | /* |
| 902 | * Over-ride default table to reserve additional IRQs for use by ISA |
| 903 | * e.g. acpi_irq_isa=5 |
| 904 | * Useful for telling ACPI how not to interfere with your ISA sound card. |
| 905 | */ |
| 906 | static int __init acpi_irq_isa(char *str) |
| 907 | { |
| 908 | return acpi_irq_penalty_update(str, 1); |
| 909 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 910 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | __setup("acpi_irq_isa=", acpi_irq_isa); |
| 912 | |
| 913 | /* |
| 914 | * Over-ride default table to free additional IRQs for use by PCI |
| 915 | * e.g. acpi_irq_pci=7,15 |
| 916 | * Used for acpi_irq_balance to free up IRQs to reduce PCI IRQ sharing. |
| 917 | */ |
| 918 | static int __init acpi_irq_pci(char *str) |
| 919 | { |
| 920 | return acpi_irq_penalty_update(str, 0); |
| 921 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 922 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | __setup("acpi_irq_pci=", acpi_irq_pci); |
| 924 | |
| 925 | static int __init acpi_irq_nobalance_set(char *str) |
| 926 | { |
| 927 | acpi_irq_balance = 0; |
| 928 | return 1; |
| 929 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 930 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | __setup("acpi_irq_nobalance", acpi_irq_nobalance_set); |
| 932 | |
| 933 | int __init acpi_irq_balance_set(char *str) |
| 934 | { |
| 935 | acpi_irq_balance = 1; |
| 936 | return 1; |
| 937 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 939 | __setup("acpi_irq_balance", acpi_irq_balance_set); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | |
David Shaohua Li | 87bec66 | 2005-07-27 23:02:00 -0400 | [diff] [blame] | 941 | /* FIXME: we will remove this interface after all drivers call pci_disable_device */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 942 | static struct sysdev_class irqrouter_sysdev_class = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 943 | set_kset_name("irqrouter"), |
| 944 | .resume = irqrouter_resume, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | }; |
| 946 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | static struct sys_device device_irqrouter = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 948 | .id = 0, |
| 949 | .cls = &irqrouter_sysdev_class, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | }; |
| 951 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | static int __init irqrouter_init_sysfs(void) |
| 953 | { |
| 954 | int error; |
| 955 | |
| 956 | ACPI_FUNCTION_TRACE("irqrouter_init_sysfs"); |
| 957 | |
| 958 | if (acpi_disabled || acpi_noirq) |
| 959 | return_VALUE(0); |
| 960 | |
| 961 | error = sysdev_class_register(&irqrouter_sysdev_class); |
| 962 | if (!error) |
| 963 | error = sysdev_register(&device_irqrouter); |
| 964 | |
| 965 | return_VALUE(error); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 966 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | |
| 968 | device_initcall(irqrouter_init_sysfs); |
| 969 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 970 | static int __init acpi_pci_link_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 971 | { |
| 972 | ACPI_FUNCTION_TRACE("acpi_pci_link_init"); |
| 973 | |
| 974 | if (acpi_noirq) |
| 975 | return_VALUE(0); |
| 976 | |
| 977 | acpi_link.count = 0; |
| 978 | INIT_LIST_HEAD(&acpi_link.entries); |
| 979 | |
| 980 | if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0) |
| 981 | return_VALUE(-ENODEV); |
| 982 | |
| 983 | return_VALUE(0); |
| 984 | } |
| 985 | |
| 986 | subsys_initcall(acpi_pci_link_init); |