Blame view
drivers/pci/setup-irq.c
1.57 KB
7328c8f48 PCI: Add SPDX GPL... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
1da177e4c Linux-2.6.12-rc2 |
2 |
/* |
df62ab5e0 PCI: Tidy comments |
3 |
* Support routines for initializing a PCI subsystem |
1da177e4c Linux-2.6.12-rc2 |
4 5 6 7 8 |
* * Extruded from code written by * Dave Rusling (david.rusling@reo.mts.dec.com) * David Mosberger (davidm@cs.arizona.edu) * David Miller (davem@redhat.com) |
1da177e4c Linux-2.6.12-rc2 |
9 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
10 11 12 13 14 |
#include <linux/kernel.h> #include <linux/pci.h> #include <linux/errno.h> #include <linux/ioport.h> #include <linux/cache.h> |
47a650f27 PCI: Add pci_assi... |
15 |
#include "pci.h" |
1da177e4c Linux-2.6.12-rc2 |
16 |
|
47a650f27 PCI: Add pci_assi... |
17 |
void pci_assign_irq(struct pci_dev *dev) |
1da177e4c Linux-2.6.12-rc2 |
18 |
{ |
47a650f27 PCI: Add pci_assi... |
19 20 |
u8 pin; u8 slot = -1; |
691cd0c2e PCI: PCI devices ... |
21 |
int irq = 0; |
47a650f27 PCI: Add pci_assi... |
22 23 24 |
struct pci_host_bridge *hbrg = pci_find_host_bridge(dev->bus); if (!(hbrg->map_irq)) { |
7506dc798 PCI: Add wrappers... |
25 26 |
pci_dbg(dev, "runtime IRQ mapping not provided by arch "); |
47a650f27 PCI: Add pci_assi... |
27 28 |
return; } |
1da177e4c Linux-2.6.12-rc2 |
29 30 31 32 33 34 35 36 |
/* If this device is not on the primary bus, we need to figure out which interrupt pin it will come in on. We know which slot it will come in on 'cos that slot is where the bridge is. Each time the interrupt line passes through a PCI-PCI bridge we must apply the swizzle function. */ pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); |
691cd0c2e PCI: PCI devices ... |
37 38 |
/* Cope with illegal. */ if (pin > 4) |
1da177e4c Linux-2.6.12-rc2 |
39 |
pin = 1; |
47a650f27 PCI: Add pci_assi... |
40 |
if (pin) { |
691cd0c2e PCI: PCI devices ... |
41 |
/* Follow the chain of bridges, swizzling as we go. */ |
47a650f27 PCI: Add pci_assi... |
42 43 |
if (hbrg->swizzle_irq) slot = (*(hbrg->swizzle_irq))(dev, &pin); |
1da177e4c Linux-2.6.12-rc2 |
44 |
|
47a650f27 PCI: Add pci_assi... |
45 46 47 48 49 |
/* * If a swizzling function is not used map_irq must * ignore slot */ irq = (*(hbrg->map_irq))(dev, slot, pin); |
691cd0c2e PCI: PCI devices ... |
50 51 52 |
if (irq == -1) irq = 0; } |
1da177e4c Linux-2.6.12-rc2 |
53 |
dev->irq = irq; |
7506dc798 PCI: Add wrappers... |
54 55 |
pci_dbg(dev, "assign IRQ: got %d ", dev->irq); |
1da177e4c Linux-2.6.12-rc2 |
56 57 58 |
/* Always tell the device, so the driver knows what is the real IRQ to use; the device does not use it. */ |
606799cc5 PCI: Inline and r... |
59 |
pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); |
1da177e4c Linux-2.6.12-rc2 |
60 |
} |