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
,
72 * If a link is initialized, we never change its active and initialized
73 * later even the link is disable. Instead, we just repick the active irq
75 struct acpi_pci_link_irq
{
76 u8 active
; /* Current IRQ */
77 u8 edge_level
; /* All IRQs */
78 u8 active_high_low
; /* All IRQs */
81 u8 possible
[ACPI_PCI_LINK_MAX_POSSIBLE
];
86 struct acpi_pci_link
{
87 struct list_head node
;
88 struct acpi_device
*device
;
90 struct acpi_pci_link_irq irq
;
96 struct list_head entries
;
98 DECLARE_MUTEX(acpi_link_lock
);
101 /* --------------------------------------------------------------------------
102 PCI Link Device Management
103 -------------------------------------------------------------------------- */
106 * set context (link) possible list from resource list
109 acpi_pci_link_check_possible (
110 struct acpi_resource
*resource
,
113 struct acpi_pci_link
*link
= (struct acpi_pci_link
*) context
;
116 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
118 switch (resource
->id
) {
119 case ACPI_RSTYPE_START_DPF
:
120 return_ACPI_STATUS(AE_OK
);
121 case ACPI_RSTYPE_IRQ
:
123 struct acpi_resource_irq
*p
= &resource
->data
.irq
;
124 if (!p
|| !p
->number_of_interrupts
) {
125 ACPI_DEBUG_PRINT((ACPI_DB_WARN
, "Blank IRQ resource\n"));
126 return_ACPI_STATUS(AE_OK
);
128 for (i
= 0; (i
<p
->number_of_interrupts
&& i
<ACPI_PCI_LINK_MAX_POSSIBLE
); i
++) {
129 if (!p
->interrupts
[i
]) {
130 ACPI_DEBUG_PRINT((ACPI_DB_WARN
, "Invalid IRQ %d\n", p
->interrupts
[i
]));
133 link
->irq
.possible
[i
] = p
->interrupts
[i
];
134 link
->irq
.possible_count
++;
136 link
->irq
.edge_level
= p
->edge_level
;
137 link
->irq
.active_high_low
= p
->active_high_low
;
138 link
->irq
.resource_type
= ACPI_RSTYPE_IRQ
;
141 case ACPI_RSTYPE_EXT_IRQ
:
143 struct acpi_resource_ext_irq
*p
= &resource
->data
.extended_irq
;
144 if (!p
|| !p
->number_of_interrupts
) {
145 ACPI_DEBUG_PRINT((ACPI_DB_WARN
,
146 "Blank EXT IRQ resource\n"));
147 return_ACPI_STATUS(AE_OK
);
149 for (i
= 0; (i
<p
->number_of_interrupts
&& i
<ACPI_PCI_LINK_MAX_POSSIBLE
); i
++) {
150 if (!p
->interrupts
[i
]) {
151 ACPI_DEBUG_PRINT((ACPI_DB_WARN
, "Invalid IRQ %d\n", p
->interrupts
[i
]));
154 link
->irq
.possible
[i
] = p
->interrupts
[i
];
155 link
->irq
.possible_count
++;
157 link
->irq
.edge_level
= p
->edge_level
;
158 link
->irq
.active_high_low
= p
->active_high_low
;
159 link
->irq
.resource_type
= ACPI_RSTYPE_EXT_IRQ
;
163 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
164 "Resource is not an IRQ entry\n"));
165 return_ACPI_STATUS(AE_OK
);
168 return_ACPI_STATUS(AE_CTRL_TERMINATE
);
173 acpi_pci_link_get_possible (
174 struct acpi_pci_link
*link
)
178 ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible");
181 return_VALUE(-EINVAL
);
183 status
= acpi_walk_resources(link
->handle
, METHOD_NAME__PRS
,
184 acpi_pci_link_check_possible
, link
);
185 if (ACPI_FAILURE(status
)) {
186 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Error evaluating _PRS\n"));
187 return_VALUE(-ENODEV
);
190 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
191 "Found %d possible IRQs\n", link
->irq
.possible_count
));
198 acpi_pci_link_check_current (
199 struct acpi_resource
*resource
,
202 int *irq
= (int *) context
;
204 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
206 switch (resource
->id
) {
207 case ACPI_RSTYPE_IRQ
:
209 struct acpi_resource_irq
*p
= &resource
->data
.irq
;
210 if (!p
|| !p
->number_of_interrupts
) {
212 * IRQ descriptors may have no IRQ# bits set,
213 * particularly those those w/ _STA disabled
215 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
216 "Blank IRQ resource\n"));
217 return_ACPI_STATUS(AE_OK
);
219 *irq
= p
->interrupts
[0];
222 case ACPI_RSTYPE_EXT_IRQ
:
224 struct acpi_resource_ext_irq
*p
= &resource
->data
.extended_irq
;
225 if (!p
|| !p
->number_of_interrupts
) {
227 * extended IRQ descriptors must
228 * return at least 1 IRQ
230 ACPI_DEBUG_PRINT((ACPI_DB_WARN
,
231 "Blank EXT IRQ resource\n"));
232 return_ACPI_STATUS(AE_OK
);
234 *irq
= p
->interrupts
[0];
238 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
239 "Resource isn't an IRQ\n"));
240 return_ACPI_STATUS(AE_OK
);
242 return_ACPI_STATUS(AE_CTRL_TERMINATE
);
246 * Run _CRS and set link->irq.active
253 acpi_pci_link_get_current (
254 struct acpi_pci_link
*link
)
257 acpi_status status
= AE_OK
;
260 ACPI_FUNCTION_TRACE("acpi_pci_link_get_current");
262 if (!link
|| !link
->handle
)
263 return_VALUE(-EINVAL
);
265 link
->irq
.active
= 0;
267 /* in practice, status disabled is meaningless, ignore it */
269 /* Query _STA, set link->device->status */
270 result
= acpi_bus_get_status(link
->device
);
272 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Unable to read status\n"));
276 if (!link
->device
->status
.enabled
) {
277 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Link disabled\n"));
283 * Query and parse _CRS to get the current IRQ assignment.
286 status
= acpi_walk_resources(link
->handle
, METHOD_NAME__CRS
,
287 acpi_pci_link_check_current
, &irq
);
288 if (ACPI_FAILURE(status
)) {
289 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Error evaluating _CRS\n"));
294 if (acpi_strict
&& !irq
) {
295 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "_CRS returned 0\n"));
299 link
->irq
.active
= irq
;
301 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Link at IRQ %d \n", link
->irq
.active
));
304 return_VALUE(result
);
309 struct acpi_pci_link
*link
,
313 acpi_status status
= AE_OK
;
315 struct acpi_resource res
;
316 struct acpi_resource end
;
318 struct acpi_buffer buffer
= {0, NULL
};
320 ACPI_FUNCTION_TRACE("acpi_pci_link_set");
323 return_VALUE(-EINVAL
);
325 resource
= kmalloc( sizeof(*resource
)+1, GFP_KERNEL
);
327 return_VALUE(-ENOMEM
);
329 memset(resource
, 0, sizeof(*resource
)+1);
330 buffer
.length
= sizeof(*resource
) +1;
331 buffer
.pointer
= resource
;
333 switch(link
->irq
.resource_type
) {
334 case ACPI_RSTYPE_IRQ
:
335 resource
->res
.id
= ACPI_RSTYPE_IRQ
;
336 resource
->res
.length
= sizeof(struct acpi_resource
);
337 resource
->res
.data
.irq
.edge_level
= link
->irq
.edge_level
;
338 resource
->res
.data
.irq
.active_high_low
= link
->irq
.active_high_low
;
339 if (link
->irq
.edge_level
== ACPI_EDGE_SENSITIVE
)
340 resource
->res
.data
.irq
.shared_exclusive
= ACPI_EXCLUSIVE
;
342 resource
->res
.data
.irq
.shared_exclusive
= ACPI_SHARED
;
343 resource
->res
.data
.irq
.number_of_interrupts
= 1;
344 resource
->res
.data
.irq
.interrupts
[0] = irq
;
347 case ACPI_RSTYPE_EXT_IRQ
:
348 resource
->res
.id
= ACPI_RSTYPE_EXT_IRQ
;
349 resource
->res
.length
= sizeof(struct acpi_resource
);
350 resource
->res
.data
.extended_irq
.producer_consumer
= ACPI_CONSUMER
;
351 resource
->res
.data
.extended_irq
.edge_level
= link
->irq
.edge_level
;
352 resource
->res
.data
.extended_irq
.active_high_low
= link
->irq
.active_high_low
;
353 if (link
->irq
.edge_level
== ACPI_EDGE_SENSITIVE
)
354 resource
->res
.data
.irq
.shared_exclusive
= ACPI_EXCLUSIVE
;
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 */
362 printk("ACPI BUG: resource_type %d\n", link
->irq
.resource_type
);
367 resource
->end
.id
= ACPI_RSTYPE_END_TAG
;
369 /* Attempt to set the resource */
370 status
= acpi_set_current_resources(link
->handle
, &buffer
);
372 /* check for total failure */
373 if (ACPI_FAILURE(status
)) {
374 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Error evaluating _SRS\n"));
379 /* Query _STA, set device->status */
380 result
= acpi_bus_get_status(link
->device
);
382 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Unable to read status\n"));
385 if (!link
->device
->status
.enabled
) {
386 printk(KERN_WARNING PREFIX
387 "%s [%s] disabled and referenced, BIOS bug.\n",
388 acpi_device_name(link
->device
),
389 acpi_device_bid(link
->device
));
392 /* Query _CRS, set link->irq.active */
393 result
= acpi_pci_link_get_current(link
);
399 * Is current setting not what we set?
400 * set link->irq.active
402 if (link
->irq
.active
!= irq
) {
404 * policy: when _CRS doesn't return what we just _SRS
405 * assume _SRS worked and override _CRS value.
407 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
),
411 link
->irq
.active
, irq
);
412 link
->irq
.active
= irq
;
415 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "Set IRQ %d\n", link
->irq
.active
));
419 return_VALUE(result
);
423 /* --------------------------------------------------------------------------
424 PCI Link IRQ Management
425 -------------------------------------------------------------------------- */
428 * "acpi_irq_balance" (default in APIC mode) enables ACPI to use PIC Interrupt
429 * Link Devices to move the PIRQs around to minimize sharing.
431 * "acpi_irq_nobalance" (default in PIC mode) tells ACPI not to move any PIC IRQs
432 * that the BIOS has already set to active. This is necessary because
433 * ACPI has no automatic means of knowing what ISA IRQs are used. Note that
434 * if the BIOS doesn't set a Link Device active, ACPI needs to program it
435 * even if acpi_irq_nobalance is set.
437 * A tables of penalties avoids directing PCI interrupts to well known
438 * ISA IRQs. Boot params are available to over-ride the default table:
440 * List interrupts that are free for PCI use.
443 * List interrupts that should not be used for PCI:
446 * Note that PCI IRQ routers have a list of possible IRQs,
447 * which may not include the IRQs this table says are available.
449 * Since this heuristic can't tell the difference between a link
450 * that no device will attach to, vs. a link which may be shared
451 * by multiple active devices -- it is not optimal.
453 * If interrupt performance is that important, get an IO-APIC system
454 * with a pin dedicated to each device. Or for that matter, an MSI
458 #define ACPI_MAX_IRQS 256
459 #define ACPI_MAX_ISA_IRQ 16
461 #define PIRQ_PENALTY_PCI_AVAILABLE (0)
462 #define PIRQ_PENALTY_PCI_POSSIBLE (16*16)
463 #define PIRQ_PENALTY_PCI_USING (16*16*16)
464 #define PIRQ_PENALTY_ISA_TYPICAL (16*16*16*16)
465 #define PIRQ_PENALTY_ISA_USED (16*16*16*16*16)
466 #define PIRQ_PENALTY_ISA_ALWAYS (16*16*16*16*16*16)
468 static int acpi_irq_penalty
[ACPI_MAX_IRQS
] = {
469 PIRQ_PENALTY_ISA_ALWAYS
, /* IRQ0 timer */
470 PIRQ_PENALTY_ISA_ALWAYS
, /* IRQ1 keyboard */
471 PIRQ_PENALTY_ISA_ALWAYS
, /* IRQ2 cascade */
472 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ3 serial */
473 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ4 serial */
474 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ5 sometimes SoundBlaster */
475 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ6 */
476 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ7 parallel, spurious */
477 PIRQ_PENALTY_ISA_TYPICAL
, /* IRQ8 rtc, sometimes */
478 PIRQ_PENALTY_PCI_AVAILABLE
, /* IRQ9 PCI, often acpi */
479 PIRQ_PENALTY_PCI_AVAILABLE
, /* IRQ10 PCI */
480 PIRQ_PENALTY_PCI_AVAILABLE
, /* IRQ11 PCI */
481 PIRQ_PENALTY_ISA_USED
, /* IRQ12 mouse */
482 PIRQ_PENALTY_ISA_USED
, /* IRQ13 fpe, sometimes */
483 PIRQ_PENALTY_ISA_USED
, /* IRQ14 ide0 */
484 PIRQ_PENALTY_ISA_USED
, /* IRQ15 ide1 */
489 acpi_irq_penalty_init(void)
491 struct list_head
*node
= NULL
;
492 struct acpi_pci_link
*link
= NULL
;
495 ACPI_FUNCTION_TRACE("acpi_irq_penalty_init");
498 * Update penalties to facilitate IRQ balancing.
500 list_for_each(node
, &acpi_link
.entries
) {
502 link
= list_entry(node
, struct acpi_pci_link
, node
);
504 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link context\n"));
509 * reflect the possible and active irqs in the penalty table --
510 * useful for breaking ties.
512 if (link
->irq
.possible_count
) {
513 int penalty
= PIRQ_PENALTY_PCI_POSSIBLE
/ link
->irq
.possible_count
;
515 for (i
= 0; i
< link
->irq
.possible_count
; i
++) {
516 if (link
->irq
.possible
[i
] < ACPI_MAX_ISA_IRQ
)
517 acpi_irq_penalty
[link
->irq
.possible
[i
]] += penalty
;
520 } else if (link
->irq
.active
) {
521 acpi_irq_penalty
[link
->irq
.active
] += PIRQ_PENALTY_PCI_POSSIBLE
;
524 /* Add a penalty for the SCI */
525 acpi_irq_penalty
[acpi_fadt
.sci_int
] += PIRQ_PENALTY_PCI_USING
;
530 static int acpi_irq_balance
; /* 0: static, 1: balance */
532 static int acpi_pci_link_allocate(
533 struct acpi_pci_link
*link
)
538 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
540 if (link
->irq
.initialized
) {
541 if (link
->refcnt
== 0)
542 /* This means the link is disabled but initialized */
543 acpi_pci_link_set(link
, link
->irq
.active
);
548 * search for active IRQ in list of possible IRQs.
550 for (i
= 0; i
< link
->irq
.possible_count
; ++i
) {
551 if (link
->irq
.active
== link
->irq
.possible
[i
])
555 * forget active IRQ that is not in possible list
557 if (i
== link
->irq
.possible_count
) {
559 printk(KERN_WARNING PREFIX
"_CRS %d not found"
560 " in _PRS\n", link
->irq
.active
);
561 link
->irq
.active
= 0;
565 * if active found, use it; else pick entry from end of possible list.
567 if (link
->irq
.active
) {
568 irq
= link
->irq
.active
;
570 irq
= link
->irq
.possible
[link
->irq
.possible_count
- 1];
573 if (acpi_irq_balance
|| !link
->irq
.active
) {
575 * Select the best IRQ. This is done in reverse to promote
576 * the use of IRQs 9, 10, 11, and >15.
578 for (i
= (link
->irq
.possible_count
- 1); i
>= 0; i
--) {
579 if (acpi_irq_penalty
[irq
] > acpi_irq_penalty
[link
->irq
.possible
[i
]])
580 irq
= link
->irq
.possible
[i
];
584 /* Attempt to enable the link device at this IRQ. */
585 if (acpi_pci_link_set(link
, irq
)) {
586 printk(PREFIX
"Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n"
587 "Try pci=noacpi or acpi=off\n",
588 acpi_device_name(link
->device
),
589 acpi_device_bid(link
->device
));
590 return_VALUE(-ENODEV
);
592 acpi_irq_penalty
[link
->irq
.active
] += PIRQ_PENALTY_PCI_USING
;
593 printk(PREFIX
"%s [%s] enabled at IRQ %d\n",
594 acpi_device_name(link
->device
),
595 acpi_device_bid(link
->device
), link
->irq
.active
);
598 link
->irq
.initialized
= 1;
604 * acpi_pci_link_allocate_irq
605 * success: return IRQ >= 0
610 acpi_pci_link_allocate_irq (
614 int *active_high_low
,
618 struct acpi_device
*device
= NULL
;
619 struct acpi_pci_link
*link
= NULL
;
621 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq");
623 result
= acpi_bus_get_device(handle
, &device
);
625 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link device\n"));
629 link
= (struct acpi_pci_link
*) acpi_driver_data(device
);
631 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link context\n"));
635 /* TBD: Support multiple index (IRQ) entries per Link Device */
637 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid index %d\n", index
));
641 down(&acpi_link_lock
);
642 if (acpi_pci_link_allocate(link
)) {
647 if (!link
->irq
.active
) {
649 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Link active IRQ is 0!\n"));
655 if (edge_level
) *edge_level
= link
->irq
.edge_level
;
656 if (active_high_low
) *active_high_low
= link
->irq
.active_high_low
;
657 if (name
) *name
= acpi_device_bid(link
->device
);
658 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
659 "Link %s is referenced\n", acpi_device_bid(link
->device
)));
660 return_VALUE(link
->irq
.active
);
664 * We don't change link's irq information here. After it is reenabled, we
665 * continue use the info
668 acpi_pci_link_free_irq(acpi_handle handle
)
670 struct acpi_device
*device
= NULL
;
671 struct acpi_pci_link
*link
= NULL
;
674 ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq");
676 result
= acpi_bus_get_device(handle
, &device
);
678 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link device\n"));
682 link
= (struct acpi_pci_link
*) acpi_driver_data(device
);
684 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Invalid link context\n"));
688 down(&acpi_link_lock
);
689 if (!link
->irq
.initialized
) {
691 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
, "Link isn't initialized\n"));
697 * The Link reference count allows us to _DISable an unused link
698 * and suspend time, and set it again on resume.
699 * However, 2.6.12 still has irq_router.resume
700 * which blindly restores the link state.
701 * So we disable the reference count method
702 * to prevent duplicate acpi_pci_link_set()
703 * which would harm some systems
707 ACPI_DEBUG_PRINT((ACPI_DB_INFO
,
708 "Link %s is dereferenced\n", acpi_device_bid(link
->device
)));
710 if (link
->refcnt
== 0) {
711 acpi_ut_evaluate_object(link
->handle
, "_DIS", 0, NULL
);
714 return_VALUE(link
->irq
.active
);
716 /* --------------------------------------------------------------------------
718 -------------------------------------------------------------------------- */
722 struct acpi_device
*device
)
725 struct acpi_pci_link
*link
= NULL
;
729 ACPI_FUNCTION_TRACE("acpi_pci_link_add");
732 return_VALUE(-EINVAL
);
734 link
= kmalloc(sizeof(struct acpi_pci_link
), GFP_KERNEL
);
736 return_VALUE(-ENOMEM
);
737 memset(link
, 0, sizeof(struct acpi_pci_link
));
739 link
->device
= device
;
740 link
->handle
= device
->handle
;
741 strcpy(acpi_device_name(device
), ACPI_PCI_LINK_DEVICE_NAME
);
742 strcpy(acpi_device_class(device
), ACPI_PCI_LINK_CLASS
);
743 acpi_driver_data(device
) = link
;
745 down(&acpi_link_lock
);
746 result
= acpi_pci_link_get_possible(link
);
750 /* query and set link->irq.active */
751 acpi_pci_link_get_current(link
);
753 printk(PREFIX
"%s [%s] (IRQs", acpi_device_name(device
),
754 acpi_device_bid(device
));
755 for (i
= 0; i
< link
->irq
.possible_count
; i
++) {
756 if (link
->irq
.active
== link
->irq
.possible
[i
]) {
757 printk(" *%d", link
->irq
.possible
[i
]);
761 printk(" %d", link
->irq
.possible
[i
]);
767 printk(" *%d", link
->irq
.active
);
769 if(!link
->device
->status
.enabled
)
770 printk(", disabled.");
774 /* TBD: Acquire/release lock */
775 list_add_tail(&link
->node
, &acpi_link
.entries
);
779 /* disable all links -- to be activated on use */
780 acpi_ut_evaluate_object(link
->handle
, "_DIS", 0, NULL
);
786 return_VALUE(result
);
790 acpi_pci_link_resume(
791 struct acpi_pci_link
*link
)
793 ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
795 if (link
->refcnt
&& link
->irq
.active
&& link
->irq
.initialized
)
796 return_VALUE(acpi_pci_link_set(link
, link
->irq
.active
));
802 * FIXME: this is a workaround to avoid nasty warning. It will be removed
803 * after every device calls pci_disable_device in .resume.
807 irqrouter_resume(struct sys_device
*dev
)
809 struct list_head
*node
= NULL
;
810 struct acpi_pci_link
*link
= NULL
;
812 ACPI_FUNCTION_TRACE("irqrouter_resume");
815 list_for_each(node
, &acpi_link
.entries
) {
816 link
= list_entry(node
, struct acpi_pci_link
, node
);
818 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
819 "Invalid link context\n"));
822 acpi_pci_link_resume(link
);
830 acpi_pci_link_remove (
831 struct acpi_device
*device
,
834 struct acpi_pci_link
*link
= NULL
;
836 ACPI_FUNCTION_TRACE("acpi_pci_link_remove");
838 if (!device
|| !acpi_driver_data(device
))
839 return_VALUE(-EINVAL
);
841 link
= (struct acpi_pci_link
*) acpi_driver_data(device
);
843 down(&acpi_link_lock
);
844 list_del(&link
->node
);
853 * modify acpi_irq_penalty[] from cmdline
855 static int __init
acpi_irq_penalty_update(char *str
, int used
)
859 for (i
= 0; i
< 16; i
++) {
863 retval
= get_option(&str
,&irq
);
866 break; /* no number found */
871 if (irq
>= ACPI_MAX_IRQS
)
875 acpi_irq_penalty
[irq
] += PIRQ_PENALTY_ISA_USED
;
877 acpi_irq_penalty
[irq
] = PIRQ_PENALTY_PCI_AVAILABLE
;
879 if (retval
!= 2) /* no next number */
886 * We'd like PNP to call this routine for the
887 * single ISA_USED value for each legacy device.
888 * But instead it calls us with each POSSIBLE setting.
889 * There is no ISA_POSSIBLE weight, so we simply use
890 * the (small) PCI_USING penalty.
892 void acpi_penalize_isa_irq(int irq
, int active
)
895 acpi_irq_penalty
[irq
] += PIRQ_PENALTY_ISA_USED
;
897 acpi_irq_penalty
[irq
] += PIRQ_PENALTY_PCI_USING
;
901 * Over-ride default table to reserve additional IRQs for use by ISA
902 * e.g. acpi_irq_isa=5
903 * Useful for telling ACPI how not to interfere with your ISA sound card.
905 static int __init
acpi_irq_isa(char *str
)
907 return acpi_irq_penalty_update(str
, 1);
909 __setup("acpi_irq_isa=", acpi_irq_isa
);
912 * Over-ride default table to free additional IRQs for use by PCI
913 * e.g. acpi_irq_pci=7,15
914 * Used for acpi_irq_balance to free up IRQs to reduce PCI IRQ sharing.
916 static int __init
acpi_irq_pci(char *str
)
918 return acpi_irq_penalty_update(str
, 0);
920 __setup("acpi_irq_pci=", acpi_irq_pci
);
922 static int __init
acpi_irq_nobalance_set(char *str
)
924 acpi_irq_balance
= 0;
927 __setup("acpi_irq_nobalance", acpi_irq_nobalance_set
);
929 int __init
acpi_irq_balance_set(char *str
)
931 acpi_irq_balance
= 1;
934 __setup("acpi_irq_balance", acpi_irq_balance_set
);
937 /* FIXME: we will remove this interface after all drivers call pci_disable_device */
938 static struct sysdev_class irqrouter_sysdev_class
= {
939 set_kset_name("irqrouter"),
940 .resume
= irqrouter_resume
,
944 static struct sys_device device_irqrouter
= {
946 .cls
= &irqrouter_sysdev_class
,
950 static int __init
irqrouter_init_sysfs(void)
954 ACPI_FUNCTION_TRACE("irqrouter_init_sysfs");
956 if (acpi_disabled
|| acpi_noirq
)
959 error
= sysdev_class_register(&irqrouter_sysdev_class
);
961 error
= sysdev_register(&device_irqrouter
);
966 device_initcall(irqrouter_init_sysfs
);
969 static int __init
acpi_pci_link_init (void)
971 ACPI_FUNCTION_TRACE("acpi_pci_link_init");
977 INIT_LIST_HEAD(&acpi_link
.entries
);
979 if (acpi_bus_register_driver(&acpi_pci_link_driver
) < 0)
980 return_VALUE(-ENODEV
);
985 subsys_initcall(acpi_pci_link_init
);