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