powerpc/pci: Merge ppc32 and ppc64 versions of phb_scan()
The two versions are doing almost exactly the same thing. No need to maintain them as separate files. This patch also has the side effect of making the PCI device tree scanning code available to 32 bit powerpc machines, but no board ports actually make use of this feature at this point. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Kumar Gala <galak@kernel.crashing.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:

committed by
Benjamin Herrenschmidt

parent
c5b20d3926
commit
0ed2c722c6
@@ -276,7 +276,7 @@ static int __devinit of_pci_phb_probe(struct of_device *dev,
|
||||
#endif /* CONFIG_EEH */
|
||||
|
||||
/* Scan the bus */
|
||||
scan_phb(phb);
|
||||
pcibios_scan_phb(phb, dev->node);
|
||||
if (phb->bus == NULL)
|
||||
return -ENXIO;
|
||||
|
||||
|
@@ -1688,3 +1688,52 @@ int early_find_capability(struct pci_controller *hose, int bus, int devfn,
|
||||
{
|
||||
return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap);
|
||||
}
|
||||
|
||||
/**
|
||||
* pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
|
||||
* @hose: Pointer to the PCI host controller instance structure
|
||||
* @sysdata: value to use for sysdata pointer. ppc32 and ppc64 differ here
|
||||
*
|
||||
* Note: the 'data' pointer is a temporary measure. As 32 and 64 bit
|
||||
* pci code gets merged, this parameter should become unnecessary because
|
||||
* both will use the same value.
|
||||
*/
|
||||
void __devinit pcibios_scan_phb(struct pci_controller *hose, void *sysdata)
|
||||
{
|
||||
struct pci_bus *bus;
|
||||
struct device_node *node = hose->dn;
|
||||
int mode;
|
||||
|
||||
pr_debug("PCI: Scanning PHB %s\n",
|
||||
node ? node->full_name : "<NO NAME>");
|
||||
|
||||
/* Create an empty bus for the toplevel */
|
||||
bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops,
|
||||
sysdata);
|
||||
if (bus == NULL) {
|
||||
pr_err("Failed to create bus for PCI domain %04x\n",
|
||||
hose->global_number);
|
||||
return;
|
||||
}
|
||||
bus->secondary = hose->first_busno;
|
||||
hose->bus = bus;
|
||||
|
||||
/* Get some IO space for the new PHB */
|
||||
pcibios_setup_phb_io_space(hose);
|
||||
|
||||
/* Wire up PHB bus resources */
|
||||
pcibios_setup_phb_resources(hose);
|
||||
|
||||
/* Get probe mode and perform scan */
|
||||
mode = PCI_PROBE_NORMAL;
|
||||
if (node && ppc_md.pci_probe_mode)
|
||||
mode = ppc_md.pci_probe_mode(bus);
|
||||
pr_debug(" probe mode: %d\n", mode);
|
||||
if (mode == PCI_PROBE_DEVTREE) {
|
||||
bus->subordinate = hose->last_busno;
|
||||
of_scan_bus(node, bus);
|
||||
}
|
||||
|
||||
if (mode == PCI_PROBE_NORMAL)
|
||||
hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
|
||||
}
|
||||
|
@@ -354,36 +354,15 @@ pci_create_OF_bus_map(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void __devinit pcibios_scan_phb(struct pci_controller *hose)
|
||||
void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose)
|
||||
{
|
||||
struct pci_bus *bus;
|
||||
struct device_node *node = hose->dn;
|
||||
unsigned long io_offset;
|
||||
struct resource *res = &hose->io_resource;
|
||||
|
||||
pr_debug("PCI: Scanning PHB %s\n",
|
||||
node ? node->full_name : "<NO NAME>");
|
||||
|
||||
/* Create an empty bus for the toplevel */
|
||||
bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
|
||||
if (bus == NULL) {
|
||||
printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
|
||||
hose->global_number);
|
||||
return;
|
||||
}
|
||||
bus->secondary = hose->first_busno;
|
||||
hose->bus = bus;
|
||||
|
||||
/* Fixup IO space offset */
|
||||
io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
|
||||
res->start = (res->start + io_offset) & 0xffffffffu;
|
||||
res->end = (res->end + io_offset) & 0xffffffffu;
|
||||
|
||||
/* Wire up PHB bus resources */
|
||||
pcibios_setup_phb_resources(hose);
|
||||
|
||||
/* Scan children */
|
||||
hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
|
||||
}
|
||||
|
||||
static int __init pcibios_init(void)
|
||||
@@ -401,7 +380,7 @@ static int __init pcibios_init(void)
|
||||
if (pci_assign_all_buses)
|
||||
hose->first_busno = next_busno;
|
||||
hose->last_busno = 0xff;
|
||||
pcibios_scan_phb(hose);
|
||||
pcibios_scan_phb(hose, hose);
|
||||
pci_bus_add_devices(hose->bus);
|
||||
if (pci_assign_all_buses || next_busno <= hose->last_busno)
|
||||
next_busno = hose->last_busno + pcibios_assign_bus_offset;
|
||||
|
@@ -43,45 +43,6 @@ unsigned long pci_probe_only = 1;
|
||||
unsigned long pci_io_base = ISA_IO_BASE;
|
||||
EXPORT_SYMBOL(pci_io_base);
|
||||
|
||||
void __devinit scan_phb(struct pci_controller *hose)
|
||||
{
|
||||
struct pci_bus *bus;
|
||||
struct device_node *node = hose->dn;
|
||||
int mode;
|
||||
|
||||
pr_debug("PCI: Scanning PHB %s\n",
|
||||
node ? node->full_name : "<NO NAME>");
|
||||
|
||||
/* Create an empty bus for the toplevel */
|
||||
bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, node);
|
||||
if (bus == NULL) {
|
||||
printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
|
||||
hose->global_number);
|
||||
return;
|
||||
}
|
||||
bus->secondary = hose->first_busno;
|
||||
hose->bus = bus;
|
||||
|
||||
/* Get some IO space for the new PHB */
|
||||
pcibios_map_io_space(bus);
|
||||
|
||||
/* Wire up PHB bus resources */
|
||||
pcibios_setup_phb_resources(hose);
|
||||
|
||||
/* Get probe mode and perform scan */
|
||||
mode = PCI_PROBE_NORMAL;
|
||||
if (node && ppc_md.pci_probe_mode)
|
||||
mode = ppc_md.pci_probe_mode(bus);
|
||||
pr_debug(" probe mode: %d\n", mode);
|
||||
if (mode == PCI_PROBE_DEVTREE) {
|
||||
bus->subordinate = hose->last_busno;
|
||||
of_scan_bus(node, bus);
|
||||
}
|
||||
|
||||
if (mode == PCI_PROBE_NORMAL)
|
||||
hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
|
||||
}
|
||||
|
||||
static int __init pcibios_init(void)
|
||||
{
|
||||
struct pci_controller *hose, *tmp;
|
||||
@@ -103,7 +64,7 @@ static int __init pcibios_init(void)
|
||||
|
||||
/* Scan all of the recorded PCI controllers. */
|
||||
list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
|
||||
scan_phb(hose);
|
||||
pcibios_scan_phb(hose, hose->dn);
|
||||
pci_bus_add_devices(hose->bus);
|
||||
}
|
||||
|
||||
@@ -237,6 +198,11 @@ int __devinit pcibios_map_io_space(struct pci_bus *bus)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pcibios_map_io_space);
|
||||
|
||||
void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose)
|
||||
{
|
||||
pcibios_map_io_space(hose->bus);
|
||||
}
|
||||
|
||||
#define IOBASE_BRIDGE_NUMBER 0
|
||||
#define IOBASE_MEMORY 1
|
||||
#define IOBASE_IO 2
|
||||
|
Reference in New Issue
Block a user