pci.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _ASM_TILE_PCI_H
  15. #define _ASM_TILE_PCI_H
  16. #include <linux/pci.h>
  17. #include <linux/numa.h>
  18. #include <asm-generic/pci_iomap.h>
  19. #ifndef __tilegx__
  20. /*
  21. * Structure of a PCI controller (host bridge)
  22. */
  23. struct pci_controller {
  24. int index; /* PCI domain number */
  25. struct pci_bus *root_bus;
  26. int first_busno;
  27. int last_busno;
  28. int hv_cfg_fd[2]; /* config{0,1} fds for this PCIe controller */
  29. int hv_mem_fd; /* fd to Hypervisor for MMIO operations */
  30. struct pci_ops *ops;
  31. int irq_base; /* Base IRQ from the Hypervisor */
  32. int plx_gen1; /* flag for PLX Gen 1 configuration */
  33. /* Address ranges that are routed to this controller/bridge. */
  34. struct resource mem_resources[3];
  35. };
  36. /*
  37. * This flag tells if the platform is TILEmpower that needs
  38. * special configuration for the PLX switch chip.
  39. */
  40. extern int tile_plx_gen1;
  41. static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) {}
  42. #define TILE_NUM_PCIE 2
  43. #else
  44. #include <asm/page.h>
  45. #include <gxio/trio.h>
  46. /**
  47. * We reserve the hugepage-size address range at the top of the 64-bit address
  48. * space to serve as the PCI window, emulating the BAR0 space of an endpoint
  49. * device. This window is used by the chip-to-chip applications running on
  50. * the RC node. The reason for carving out this window is that Mem-Maps that
  51. * back up this window will not overlap with those that map the real physical
  52. * memory.
  53. */
  54. #define PCIE_HOST_BAR0_SIZE HPAGE_SIZE
  55. #define PCIE_HOST_BAR0_START HPAGE_MASK
  56. /**
  57. * The first PAGE_SIZE of the above "BAR" window is mapped to the
  58. * gxpci_host_regs structure.
  59. */
  60. #define PCIE_HOST_REGS_SIZE PAGE_SIZE
  61. /*
  62. * This is the PCI address where the Mem-Map interrupt regions start.
  63. * We use the 2nd to the last huge page of the 64-bit address space.
  64. * The last huge page is used for the rootcomplex "bar", for C2C purpose.
  65. */
  66. #define MEM_MAP_INTR_REGIONS_BASE (HPAGE_MASK - HPAGE_SIZE)
  67. /*
  68. * Each Mem-Map interrupt region occupies 4KB.
  69. */
  70. #define MEM_MAP_INTR_REGION_SIZE (1<< TRIO_MAP_MEM_LIM__ADDR_SHIFT)
  71. /*
  72. * Structure of a PCI controller (host bridge) on Gx.
  73. */
  74. struct pci_controller {
  75. /* Pointer back to the TRIO that this PCIe port is connected to. */
  76. gxio_trio_context_t *trio;
  77. int mac; /* PCIe mac index on the TRIO shim */
  78. int trio_index; /* Index of TRIO shim that contains the MAC. */
  79. int pio_mem_index; /* PIO region index for memory access */
  80. /*
  81. * Mem-Map regions for all the memory controllers so that Linux can
  82. * map all of its physical memory space to the PCI bus.
  83. */
  84. int mem_maps[MAX_NUMNODES];
  85. int index; /* PCI domain number */
  86. struct pci_bus *root_bus;
  87. int last_busno;
  88. struct pci_ops *ops;
  89. /* Table that maps the INTx numbers to Linux irq numbers. */
  90. int irq_intx_table[4];
  91. struct resource mem_space;
  92. /* Address ranges that are routed to this controller/bridge. */
  93. struct resource mem_resources[3];
  94. };
  95. extern struct pci_controller pci_controllers[TILEGX_NUM_TRIO * TILEGX_TRIO_PCIES];
  96. extern gxio_trio_context_t trio_contexts[TILEGX_NUM_TRIO];
  97. extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
  98. #endif /* __tilegx__ */
  99. /*
  100. * The hypervisor maps the entirety of CPA-space as bus addresses, so
  101. * bus addresses are physical addresses. The networking and block
  102. * device layers use this boolean for bounce buffer decisions.
  103. */
  104. #define PCI_DMA_BUS_IS_PHYS 1
  105. int __init tile_pci_init(void);
  106. int __init pcibios_init(void);
  107. void __devinit pcibios_fixup_bus(struct pci_bus *bus);
  108. #define pci_domain_nr(bus) (((struct pci_controller *)(bus)->sysdata)->index)
  109. /*
  110. * This decides whether to display the domain number in /proc.
  111. */
  112. static inline int pci_proc_domain(struct pci_bus *bus)
  113. {
  114. return 1;
  115. }
  116. /*
  117. * pcibios_assign_all_busses() tells whether or not the bus numbers
  118. * should be reassigned, in case the BIOS didn't do it correctly, or
  119. * in case we don't have a BIOS and we want to let Linux do it.
  120. */
  121. static inline int pcibios_assign_all_busses(void)
  122. {
  123. return 1;
  124. }
  125. #define PCIBIOS_MIN_MEM 0
  126. #define PCIBIOS_MIN_IO 0
  127. /* Use any cpu for PCI. */
  128. #define cpumask_of_pcibus(bus) cpu_online_mask
  129. /* implement the pci_ DMA API in terms of the generic device dma_ one */
  130. #include <asm-generic/pci-dma-compat.h>
  131. /* generic pci stuff */
  132. #include <asm-generic/pci.h>
  133. #endif /* _ASM_TILE_PCI_H */