drv_trio_intf.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. * Copyright 2012 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. /**
  15. * Interface definitions for the trio driver.
  16. */
  17. #ifndef _SYS_HV_DRV_TRIO_INTF_H
  18. #define _SYS_HV_DRV_TRIO_INTF_H
  19. #include <arch/trio.h>
  20. /** The vendor ID for all Tilera processors. */
  21. #define TILERA_VENDOR_ID 0x1a41
  22. /** The device ID for the Gx36 processor. */
  23. #define TILERA_GX36_DEV_ID 0x0200
  24. /** Device ID for our internal bridge when running as RC. */
  25. #define TILERA_GX36_RC_DEV_ID 0x2000
  26. /** Maximum number of TRIO interfaces. */
  27. #define TILEGX_NUM_TRIO 2
  28. /** Gx36 has max 3 PCIe MACs per TRIO interface. */
  29. #define TILEGX_TRIO_PCIES 3
  30. /** Specify port properties for a PCIe MAC. */
  31. struct pcie_port_property
  32. {
  33. /** If true, the link can be configured in PCIe root complex mode. */
  34. uint8_t allow_rc: 1;
  35. /** If true, the link can be configured in PCIe endpoint mode. */
  36. uint8_t allow_ep: 1;
  37. /** If true, the link can be configured in StreamIO mode. */
  38. uint8_t allow_sio: 1;
  39. /** If true, the link is allowed to support 1-lane operation. Software
  40. * will not consider it an error if the link comes up as a x1 link. */
  41. uint8_t allow_x1: 1;
  42. /** If true, the link is allowed to support 2-lane operation. Software
  43. * will not consider it an error if the link comes up as a x2 link. */
  44. uint8_t allow_x2: 1;
  45. /** If true, the link is allowed to support 4-lane operation. Software
  46. * will not consider it an error if the link comes up as a x4 link. */
  47. uint8_t allow_x4: 1;
  48. /** If true, the link is allowed to support 8-lane operation. Software
  49. * will not consider it an error if the link comes up as a x8 link. */
  50. uint8_t allow_x8: 1;
  51. /** If true, this link is connected to a device which may or may not
  52. * be present. */
  53. uint8_t removable: 1;
  54. };
  55. /** Configurations can be issued to configure a char stream interrupt. */
  56. typedef enum pcie_stream_intr_config_sel_e
  57. {
  58. /** Interrupt configuration for memory map regions. */
  59. MEM_MAP_SEL,
  60. /** Interrupt configuration for push DMAs. */
  61. PUSH_DMA_SEL,
  62. /** Interrupt configuration for pull DMAs. */
  63. PULL_DMA_SEL,
  64. }
  65. pcie_stream_intr_config_sel_t;
  66. /** The mmap file offset (PA) of the TRIO config region. */
  67. #define HV_TRIO_CONFIG_OFFSET \
  68. ((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_CFG << \
  69. TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT)
  70. /** The maximum size of the TRIO config region. */
  71. #define HV_TRIO_CONFIG_SIZE \
  72. (1ULL << TRIO_CFG_REGION_ADDR__REGION_SHIFT)
  73. /** Size of the config region mapped into client. We can't use
  74. * TRIO_MMIO_ADDRESS_SPACE__OFFSET_WIDTH because it
  75. * will require the kernel to allocate 4GB VA space
  76. * from the VMALLOC region which has a total range
  77. * of 4GB.
  78. */
  79. #define HV_TRIO_CONFIG_IOREMAP_SIZE \
  80. ((uint64_t) 1 << TRIO_CFG_REGION_ADDR__PROT_SHIFT)
  81. /** The mmap file offset (PA) of a scatter queue region. */
  82. #define HV_TRIO_SQ_OFFSET(queue) \
  83. (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_MAP_SQ << \
  84. TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
  85. ((queue) << TRIO_MAP_SQ_REGION_ADDR__SQ_SEL_SHIFT))
  86. /** The maximum size of a scatter queue region. */
  87. #define HV_TRIO_SQ_SIZE \
  88. (1ULL << TRIO_MAP_SQ_REGION_ADDR__SQ_SEL_SHIFT)
  89. /** The "hardware MMIO region" of the first PIO region. */
  90. #define HV_TRIO_FIRST_PIO_REGION 8
  91. /** The mmap file offset (PA) of a PIO region. */
  92. #define HV_TRIO_PIO_OFFSET(region) \
  93. (((unsigned long long)(region) + HV_TRIO_FIRST_PIO_REGION) \
  94. << TRIO_PIO_REGIONS_ADDR__REGION_SHIFT)
  95. /** The maximum size of a PIO region. */
  96. #define HV_TRIO_PIO_SIZE (1ULL << TRIO_PIO_REGIONS_ADDR__ADDR_WIDTH)
  97. /** The mmap file offset (PA) of a push DMA region. */
  98. #define HV_TRIO_PUSH_DMA_OFFSET(ring) \
  99. (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_PUSH_DMA << \
  100. TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
  101. ((ring) << TRIO_PUSH_DMA_REGION_ADDR__RING_SEL_SHIFT))
  102. /** The mmap file offset (PA) of a pull DMA region. */
  103. #define HV_TRIO_PULL_DMA_OFFSET(ring) \
  104. (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_PULL_DMA << \
  105. TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
  106. ((ring) << TRIO_PULL_DMA_REGION_ADDR__RING_SEL_SHIFT))
  107. /** The maximum size of a DMA region. */
  108. #define HV_TRIO_DMA_REGION_SIZE \
  109. (1ULL << TRIO_PUSH_DMA_REGION_ADDR__RING_SEL_SHIFT)
  110. /** The mmap file offset (PA) of a Mem-Map interrupt region. */
  111. #define HV_TRIO_MEM_MAP_INTR_OFFSET(map) \
  112. (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_MAP_MEM << \
  113. TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
  114. ((map) << TRIO_MAP_MEM_REGION_ADDR__MAP_SEL_SHIFT))
  115. /** The maximum size of a Mem-Map interrupt region. */
  116. #define HV_TRIO_MEM_MAP_INTR_SIZE \
  117. (1ULL << TRIO_MAP_MEM_REGION_ADDR__MAP_SEL_SHIFT)
  118. /** A flag bit indicating a fixed resource allocation. */
  119. #define HV_TRIO_ALLOC_FIXED 0x01
  120. /** TRIO requires that all mappings have 4kB aligned start addresses. */
  121. #define HV_TRIO_PAGE_SHIFT 12
  122. /** TRIO requires that all mappings have 4kB aligned start addresses. */
  123. #define HV_TRIO_PAGE_SIZE (1ull << HV_TRIO_PAGE_SHIFT)
  124. /* Specify all PCIe port properties for a TRIO. */
  125. struct pcie_trio_ports_property
  126. {
  127. struct pcie_port_property ports[TILEGX_TRIO_PCIES];
  128. /** Set if this TRIO belongs to a Gx72 device. */
  129. uint8_t is_gx72;
  130. };
  131. /* Flags indicating traffic class. */
  132. #define HV_TRIO_FLAG_TC_SHIFT 4
  133. #define HV_TRIO_FLAG_TC_RMASK 0xf
  134. #define HV_TRIO_FLAG_TC(N) \
  135. ((((N) & HV_TRIO_FLAG_TC_RMASK) + 1) << HV_TRIO_FLAG_TC_SHIFT)
  136. /* Flags indicating virtual functions. */
  137. #define HV_TRIO_FLAG_VFUNC_SHIFT 8
  138. #define HV_TRIO_FLAG_VFUNC_RMASK 0xff
  139. #define HV_TRIO_FLAG_VFUNC(N) \
  140. ((((N) & HV_TRIO_FLAG_VFUNC_RMASK) + 1) << HV_TRIO_FLAG_VFUNC_SHIFT)
  141. /* Flag indicating an ordered PIO region. */
  142. #define HV_TRIO_PIO_FLAG_ORDERED (1 << 16)
  143. /* Flags indicating special types of PIO regions. */
  144. #define HV_TRIO_PIO_FLAG_SPACE_SHIFT 17
  145. #define HV_TRIO_PIO_FLAG_SPACE_MASK (0x3 << HV_TRIO_PIO_FLAG_SPACE_SHIFT)
  146. #define HV_TRIO_PIO_FLAG_CONFIG_SPACE (0x1 << HV_TRIO_PIO_FLAG_SPACE_SHIFT)
  147. #define HV_TRIO_PIO_FLAG_IO_SPACE (0x2 << HV_TRIO_PIO_FLAG_SPACE_SHIFT)
  148. #endif /* _SYS_HV_DRV_TRIO_INTF_H */