aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/pci-common.c
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2009-08-25 12:20:45 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-08-28 00:24:15 -0400
commit89c2dd62a389c5fed07c4b13c906c43214fc7491 (patch)
treef36a94c317f9731d303d0bed029fbd6b267930b7 /arch/powerpc/kernel/pci-common.c
parentfbe65447197789a3ccccc27755956f6a4c445089 (diff)
powerpc/pci: Pull ppc32 PCI features into common
Some of the PCI features we have in ppc32 we will need on ppc64 platforms in the future. These include support for: * ppc_md.pci_exclude_device * indirect config cycles * early config cycles We also simplified the logic in fake_pci_bus() to assume it will always get a valid pci_controller. Since all current callers seem to pass it one. Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Acked-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/pci-common.c')
-rw-r--r--arch/powerpc/kernel/pci-common.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 725ea9144e38..8f84a9a8428e 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1617,3 +1617,74 @@ void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
1617 (unsigned long)hose->io_base_virt - _IO_BASE); 1617 (unsigned long)hose->io_base_virt - _IO_BASE);
1618 1618
1619} 1619}
1620
1621/*
1622 * Null PCI config access functions, for the case when we can't
1623 * find a hose.
1624 */
1625#define NULL_PCI_OP(rw, size, type) \
1626static int \
1627null_##rw##_config_##size(struct pci_dev *dev, int offset, type val) \
1628{ \
1629 return PCIBIOS_DEVICE_NOT_FOUND; \
1630}
1631
1632static int
1633null_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
1634 int len, u32 *val)
1635{
1636 return PCIBIOS_DEVICE_NOT_FOUND;
1637}
1638
1639static int
1640null_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
1641 int len, u32 val)
1642{
1643 return PCIBIOS_DEVICE_NOT_FOUND;
1644}
1645
1646static struct pci_ops null_pci_ops =
1647{
1648 .read = null_read_config,
1649 .write = null_write_config,
1650};
1651
1652/*
1653 * These functions are used early on before PCI scanning is done
1654 * and all of the pci_dev and pci_bus structures have been created.
1655 */
1656static struct pci_bus *
1657fake_pci_bus(struct pci_controller *hose, int busnr)
1658{
1659 static struct pci_bus bus;
1660
1661 if (hose == 0) {
1662 printk(KERN_ERR "Can't find hose for PCI bus %d!\n", busnr);
1663 }
1664 bus.number = busnr;
1665 bus.sysdata = hose;
1666 bus.ops = hose? hose->ops: &null_pci_ops;
1667 return &bus;
1668}
1669
1670#define EARLY_PCI_OP(rw, size, type) \
1671int early_##rw##_config_##size(struct pci_controller *hose, int bus, \
1672 int devfn, int offset, type value) \
1673{ \
1674 return pci_bus_##rw##_config_##size(fake_pci_bus(hose, bus), \
1675 devfn, offset, value); \
1676}
1677
1678EARLY_PCI_OP(read, byte, u8 *)
1679EARLY_PCI_OP(read, word, u16 *)
1680EARLY_PCI_OP(read, dword, u32 *)
1681EARLY_PCI_OP(write, byte, u8)
1682EARLY_PCI_OP(write, word, u16)
1683EARLY_PCI_OP(write, dword, u32)
1684
1685extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap);
1686int early_find_capability(struct pci_controller *hose, int bus, int devfn,
1687 int cap)
1688{
1689 return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap);
1690}