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
:
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
]));
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"));
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
]));
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"));
158 return_ACPI_STATUS(AE_OK
);
161 return_ACPI_STATUS(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"));
210 return_ACPI_STATUS(AE_OK
);
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"));
225 return_ACPI_STATUS(AE_OK
);
227 *irq
= p
->interrupts
[0];
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
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
= {0, NULL
};
313 ACPI_FUNCTION_TRACE("acpi_pci_link_set");
316 return_VALUE(-EINVAL
);
318 resource
= kmalloc( sizeof(*resource
)+1, GFP_KERNEL
);
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
;
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
;
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
;
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 */
355 printk("ACPI BUG: resource_type %d\n", link
->irq
.resource_type
);
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"));
372 /* Query _STA, set device->status */
373 result
= acpi_bus_get_status(link
->device
);
375 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Unable to read status\n"));
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
);
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
));
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.
436 * List interrupts that should not be used for PCI:
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
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 */
482 acpi_irq_penalty_init(void)
484 struct list_head
*node
= NULL
;
485 struct acpi_pci_link
*link
= NULL
;
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
);
497 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link context\n"));
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
;
523 static int acpi_irq_balance
; /* 0: static, 1: balance */
525 static int acpi_pci_link_allocate(
526 struct acpi_pci_link
*link
)
531 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
533 if (link
->irq
.initialized
)
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
])
544 * forget active IRQ that is not in possible list
546 if (i
== link
->irq
.possible_count
) {
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
;
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
);
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;
593 * acpi_pci_link_get_irq
594 * success: return IRQ >= 0
599 acpi_pci_link_get_irq (
603 int *active_high_low
,
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
);
614 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link device\n"));
618 link
= (struct acpi_pci_link
*) acpi_driver_data(device
);
620 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link context\n"));
624 /* TBD: Support multiple index (IRQ) entries per Link Device */
626 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid index %d\n", index
));
630 if (acpi_pci_link_allocate(link
))
633 if (!link
->irq
.active
) {
634 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Link active IRQ is 0!\n"));
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 /* --------------------------------------------------------------------------
647 -------------------------------------------------------------------------- */
651 struct acpi_device
*device
)
654 struct acpi_pci_link
*link
= NULL
;
658 ACPI_FUNCTION_TRACE("acpi_pci_link_add");
661 return_VALUE(-EINVAL
);
663 link
= kmalloc(sizeof(struct acpi_pci_link
), GFP_KERNEL
);
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
);
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
]);
689 printk(" %d", link
->irq
.possible
[i
]);
695 printk(" *%d", link
->irq
.active
);
697 if(!link
->device
->status
.enabled
)
698 printk(", disabled.");
702 /* TBD: Acquire/release lock */
703 list_add_tail(&link
->node
, &acpi_link
.entries
);
707 /* disable all links -- to be activated on use */
708 acpi_ut_evaluate_object(link
->handle
, "_DIS", 0, NULL
);
713 return_VALUE(result
);
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
));
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
);
743 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link context\n"));
747 acpi_pci_link_resume(link
);
754 acpi_pci_link_remove (
755 struct acpi_device
*device
,
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
);
776 * modify acpi_irq_penalty[] from cmdline
778 static int __init
acpi_irq_penalty_update(char *str
, int used
)
782 for (i
= 0; i
< 16; i
++) {
786 retval
= get_option(&str
,&irq
);
789 break; /* no number found */
794 if (irq
>= ACPI_MAX_IRQS
)
798 acpi_irq_penalty
[irq
] += PIRQ_PENALTY_ISA_USED
;
800 acpi_irq_penalty
[irq
] = PIRQ_PENALTY_PCI_AVAILABLE
;
802 if (retval
!= 2) /* no next number */
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;
847 __setup("acpi_irq_nobalance", acpi_irq_nobalance_set
);
849 int __init
acpi_irq_balance_set(char *str
)
851 acpi_irq_balance
= 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
= {
865 .cls
= &irqrouter_sysdev_class
,
869 static int __init
irqrouter_init_sysfs(void)
873 ACPI_FUNCTION_TRACE("irqrouter_init_sysfs");
875 if (acpi_disabled
|| acpi_noirq
)
878 error
= sysdev_class_register(&irqrouter_sysdev_class
);
880 error
= sysdev_register(&device_irqrouter
);
885 device_initcall(irqrouter_init_sysfs
);
888 static int __init
acpi_pci_link_init (void)
890 ACPI_FUNCTION_TRACE("acpi_pci_link_init");
896 INIT_LIST_HEAD(&acpi_link
.entries
);
898 if (acpi_bus_register_driver(&acpi_pci_link_driver
) < 0)
899 return_VALUE(-ENODEV
);
904 subsys_initcall(acpi_pci_link_init
);