Merge branch 'next-sriov' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/power...
[linux-2.6-block.git] / arch / powerpc / platforms / powernv / pci.c
index 02badcef5ceac52ff6adcdc2b7eda40f068f3db9..bca2aeb6e4b6a4f179622c4786d79e7f65062069 100644 (file)
@@ -662,54 +662,6 @@ void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
        tbl->it_type = TCE_PCI;
 }
 
-static struct iommu_table *pnv_pci_setup_bml_iommu(struct pci_controller *hose)
-{
-       struct iommu_table *tbl;
-       const __be64 *basep, *swinvp;
-       const __be32 *sizep;
-
-       basep = of_get_property(hose->dn, "linux,tce-base", NULL);
-       sizep = of_get_property(hose->dn, "linux,tce-size", NULL);
-       if (basep == NULL || sizep == NULL) {
-               pr_err("PCI: %s has missing tce entries !\n",
-                      hose->dn->full_name);
-               return NULL;
-       }
-       tbl = kzalloc_node(sizeof(struct iommu_table), GFP_KERNEL, hose->node);
-       if (WARN_ON(!tbl))
-               return NULL;
-       pnv_pci_setup_iommu_table(tbl, __va(be64_to_cpup(basep)),
-                                 be32_to_cpup(sizep), 0, IOMMU_PAGE_SHIFT_4K);
-       iommu_init_table(tbl, hose->node);
-       iommu_register_group(tbl, pci_domain_nr(hose->bus), 0);
-
-       /* Deal with SW invalidated TCEs when needed (BML way) */
-       swinvp = of_get_property(hose->dn, "linux,tce-sw-invalidate-info",
-                                NULL);
-       if (swinvp) {
-               tbl->it_busno = be64_to_cpu(swinvp[1]);
-               tbl->it_index = (unsigned long)ioremap(be64_to_cpup(swinvp), 8);
-               tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE;
-       }
-       return tbl;
-}
-
-static void pnv_pci_dma_fallback_setup(struct pci_controller *hose,
-                                      struct pci_dev *pdev)
-{
-       struct device_node *np = pci_bus_to_OF_node(hose->bus);
-       struct pci_dn *pdn;
-
-       if (np == NULL)
-               return;
-       pdn = PCI_DN(np);
-       if (!pdn->iommu_table)
-               pdn->iommu_table = pnv_pci_setup_bml_iommu(hose);
-       if (!pdn->iommu_table)
-               return;
-       set_iommu_table_base_and_group(&pdev->dev, pdn->iommu_table);
-}
-
 static void pnv_pci_dma_dev_setup(struct pci_dev *pdev)
 {
        struct pci_controller *hose = pci_bus_to_host(pdev->bus);
@@ -733,13 +685,8 @@ static void pnv_pci_dma_dev_setup(struct pci_dev *pdev)
        }
 #endif /* CONFIG_PCI_IOV */
 
-       /* If we have no phb structure, try to setup a fallback based on
-        * the device-tree (RTAS PCI for example)
-        */
        if (phb && phb->dma_dev_setup)
                phb->dma_dev_setup(phb, pdev);
-       else
-               pnv_pci_dma_fallback_setup(hose, pdev);
 }
 
 int pnv_pci_dma_set_mask(struct pci_dev *pdev, u64 dma_mask)
@@ -785,44 +732,36 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_IBM, 0x3b9, pnv_p7ioc_rc_quirk);
 void __init pnv_pci_init(void)
 {
        struct device_node *np;
+       bool found_ioda = false;
 
        pci_add_flags(PCI_CAN_SKIP_ISA_ALIGN);
 
-       /* OPAL absent, try POPAL first then RTAS detection of PHBs */
-       if (!firmware_has_feature(FW_FEATURE_OPAL)) {
-#ifdef CONFIG_PPC_POWERNV_RTAS
-               init_pci_config_tokens();
-               find_and_init_phbs();
-#endif /* CONFIG_PPC_POWERNV_RTAS */
-       }
-       /* OPAL is here, do our normal stuff */
-       else {
-               int found_ioda = 0;
+       /* If we don't have OPAL, eg. in sim, just skip PCI probe */
+       if (!firmware_has_feature(FW_FEATURE_OPAL))
+               return;
 
-               /* Look for IODA IO-Hubs. We don't support mixing IODA
-                * and p5ioc2 due to the need to change some global
-                * probing flags
-                */
-               for_each_compatible_node(np, NULL, "ibm,ioda-hub") {
-                       pnv_pci_init_ioda_hub(np);
-                       found_ioda = 1;
-               }
+       /* Look for IODA IO-Hubs. We don't support mixing IODA
+        * and p5ioc2 due to the need to change some global
+        * probing flags
+        */
+       for_each_compatible_node(np, NULL, "ibm,ioda-hub") {
+               pnv_pci_init_ioda_hub(np);
+               found_ioda = true;
+       }
 
-               /* Look for p5ioc2 IO-Hubs */
-               if (!found_ioda)
-                       for_each_compatible_node(np, NULL, "ibm,p5ioc2")
-                               pnv_pci_init_p5ioc2_hub(np);
+       /* Look for p5ioc2 IO-Hubs */
+       if (!found_ioda)
+               for_each_compatible_node(np, NULL, "ibm,p5ioc2")
+                       pnv_pci_init_p5ioc2_hub(np);
 
-               /* Look for ioda2 built-in PHB3's */
-               for_each_compatible_node(np, NULL, "ibm,ioda2-phb")
-                       pnv_pci_init_ioda2_phb(np);
-       }
+       /* Look for ioda2 built-in PHB3's */
+       for_each_compatible_node(np, NULL, "ibm,ioda2-phb")
+               pnv_pci_init_ioda2_phb(np);
 
        /* Setup the linkage between OF nodes and PHBs */
        pci_devs_phb_init();
 
        /* Configure IOMMU DMA hooks */
-       ppc_md.pci_dma_dev_setup = pnv_pci_dma_dev_setup;
        ppc_md.tce_build = pnv_tce_build_vm;
        ppc_md.tce_free = pnv_tce_free_vm;
        ppc_md.tce_build_rm = pnv_tce_build_rm;
@@ -838,3 +777,7 @@ void __init pnv_pci_init(void)
 }
 
 machine_subsys_initcall_sync(powernv, tce_iommu_bus_notifier_init);
+
+struct pci_controller_ops pnv_pci_controller_ops = {
+       .dma_dev_setup = pnv_pci_dma_dev_setup,
+};