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 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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>
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
,
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 */
78 u8 possible
[ACPI_PCI_LINK_MAX_POSSIBLE
];
81 struct acpi_pci_link
{
82 struct list_head node
;
83 struct acpi_device
*device
;
85 struct acpi_pci_link_irq irq
;
90 struct list_head entries
;
94 /* --------------------------------------------------------------------------
95 PCI Link Device Management
96 -------------------------------------------------------------------------- */
99 * set context (link) possible list from resource list
102 acpi_pci_link_check_possible (
103 struct acpi_resource
*resource
,
106 struct acpi_pci_link
*link
= (struct acpi_pci_link
*) context
;
109 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
111 switch (resource
->id
) {
112 case ACPI_RSTYPE_START_DPF
:
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"));
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
]));
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
;
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"));
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
]));
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
;
156 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
157 "Resource is not an IRQ entry\n"));
161 return AE_CTRL_TERMINATE
;
166 acpi_pci_link_get_possible (
167 struct acpi_pci_link
*link
)
171 ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible");
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
));
191 acpi_pci_link_check_current (
192 struct acpi_resource
*resource
,
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"));
212 *irq
= p
->interrupts
[0];
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"));
227 *irq
= p
->interrupts
[0];
231 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
232 "Resource isn't an IRQ\n"));
235 return AE_CTRL_TERMINATE
;
239 * Run _CRS and set link->irq.active
246 acpi_pci_link_get_current (
247 struct acpi_pci_link
*link
)
250 acpi_status status
= AE_OK
;
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 */
262 /* Query _STA, set link->device->status */
263 result
= acpi_bus_get_status(link
->device
);
265 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Unable to read status\n"));
269 if (!link
->device
->status
.enabled
) {
270 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Link disabled\n"));
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"));
287 if (acpi_strict
&& !irq
) {
288 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "_CRS returned 0\n"));
292 link
->irq
.active
= irq
;
294 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Link at IRQ %d \n", link
->irq
.active
));
297 return_VALUE(result
);
302 struct acpi_pci_link
*link
,
306 acpi_status status
= AE_OK
;
308 struct acpi_resource res
;
309 struct acpi_resource end
;
311 struct acpi_buffer buffer
= {sizeof(resource
)+1, &resource
};
313 ACPI_FUNCTION_TRACE("acpi_pci_link_set");
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
;
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
;
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
;
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 */
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
);
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
);
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
));
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.
426 * List interrupts that should not be used for PCI:
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
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 */
472 acpi_irq_penalty_init(void)
474 struct list_head
*node
= NULL
;
475 struct acpi_pci_link
*link
= NULL
;
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
);
487 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link context\n"));
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
;
513 static int acpi_irq_balance
; /* 0: static, 1: balance */
515 static int acpi_pci_link_allocate(struct acpi_pci_link
* link
) {
519 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
521 if (link
->irq
.initialized
)
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
])
532 * forget active IRQ that is not in possible list
534 if (i
== link
->irq
.possible_count
) {
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
;
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
);
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;
582 acpi_pci_link_get_irq (
586 int* active_high_low
)
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
);
596 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link device\n"));
600 link
= (struct acpi_pci_link
*) acpi_driver_data(device
);
602 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link context\n"));
606 /* TBD: Support multiple index (IRQ) entries per Link Device */
608 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid index %d\n", index
));
612 if (acpi_pci_link_allocate(link
))
615 if (!link
->irq
.active
) {
616 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Link active IRQ is 0!\n"));
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 /* --------------------------------------------------------------------------
628 -------------------------------------------------------------------------- */
632 struct acpi_device
*device
)
635 struct acpi_pci_link
*link
= NULL
;
639 ACPI_FUNCTION_TRACE("acpi_pci_link_add");
642 return_VALUE(-EINVAL
);
644 link
= kmalloc(sizeof(struct acpi_pci_link
), GFP_KERNEL
);
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
);
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
]);
670 printk(" %d", link
->irq
.possible
[i
]);
676 printk(" *%d", link
->irq
.active
);
678 if(!link
->device
->status
.enabled
)
679 printk(", disabled.");
683 /* TBD: Acquire/release lock */
684 list_add_tail(&link
->node
, &acpi_link
.entries
);
688 /* disable all links -- to be activated on use */
689 acpi_ut_evaluate_object(link
->handle
, "_DIS", 0, NULL
);
694 return_VALUE(result
);
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
));
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
);
724 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link context\n"));
728 acpi_pci_link_resume(link
);
735 acpi_pci_link_remove (
736 struct acpi_device
*device
,
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
);
757 * modify acpi_irq_penalty[] from cmdline
759 static int __init
acpi_irq_penalty_update(char *str
, int used
)
763 for (i
= 0; i
< 16; i
++) {
767 retval
= get_option(&str
,&irq
);
770 break; /* no number found */
775 if (irq
>= ACPI_MAX_IRQS
)
779 acpi_irq_penalty
[irq
] += PIRQ_PENALTY_ISA_USED
;
781 acpi_irq_penalty
[irq
] = PIRQ_PENALTY_PCI_AVAILABLE
;
783 if (retval
!= 2) /* no next number */
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;
816 __setup("acpi_irq_nobalance", acpi_irq_nobalance_set
);
818 int __init
acpi_irq_balance_set(char *str
)
820 acpi_irq_balance
= 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
= {
834 .cls
= &irqrouter_sysdev_class
,
838 static int __init
irqrouter_init_sysfs(void)
842 ACPI_FUNCTION_TRACE("irqrouter_init_sysfs");
844 if (acpi_disabled
|| acpi_noirq
)
847 error
= sysdev_class_register(&irqrouter_sysdev_class
);
849 error
= sysdev_register(&device_irqrouter
);
854 device_initcall(irqrouter_init_sysfs
);
857 static int __init
acpi_pci_link_init (void)
859 ACPI_FUNCTION_TRACE("acpi_pci_link_init");
865 INIT_LIST_HEAD(&acpi_link
.entries
);
867 if (acpi_bus_register_driver(&acpi_pci_link_driver
) < 0)
868 return_VALUE(-ENODEV
);
873 subsys_initcall(acpi_pci_link_init
);