aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/setup-irq.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/pci/setup-irq.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/pci/setup-irq.c')
-rw-r--r--drivers/pci/setup-irq.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c
new file mode 100644
index 000000000000..a251289c9958
--- /dev/null
+++ b/drivers/pci/setup-irq.c
@@ -0,0 +1,64 @@
1/*
2 * drivers/pci/setup-irq.c
3 *
4 * Extruded from code written by
5 * Dave Rusling (david.rusling@reo.mts.dec.com)
6 * David Mosberger (davidm@cs.arizona.edu)
7 * David Miller (davem@redhat.com)
8 *
9 * Support routines for initializing a PCI subsystem.
10 */
11
12
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/errno.h>
17#include <linux/ioport.h>
18#include <linux/cache.h>
19
20
21static void __init
22pdev_fixup_irq(struct pci_dev *dev,
23 u8 (*swizzle)(struct pci_dev *, u8 *),
24 int (*map_irq)(struct pci_dev *, u8, u8))
25{
26 u8 pin, slot;
27 int irq;
28
29 /* If this device is not on the primary bus, we need to figure out
30 which interrupt pin it will come in on. We know which slot it
31 will come in on 'cos that slot is where the bridge is. Each
32 time the interrupt line passes through a PCI-PCI bridge we must
33 apply the swizzle function. */
34
35 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
36 /* Cope with 0 and illegal. */
37 if (pin == 0 || pin > 4)
38 pin = 1;
39
40 /* Follow the chain of bridges, swizzling as we go. */
41 slot = (*swizzle)(dev, &pin);
42
43 irq = (*map_irq)(dev, slot, pin);
44 if (irq == -1)
45 irq = 0;
46 dev->irq = irq;
47
48 pr_debug("PCI: fixup irq: (%s) got %d\n",
49 dev->dev.kobj.name, dev->irq);
50
51 /* Always tell the device, so the driver knows what is
52 the real IRQ to use; the device does not use it. */
53 pcibios_update_irq(dev, irq);
54}
55
56void __init
57pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *),
58 int (*map_irq)(struct pci_dev *, u8, u8))
59{
60 struct pci_dev *dev = NULL;
61 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
62 pdev_fixup_irq(dev, swizzle, map_irq);
63 }
64}