[NEIGHBOUR]: Remove unused fields in struct neigh_parms and neigh_table
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / acpi / pci_link.c
blob520b28ad0740e6626038d2ab136e270a9260d6d5
1 /*
2 * pci_link.c - ACPI PCI Interrupt Link Device Driver ($Revision: 34 $)
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>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
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.
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.
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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).
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>
42 #include <acpi/acpi_bus.h>
43 #include <acpi/acpi_drivers.h>
46 #define _COMPONENT ACPI_PCI_COMPONENT
47 ACPI_MODULE_NAME ("pci_link")
49 #define ACPI_PCI_LINK_CLASS "pci_irq_routing"
50 #define ACPI_PCI_LINK_HID "PNP0C0F"
51 #define ACPI_PCI_LINK_DRIVER_NAME "ACPI PCI Interrupt Link Driver"
52 #define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link"
53 #define ACPI_PCI_LINK_FILE_INFO "info"
54 #define ACPI_PCI_LINK_FILE_STATUS "state"
56 #define ACPI_PCI_LINK_MAX_POSSIBLE 16
58 static int acpi_pci_link_add (struct acpi_device *device);
59 static int acpi_pci_link_remove (struct acpi_device *device, int type);
61 static struct acpi_driver acpi_pci_link_driver = {
62 .name = ACPI_PCI_LINK_DRIVER_NAME,
63 .class = ACPI_PCI_LINK_CLASS,
64 .ids = ACPI_PCI_LINK_HID,
65 .ops = {
66 .add = acpi_pci_link_add,
67 .remove = acpi_pci_link_remove,
71 struct acpi_pci_link_irq {
72 u8 active; /* Current IRQ */
73 u8 edge_level; /* All IRQs */
74 u8 active_high_low; /* All IRQs */
75 u8 initialized;
76 u8 resource_type;
77 u8 possible_count;
78 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
81 struct acpi_pci_link {
82 struct list_head node;
83 struct acpi_device *device;
84 acpi_handle handle;
85 struct acpi_pci_link_irq irq;
88 static struct {
89 int count;
90 struct list_head entries;
91 } acpi_link;
94 /* --------------------------------------------------------------------------
95 PCI Link Device Management
96 -------------------------------------------------------------------------- */
99 * set context (link) possible list from resource list
101 static acpi_status
102 acpi_pci_link_check_possible (
103 struct acpi_resource *resource,
104 void *context)
106 struct acpi_pci_link *link = (struct acpi_pci_link *) context;
107 u32 i = 0;
109 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
111 switch (resource->id) {
112 case ACPI_RSTYPE_START_DPF:
113 return_ACPI_STATUS(AE_OK);
114 case ACPI_RSTYPE_IRQ:
116 struct acpi_resource_irq *p = &resource->data.irq;
117 if (!p || !p->number_of_interrupts) {
118 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Blank IRQ resource\n"));
119 return_ACPI_STATUS(AE_OK);
121 for (i = 0; (i<p->number_of_interrupts && i<ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
122 if (!p->interrupts[i]) {
123 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ %d\n", p->interrupts[i]));
124 continue;
126 link->irq.possible[i] = p->interrupts[i];
127 link->irq.possible_count++;
129 link->irq.edge_level = p->edge_level;
130 link->irq.active_high_low = p->active_high_low;
131 link->irq.resource_type = ACPI_RSTYPE_IRQ;
132 break;
134 case ACPI_RSTYPE_EXT_IRQ:
136 struct acpi_resource_ext_irq *p = &resource->data.extended_irq;
137 if (!p || !p->number_of_interrupts) {
138 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
139 "Blank EXT IRQ resource\n"));
140 return_ACPI_STATUS(AE_OK);
142 for (i = 0; (i<p->number_of_interrupts && i<ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
143 if (!p->interrupts[i]) {
144 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ %d\n", p->interrupts[i]));
145 continue;
147 link->irq.possible[i] = p->interrupts[i];
148 link->irq.possible_count++;
150 link->irq.edge_level = p->edge_level;
151 link->irq.active_high_low = p->active_high_low;
152 link->irq.resource_type = ACPI_RSTYPE_EXT_IRQ;
153 break;
155 default:
156 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
157 "Resource is not an IRQ entry\n"));
158 return_ACPI_STATUS(AE_OK);
161 return_ACPI_STATUS(AE_CTRL_TERMINATE);
165 static int
166 acpi_pci_link_get_possible (
167 struct acpi_pci_link *link)
169 acpi_status status;
171 ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible");
173 if (!link)
174 return_VALUE(-EINVAL);
176 status = acpi_walk_resources(link->handle, METHOD_NAME__PRS,
177 acpi_pci_link_check_possible, link);
178 if (ACPI_FAILURE(status)) {
179 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n"));
180 return_VALUE(-ENODEV);
183 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
184 "Found %d possible IRQs\n", link->irq.possible_count));
186 return_VALUE(0);
190 static acpi_status
191 acpi_pci_link_check_current (
192 struct acpi_resource *resource,
193 void *context)
195 int *irq = (int *) context;
197 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
199 switch (resource->id) {
200 case ACPI_RSTYPE_IRQ:
202 struct acpi_resource_irq *p = &resource->data.irq;
203 if (!p || !p->number_of_interrupts) {
205 * IRQ descriptors may have no IRQ# bits set,
206 * particularly those those w/ _STA disabled
208 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
209 "Blank IRQ resource\n"));
210 return_ACPI_STATUS(AE_OK);
212 *irq = p->interrupts[0];
213 break;
215 case ACPI_RSTYPE_EXT_IRQ:
217 struct acpi_resource_ext_irq *p = &resource->data.extended_irq;
218 if (!p || !p->number_of_interrupts) {
220 * extended IRQ descriptors must
221 * return at least 1 IRQ
223 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
224 "Blank EXT IRQ resource\n"));
225 return_ACPI_STATUS(AE_OK);
227 *irq = p->interrupts[0];
228 break;
230 default:
231 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
232 "Resource isn't an IRQ\n"));
233 return_ACPI_STATUS(AE_OK);
235 return_ACPI_STATUS(AE_CTRL_TERMINATE);
239 * Run _CRS and set link->irq.active
241 * return value:
242 * 0 - success
243 * !0 - failure
245 static int
246 acpi_pci_link_get_current (
247 struct acpi_pci_link *link)
249 int result = 0;
250 acpi_status status = AE_OK;
251 int irq = 0;
253 ACPI_FUNCTION_TRACE("acpi_pci_link_get_current");
255 if (!link || !link->handle)
256 return_VALUE(-EINVAL);
258 link->irq.active = 0;
260 /* in practice, status disabled is meaningless, ignore it */
261 if (acpi_strict) {
262 /* Query _STA, set link->device->status */
263 result = acpi_bus_get_status(link->device);
264 if (result) {
265 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n"));
266 goto end;
269 if (!link->device->status.enabled) {
270 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n"));
271 return_VALUE(0);
276 * Query and parse _CRS to get the current IRQ assignment.
279 status = acpi_walk_resources(link->handle, METHOD_NAME__CRS,
280 acpi_pci_link_check_current, &irq);
281 if (ACPI_FAILURE(status)) {
282 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n"));
283 result = -ENODEV;
284 goto end;
287 if (acpi_strict && !irq) {
288 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_CRS returned 0\n"));
289 result = -ENODEV;
292 link->irq.active = irq;
294 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active));
296 end:
297 return_VALUE(result);
300 static int
301 acpi_pci_link_set (
302 struct acpi_pci_link *link,
303 int irq)
305 int result = 0;
306 acpi_status status = AE_OK;
307 struct {
308 struct acpi_resource res;
309 struct acpi_resource end;
310 } *resource;
311 struct acpi_buffer buffer = {0, NULL};
313 ACPI_FUNCTION_TRACE("acpi_pci_link_set");
315 if (!link || !irq)
316 return_VALUE(-EINVAL);
318 resource = kmalloc( sizeof(*resource)+1, GFP_KERNEL);
319 if(!resource)
320 return_VALUE(-ENOMEM);
322 memset(resource, 0, sizeof(*resource)+1);
323 buffer.length = sizeof(*resource) +1;
324 buffer.pointer = resource;
326 switch(link->irq.resource_type) {
327 case ACPI_RSTYPE_IRQ:
328 resource->res.id = ACPI_RSTYPE_IRQ;
329 resource->res.length = sizeof(struct acpi_resource);
330 resource->res.data.irq.edge_level = link->irq.edge_level;
331 resource->res.data.irq.active_high_low = link->irq.active_high_low;
332 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE)
333 resource->res.data.irq.shared_exclusive = ACPI_EXCLUSIVE;
334 else
335 resource->res.data.irq.shared_exclusive = ACPI_SHARED;
336 resource->res.data.irq.number_of_interrupts = 1;
337 resource->res.data.irq.interrupts[0] = irq;
338 break;
340 case ACPI_RSTYPE_EXT_IRQ:
341 resource->res.id = ACPI_RSTYPE_EXT_IRQ;
342 resource->res.length = sizeof(struct acpi_resource);
343 resource->res.data.extended_irq.producer_consumer = ACPI_CONSUMER;
344 resource->res.data.extended_irq.edge_level = link->irq.edge_level;
345 resource->res.data.extended_irq.active_high_low = link->irq.active_high_low;
346 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE)
347 resource->res.data.irq.shared_exclusive = ACPI_EXCLUSIVE;
348 else
349 resource->res.data.irq.shared_exclusive = ACPI_SHARED;
350 resource->res.data.extended_irq.number_of_interrupts = 1;
351 resource->res.data.extended_irq.interrupts[0] = irq;
352 /* ignore resource_source, it's optional */
353 break;
354 default:
355 printk("ACPI BUG: resource_type %d\n", link->irq.resource_type);
356 result = -EINVAL;
357 goto end;
360 resource->end.id = ACPI_RSTYPE_END_TAG;
362 /* Attempt to set the resource */
363 status = acpi_set_current_resources(link->handle, &buffer);
365 /* check for total failure */
366 if (ACPI_FAILURE(status)) {
367 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SRS\n"));
368 result = -ENODEV;
369 goto end;
372 /* Query _STA, set device->status */
373 result = acpi_bus_get_status(link->device);
374 if (result) {
375 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n"));
376 goto end;
378 if (!link->device->status.enabled) {
379 printk(KERN_WARNING PREFIX
380 "%s [%s] disabled and referenced, BIOS bug.\n",
381 acpi_device_name(link->device),
382 acpi_device_bid(link->device));
385 /* Query _CRS, set link->irq.active */
386 result = acpi_pci_link_get_current(link);
387 if (result) {
388 goto end;
392 * Is current setting not what we set?
393 * set link->irq.active
395 if (link->irq.active != irq) {
397 * policy: when _CRS doesn't return what we just _SRS
398 * assume _SRS worked and override _CRS value.
400 printk(KERN_WARNING PREFIX
401 "%s [%s] BIOS reported IRQ %d, using IRQ %d\n",
402 acpi_device_name(link->device),
403 acpi_device_bid(link->device),
404 link->irq.active, irq);
405 link->irq.active = irq;
408 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Set IRQ %d\n", link->irq.active));
410 end:
411 kfree(resource);
412 return_VALUE(result);
416 /* --------------------------------------------------------------------------
417 PCI Link IRQ Management
418 -------------------------------------------------------------------------- */
421 * "acpi_irq_balance" (default in APIC mode) enables ACPI to use PIC Interrupt
422 * Link Devices to move the PIRQs around to minimize sharing.
424 * "acpi_irq_nobalance" (default in PIC mode) tells ACPI not to move any PIC IRQs
425 * that the BIOS has already set to active. This is necessary because
426 * ACPI has no automatic means of knowing what ISA IRQs are used. Note that
427 * if the BIOS doesn't set a Link Device active, ACPI needs to program it
428 * even if acpi_irq_nobalance is set.
430 * A tables of penalties avoids directing PCI interrupts to well known
431 * ISA IRQs. Boot params are available to over-ride the default table:
433 * List interrupts that are free for PCI use.
434 * acpi_irq_pci=n[,m]
436 * List interrupts that should not be used for PCI:
437 * acpi_irq_isa=n[,m]
439 * Note that PCI IRQ routers have a list of possible IRQs,
440 * which may not include the IRQs this table says are available.
442 * Since this heuristic can't tell the difference between a link
443 * that no device will attach to, vs. a link which may be shared
444 * by multiple active devices -- it is not optimal.
446 * If interrupt performance is that important, get an IO-APIC system
447 * with a pin dedicated to each device. Or for that matter, an MSI
448 * enabled system.
451 #define ACPI_MAX_IRQS 256
452 #define ACPI_MAX_ISA_IRQ 16
454 #define PIRQ_PENALTY_PCI_AVAILABLE (0)
455 #define PIRQ_PENALTY_PCI_POSSIBLE (16*16)
456 #define PIRQ_PENALTY_PCI_USING (16*16*16)
457 #define PIRQ_PENALTY_ISA_TYPICAL (16*16*16*16)
458 #define PIRQ_PENALTY_ISA_USED (16*16*16*16*16)
459 #define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16)
461 static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
462 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */
463 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */
464 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */
465 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ3 serial */
466 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ4 serial */
467 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ5 sometimes SoundBlaster */
468 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ6 */
469 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ7 parallel, spurious */
470 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ8 rtc, sometimes */
471 PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ9 PCI, often acpi */
472 PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ10 PCI */
473 PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ11 PCI */
474 PIRQ_PENALTY_ISA_USED, /* IRQ12 mouse */
475 PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */
476 PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */
477 PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */
478 /* >IRQ15 */
481 int __init
482 acpi_irq_penalty_init(void)
484 struct list_head *node = NULL;
485 struct acpi_pci_link *link = NULL;
486 int i = 0;
488 ACPI_FUNCTION_TRACE("acpi_irq_penalty_init");
491 * Update penalties to facilitate IRQ balancing.
493 list_for_each(node, &acpi_link.entries) {
495 link = list_entry(node, struct acpi_pci_link, node);
496 if (!link) {
497 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
498 continue;
502 * reflect the possible and active irqs in the penalty table --
503 * useful for breaking ties.
505 if (link->irq.possible_count) {
506 int penalty = PIRQ_PENALTY_PCI_POSSIBLE / link->irq.possible_count;
508 for (i = 0; i < link->irq.possible_count; i++) {
509 if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ)
510 acpi_irq_penalty[link->irq.possible[i]] += penalty;
513 } else if (link->irq.active) {
514 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_POSSIBLE;
517 /* Add a penalty for the SCI */
518 acpi_irq_penalty[acpi_fadt.sci_int] += PIRQ_PENALTY_PCI_USING;
520 return_VALUE(0);
523 static int acpi_irq_balance; /* 0: static, 1: balance */
525 static int acpi_pci_link_allocate(
526 struct acpi_pci_link *link)
528 int irq;
529 int i;
531 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
533 if (link->irq.initialized)
534 return_VALUE(0);
537 * search for active IRQ in list of possible IRQs.
539 for (i = 0; i < link->irq.possible_count; ++i) {
540 if (link->irq.active == link->irq.possible[i])
541 break;
544 * forget active IRQ that is not in possible list
546 if (i == link->irq.possible_count) {
547 if (acpi_strict)
548 printk(KERN_WARNING PREFIX "_CRS %d not found"
549 " in _PRS\n", link->irq.active);
550 link->irq.active = 0;
554 * if active found, use it; else pick entry from end of possible list.
556 if (link->irq.active) {
557 irq = link->irq.active;
558 } else {
559 irq = link->irq.possible[link->irq.possible_count - 1];
562 if (acpi_irq_balance || !link->irq.active) {
564 * Select the best IRQ. This is done in reverse to promote
565 * the use of IRQs 9, 10, 11, and >15.
567 for (i = (link->irq.possible_count - 1); i >= 0; i--) {
568 if (acpi_irq_penalty[irq] > acpi_irq_penalty[link->irq.possible[i]])
569 irq = link->irq.possible[i];
573 /* Attempt to enable the link device at this IRQ. */
574 if (acpi_pci_link_set(link, irq)) {
575 printk(PREFIX "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n"
576 "Try pci=noacpi or acpi=off\n",
577 acpi_device_name(link->device),
578 acpi_device_bid(link->device));
579 return_VALUE(-ENODEV);
580 } else {
581 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
582 printk(PREFIX "%s [%s] enabled at IRQ %d\n",
583 acpi_device_name(link->device),
584 acpi_device_bid(link->device), link->irq.active);
587 link->irq.initialized = 1;
589 return_VALUE(0);
593 * acpi_pci_link_get_irq
594 * success: return IRQ >= 0
595 * failure: return -1
599 acpi_pci_link_get_irq (
600 acpi_handle handle,
601 int index,
602 int *edge_level,
603 int *active_high_low,
604 char **name)
606 int result = 0;
607 struct acpi_device *device = NULL;
608 struct acpi_pci_link *link = NULL;
610 ACPI_FUNCTION_TRACE("acpi_pci_link_get_irq");
612 result = acpi_bus_get_device(handle, &device);
613 if (result) {
614 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n"));
615 return_VALUE(-1);
618 link = (struct acpi_pci_link *) acpi_driver_data(device);
619 if (!link) {
620 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
621 return_VALUE(-1);
624 /* TBD: Support multiple index (IRQ) entries per Link Device */
625 if (index) {
626 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid index %d\n", index));
627 return_VALUE(-1);
630 if (acpi_pci_link_allocate(link))
631 return_VALUE(-1);
633 if (!link->irq.active) {
634 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n"));
635 return_VALUE(-1);
638 if (edge_level) *edge_level = link->irq.edge_level;
639 if (active_high_low) *active_high_low = link->irq.active_high_low;
640 if (name) *name = acpi_device_bid(link->device);
641 return_VALUE(link->irq.active);
645 /* --------------------------------------------------------------------------
646 Driver Interface
647 -------------------------------------------------------------------------- */
649 static int
650 acpi_pci_link_add (
651 struct acpi_device *device)
653 int result = 0;
654 struct acpi_pci_link *link = NULL;
655 int i = 0;
656 int found = 0;
658 ACPI_FUNCTION_TRACE("acpi_pci_link_add");
660 if (!device)
661 return_VALUE(-EINVAL);
663 link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
664 if (!link)
665 return_VALUE(-ENOMEM);
666 memset(link, 0, sizeof(struct acpi_pci_link));
668 link->device = device;
669 link->handle = device->handle;
670 strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME);
671 strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
672 acpi_driver_data(device) = link;
674 result = acpi_pci_link_get_possible(link);
675 if (result)
676 goto end;
678 /* query and set link->irq.active */
679 acpi_pci_link_get_current(link);
681 printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device),
682 acpi_device_bid(device));
683 for (i = 0; i < link->irq.possible_count; i++) {
684 if (link->irq.active == link->irq.possible[i]) {
685 printk(" *%d", link->irq.possible[i]);
686 found = 1;
688 else
689 printk(" %d", link->irq.possible[i]);
692 printk(")");
694 if (!found)
695 printk(" *%d", link->irq.active);
697 if(!link->device->status.enabled)
698 printk(", disabled.");
700 printk("\n");
702 /* TBD: Acquire/release lock */
703 list_add_tail(&link->node, &acpi_link.entries);
704 acpi_link.count++;
706 end:
707 /* disable all links -- to be activated on use */
708 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
710 if (result)
711 kfree(link);
713 return_VALUE(result);
717 static int
718 acpi_pci_link_resume (
719 struct acpi_pci_link *link)
721 ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
723 if (link->irq.active && link->irq.initialized)
724 return_VALUE(acpi_pci_link_set(link, link->irq.active));
725 else
726 return_VALUE(0);
730 static int
731 irqrouter_resume(
732 struct sys_device *dev)
734 struct list_head *node = NULL;
735 struct acpi_pci_link *link = NULL;
737 ACPI_FUNCTION_TRACE("irqrouter_resume");
739 list_for_each(node, &acpi_link.entries) {
741 link = list_entry(node, struct acpi_pci_link, node);
742 if (!link) {
743 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
744 continue;
747 acpi_pci_link_resume(link);
749 return_VALUE(0);
753 static int
754 acpi_pci_link_remove (
755 struct acpi_device *device,
756 int type)
758 struct acpi_pci_link *link = NULL;
760 ACPI_FUNCTION_TRACE("acpi_pci_link_remove");
762 if (!device || !acpi_driver_data(device))
763 return_VALUE(-EINVAL);
765 link = (struct acpi_pci_link *) acpi_driver_data(device);
767 /* TBD: Acquire/release lock */
768 list_del(&link->node);
770 kfree(link);
772 return_VALUE(0);
776 * modify acpi_irq_penalty[] from cmdline
778 static int __init acpi_irq_penalty_update(char *str, int used)
780 int i;
782 for (i = 0; i < 16; i++) {
783 int retval;
784 int irq;
786 retval = get_option(&str,&irq);
788 if (!retval)
789 break; /* no number found */
791 if (irq < 0)
792 continue;
794 if (irq >= ACPI_MAX_IRQS)
795 continue;
797 if (used)
798 acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
799 else
800 acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
802 if (retval != 2) /* no next number */
803 break;
805 return 1;
809 * We'd like PNP to call this routine for the
810 * single ISA_USED value for each legacy device.
811 * But instead it calls us with each POSSIBLE setting.
812 * There is no ISA_POSSIBLE weight, so we simply use
813 * the (small) PCI_USING penalty.
815 void acpi_penalize_isa_irq(int irq)
817 acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
821 * Over-ride default table to reserve additional IRQs for use by ISA
822 * e.g. acpi_irq_isa=5
823 * Useful for telling ACPI how not to interfere with your ISA sound card.
825 static int __init acpi_irq_isa(char *str)
827 return acpi_irq_penalty_update(str, 1);
829 __setup("acpi_irq_isa=", acpi_irq_isa);
832 * Over-ride default table to free additional IRQs for use by PCI
833 * e.g. acpi_irq_pci=7,15
834 * Used for acpi_irq_balance to free up IRQs to reduce PCI IRQ sharing.
836 static int __init acpi_irq_pci(char *str)
838 return acpi_irq_penalty_update(str, 0);
840 __setup("acpi_irq_pci=", acpi_irq_pci);
842 static int __init acpi_irq_nobalance_set(char *str)
844 acpi_irq_balance = 0;
845 return 1;
847 __setup("acpi_irq_nobalance", acpi_irq_nobalance_set);
849 int __init acpi_irq_balance_set(char *str)
851 acpi_irq_balance = 1;
852 return 1;
854 __setup("acpi_irq_balance", acpi_irq_balance_set);
857 static struct sysdev_class irqrouter_sysdev_class = {
858 set_kset_name("irqrouter"),
859 .resume = irqrouter_resume,
863 static struct sys_device device_irqrouter = {
864 .id = 0,
865 .cls = &irqrouter_sysdev_class,
869 static int __init irqrouter_init_sysfs(void)
871 int error;
873 ACPI_FUNCTION_TRACE("irqrouter_init_sysfs");
875 if (acpi_disabled || acpi_noirq)
876 return_VALUE(0);
878 error = sysdev_class_register(&irqrouter_sysdev_class);
879 if (!error)
880 error = sysdev_register(&device_irqrouter);
882 return_VALUE(error);
885 device_initcall(irqrouter_init_sysfs);
888 static int __init acpi_pci_link_init (void)
890 ACPI_FUNCTION_TRACE("acpi_pci_link_init");
892 if (acpi_noirq)
893 return_VALUE(0);
895 acpi_link.count = 0;
896 INIT_LIST_HEAD(&acpi_link.entries);
898 if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0)
899 return_VALUE(-ENODEV);
901 return_VALUE(0);
904 subsys_initcall(acpi_pci_link_init);