drv_trio_intf.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. /** Reserved. */
  52. uint8_t reserved: 1;
  53. };
  54. /** Configurations can be issued to configure a char stream interrupt. */
  55. typedef enum pcie_stream_intr_config_sel_e
  56. {
  57. /** Interrupt configuration for memory map regions. */
  58. MEM_MAP_SEL,
  59. /** Interrupt configuration for push DMAs. */
  60. PUSH_DMA_SEL,
  61. /** Interrupt configuration for pull DMAs. */
  62. PULL_DMA_SEL,
  63. }
  64. pcie_stream_intr_config_sel_t;
  65. /** The mmap file offset (PA) of the TRIO config region. */
  66. #define HV_TRIO_CONFIG_OFFSET \
  67. ((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_CFG << \
  68. TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT)
  69. /** The maximum size of the TRIO config region. */
  70. #define HV_TRIO_CONFIG_SIZE \
  71. (1ULL << TRIO_CFG_REGION_ADDR__REGION_SHIFT)
  72. /** Size of the config region mapped into client. We can't use
  73. * TRIO_MMIO_ADDRESS_SPACE__OFFSET_WIDTH because it
  74. * will require the kernel to allocate 4GB VA space
  75. * from the VMALLOC region which has a total range
  76. * of 4GB.
  77. */
  78. #define HV_TRIO_CONFIG_IOREMAP_SIZE \
  79. ((uint64_t) 1 << TRIO_CFG_REGION_ADDR__PROT_SHIFT)
  80. /** The mmap file offset (PA) of a scatter queue region. */
  81. #define HV_TRIO_SQ_OFFSET(queue) \
  82. (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_MAP_SQ << \
  83. TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
  84. ((queue) << TRIO_MAP_SQ_REGION_ADDR__SQ_SEL_SHIFT))
  85. /** The maximum size of a scatter queue region. */
  86. #define HV_TRIO_SQ_SIZE \
  87. (1ULL << TRIO_MAP_SQ_REGION_ADDR__SQ_SEL_SHIFT)
  88. /** The "hardware MMIO region" of the first PIO region. */
  89. #define HV_TRIO_FIRST_PIO_REGION 8
  90. /** The mmap file offset (PA) of a PIO region. */
  91. #define HV_TRIO_PIO_OFFSET(region) \
  92. (((unsigned long long)(region) + HV_TRIO_FIRST_PIO_REGION) \
  93. << TRIO_PIO_REGIONS_ADDR__REGION_SHIFT)
  94. /** The maximum size of a PIO region. */
  95. #define HV_TRIO_PIO_SIZE (1ULL << TRIO_PIO_REGIONS_ADDR__ADDR_WIDTH)
  96. /** The mmap file offset (PA) of a push DMA region. */
  97. #define HV_TRIO_PUSH_DMA_OFFSET(ring) \
  98. (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_PUSH_DMA << \
  99. TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
  100. ((ring) << TRIO_PUSH_DMA_REGION_ADDR__RING_SEL_SHIFT))
  101. /** The mmap file offset (PA) of a pull DMA region. */
  102. #define HV_TRIO_PULL_DMA_OFFSET(ring) \
  103. (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_PULL_DMA << \
  104. TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
  105. ((ring) << TRIO_PULL_DMA_REGION_ADDR__RING_SEL_SHIFT))
  106. /** The maximum size of a DMA region. */
  107. #define HV_TRIO_DMA_REGION_SIZE \
  108. (1ULL << TRIO_PUSH_DMA_REGION_ADDR__RING_SEL_SHIFT)
  109. /** The mmap file offset (PA) of a Mem-Map interrupt region. */
  110. #define HV_TRIO_MEM_MAP_INTR_OFFSET(map) \
  111. (((unsigned long long)TRIO_MMIO_ADDRESS_SPACE__REGION_VAL_MAP_MEM << \
  112. TRIO_MMIO_ADDRESS_SPACE__REGION_SHIFT) | \
  113. ((map) << TRIO_MAP_MEM_REGION_ADDR__MAP_SEL_SHIFT))
  114. /** The maximum size of a Mem-Map interrupt region. */
  115. #define HV_TRIO_MEM_MAP_INTR_SIZE \
  116. (1ULL << TRIO_MAP_MEM_REGION_ADDR__MAP_SEL_SHIFT)
  117. /** A flag bit indicating a fixed resource allocation. */
  118. #define HV_TRIO_ALLOC_FIXED 0x01
  119. /** TRIO requires that all mappings have 4kB aligned start addresses. */
  120. #define HV_TRIO_PAGE_SHIFT 12
  121. /** TRIO requires that all mappings have 4kB aligned start addresses. */
  122. #define HV_TRIO_PAGE_SIZE (1ull << HV_TRIO_PAGE_SHIFT)
  123. /* Specify all PCIe port properties for a TRIO. */
  124. struct pcie_trio_ports_property
  125. {
  126. struct pcie_port_property ports[TILEGX_TRIO_PCIES];
  127. };
  128. /* Flags indicating traffic class. */
  129. #define HV_TRIO_FLAG_TC_SHIFT 4
  130. #define HV_TRIO_FLAG_TC_RMASK 0xf
  131. #define HV_TRIO_FLAG_TC(N) \
  132. ((((N) & HV_TRIO_FLAG_TC_RMASK) + 1) << HV_TRIO_FLAG_TC_SHIFT)
  133. /* Flags indicating virtual functions. */
  134. #define HV_TRIO_FLAG_VFUNC_SHIFT 8
  135. #define HV_TRIO_FLAG_VFUNC_RMASK 0xff
  136. #define HV_TRIO_FLAG_VFUNC(N) \
  137. ((((N) & HV_TRIO_FLAG_VFUNC_RMASK) + 1) << HV_TRIO_FLAG_VFUNC_SHIFT)
  138. /* Flag indicating an ordered PIO region. */
  139. #define HV_TRIO_PIO_FLAG_ORDERED (1 << 16)
  140. /* Flags indicating special types of PIO regions. */
  141. #define HV_TRIO_PIO_FLAG_SPACE_SHIFT 17
  142. #define HV_TRIO_PIO_FLAG_SPACE_MASK (0x3 << HV_TRIO_PIO_FLAG_SPACE_SHIFT)
  143. #define HV_TRIO_PIO_FLAG_CONFIG_SPACE (0x1 << HV_TRIO_PIO_FLAG_SPACE_SHIFT)
  144. #define HV_TRIO_PIO_FLAG_IO_SPACE (0x2 << HV_TRIO_PIO_FLAG_SPACE_SHIFT)
  145. #endif /* _SYS_HV_DRV_TRIO_INTF_H */