Commit 68feac87 authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Jesse Barnes

PCI: add pci_common_swizzle() for INTx swizzling

This patch adds pci_common_swizzle(), which swizzles INTx values all the
way up to a root bridge.

This common implementation can replace several architecture-specific
ones.  This should someday be combined with pci_get_interrupt_pin(),
but I left it separate for now to make reviewing easier.
Signed-off-by: default avatarBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent e8c331e9
...@@ -1421,6 +1421,26 @@ pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge) ...@@ -1421,6 +1421,26 @@ pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
return pin; return pin;
} }
/**
* pci_common_swizzle - swizzle INTx all the way to root bridge
* @dev: the PCI device
* @pinp: pointer to the INTx pin value (1=INTA, 2=INTB, 3=INTD, 4=INTD)
*
* Perform INTx swizzling for a device. This traverses through all PCI-to-PCI
* bridges all the way up to a PCI root bus.
*/
u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp)
{
u8 pin = *pinp;
while (dev->bus->self) {
pin = pci_swizzle_interrupt_pin(dev, pin);
dev = dev->bus->self;
}
*pinp = pin;
return PCI_SLOT(dev->devfn);
}
/** /**
* pci_release_region - Release a PCI bar * pci_release_region - Release a PCI bar
* @pdev: PCI device whose resources were previously reserved by pci_request_region * @pdev: PCI device whose resources were previously reserved by pci_request_region
......
...@@ -545,6 +545,7 @@ struct resource *pci_find_parent_resource(const struct pci_dev *dev, ...@@ -545,6 +545,7 @@ struct resource *pci_find_parent_resource(const struct pci_dev *dev,
struct resource *res); struct resource *res);
u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin); u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin);
int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp);
extern struct pci_dev *pci_dev_get(struct pci_dev *dev); extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
extern void pci_dev_put(struct pci_dev *dev); extern void pci_dev_put(struct pci_dev *dev);
extern void pci_remove_bus(struct pci_bus *b); extern void pci_remove_bus(struct pci_bus *b);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment