aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze/pci/pci-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/microblaze/pci/pci-common.c')
-rw-r--r--arch/microblaze/pci/pci-common.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 53599067d2f9..041b1d86d75b 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -50,6 +50,11 @@ unsigned int pci_flags;
50 50
51static struct dma_map_ops *pci_dma_ops = &dma_direct_ops; 51static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
52 52
53unsigned long isa_io_base;
54unsigned long pci_dram_offset;
55static int pci_bus_count;
56
57
53void set_pci_dma_ops(struct dma_map_ops *dma_ops) 58void set_pci_dma_ops(struct dma_map_ops *dma_ops)
54{ 59{
55 pci_dma_ops = dma_ops; 60 pci_dma_ops = dma_ops;
@@ -1558,6 +1563,112 @@ void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
1558 (unsigned long)hose->io_base_virt - _IO_BASE); 1563 (unsigned long)hose->io_base_virt - _IO_BASE);
1559} 1564}
1560 1565
1566struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
1567{
1568 struct pci_controller *hose = bus->sysdata;
1569
1570 return of_node_get(hose->dn);
1571}
1572
1573static void __devinit pcibios_scan_phb(struct pci_controller *hose)
1574{
1575 struct pci_bus *bus;
1576 struct device_node *node = hose->dn;
1577 unsigned long io_offset;
1578 struct resource *res = &hose->io_resource;
1579
1580 pr_debug("PCI: Scanning PHB %s\n",
1581 node ? node->full_name : "<NO NAME>");
1582
1583 /* Create an empty bus for the toplevel */
1584 bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
1585 if (bus == NULL) {
1586 printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
1587 hose->global_number);
1588 return;
1589 }
1590 bus->secondary = hose->first_busno;
1591 hose->bus = bus;
1592
1593 /* Fixup IO space offset */
1594 io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
1595 res->start = (res->start + io_offset) & 0xffffffffu;
1596 res->end = (res->end + io_offset) & 0xffffffffu;
1597
1598 /* Wire up PHB bus resources */
1599 pcibios_setup_phb_resources(hose);
1600
1601 /* Scan children */
1602 hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
1603}
1604
1605static int __init pcibios_init(void)
1606{
1607 struct pci_controller *hose, *tmp;
1608 int next_busno = 0;
1609
1610 printk(KERN_INFO "PCI: Probing PCI hardware\n");
1611
1612 /* Scan all of the recorded PCI controllers. */
1613 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
1614 hose->last_busno = 0xff;
1615 pcibios_scan_phb(hose);
1616 printk(KERN_INFO "calling pci_bus_add_devices()\n");
1617 pci_bus_add_devices(hose->bus);
1618 if (next_busno <= hose->last_busno)
1619 next_busno = hose->last_busno + 1;
1620 }
1621 pci_bus_count = next_busno;
1622
1623 /* Call common code to handle resource allocation */
1624 pcibios_resource_survey();
1625
1626 return 0;
1627}
1628
1629subsys_initcall(pcibios_init);
1630
1631static struct pci_controller *pci_bus_to_hose(int bus)
1632{
1633 struct pci_controller *hose, *tmp;
1634
1635 list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
1636 if (bus >= hose->first_busno && bus <= hose->last_busno)
1637 return hose;
1638 return NULL;
1639}
1640
1641/* Provide information on locations of various I/O regions in physical
1642 * memory. Do this on a per-card basis so that we choose the right
1643 * root bridge.
1644 * Note that the returned IO or memory base is a physical address
1645 */
1646
1647long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn)
1648{
1649 struct pci_controller *hose;
1650 long result = -EOPNOTSUPP;
1651
1652 hose = pci_bus_to_hose(bus);
1653 if (!hose)
1654 return -ENODEV;
1655
1656 switch (which) {
1657 case IOBASE_BRIDGE_NUMBER:
1658 return (long)hose->first_busno;
1659 case IOBASE_MEMORY:
1660 return (long)hose->pci_mem_offset;
1661 case IOBASE_IO:
1662 return (long)hose->io_base_phys;
1663 case IOBASE_ISA_IO:
1664 return (long)isa_io_base;
1665 case IOBASE_ISA_MEM:
1666 return (long)isa_mem_base;
1667 }
1668
1669 return result;
1670}
1671
1561/* 1672/*
1562 * Null PCI config access functions, for the case when we can't 1673 * Null PCI config access functions, for the case when we can't
1563 * find a hose. 1674 * find a hose.
@@ -1626,3 +1737,4 @@ int early_find_capability(struct pci_controller *hose, int bus, int devfn,
1626{ 1737{
1627 return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap); 1738 return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap);
1628} 1739}
1740