diff options
author | Kumar Gala <galak@kernel.crashing.org> | 2009-08-25 12:20:45 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-08-28 00:24:15 -0400 |
commit | 89c2dd62a389c5fed07c4b13c906c43214fc7491 (patch) | |
tree | f36a94c317f9731d303d0bed029fbd6b267930b7 /arch/powerpc/kernel/pci-common.c | |
parent | fbe65447197789a3ccccc27755956f6a4c445089 (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.c | 71 |
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) \ | ||
1626 | static int \ | ||
1627 | null_##rw##_config_##size(struct pci_dev *dev, int offset, type val) \ | ||
1628 | { \ | ||
1629 | return PCIBIOS_DEVICE_NOT_FOUND; \ | ||
1630 | } | ||
1631 | |||
1632 | static int | ||
1633 | null_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 | |||
1639 | static int | ||
1640 | null_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 | |||
1646 | static 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 | */ | ||
1656 | static struct pci_bus * | ||
1657 | fake_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) \ | ||
1671 | int 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 | |||
1678 | EARLY_PCI_OP(read, byte, u8 *) | ||
1679 | EARLY_PCI_OP(read, word, u16 *) | ||
1680 | EARLY_PCI_OP(read, dword, u32 *) | ||
1681 | EARLY_PCI_OP(write, byte, u8) | ||
1682 | EARLY_PCI_OP(write, word, u16) | ||
1683 | EARLY_PCI_OP(write, dword, u32) | ||
1684 | |||
1685 | extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); | ||
1686 | int 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 | } | ||