0001
0002
0003
0004
0005
0006
0007
0008 #undef DEBUG
0009
0010 #include <linux/string.h>
0011 #include <linux/kernel.h>
0012 #include <linux/init.h>
0013 #include <linux/export.h>
0014 #include <linux/mod_devicetable.h>
0015 #include <linux/pci.h>
0016 #include <linux/of.h>
0017 #include <linux/of_device.h>
0018 #include <linux/of_platform.h>
0019 #include <linux/atomic.h>
0020
0021 #include <asm/errno.h>
0022 #include <asm/topology.h>
0023 #include <asm/pci-bridge.h>
0024 #include <asm/ppc-pci.h>
0025 #include <asm/eeh.h>
0026
0027 #ifdef CONFIG_PPC_OF_PLATFORM_PCI
0028
0029
0030
0031
0032
0033
0034
0035 static int of_pci_phb_probe(struct platform_device *dev)
0036 {
0037 struct pci_controller *phb;
0038
0039
0040 if (ppc_md.pci_setup_phb == NULL)
0041 return -ENODEV;
0042
0043 pr_info("Setting up PCI bus %pOF\n", dev->dev.of_node);
0044
0045
0046 phb = pcibios_alloc_controller(dev->dev.of_node);
0047 if (!phb)
0048 return -ENODEV;
0049
0050
0051 phb->parent = &dev->dev;
0052
0053
0054 if (ppc_md.pci_setup_phb(phb)) {
0055 pcibios_free_controller(phb);
0056 return -ENODEV;
0057 }
0058
0059
0060 pci_process_bridge_OF_ranges(phb, dev->dev.of_node, 0);
0061
0062
0063 pci_devs_phb_init_dynamic(phb);
0064
0065
0066 eeh_phb_pe_create(phb);
0067
0068
0069 pcibios_scan_phb(phb);
0070 if (phb->bus == NULL)
0071 return -ENXIO;
0072
0073
0074
0075
0076
0077 pcibios_claim_one_bus(phb->bus);
0078
0079
0080 pci_bus_add_devices(phb->bus);
0081
0082 return 0;
0083 }
0084
0085 static const struct of_device_id of_pci_phb_ids[] = {
0086 { .type = "pci", },
0087 { .type = "pcix", },
0088 { .type = "pcie", },
0089 { .type = "pciex", },
0090 { .type = "ht", },
0091 {}
0092 };
0093
0094 static struct platform_driver of_pci_phb_driver = {
0095 .probe = of_pci_phb_probe,
0096 .driver = {
0097 .name = "of-pci",
0098 .of_match_table = of_pci_phb_ids,
0099 },
0100 };
0101
0102 builtin_platform_driver(of_pci_phb_driver);
0103
0104 #endif