0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/kernel.h>
0012 #include <linux/pci.h>
0013 #include <linux/errno.h>
0014 #include <linux/ioport.h>
0015 #include <linux/cache.h>
0016 #include "pci.h"
0017
0018 void pci_assign_irq(struct pci_dev *dev)
0019 {
0020 u8 pin;
0021 u8 slot = -1;
0022 int irq = 0;
0023 struct pci_host_bridge *hbrg = pci_find_host_bridge(dev->bus);
0024
0025 if (!(hbrg->map_irq)) {
0026 pci_dbg(dev, "runtime IRQ mapping not provided by arch\n");
0027 return;
0028 }
0029
0030
0031
0032
0033
0034
0035
0036
0037 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
0038
0039 if (pin > 4)
0040 pin = 1;
0041
0042 if (pin) {
0043
0044 if (hbrg->swizzle_irq)
0045 slot = (*(hbrg->swizzle_irq))(dev, &pin);
0046
0047
0048
0049
0050
0051 irq = (*(hbrg->map_irq))(dev, slot, pin);
0052 if (irq == -1)
0053 irq = 0;
0054 }
0055 dev->irq = irq;
0056
0057 pci_dbg(dev, "assign IRQ: got %d\n", dev->irq);
0058
0059
0060
0061
0062
0063 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
0064 }