home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / Linux / PCI / setup-irq.c < prev    next >
C/C++ Source or Header  |  2001-05-19  |  2KB  |  72 lines

  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.  
  21. #define DEBUG_CONFIG 0
  22. #if DEBUG_CONFIG
  23. # define DBGC(args)     printk args
  24. #else
  25. # define DBGC(args)
  26. #endif
  27.  
  28.  
  29. static void __init
  30. pdev_fixup_irq(struct pci_dev *dev,
  31.            u8 (*swizzle)(struct pci_dev *, u8 *),
  32.            int (*map_irq)(struct pci_dev *, u8, u8))
  33. {
  34.     u8 pin, slot;
  35.     int irq;
  36.  
  37.     /* If this device is not on the primary bus, we need to figure out
  38.        which interrupt pin it will come in on.   We know which slot it
  39.        will come in on 'cos that slot is where the bridge is.   Each
  40.        time the interrupt line passes through a PCI-PCI bridge we must
  41.        apply the swizzle function.  */
  42.  
  43.     pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
  44.     /* Cope with 0 and illegal. */
  45.     if (pin == 0 || pin > 4)
  46.         pin = 1;
  47.  
  48.     /* Follow the chain of bridges, swizzling as we go.  */
  49.     slot = (*swizzle)(dev, &pin);
  50.  
  51.     irq = (*map_irq)(dev, slot, pin);
  52.     if (irq == -1)
  53.         irq = 0;
  54.     dev->irq = irq;
  55.  
  56.     DBGC((KERN_ERR "PCI fixup irq: (%s) got %d\n", dev->name, dev->irq));
  57.  
  58.     /* Always tell the device, so the driver knows what is
  59.        the real IRQ to use; the device does not use it. */
  60.     pcibios_update_irq(dev, irq);
  61. }
  62.  
  63. void __init
  64. pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *),
  65.            int (*map_irq)(struct pci_dev *, u8, u8))
  66. {
  67.     struct pci_dev *dev;
  68.     pci_for_each_dev(dev) {
  69.         pdev_fixup_irq(dev, swizzle, map_irq);
  70.     }
  71. }
  72.