initial commit with v2.6.9
[linux-2.6.9-moxart.git] / drivers / acpi / pci_link.c
blob86e8a0ca0cb84461418745ced3e87d2df7e4c762
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 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 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 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 AE_OK;
161 return 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 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 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 AE_OK;
235 return 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 = {sizeof(resource)+1, &resource};
313 ACPI_FUNCTION_TRACE("acpi_pci_link_set");
315 if (!link || !irq)
316 return_VALUE(-EINVAL);
318 memset(&resource, 0, sizeof(resource));
320 switch(link->irq.resource_type) {
321 case ACPI_RSTYPE_IRQ:
322 resource.res.id = ACPI_RSTYPE_IRQ;
323 resource.res.length = sizeof(struct acpi_resource);
324 resource.res.data.irq.edge_level = link->irq.edge_level;
325 resource.res.data.irq.active_high_low = link->irq.active_high_low;
326 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE)
327 resource.res.data.irq.shared_exclusive = ACPI_EXCLUSIVE;
328 else
329 resource.res.data.irq.shared_exclusive = ACPI_SHARED;
330 resource.res.data.irq.number_of_interrupts = 1;
331 resource.res.data.irq.interrupts[0] = irq;
332 break;
334 case ACPI_RSTYPE_EXT_IRQ:
335 resource.res.id = ACPI_RSTYPE_EXT_IRQ;
336 resource.res.length = sizeof(struct acpi_resource);
337 resource.res.data.extended_irq.producer_consumer = ACPI_CONSUMER;
338 resource.res.data.extended_irq.edge_level = link->irq.edge_level;
339 resource.res.data.extended_irq.active_high_low = link->irq.active_high_low;
340 if (link->irq.edge_level == ACPI_EDGE_SENSITIVE)
341 resource.res.data.irq.shared_exclusive = ACPI_EXCLUSIVE;
342 else
343 resource.res.data.irq.shared_exclusive = ACPI_SHARED;
344 resource.res.data.extended_irq.number_of_interrupts = 1;
345 resource.res.data.extended_irq.interrupts[0] = irq;
346 /* ignore resource_source, it's optional */
347 break;
348 default:
349 printk("ACPI BUG: resource_type %d\n", link->irq.resource_type);
350 return_VALUE(-EINVAL);
353 resource.end.id = ACPI_RSTYPE_END_TAG;
355 /* Attempt to set the resource */
356 status = acpi_set_current_resources(link->handle, &buffer);
358 /* check for total failure */
359 if (ACPI_FAILURE(status)) {
360 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SRS\n"));
361 return_VALUE(-ENODEV);
364 /* Query _STA, set device->status */
365 result = acpi_bus_get_status(link->device);
366 if (result) {
367 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n"));
368 return_VALUE(result);
370 if (!link->device->status.enabled) {
371 printk(KERN_WARNING PREFIX
372 "%s [%s] disabled and referenced, BIOS bug.\n",
373 acpi_device_name(link->device),
374 acpi_device_bid(link->device));
377 /* Query _CRS, set link->irq.active */
378 result = acpi_pci_link_get_current(link);
379 if (result) {
380 return_VALUE(result);
384 * Is current setting not what we set?
385 * set link->irq.active
387 if (link->irq.active != irq) {
389 * policy: when _CRS doesn't return what we just _SRS
390 * assume _SRS worked and override _CRS value.
392 printk(KERN_WARNING PREFIX
393 "%s [%s] BIOS reported IRQ %d, using IRQ %d\n",
394 acpi_device_name(link->device),
395 acpi_device_bid(link->device),
396 link->irq.active, irq);
397 link->irq.active = irq;
400 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Set IRQ %d\n", link->irq.active));
402 return_VALUE(0);
406 /* --------------------------------------------------------------------------
407 PCI Link IRQ Management
408 -------------------------------------------------------------------------- */
411 * "acpi_irq_balance" (default in APIC mode) enables ACPI to use PIC Interrupt
412 * Link Devices to move the PIRQs around to minimize sharing.
414 * "acpi_irq_nobalance" (default in PIC mode) tells ACPI not to move any PIC IRQs
415 * that the BIOS has already set to active. This is necessary because
416 * ACPI has no automatic means of knowing what ISA IRQs are used. Note that
417 * if the BIOS doesn't set a Link Device active, ACPI needs to program it
418 * even if acpi_irq_nobalance is set.
420 * A tables of penalties avoids directing PCI interrupts to well known
421 * ISA IRQs. Boot params are available to over-ride the default table:
423 * List interrupts that are free for PCI use.
424 * acpi_irq_pci=n[,m]
426 * List interrupts that should not be used for PCI:
427 * acpi_irq_isa=n[,m]
429 * Note that PCI IRQ routers have a list of possible IRQs,
430 * which may not include the IRQs this table says are available.
432 * Since this heuristic can't tell the difference between a link
433 * that no device will attach to, vs. a link which may be shared
434 * by multiple active devices -- it is not optimal.
436 * If interrupt performance is that important, get an IO-APIC system
437 * with a pin dedicated to each device. Or for that matter, an MSI
438 * enabled system.
441 #define ACPI_MAX_IRQS 256
442 #define ACPI_MAX_ISA_IRQ 16
444 #define PIRQ_PENALTY_PCI_AVAILABLE (0)
445 #define PIRQ_PENALTY_PCI_POSSIBLE (16*16)
446 #define PIRQ_PENALTY_PCI_USING (16*16*16)
447 #define PIRQ_PENALTY_ISA_TYPICAL (16*16*16*16)
448 #define PIRQ_PENALTY_ISA_USED (16*16*16*16*16)
449 #define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16)
451 static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
452 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ0 timer */
453 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ1 keyboard */
454 PIRQ_PENALTY_ISA_ALWAYS, /* IRQ2 cascade */
455 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ3 serial */
456 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ4 serial */
457 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ5 sometimes SoundBlaster */
458 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ6 */
459 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ7 parallel, spurious */
460 PIRQ_PENALTY_ISA_TYPICAL, /* IRQ8 rtc, sometimes */
461 PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ9 PCI, often acpi */
462 PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ10 PCI */
463 PIRQ_PENALTY_PCI_AVAILABLE, /* IRQ11 PCI */
464 PIRQ_PENALTY_ISA_USED, /* IRQ12 mouse */
465 PIRQ_PENALTY_ISA_USED, /* IRQ13 fpe, sometimes */
466 PIRQ_PENALTY_ISA_USED, /* IRQ14 ide0 */
467 PIRQ_PENALTY_ISA_USED, /* IRQ15 ide1 */
468 /* >IRQ15 */
471 int __init
472 acpi_irq_penalty_init(void)
474 struct list_head *node = NULL;
475 struct acpi_pci_link *link = NULL;
476 int i = 0;
478 ACPI_FUNCTION_TRACE("acpi_irq_penalty_init");
481 * Update penalties to facilitate IRQ balancing.
483 list_for_each(node, &acpi_link.entries) {
485 link = list_entry(node, struct acpi_pci_link, node);
486 if (!link) {
487 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
488 continue;
492 * reflect the possible and active irqs in the penalty table --
493 * useful for breaking ties.
495 if (link->irq.possible_count) {
496 int penalty = PIRQ_PENALTY_PCI_POSSIBLE / link->irq.possible_count;
498 for (i = 0; i < link->irq.possible_count; i++) {
499 if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ)
500 acpi_irq_penalty[link->irq.possible[i]] += penalty;
503 } else if (link->irq.active) {
504 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_POSSIBLE;
507 /* Add a penalty for the SCI */
508 acpi_irq_penalty[acpi_fadt.sci_int] += PIRQ_PENALTY_PCI_USING;
510 return_VALUE(0);
513 static int acpi_irq_balance; /* 0: static, 1: balance */
515 static int acpi_pci_link_allocate(struct acpi_pci_link* link) {
516 int irq;
517 int i;
519 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
521 if (link->irq.initialized)
522 return_VALUE(0);
525 * search for active IRQ in list of possible IRQs.
527 for (i = 0; i < link->irq.possible_count; ++i) {
528 if (link->irq.active == link->irq.possible[i])
529 break;
532 * forget active IRQ that is not in possible list
534 if (i == link->irq.possible_count) {
535 if (acpi_strict)
536 printk(KERN_WARNING PREFIX "_CRS %d not found"
537 " in _PRS\n", link->irq.active);
538 link->irq.active = 0;
542 * if active found, use it; else pick entry from end of possible list.
544 if (link->irq.active) {
545 irq = link->irq.active;
546 } else {
547 irq = link->irq.possible[link->irq.possible_count - 1];
550 if (acpi_irq_balance || !link->irq.active) {
552 * Select the best IRQ. This is done in reverse to promote
553 * the use of IRQs 9, 10, 11, and >15.
555 for (i = (link->irq.possible_count - 1); i >= 0; i--) {
556 if (acpi_irq_penalty[irq] > acpi_irq_penalty[link->irq.possible[i]])
557 irq = link->irq.possible[i];
561 /* Attempt to enable the link device at this IRQ. */
562 if (acpi_pci_link_set(link, irq)) {
563 printk(PREFIX "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n"
564 "Try pci=noacpi or acpi=off\n",
565 acpi_device_name(link->device),
566 acpi_device_bid(link->device));
567 return_VALUE(-ENODEV);
568 } else {
569 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
570 printk(PREFIX "%s [%s] enabled at IRQ %d\n",
571 acpi_device_name(link->device),
572 acpi_device_bid(link->device), link->irq.active);
575 link->irq.initialized = 1;
577 return_VALUE(0);
582 acpi_pci_link_get_irq (
583 acpi_handle handle,
584 int index,
585 int* edge_level,
586 int* active_high_low)
588 int result = 0;
589 struct acpi_device *device = NULL;
590 struct acpi_pci_link *link = NULL;
592 ACPI_FUNCTION_TRACE("acpi_pci_link_get_irq");
594 result = acpi_bus_get_device(handle, &device);
595 if (result) {
596 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n"));
597 return_VALUE(0);
600 link = (struct acpi_pci_link *) acpi_driver_data(device);
601 if (!link) {
602 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
603 return_VALUE(0);
606 /* TBD: Support multiple index (IRQ) entries per Link Device */
607 if (index) {
608 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid index %d\n", index));
609 return_VALUE(0);
612 if (acpi_pci_link_allocate(link))
613 return_VALUE(0);
615 if (!link->irq.active) {
616 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n"));
617 return_VALUE(0);
620 if (edge_level) *edge_level = link->irq.edge_level;
621 if (active_high_low) *active_high_low = link->irq.active_high_low;
622 return_VALUE(link->irq.active);
626 /* --------------------------------------------------------------------------
627 Driver Interface
628 -------------------------------------------------------------------------- */
630 static int
631 acpi_pci_link_add (
632 struct acpi_device *device)
634 int result = 0;
635 struct acpi_pci_link *link = NULL;
636 int i = 0;
637 int found = 0;
639 ACPI_FUNCTION_TRACE("acpi_pci_link_add");
641 if (!device)
642 return_VALUE(-EINVAL);
644 link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
645 if (!link)
646 return_VALUE(-ENOMEM);
647 memset(link, 0, sizeof(struct acpi_pci_link));
649 link->device = device;
650 link->handle = device->handle;
651 strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME);
652 strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
653 acpi_driver_data(device) = link;
655 result = acpi_pci_link_get_possible(link);
656 if (result)
657 goto end;
659 /* query and set link->irq.active */
660 acpi_pci_link_get_current(link);
662 printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device),
663 acpi_device_bid(device));
664 for (i = 0; i < link->irq.possible_count; i++) {
665 if (link->irq.active == link->irq.possible[i]) {
666 printk(" *%d", link->irq.possible[i]);
667 found = 1;
669 else
670 printk(" %d", link->irq.possible[i]);
673 printk(")");
675 if (!found)
676 printk(" *%d", link->irq.active);
678 if(!link->device->status.enabled)
679 printk(", disabled.");
681 printk("\n");
683 /* TBD: Acquire/release lock */
684 list_add_tail(&link->node, &acpi_link.entries);
685 acpi_link.count++;
687 end:
688 /* disable all links -- to be activated on use */
689 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
691 if (result)
692 kfree(link);
694 return_VALUE(result);
698 static int
699 acpi_pci_link_resume (
700 struct acpi_pci_link *link)
702 ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
704 if (link->irq.active && link->irq.initialized)
705 return_VALUE(acpi_pci_link_set(link, link->irq.active));
706 else
707 return_VALUE(0);
711 static int
712 irqrouter_resume(
713 struct sys_device *dev)
715 struct list_head *node = NULL;
716 struct acpi_pci_link *link = NULL;
718 ACPI_FUNCTION_TRACE("irqrouter_resume");
720 list_for_each(node, &acpi_link.entries) {
722 link = list_entry(node, struct acpi_pci_link, node);
723 if (!link) {
724 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
725 continue;
728 acpi_pci_link_resume(link);
730 return_VALUE(0);
734 static int
735 acpi_pci_link_remove (
736 struct acpi_device *device,
737 int type)
739 struct acpi_pci_link *link = NULL;
741 ACPI_FUNCTION_TRACE("acpi_pci_link_remove");
743 if (!device || !acpi_driver_data(device))
744 return_VALUE(-EINVAL);
746 link = (struct acpi_pci_link *) acpi_driver_data(device);
748 /* TBD: Acquire/release lock */
749 list_del(&link->node);
751 kfree(link);
753 return_VALUE(0);
757 * modify acpi_irq_penalty[] from cmdline
759 static int __init acpi_irq_penalty_update(char *str, int used)
761 int i;
763 for (i = 0; i < 16; i++) {
764 int retval;
765 int irq;
767 retval = get_option(&str,&irq);
769 if (!retval)
770 break; /* no number found */
772 if (irq < 0)
773 continue;
775 if (irq >= ACPI_MAX_IRQS)
776 continue;
778 if (used)
779 acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
780 else
781 acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
783 if (retval != 2) /* no next number */
784 break;
786 return 1;
790 * Over-ride default table to reserve additional IRQs for use by ISA
791 * e.g. acpi_irq_isa=5
792 * Useful for telling ACPI how not to interfere with your ISA sound card.
794 static int __init acpi_irq_isa(char *str)
796 return(acpi_irq_penalty_update(str, 1));
798 __setup("acpi_irq_isa=", acpi_irq_isa);
801 * Over-ride default table to free additional IRQs for use by PCI
802 * e.g. acpi_irq_pci=7,15
803 * Used for acpi_irq_balance to free up IRQs to reduce PCI IRQ sharing.
805 static int __init acpi_irq_pci(char *str)
807 return(acpi_irq_penalty_update(str, 0));
809 __setup("acpi_irq_pci=", acpi_irq_pci);
811 static int __init acpi_irq_nobalance_set(char *str)
813 acpi_irq_balance = 0;
814 return(1);
816 __setup("acpi_irq_nobalance", acpi_irq_nobalance_set);
818 int __init acpi_irq_balance_set(char *str)
820 acpi_irq_balance = 1;
821 return(1);
823 __setup("acpi_irq_balance", acpi_irq_balance_set);
826 static struct sysdev_class irqrouter_sysdev_class = {
827 set_kset_name("irqrouter"),
828 .resume = irqrouter_resume,
832 static struct sys_device device_irqrouter = {
833 .id = 0,
834 .cls = &irqrouter_sysdev_class,
838 static int __init irqrouter_init_sysfs(void)
840 int error;
842 ACPI_FUNCTION_TRACE("irqrouter_init_sysfs");
844 if (acpi_disabled || acpi_noirq)
845 return_VALUE(0);
847 error = sysdev_class_register(&irqrouter_sysdev_class);
848 if (!error)
849 error = sysdev_register(&device_irqrouter);
851 return_VALUE(error);
854 device_initcall(irqrouter_init_sysfs);
857 static int __init acpi_pci_link_init (void)
859 ACPI_FUNCTION_TRACE("acpi_pci_link_init");
861 if (acpi_noirq)
862 return_VALUE(0);
864 acpi_link.count = 0;
865 INIT_LIST_HEAD(&acpi_link.entries);
867 if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0)
868 return_VALUE(-ENODEV);
870 return_VALUE(0);
873 subsys_initcall(acpi_pci_link_init);