aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2012-07-10 20:26:47 -0400
committerKumar Gala <galak@kernel.crashing.org>2012-07-11 08:49:33 -0400
commit07e4f8014f4d3404de7cdeaba3fe307cc6eecb79 (patch)
treec5b4abe15012b02154183fb4bc03ff54b693f00f /arch/powerpc/sysdev
parent478a4829d815865b919c1fa20f0f33543a2291fb (diff)
powerpc/fsl-pci: get PCI init out of board files
As an alternative incremental starting point to Jia Hongtao's patchset, get the FSL PCI init out of the board files, but do not yet convert to a platform driver. Rather than having each board supply a magic register offset for determining the "primary" bus, we look for which PCI host bridge contains an ISA node within its subtree. If there is no ISA node, normally that would mean there is no primary bus, but until certain bugs are fixed we arbitrarily designate a primary in this case. Conversion to a platform driver and related improvements can happen after this, as the ordering issues are sorted out. Signed-off-by: Scott Wood <scottwood@freescale.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/sysdev')
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c71
-rw-r--r--arch/powerpc/sysdev/fsl_pci.h8
2 files changed, 78 insertions, 1 deletions
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index edbf79465d50..a7b2a600d0a4 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * MPC83xx/85xx/86xx PCI/PCIE support routing. 2 * MPC83xx/85xx/86xx PCI/PCIE support routing.
3 * 3 *
4 * Copyright 2007-2011 Freescale Semiconductor, Inc. 4 * Copyright 2007-2012 Freescale Semiconductor, Inc.
5 * Copyright 2008-2009 MontaVista Software, Inc. 5 * Copyright 2008-2009 MontaVista Software, Inc.
6 * 6 *
7 * Initial author: Xianghua Xiao <x.xiao@freescale.com> 7 * Initial author: Xianghua Xiao <x.xiao@freescale.com>
@@ -807,3 +807,72 @@ u64 fsl_pci_immrbar_base(struct pci_controller *hose)
807 807
808 return 0; 808 return 0;
809} 809}
810
811#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
812static const struct of_device_id pci_ids[] = {
813 { .compatible = "fsl,mpc8540-pci", },
814 { .compatible = "fsl,mpc8548-pcie", },
815 { .compatible = "fsl,mpc8610-pci", },
816 { .compatible = "fsl,mpc8641-pcie", },
817 { .compatible = "fsl,p1022-pcie", },
818 { .compatible = "fsl,p1010-pcie", },
819 { .compatible = "fsl,p1023-pcie", },
820 { .compatible = "fsl,p4080-pcie", },
821 { .compatible = "fsl,qoriq-pcie-v2.3", },
822 { .compatible = "fsl,qoriq-pcie-v2.2", },
823 {},
824};
825
826struct device_node *fsl_pci_primary;
827
828void __devinit fsl_pci_init(void)
829{
830 struct device_node *node;
831 struct pci_controller *hose;
832 dma_addr_t max = 0xffffffff;
833
834 /* Callers can specify the primary bus using other means. */
835 if (!fsl_pci_primary) {
836 /* If a PCI host bridge contains an ISA node, it's primary. */
837 node = of_find_node_by_type(NULL, "isa");
838 while ((fsl_pci_primary = of_get_parent(node))) {
839 of_node_put(node);
840 node = fsl_pci_primary;
841
842 if (of_match_node(pci_ids, node))
843 break;
844 }
845 }
846
847 node = NULL;
848 for_each_node_by_type(node, "pci") {
849 if (of_match_node(pci_ids, node)) {
850 /*
851 * If there's no PCI host bridge with ISA, arbitrarily
852 * designate one as primary. This can go away once
853 * various bugs with primary-less systems are fixed.
854 */
855 if (!fsl_pci_primary)
856 fsl_pci_primary = node;
857
858 fsl_add_bridge(node, fsl_pci_primary == node);
859 hose = pci_find_hose_for_OF_device(node);
860 max = min(max, hose->dma_window_base_cur +
861 hose->dma_window_size);
862 }
863 }
864
865#ifdef CONFIG_SWIOTLB
866 /*
867 * if we couldn't map all of DRAM via the dma windows
868 * we need SWIOTLB to handle buffers located outside of
869 * dma capable memory region
870 */
871 if (memblock_end_of_DRAM() - 1 > max) {
872 ppc_swiotlb_enable = 1;
873 set_pci_dma_ops(&swiotlb_dma_ops);
874 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
875 }
876#endif
877}
878#endif
diff --git a/arch/powerpc/sysdev/fsl_pci.h b/arch/powerpc/sysdev/fsl_pci.h
index a39ed5cc2c5a..baa0fd18289f 100644
--- a/arch/powerpc/sysdev/fsl_pci.h
+++ b/arch/powerpc/sysdev/fsl_pci.h
@@ -93,5 +93,13 @@ extern void fsl_pcibios_fixup_bus(struct pci_bus *bus);
93extern int mpc83xx_add_bridge(struct device_node *dev); 93extern int mpc83xx_add_bridge(struct device_node *dev);
94u64 fsl_pci_immrbar_base(struct pci_controller *hose); 94u64 fsl_pci_immrbar_base(struct pci_controller *hose);
95 95
96extern struct device_node *fsl_pci_primary;
97
98#ifdef CONFIG_FSL_PCI
99void fsl_pci_init(void);
100#else
101static inline void fsl_pci_init(void) {}
102#endif
103
96#endif /* __POWERPC_FSL_PCI_H */ 104#endif /* __POWERPC_FSL_PCI_H */
97#endif /* __KERNEL__ */ 105#endif /* __KERNEL__ */