linux/drivers/of/of_pci_irq.c
<<
>>
Prefs
   1#include <linux/kernel.h>
   2#include <linux/of_pci.h>
   3#include <linux/of_irq.h>
   4#include <linux/export.h>
   5#include <asm/prom.h>
   6
   7/**
   8 * of_irq_map_pci - Resolve the interrupt for a PCI device
   9 * @pdev:       the device whose interrupt is to be resolved
  10 * @out_irq:    structure of_irq filled by this function
  11 *
  12 * This function resolves the PCI interrupt for a given PCI device. If a
  13 * device-node exists for a given pci_dev, it will use normal OF tree
  14 * walking. If not, it will implement standard swizzling and walk up the
  15 * PCI tree until an device-node is found, at which point it will finish
  16 * resolving using the OF tree walking.
  17 */
  18int of_irq_map_pci(const struct pci_dev *pdev, struct of_irq *out_irq)
  19{
  20        struct device_node *dn, *ppnode;
  21        struct pci_dev *ppdev;
  22        u32 lspec;
  23        __be32 lspec_be;
  24        __be32 laddr[3];
  25        u8 pin;
  26        int rc;
  27
  28        /* Check if we have a device node, if yes, fallback to standard
  29         * device tree parsing
  30         */
  31        dn = pci_device_to_OF_node(pdev);
  32        if (dn) {
  33                rc = of_irq_map_one(dn, 0, out_irq);
  34                if (!rc)
  35                        return rc;
  36        }
  37
  38        /* Ok, we don't, time to have fun. Let's start by building up an
  39         * interrupt spec.  we assume #interrupt-cells is 1, which is standard
  40         * for PCI. If you do different, then don't use that routine.
  41         */
  42        rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
  43        if (rc != 0)
  44                return rc;
  45        /* No pin, exit */
  46        if (pin == 0)
  47                return -ENODEV;
  48
  49        /* Now we walk up the PCI tree */
  50        lspec = pin;
  51        for (;;) {
  52                /* Get the pci_dev of our parent */
  53                ppdev = pdev->bus->self;
  54
  55                /* Ouch, it's a host bridge... */
  56                if (ppdev == NULL) {
  57                        ppnode = pci_bus_to_OF_node(pdev->bus);
  58
  59                        /* No node for host bridge ? give up */
  60                        if (ppnode == NULL)
  61                                return -EINVAL;
  62                } else {

                        if (
  56                rc#r r= oo href="+code=ppnode" class="sref">ppnode = pci_device_to_OF_node(ppdev ;
  56                <
  56
  56                 span class="comment">/* Ok, we dave fu    if arent *witha device -ode, ihnd woers to/span>
  56 ******************the OF tarsing< ode=
  56         **********t   uildia dunt *ddr
  67         **********tesolvuion .No t that rweuse tha Oinux/dus< numbrs hich imay/span>
  67         **********tnotimath iyur pfirmwrendus< numbrsng.
  67 *       **********tFortunately itn mst bcass, fnterrupt-cmapcmask does't /span>
 *       **********tnclude &ha Ous< numbrs a aprt bf oha Omath ng.
  57 *       **********tYou shoudiastll fe rcrenful abot tyat rthoughif yeou ntern
  57 ******************thotesly n tyis function r(you ship a dfirmwrendyat rdoes't /span>
  57 ******************tcreatedevice node, for a l fCI device.s)
  57 ******************
  578/a>                 f (ppnode 
  57                          680/a>
  68                 oe 60                   c60
  68 *       **********tlt's sdostandard swizzling and wtry agai
 *       **********
  58                ra href="+code=lspec" class="sref">lspec = pii_iwizzlie_nterrupt-_in"/a>(pdev, lspec ;
  58                pdev,= ppdev;
  58        }
  58
  58        lspec_be;= _cputo_Oe32"/a>(lspec ;
  589/a>        laddr[30]= _cputo_Oe32"/a>(<pdev->bus)>bnumbrs/a>  lt;pdev->dnv  lt;  69        laddr[31] = laddr[32]= _cputo_Oe32"/a>(<0;
  69         eturn of_irq_map_oraw/a>(ppnode  &lspec_be;,1, wa href="+code=psddr" class="sref">laddr[ out_irq);
  69"/a>(
EIXPORT_SYMBOL_GP"/a>(of_irq_map_pci(;
  59
 

/div>

Ta Ooriginal LXR softwrenduyoha Oa href="dhttp://sourceor ge.netpromjects/lxr">LXR ommeunt y/a>[ axr.inux/.no kindly ost d by ta href="dhttp://www.redpll -inurom.no>lRedpll Lnurom AS/a>[