blob: 78927c0f155102a01f3acf97b87887819bfc546f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
41
42#include <acpi/acpi_bus.h>
43#include <acpi/acpi_drivers.h>
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#define _COMPONENT ACPI_PCI_COMPONENT
Len Brown4be44fc2005-08-05 00:44:28 -040046ACPI_MODULE_NAME("pci_link")
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define ACPI_PCI_LINK_CLASS "pci_irq_routing"
48#define ACPI_PCI_LINK_HID "PNP0C0F"
49#define ACPI_PCI_LINK_DRIVER_NAME "ACPI PCI Interrupt Link Driver"
50#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link"
51#define ACPI_PCI_LINK_FILE_INFO "info"
52#define ACPI_PCI_LINK_FILE_STATUS "state"
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#define ACPI_PCI_LINK_MAX_POSSIBLE 16
Len Brown4be44fc2005-08-05 00:44:28 -040054static int acpi_pci_link_add(struct acpi_device *device);
55static int acpi_pci_link_remove(struct acpi_device *device, int type);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57static struct acpi_driver acpi_pci_link_driver = {
Len Brown4be44fc2005-08-05 00:44:28 -040058 .name = ACPI_PCI_LINK_DRIVER_NAME,
59 .class = ACPI_PCI_LINK_CLASS,
60 .ids = ACPI_PCI_LINK_HID,
61 .ops = {
62 .add = acpi_pci_link_add,
63 .remove = acpi_pci_link_remove,
64 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070065};
66
David Shaohua Li87bec662005-07-27 23:02:00 -040067/*
68 * If a link is initialized, we never change its active and initialized
69 * later even the link is disable. Instead, we just repick the active irq
70 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070071struct acpi_pci_link_irq {
Len Brown4be44fc2005-08-05 00:44:28 -040072 u8 active; /* Current IRQ */
73 u8 edge_level; /* All IRQs */
74 u8 active_high_low; /* All IRQs */
75 u8 resource_type;
76 u8 possible_count;
77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
78 u8 initialized:1;
79 u8 reserved:7;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080};
81
82struct acpi_pci_link {
Len Brown4be44fc2005-08-05 00:44:28 -040083 struct list_head node;
84 struct acpi_device *device;
85 acpi_handle handle;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 struct acpi_pci_link_irq irq;
Len Brown4be44fc2005-08-05 00:44:28 -040087 int refcnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
90static struct {
Len Brown4be44fc2005-08-05 00:44:28 -040091 int count;
92 struct list_head entries;
93} acpi_link;
David Shaohua Li87bec662005-07-27 23:02:00 -040094DECLARE_MUTEX(acpi_link_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Linus Torvalds1da177e2005-04-16 15:20:36 -070096/* --------------------------------------------------------------------------
97 PCI Link Device Management
98 -------------------------------------------------------------------------- */
99
100/*
101 * set context (link) possible list from resource list
102 */
103static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400104acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105{
Len Brown4be44fc2005-08-05 00:44:28 -0400106 struct acpi_pci_link *link = (struct acpi_pci_link *)context;
107 u32 i = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
109 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
110
111 switch (resource->id) {
112 case ACPI_RSTYPE_START_DPF:
113 return_ACPI_STATUS(AE_OK);
114 case ACPI_RSTYPE_IRQ:
Len Brown4be44fc2005-08-05 00:44:28 -0400115 {
116 struct acpi_resource_irq *p = &resource->data.irq;
117 if (!p || !p->number_of_interrupts) {
118 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
119 "Blank IRQ resource\n"));
120 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 }
Len Brown4be44fc2005-08-05 00:44:28 -0400122 for (i = 0;
123 (i < p->number_of_interrupts
124 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
125 if (!p->interrupts[i]) {
126 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
127 "Invalid IRQ %d\n",
128 p->interrupts[i]));
129 continue;
130 }
131 link->irq.possible[i] = p->interrupts[i];
132 link->irq.possible_count++;
133 }
134 link->irq.edge_level = p->edge_level;
135 link->irq.active_high_low = p->active_high_low;
136 link->irq.resource_type = ACPI_RSTYPE_IRQ;
137 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 case ACPI_RSTYPE_EXT_IRQ:
Len Brown4be44fc2005-08-05 00:44:28 -0400140 {
141 struct acpi_resource_ext_irq *p =
142 &resource->data.extended_irq;
143 if (!p || !p->number_of_interrupts) {
144 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
145 "Blank EXT IRQ resource\n"));
146 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 }
Len Brown4be44fc2005-08-05 00:44:28 -0400148 for (i = 0;
149 (i < p->number_of_interrupts
150 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
151 if (!p->interrupts[i]) {
152 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
153 "Invalid IRQ %d\n",
154 p->interrupts[i]));
155 continue;
156 }
157 link->irq.possible[i] = p->interrupts[i];
158 link->irq.possible_count++;
159 }
160 link->irq.edge_level = p->edge_level;
161 link->irq.active_high_low = p->active_high_low;
162 link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ;
163 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 default:
Len Brown4be44fc2005-08-05 00:44:28 -0400166 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
167 "Resource is not an IRQ entry\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 return_ACPI_STATUS(AE_OK);
169 }
170
171 return_ACPI_STATUS(AE_CTRL_TERMINATE);
172}
173
Len Brown4be44fc2005-08-05 00:44:28 -0400174static int acpi_pci_link_get_possible(struct acpi_pci_link *link)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175{
Len Brown4be44fc2005-08-05 00:44:28 -0400176 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
178 ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible");
179
180 if (!link)
181 return_VALUE(-EINVAL);
182
183 status = acpi_walk_resources(link->handle, METHOD_NAME__PRS,
Len Brown4be44fc2005-08-05 00:44:28 -0400184 acpi_pci_link_check_possible, link);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 if (ACPI_FAILURE(status)) {
186 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n"));
187 return_VALUE(-ENODEV);
188 }
189
Len Brown4be44fc2005-08-05 00:44:28 -0400190 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
191 "Found %d possible IRQs\n",
192 link->irq.possible_count));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
194 return_VALUE(0);
195}
196
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400198acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199{
Len Brown4be44fc2005-08-05 00:44:28 -0400200 int *irq = (int *)context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
202 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
203
204 switch (resource->id) {
205 case ACPI_RSTYPE_IRQ:
Len Brown4be44fc2005-08-05 00:44:28 -0400206 {
207 struct acpi_resource_irq *p = &resource->data.irq;
208 if (!p || !p->number_of_interrupts) {
209 /*
210 * IRQ descriptors may have no IRQ# bits set,
211 * particularly those those w/ _STA disabled
212 */
213 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
214 "Blank IRQ resource\n"));
215 return_ACPI_STATUS(AE_OK);
216 }
217 *irq = p->interrupts[0];
218 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 case ACPI_RSTYPE_EXT_IRQ:
Len Brown4be44fc2005-08-05 00:44:28 -0400221 {
222 struct acpi_resource_ext_irq *p =
223 &resource->data.extended_irq;
224 if (!p || !p->number_of_interrupts) {
225 /*
226 * extended IRQ descriptors must
227 * return at least 1 IRQ
228 */
229 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
230 "Blank EXT IRQ resource\n"));
231 return_ACPI_STATUS(AE_OK);
232 }
233 *irq = p->interrupts[0];
234 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 default:
Len Brown4be44fc2005-08-05 00:44:28 -0400237 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource isn't an IRQ\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 return_ACPI_STATUS(AE_OK);
239 }
240 return_ACPI_STATUS(AE_CTRL_TERMINATE);
241}
242
243/*
244 * Run _CRS and set link->irq.active
245 *
246 * return value:
247 * 0 - success
248 * !0 - failure
249 */
Len Brown4be44fc2005-08-05 00:44:28 -0400250static int acpi_pci_link_get_current(struct acpi_pci_link *link)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251{
Len Brown4be44fc2005-08-05 00:44:28 -0400252 int result = 0;
253 acpi_status status = AE_OK;
254 int irq = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255
256 ACPI_FUNCTION_TRACE("acpi_pci_link_get_current");
257
258 if (!link || !link->handle)
259 return_VALUE(-EINVAL);
260
261 link->irq.active = 0;
262
263 /* in practice, status disabled is meaningless, ignore it */
264 if (acpi_strict) {
265 /* Query _STA, set link->device->status */
266 result = acpi_bus_get_status(link->device);
267 if (result) {
Len Brown4be44fc2005-08-05 00:44:28 -0400268 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
269 "Unable to read status\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 goto end;
271 }
272
273 if (!link->device->status.enabled) {
274 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n"));
275 return_VALUE(0);
276 }
277 }
278
279 /*
280 * Query and parse _CRS to get the current IRQ assignment.
281 */
282
283 status = acpi_walk_resources(link->handle, METHOD_NAME__CRS,
Len Brown4be44fc2005-08-05 00:44:28 -0400284 acpi_pci_link_check_current, &irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 if (ACPI_FAILURE(status)) {
286 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n"));
287 result = -ENODEV;
288 goto end;
289 }
290
291 if (acpi_strict && !irq) {
292 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_CRS returned 0\n"));
293 result = -ENODEV;
294 }
295
296 link->irq.active = irq;
297
298 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active));
299
Len Brown4be44fc2005-08-05 00:44:28 -0400300 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 return_VALUE(result);
302}
303
Len Brown4be44fc2005-08-05 00:44:28 -0400304static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305{
Len Brown4be44fc2005-08-05 00:44:28 -0400306 int result = 0;
307 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 struct {
Len Brown4be44fc2005-08-05 00:44:28 -0400309 struct acpi_resource res;
310 struct acpi_resource end;
311 } *resource;
312 struct acpi_buffer buffer = { 0, NULL };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
314 ACPI_FUNCTION_TRACE("acpi_pci_link_set");
315
316 if (!link || !irq)
317 return_VALUE(-EINVAL);
318
Dave Jonesa64882e2005-12-12 00:37:40 -0800319 resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC);
Len Brown4be44fc2005-08-05 00:44:28 -0400320 if (!resource)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 return_VALUE(-ENOMEM);
322
Len Brown4be44fc2005-08-05 00:44:28 -0400323 memset(resource, 0, sizeof(*resource) + 1);
324 buffer.length = sizeof(*resource) + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 buffer.pointer = resource;
326
Len Brown4be44fc2005-08-05 00:44:28 -0400327 switch (link->irq.resource_type) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 case ACPI_RSTYPE_IRQ:
329 resource->res.id = ACPI_RSTYPE_IRQ;
330 resource->res.length = sizeof(struct acpi_resource);
331 resource->res.data.irq.edge_level = link->irq.edge_level;
Len Brown4be44fc2005-08-05 00:44:28 -0400332 resource->res.data.irq.active_high_low =
333 link->irq.active_high_low;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE)
Len Brown4be44fc2005-08-05 00:44:28 -0400335 resource->res.data.irq.shared_exclusive =
336 ACPI_EXCLUSIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 else
338 resource->res.data.irq.shared_exclusive = ACPI_SHARED;
339 resource->res.data.irq.number_of_interrupts = 1;
340 resource->res.data.irq.interrupts[0] = irq;
341 break;
Len Brown4be44fc2005-08-05 00:44:28 -0400342
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 case ACPI_RSTYPE_EXT_IRQ:
344 resource->res.id = ACPI_RSTYPE_EXT_IRQ;
345 resource->res.length = sizeof(struct acpi_resource);
Len Brown4be44fc2005-08-05 00:44:28 -0400346 resource->res.data.extended_irq.producer_consumer =
347 ACPI_CONSUMER;
348 resource->res.data.extended_irq.edge_level =
349 link->irq.edge_level;
350 resource->res.data.extended_irq.active_high_low =
351 link->irq.active_high_low;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE)
Len Brown4be44fc2005-08-05 00:44:28 -0400353 resource->res.data.irq.shared_exclusive =
354 ACPI_EXCLUSIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 else
356 resource->res.data.irq.shared_exclusive = ACPI_SHARED;
357 resource->res.data.extended_irq.number_of_interrupts = 1;
358 resource->res.data.extended_irq.interrupts[0] = irq;
359 /* ignore resource_source, it's optional */
360 break;
361 default:
362 printk("ACPI BUG: resource_type %d\n", link->irq.resource_type);
363 result = -EINVAL;
364 goto end;
365
366 }
367 resource->end.id = ACPI_RSTYPE_END_TAG;
368
369 /* Attempt to set the resource */
370 status = acpi_set_current_resources(link->handle, &buffer);
371
372 /* check for total failure */
373 if (ACPI_FAILURE(status)) {
374 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SRS\n"));
375 result = -ENODEV;
376 goto end;
377 }
378
379 /* Query _STA, set device->status */
380 result = acpi_bus_get_status(link->device);
381 if (result) {
382 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n"));
383 goto end;
384 }
385 if (!link->device->status.enabled) {
386 printk(KERN_WARNING PREFIX
Len Brown4be44fc2005-08-05 00:44:28 -0400387 "%s [%s] disabled and referenced, BIOS bug.\n",
388 acpi_device_name(link->device),
389 acpi_device_bid(link->device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 }
391
392 /* Query _CRS, set link->irq.active */
393 result = acpi_pci_link_get_current(link);
394 if (result) {
395 goto end;
396 }
397
398 /*
399 * Is current setting not what we set?
400 * set link->irq.active
401 */
402 if (link->irq.active != irq) {
403 /*
404 * policy: when _CRS doesn't return what we just _SRS
405 * assume _SRS worked and override _CRS value.
406 */
Len Brown4be44fc2005-08-05 00:44:28 -0400407 printk(KERN_WARNING PREFIX
408 "%s [%s] BIOS reported IRQ %d, using IRQ %d\n",
409 acpi_device_name(link->device),
410 acpi_device_bid(link->device), link->irq.active, irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 link->irq.active = irq;
412 }
413
414 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Set IRQ %d\n", link->irq.active));
Len Brown4be44fc2005-08-05 00:44:28 -0400415
416 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 kfree(resource);
418 return_VALUE(result);
419}
420
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421/* --------------------------------------------------------------------------
422 PCI Link IRQ Management
423 -------------------------------------------------------------------------- */
424
425/*
426 * "acpi_irq_balance" (default in APIC mode) enables ACPI to use PIC Interrupt
427 * Link Devices to move the PIRQs around to minimize sharing.
428 *
429 * "acpi_irq_nobalance" (default in PIC mode) tells ACPI not to move any PIC IRQs
430 * that the BIOS has already set to active. This is necessary because
431 * ACPI has no automatic means of knowing what ISA IRQs are used. Note that
432 * if the BIOS doesn't set a Link Device active, ACPI needs to program it
433 * even if acpi_irq_nobalance is set.
434 *
435 * A tables of penalties avoids directing PCI interrupts to well known
436 * ISA IRQs. Boot params are available to over-ride the default table:
437 *
438 * List interrupts that are free for PCI use.
439 * acpi_irq_pci=n[,m]
440 *
441 * List interrupts that should not be used for PCI:
442 * acpi_irq_isa=n[,m]
443 *
444 * Note that PCI IRQ routers have a list of possible IRQs,
445 * which may not include the IRQs this table says are available.
446 *
447 * Since this heuristic can't tell the difference between a link
448 * that no device will attach to, vs. a link which may be shared
449 * by multiple active devices -- it is not optimal.
450 *
451 * If interrupt performance is that important, get an IO-APIC system
452 * with a pin dedicated to each device. Or for that matter, an MSI
453 * enabled system.
454 */
455
456#define ACPI_MAX_IRQS 256
457#define ACPI_MAX_ISA_IRQ 16
458
459#define PIRQ_PENALTY_PCI_AVAILABLE (0)
460#define PIRQ_PENALTY_PCI_POSSIBLE (16*16)
461#define PIRQ_PENALTY_PCI_USING (16*16*16)
462#define PIRQ_PENALTY_ISA_TYPICAL (16*16*16*16)
463#define PIRQ_PENALTY_ISA_USED (16*16*16*16*16)
464#define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16)
465
466static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
467 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */
468 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */
469 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */
Len Brown4be44fc2005-08-05 00:44:28 -0400470 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ3 serial */
471 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ4 serial */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ5 sometimes SoundBlaster */
473 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ6 */
474 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ7 parallel, spurious */
475 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ8 rtc, sometimes */
476 PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ9 PCI, often acpi */
477 PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ10 PCI */
478 PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ11 PCI */
479 PIRQ_PENALTY_ISA_USED, /* IRQ12 mouse */
480 PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */
481 PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */
482 PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */
Len Brown4be44fc2005-08-05 00:44:28 -0400483 /* >IRQ15 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484};
485
Len Brown4be44fc2005-08-05 00:44:28 -0400486int __init acpi_irq_penalty_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487{
Len Brown4be44fc2005-08-05 00:44:28 -0400488 struct list_head *node = NULL;
489 struct acpi_pci_link *link = NULL;
490 int i = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491
492 ACPI_FUNCTION_TRACE("acpi_irq_penalty_init");
493
494 /*
495 * Update penalties to facilitate IRQ balancing.
496 */
497 list_for_each(node, &acpi_link.entries) {
498
499 link = list_entry(node, struct acpi_pci_link, node);
500 if (!link) {
Len Brown4be44fc2005-08-05 00:44:28 -0400501 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
502 "Invalid link context\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 continue;
504 }
505
506 /*
507 * reflect the possible and active irqs in the penalty table --
508 * useful for breaking ties.
509 */
510 if (link->irq.possible_count) {
Len Brown4be44fc2005-08-05 00:44:28 -0400511 int penalty =
512 PIRQ_PENALTY_PCI_POSSIBLE /
513 link->irq.possible_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514
515 for (i = 0; i < link->irq.possible_count; i++) {
516 if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ)
Len Brown4be44fc2005-08-05 00:44:28 -0400517 acpi_irq_penalty[link->irq.
518 possible[i]] +=
519 penalty;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 }
521
522 } else if (link->irq.active) {
Len Brown4be44fc2005-08-05 00:44:28 -0400523 acpi_irq_penalty[link->irq.active] +=
524 PIRQ_PENALTY_PCI_POSSIBLE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 }
526 }
527 /* Add a penalty for the SCI */
528 acpi_irq_penalty[acpi_fadt.sci_int] += PIRQ_PENALTY_PCI_USING;
529
530 return_VALUE(0);
531}
532
533static int acpi_irq_balance; /* 0: static, 1: balance */
534
Len Brown4be44fc2005-08-05 00:44:28 -0400535static int acpi_pci_link_allocate(struct acpi_pci_link *link)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536{
Len Brown4be44fc2005-08-05 00:44:28 -0400537 int irq;
538 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539
540 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
541
David Shaohua Li87bec662005-07-27 23:02:00 -0400542 if (link->irq.initialized) {
543 if (link->refcnt == 0)
544 /* This means the link is disabled but initialized */
545 acpi_pci_link_set(link, link->irq.active);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 return_VALUE(0);
David Shaohua Li87bec662005-07-27 23:02:00 -0400547 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548
549 /*
550 * search for active IRQ in list of possible IRQs.
551 */
552 for (i = 0; i < link->irq.possible_count; ++i) {
553 if (link->irq.active == link->irq.possible[i])
554 break;
555 }
556 /*
557 * forget active IRQ that is not in possible list
558 */
559 if (i == link->irq.possible_count) {
560 if (acpi_strict)
561 printk(KERN_WARNING PREFIX "_CRS %d not found"
Len Brown4be44fc2005-08-05 00:44:28 -0400562 " in _PRS\n", link->irq.active);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 link->irq.active = 0;
564 }
565
566 /*
567 * if active found, use it; else pick entry from end of possible list.
568 */
569 if (link->irq.active) {
570 irq = link->irq.active;
571 } else {
572 irq = link->irq.possible[link->irq.possible_count - 1];
573 }
574
575 if (acpi_irq_balance || !link->irq.active) {
576 /*
577 * Select the best IRQ. This is done in reverse to promote
578 * the use of IRQs 9, 10, 11, and >15.
579 */
580 for (i = (link->irq.possible_count - 1); i >= 0; i--) {
Len Brown4be44fc2005-08-05 00:44:28 -0400581 if (acpi_irq_penalty[irq] >
582 acpi_irq_penalty[link->irq.possible[i]])
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 irq = link->irq.possible[i];
584 }
585 }
586
587 /* Attempt to enable the link device at this IRQ. */
588 if (acpi_pci_link_set(link, irq)) {
Len Brown4be44fc2005-08-05 00:44:28 -0400589 printk(PREFIX
590 "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n"
591 "Try pci=noacpi or acpi=off\n",
592 acpi_device_name(link->device),
593 acpi_device_bid(link->device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 return_VALUE(-ENODEV);
595 } else {
596 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
Len Brown4be44fc2005-08-05 00:44:28 -0400597 printk(PREFIX "%s [%s] enabled at IRQ %d\n",
598 acpi_device_name(link->device),
599 acpi_device_bid(link->device), link->irq.active);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 }
601
602 link->irq.initialized = 1;
603
604 return_VALUE(0);
605}
606
607/*
David Shaohua Li87bec662005-07-27 23:02:00 -0400608 * acpi_pci_link_allocate_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 * success: return IRQ >= 0
610 * failure: return -1
611 */
612
613int
Len Brown4be44fc2005-08-05 00:44:28 -0400614acpi_pci_link_allocate_irq(acpi_handle handle,
615 int index,
616 int *edge_level, int *active_high_low, char **name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617{
Len Brown4be44fc2005-08-05 00:44:28 -0400618 int result = 0;
619 struct acpi_device *device = NULL;
620 struct acpi_pci_link *link = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621
David Shaohua Li87bec662005-07-27 23:02:00 -0400622 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623
624 result = acpi_bus_get_device(handle, &device);
625 if (result) {
626 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n"));
627 return_VALUE(-1);
628 }
629
Len Brown4be44fc2005-08-05 00:44:28 -0400630 link = (struct acpi_pci_link *)acpi_driver_data(device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 if (!link) {
632 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
633 return_VALUE(-1);
634 }
635
636 /* TBD: Support multiple index (IRQ) entries per Link Device */
637 if (index) {
638 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid index %d\n", index));
639 return_VALUE(-1);
640 }
641
David Shaohua Li87bec662005-07-27 23:02:00 -0400642 down(&acpi_link_lock);
643 if (acpi_pci_link_allocate(link)) {
644 up(&acpi_link_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 return_VALUE(-1);
David Shaohua Li87bec662005-07-27 23:02:00 -0400646 }
Len Brown4be44fc2005-08-05 00:44:28 -0400647
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 if (!link->irq.active) {
David Shaohua Li87bec662005-07-27 23:02:00 -0400649 up(&acpi_link_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n"));
651 return_VALUE(-1);
652 }
Len Brown4be44fc2005-08-05 00:44:28 -0400653 link->refcnt++;
David Shaohua Li87bec662005-07-27 23:02:00 -0400654 up(&acpi_link_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655
Len Brown4be44fc2005-08-05 00:44:28 -0400656 if (edge_level)
657 *edge_level = link->irq.edge_level;
658 if (active_high_low)
659 *active_high_low = link->irq.active_high_low;
660 if (name)
661 *name = acpi_device_bid(link->device);
David Shaohua Li87bec662005-07-27 23:02:00 -0400662 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -0400663 "Link %s is referenced\n",
664 acpi_device_bid(link->device)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 return_VALUE(link->irq.active);
666}
667
David Shaohua Li87bec662005-07-27 23:02:00 -0400668/*
669 * We don't change link's irq information here. After it is reenabled, we
670 * continue use the info
671 */
Len Brown4be44fc2005-08-05 00:44:28 -0400672int acpi_pci_link_free_irq(acpi_handle handle)
David Shaohua Li87bec662005-07-27 23:02:00 -0400673{
Len Brown4be44fc2005-08-05 00:44:28 -0400674 struct acpi_device *device = NULL;
675 struct acpi_pci_link *link = NULL;
676 acpi_status result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677
David Shaohua Li87bec662005-07-27 23:02:00 -0400678 ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq");
679
680 result = acpi_bus_get_device(handle, &device);
681 if (result) {
682 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n"));
683 return_VALUE(-1);
684 }
685
Len Brown4be44fc2005-08-05 00:44:28 -0400686 link = (struct acpi_pci_link *)acpi_driver_data(device);
David Shaohua Li87bec662005-07-27 23:02:00 -0400687 if (!link) {
688 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
689 return_VALUE(-1);
690 }
691
692 down(&acpi_link_lock);
693 if (!link->irq.initialized) {
694 up(&acpi_link_lock);
695 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n"));
696 return_VALUE(-1);
697 }
David Shaohua Liecc21eb2005-08-03 11:00:11 -0400698#ifdef FUTURE_USE
699 /*
700 * The Link reference count allows us to _DISable an unused link
701 * and suspend time, and set it again on resume.
702 * However, 2.6.12 still has irq_router.resume
703 * which blindly restores the link state.
704 * So we disable the reference count method
705 * to prevent duplicate acpi_pci_link_set()
706 * which would harm some systems
707 */
Len Brown4be44fc2005-08-05 00:44:28 -0400708 link->refcnt--;
David Shaohua Liecc21eb2005-08-03 11:00:11 -0400709#endif
David Shaohua Li87bec662005-07-27 23:02:00 -0400710 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Len Brown4be44fc2005-08-05 00:44:28 -0400711 "Link %s is dereferenced\n",
712 acpi_device_bid(link->device)));
David Shaohua Li87bec662005-07-27 23:02:00 -0400713
714 if (link->refcnt == 0) {
715 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
716 }
717 up(&acpi_link_lock);
718 return_VALUE(link->irq.active);
719}
Len Brown4be44fc2005-08-05 00:44:28 -0400720
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721/* --------------------------------------------------------------------------
722 Driver Interface
723 -------------------------------------------------------------------------- */
724
Len Brown4be44fc2005-08-05 00:44:28 -0400725static int acpi_pci_link_add(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726{
Len Brown4be44fc2005-08-05 00:44:28 -0400727 int result = 0;
728 struct acpi_pci_link *link = NULL;
729 int i = 0;
730 int found = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731
732 ACPI_FUNCTION_TRACE("acpi_pci_link_add");
733
734 if (!device)
735 return_VALUE(-EINVAL);
736
737 link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
738 if (!link)
739 return_VALUE(-ENOMEM);
740 memset(link, 0, sizeof(struct acpi_pci_link));
741
742 link->device = device;
743 link->handle = device->handle;
744 strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME);
745 strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
746 acpi_driver_data(device) = link;
747
David Shaohua Li87bec662005-07-27 23:02:00 -0400748 down(&acpi_link_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 result = acpi_pci_link_get_possible(link);
750 if (result)
751 goto end;
752
753 /* query and set link->irq.active */
754 acpi_pci_link_get_current(link);
755
756 printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device),
Len Brown4be44fc2005-08-05 00:44:28 -0400757 acpi_device_bid(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 for (i = 0; i < link->irq.possible_count; i++) {
759 if (link->irq.active == link->irq.possible[i]) {
760 printk(" *%d", link->irq.possible[i]);
761 found = 1;
Len Brown4be44fc2005-08-05 00:44:28 -0400762 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 printk(" %d", link->irq.possible[i]);
764 }
765
766 printk(")");
767
768 if (!found)
769 printk(" *%d", link->irq.active);
770
Len Brown4be44fc2005-08-05 00:44:28 -0400771 if (!link->device->status.enabled)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 printk(", disabled.");
773
774 printk("\n");
775
776 /* TBD: Acquire/release lock */
777 list_add_tail(&link->node, &acpi_link.entries);
778 acpi_link.count++;
779
Len Brown4be44fc2005-08-05 00:44:28 -0400780 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 /* disable all links -- to be activated on use */
782 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
David Shaohua Li87bec662005-07-27 23:02:00 -0400783 up(&acpi_link_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784
785 if (result)
786 kfree(link);
787
788 return_VALUE(result);
789}
790
Len Brown4be44fc2005-08-05 00:44:28 -0400791static int acpi_pci_link_resume(struct acpi_pci_link *link)
Linus Torvalds697a2d62005-08-01 12:37:54 -0700792{
793 ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
794
795 if (link->refcnt && link->irq.active && link->irq.initialized)
796 return_VALUE(acpi_pci_link_set(link, link->irq.active));
797 else
798 return_VALUE(0);
799}
800
David Shaohua Li11e981f2005-08-03 23:46:33 -0400801/*
802 * FIXME: this is a workaround to avoid nasty warning. It will be removed
803 * after every device calls pci_disable_device in .resume.
804 */
805int acpi_in_resume;
Len Brown4be44fc2005-08-05 00:44:28 -0400806static int irqrouter_resume(struct sys_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807{
Len Brown4be44fc2005-08-05 00:44:28 -0400808 struct list_head *node = NULL;
809 struct acpi_pci_link *link = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810
Linus Torvalds697a2d62005-08-01 12:37:54 -0700811 ACPI_FUNCTION_TRACE("irqrouter_resume");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812
David Shaohua Li11e981f2005-08-03 23:46:33 -0400813 acpi_in_resume = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 list_for_each(node, &acpi_link.entries) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 link = list_entry(node, struct acpi_pci_link, node);
816 if (!link) {
David Shaohua Li87bec662005-07-27 23:02:00 -0400817 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
Len Brown4be44fc2005-08-05 00:44:28 -0400818 "Invalid link context\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 continue;
820 }
Linus Torvalds697a2d62005-08-01 12:37:54 -0700821 acpi_pci_link_resume(link);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 }
David Shaohua Li11e981f2005-08-03 23:46:33 -0400823 acpi_in_resume = 0;
Linus Torvalds697a2d62005-08-01 12:37:54 -0700824 return_VALUE(0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825}
826
Len Brown4be44fc2005-08-05 00:44:28 -0400827static int acpi_pci_link_remove(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828{
829 struct acpi_pci_link *link = NULL;
830
831 ACPI_FUNCTION_TRACE("acpi_pci_link_remove");
832
833 if (!device || !acpi_driver_data(device))
834 return_VALUE(-EINVAL);
835
Len Brown4be44fc2005-08-05 00:44:28 -0400836 link = (struct acpi_pci_link *)acpi_driver_data(device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837
David Shaohua Li87bec662005-07-27 23:02:00 -0400838 down(&acpi_link_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 list_del(&link->node);
David Shaohua Li87bec662005-07-27 23:02:00 -0400840 up(&acpi_link_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841
842 kfree(link);
843
844 return_VALUE(0);
845}
846
847/*
848 * modify acpi_irq_penalty[] from cmdline
849 */
850static int __init acpi_irq_penalty_update(char *str, int used)
851{
852 int i;
853
854 for (i = 0; i < 16; i++) {
855 int retval;
856 int irq;
857
Len Brown4be44fc2005-08-05 00:44:28 -0400858 retval = get_option(&str, &irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859
860 if (!retval)
861 break; /* no number found */
862
863 if (irq < 0)
864 continue;
Len Brown4be44fc2005-08-05 00:44:28 -0400865
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 if (irq >= ACPI_MAX_IRQS)
867 continue;
868
869 if (used)
870 acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
871 else
872 acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
873
874 if (retval != 2) /* no next number */
875 break;
876 }
877 return 1;
878}
879
880/*
881 * We'd like PNP to call this routine for the
882 * single ISA_USED value for each legacy device.
883 * But instead it calls us with each POSSIBLE setting.
884 * There is no ISA_POSSIBLE weight, so we simply use
885 * the (small) PCI_USING penalty.
886 */
David Shaohua Lic9c3e452005-04-01 00:07:31 -0500887void acpi_penalize_isa_irq(int irq, int active)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888{
David Shaohua Lic9c3e452005-04-01 00:07:31 -0500889 if (active)
890 acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
891 else
892 acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893}
894
895/*
896 * Over-ride default table to reserve additional IRQs for use by ISA
897 * e.g. acpi_irq_isa=5
898 * Useful for telling ACPI how not to interfere with your ISA sound card.
899 */
900static int __init acpi_irq_isa(char *str)
901{
902 return acpi_irq_penalty_update(str, 1);
903}
Len Brown4be44fc2005-08-05 00:44:28 -0400904
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905__setup("acpi_irq_isa=", acpi_irq_isa);
906
907/*
908 * Over-ride default table to free additional IRQs for use by PCI
909 * e.g. acpi_irq_pci=7,15
910 * Used for acpi_irq_balance to free up IRQs to reduce PCI IRQ sharing.
911 */
912static int __init acpi_irq_pci(char *str)
913{
914 return acpi_irq_penalty_update(str, 0);
915}
Len Brown4be44fc2005-08-05 00:44:28 -0400916
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917__setup("acpi_irq_pci=", acpi_irq_pci);
918
919static int __init acpi_irq_nobalance_set(char *str)
920{
921 acpi_irq_balance = 0;
922 return 1;
923}
Len Brown4be44fc2005-08-05 00:44:28 -0400924
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925__setup("acpi_irq_nobalance", acpi_irq_nobalance_set);
926
927int __init acpi_irq_balance_set(char *str)
928{
929 acpi_irq_balance = 1;
930 return 1;
931}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932
Len Brown4be44fc2005-08-05 00:44:28 -0400933__setup("acpi_irq_balance", acpi_irq_balance_set);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934
David Shaohua Li87bec662005-07-27 23:02:00 -0400935/* FIXME: we will remove this interface after all drivers call pci_disable_device */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936static struct sysdev_class irqrouter_sysdev_class = {
Len Brown4be44fc2005-08-05 00:44:28 -0400937 set_kset_name("irqrouter"),
938 .resume = irqrouter_resume,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939};
940
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941static struct sys_device device_irqrouter = {
Len Brown4be44fc2005-08-05 00:44:28 -0400942 .id = 0,
943 .cls = &irqrouter_sysdev_class,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944};
945
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946static int __init irqrouter_init_sysfs(void)
947{
948 int error;
949
950 ACPI_FUNCTION_TRACE("irqrouter_init_sysfs");
951
952 if (acpi_disabled || acpi_noirq)
953 return_VALUE(0);
954
955 error = sysdev_class_register(&irqrouter_sysdev_class);
956 if (!error)
957 error = sysdev_register(&device_irqrouter);
958
959 return_VALUE(error);
Len Brown4be44fc2005-08-05 00:44:28 -0400960}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961
962device_initcall(irqrouter_init_sysfs);
963
Len Brown4be44fc2005-08-05 00:44:28 -0400964static int __init acpi_pci_link_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965{
966 ACPI_FUNCTION_TRACE("acpi_pci_link_init");
967
968 if (acpi_noirq)
969 return_VALUE(0);
970
971 acpi_link.count = 0;
972 INIT_LIST_HEAD(&acpi_link.entries);
973
974 if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0)
975 return_VALUE(-ENODEV);
976
977 return_VALUE(0);
978}
979
980subsys_initcall(acpi_pci_link_init);