aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile/kernel/pci_gx.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/tile/kernel/pci_gx.c')
-rw-r--r--arch/tile/kernel/pci_gx.c113
1 files changed, 58 insertions, 55 deletions
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index 1b996bb628f..27f7ab02113 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -40,22 +40,8 @@
40#include <arch/sim.h> 40#include <arch/sim.h>
41 41
42/* 42/*
43 * Initialization flow and process 43 * This file containes the routines to search for PCI buses,
44 * -------------------------------
45 *
46 * This files containes the routines to search for PCI buses,
47 * enumerate the buses, and configure any attached devices. 44 * enumerate the buses, and configure any attached devices.
48 *
49 * There are two entry points here:
50 * 1) tile_pci_init
51 * This sets up the pci_controller structs, and opens the
52 * FDs to the hypervisor. This is called from setup_arch() early
53 * in the boot process.
54 * 2) pcibios_init
55 * This probes the PCI bus(es) for any attached hardware. It's
56 * called by subsys_initcall. All of the real work is done by the
57 * generic Linux PCI layer.
58 *
59 */ 45 */
60 46
61#define DEBUG_PCI_CFG 0 47#define DEBUG_PCI_CFG 0
@@ -110,6 +96,21 @@ static struct pci_ops tile_cfg_ops;
110/* Mask of CPUs that should receive PCIe interrupts. */ 96/* Mask of CPUs that should receive PCIe interrupts. */
111static struct cpumask intr_cpus_map; 97static struct cpumask intr_cpus_map;
112 98
99/* PCI I/O space support is not implemented. */
100static struct resource pci_ioport_resource = {
101 .name = "PCI IO",
102 .start = 0,
103 .end = 0,
104 .flags = IORESOURCE_IO,
105};
106
107static struct resource pci_iomem_resource = {
108 .name = "PCI mem",
109 .start = TILE_PCI_MEM_START,
110 .end = TILE_PCI_MEM_END,
111 .flags = IORESOURCE_MEM,
112};
113
113/* 114/*
114 * We don't need to worry about the alignment of resources. 115 * We don't need to worry about the alignment of resources.
115 */ 116 */
@@ -334,8 +335,6 @@ free_irqs:
334} 335}
335 336
336/* 337/*
337 * First initialization entry point, called from setup_arch().
338 *
339 * Find valid controllers and fill in pci_controller structs for each 338 * Find valid controllers and fill in pci_controller structs for each
340 * of them. 339 * of them.
341 * 340 *
@@ -583,10 +582,7 @@ static int __devinit setup_pcie_rc_delay(char *str)
583early_param("pcie_rc_delay", setup_pcie_rc_delay); 582early_param("pcie_rc_delay", setup_pcie_rc_delay);
584 583
585/* 584/*
586 * Second PCI initialization entry point, called by subsys_initcall. 585 * PCI initialization entry point, called by subsys_initcall.
587 *
588 * The controllers have been set up by the time we get here, by a call to
589 * tile_pci_init.
590 */ 586 */
591int __init pcibios_init(void) 587int __init pcibios_init(void)
592{ 588{
@@ -594,15 +590,13 @@ int __init pcibios_init(void)
594 LIST_HEAD(resources); 590 LIST_HEAD(resources);
595 int i; 591 int i;
596 592
593 tile_pci_init();
594
597 if (num_rc_controllers == 0 && num_ep_controllers == 0) 595 if (num_rc_controllers == 0 && num_ep_controllers == 0)
598 return 0; 596 return 0;
599 597
600 pr_info("PCI: Probing PCI hardware\n");
601
602 /* 598 /*
603 * We loop over all the TRIO shims and set up the MMIO mappings. 599 * We loop over all the TRIO shims and set up the MMIO mappings.
604 * This step can't be done in tile_pci_init because the MM subsystem
605 * hasn't been initialized then.
606 */ 600 */
607 for (i = 0; i < TILEGX_NUM_TRIO; i++) { 601 for (i = 0; i < TILEGX_NUM_TRIO; i++) {
608 gxio_trio_context_t *context = &trio_contexts[i]; 602 gxio_trio_context_t *context = &trio_contexts[i];
@@ -645,9 +639,7 @@ int __init pcibios_init(void)
645 unsigned int class_code_revision; 639 unsigned int class_code_revision;
646 int trio_index; 640 int trio_index;
647 int mac; 641 int mac;
648#ifndef USE_SHARED_PCIE_CONFIG_REGION
649 int ret; 642 int ret;
650#endif
651 643
652 if (trio_context->fd < 0) 644 if (trio_context->fd < 0)
653 continue; 645 continue;
@@ -802,8 +794,6 @@ int __init pcibios_init(void)
802 pr_err("PCI: PCI CFG PIO alloc failure for mac %d " 794 pr_err("PCI: PCI CFG PIO alloc failure for mac %d "
803 "on TRIO %d, give up\n", mac, trio_index); 795 "on TRIO %d, give up\n", mac, trio_index);
804 796
805 /* TBD: cleanup ... */
806
807 continue; 797 continue;
808 } 798 }
809 799
@@ -819,8 +809,6 @@ int __init pcibios_init(void)
819 pr_err("PCI: PCI CFG PIO init failure for mac %d " 809 pr_err("PCI: PCI CFG PIO init failure for mac %d "
820 "on TRIO %d, give up\n", mac, trio_index); 810 "on TRIO %d, give up\n", mac, trio_index);
821 811
822 /* TBD: cleanup ... */
823
824 continue; 812 continue;
825 } 813 }
826 814
@@ -837,8 +825,6 @@ int __init pcibios_init(void)
837 pr_err("PCI: PIO map failure for mac %d on TRIO %d\n", 825 pr_err("PCI: PIO map failure for mac %d on TRIO %d\n",
838 mac, trio_index); 826 mac, trio_index);
839 827
840 /* TBD: cleanup ... */
841
842 continue; 828 continue;
843 } 829 }
844 830
@@ -852,7 +838,14 @@ int __init pcibios_init(void)
852 continue; 838 continue;
853 } 839 }
854 840
855 pci_add_resource(&resources, &iomem_resource); 841 /*
842 * The PCI memory resource is located above the PA space.
843 * The memory range for the PCI root bus should not overlap
844 * with the physical RAM
845 */
846 pci_add_resource_offset(&resources, &iomem_resource,
847 1ULL << CHIP_PA_WIDTH());
848
856 bus = pci_scan_root_bus(NULL, 0, controller->ops, 849 bus = pci_scan_root_bus(NULL, 0, controller->ops,
857 controller, &resources); 850 controller, &resources);
858 controller->root_bus = bus; 851 controller->root_bus = bus;
@@ -923,11 +916,6 @@ int __init pcibios_init(void)
923 } 916 }
924 917
925 /* 918 /*
926 * We always assign 32-bit PCI bus BAR ranges.
927 */
928 BUG_ON(bus_address_hi != 0);
929
930 /*
931 * Alloc a PIO region for PCI memory access for each RC port. 919 * Alloc a PIO region for PCI memory access for each RC port.
932 */ 920 */
933 ret = gxio_trio_alloc_pio_regions(trio_context, 1, 0, 0); 921 ret = gxio_trio_alloc_pio_regions(trio_context, 1, 0, 0);
@@ -936,8 +924,6 @@ int __init pcibios_init(void)
936 "give up\n", controller->trio_index, 924 "give up\n", controller->trio_index,
937 controller->mac); 925 controller->mac);
938 926
939 /* TBD: cleanup ... */
940
941 continue; 927 continue;
942 } 928 }
943 929
@@ -950,15 +936,13 @@ int __init pcibios_init(void)
950 ret = gxio_trio_init_pio_region_aux(trio_context, 936 ret = gxio_trio_init_pio_region_aux(trio_context,
951 controller->pio_mem_index, 937 controller->pio_mem_index,
952 controller->mac, 938 controller->mac,
953 bus_address_hi, 939 0,
954 0); 940 0);
955 if (ret < 0) { 941 if (ret < 0) {
956 pr_err("PCI: MEM PIO init failure on TRIO %d mac %d, " 942 pr_err("PCI: MEM PIO init failure on TRIO %d mac %d, "
957 "give up\n", controller->trio_index, 943 "give up\n", controller->trio_index,
958 controller->mac); 944 controller->mac);
959 945
960 /* TBD: cleanup ... */
961
962 continue; 946 continue;
963 } 947 }
964 948
@@ -980,8 +964,6 @@ int __init pcibios_init(void)
980 controller->trio_index, 964 controller->trio_index,
981 controller->mac, j); 965 controller->mac, j);
982 966
983 /* TBD: cleanup ... */
984
985 goto alloc_mem_map_failed; 967 goto alloc_mem_map_failed;
986 } 968 }
987 969
@@ -991,9 +973,13 @@ int __init pcibios_init(void)
991 * Initialize the Mem-Map and the I/O MMU so that all 973 * Initialize the Mem-Map and the I/O MMU so that all
992 * the physical memory can be accessed by the endpoint 974 * the physical memory can be accessed by the endpoint
993 * devices. The base bus address is set to the base CPA 975 * devices. The base bus address is set to the base CPA
994 * of this memory controller, so is the base VA. The 976 * of this memory controller plus an offset (see pci.h).
977 * The region's base VA is set to the base CPA. The
995 * I/O MMU table essentially translates the CPA to 978 * I/O MMU table essentially translates the CPA to
996 * the real PA. 979 * the real PA. Implicitly, for node 0, we create
980 * a separate Mem-Map region that serves as the inbound
981 * window for legacy 32-bit devices. This is a direct
982 * map of the low 4GB CPA space.
997 */ 983 */
998 ret = gxio_trio_init_memory_map_mmu_aux(trio_context, 984 ret = gxio_trio_init_memory_map_mmu_aux(trio_context,
999 controller->mem_maps[j], 985 controller->mem_maps[j],
@@ -1001,7 +987,8 @@ int __init pcibios_init(void)
1001 nr_pages << PAGE_SHIFT, 987 nr_pages << PAGE_SHIFT,
1002 trio_context->asid, 988 trio_context->asid,
1003 controller->mac, 989 controller->mac,
1004 start_pfn << PAGE_SHIFT, 990 (start_pfn << PAGE_SHIFT) +
991 TILE_PCI_MEM_MAP_BASE_OFFSET,
1005 j, 992 j,
1006 GXIO_TRIO_ORDER_MODE_UNORDERED); 993 GXIO_TRIO_ORDER_MODE_UNORDERED);
1007 if (ret < 0) { 994 if (ret < 0) {
@@ -1010,11 +997,8 @@ int __init pcibios_init(void)
1010 controller->trio_index, 997 controller->trio_index,
1011 controller->mac, j); 998 controller->mac, j);
1012 999
1013 /* TBD: cleanup ... */
1014
1015 goto alloc_mem_map_failed; 1000 goto alloc_mem_map_failed;
1016 } 1001 }
1017
1018 continue; 1002 continue;
1019 1003
1020alloc_mem_map_failed: 1004alloc_mem_map_failed:
@@ -1028,11 +1012,19 @@ alloc_mem_map_failed:
1028subsys_initcall(pcibios_init); 1012subsys_initcall(pcibios_init);
1029 1013
1030/* 1014/*
1031 * No bus fixups needed. 1015 * PCI scan code calls the arch specific pcibios_fixup_bus() each time it scans
1016 * a new bridge. Called after each bus is probed, but before its children are
1017 * examined.
1032 */ 1018 */
1033void __devinit pcibios_fixup_bus(struct pci_bus *bus) 1019void __devinit pcibios_fixup_bus(struct pci_bus *bus)
1034{ 1020{
1035 /* Nothing needs to be done. */ 1021 struct pci_dev *dev = bus->self;
1022
1023 if (!dev) {
1024 /* This is the root bus. */
1025 bus->resource[0] = &pci_ioport_resource;
1026 bus->resource[1] = &pci_iomem_resource;
1027 }
1036} 1028}
1037 1029
1038/* 1030/*
@@ -1069,6 +1061,17 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
1069 return pci_enable_resources(dev, mask); 1061 return pci_enable_resources(dev, mask);
1070} 1062}
1071 1063
1064/* Called for each device after PCI setup is done. */
1065static void __init
1066pcibios_fixup_final(struct pci_dev *pdev)
1067{
1068 set_dma_ops(&pdev->dev, gx_pci_dma_map_ops);
1069 set_dma_offset(&pdev->dev, TILE_PCI_MEM_MAP_BASE_OFFSET);
1070 pdev->dev.archdata.max_direct_dma_addr =
1071 TILE_PCI_MAX_DIRECT_DMA_ADDRESS;
1072}
1073DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_final);
1074
1072/* Map a PCI MMIO bus address into VA space. */ 1075/* Map a PCI MMIO bus address into VA space. */
1073void __iomem *ioremap(resource_size_t phys_addr, unsigned long size) 1076void __iomem *ioremap(resource_size_t phys_addr, unsigned long size)
1074{ 1077{
@@ -1127,7 +1130,7 @@ got_it:
1127 * We need to keep the PCI bus address's in-page offset in the VA. 1130 * We need to keep the PCI bus address's in-page offset in the VA.
1128 */ 1131 */
1129 return iorpc_ioremap(trio_fd, offset, size) + 1132 return iorpc_ioremap(trio_fd, offset, size) +
1130 (phys_addr & (PAGE_SIZE - 1)); 1133 (phys_addr & (PAGE_SIZE - 1));
1131} 1134}
1132EXPORT_SYMBOL(ioremap); 1135EXPORT_SYMBOL(ioremap);
1133 1136