dmab2709.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*++
  2. Copyright (c) 2016 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. dmab2709.h
  5. Abstract:
  6. This header contains definitions for using the Broadcom 2709 DMA controller.
  7. Author:
  8. Chris Stevens 12-Feb-2016
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // --------------------------------------------------------------------- Macros
  15. //
  16. //
  17. // These macros convert a channel and register into the correct offset.
  18. //
  19. #define DMA_BCM2709_CHANNEL_REGISTER(_Channel, _Register) \
  20. (DmaBcm2709Channel0 + ((_Channel) * 0x100) + (_Register))
  21. //
  22. // ---------------------------------------------------------------- Definitions
  23. //
  24. #define UUID_DMA_BCM2709_CONTROLLER \
  25. {{0x383496c4, 0x4EEFDFD2, 0xBC4CAF1E, 0x00B83312}}
  26. //
  27. // Define the total number of DMA channels supported.
  28. //
  29. #define DMA_BCM2709_CHANNEL_COUNT 13
  30. //
  31. // Define the cut off for lite DMA channels.
  32. //
  33. #define DMA_BCM2709_LITE_CHANNEL_START 7
  34. //
  35. // Define the maximum transfer size for one control block, rounded down to the
  36. // nearest page boundary to prevent awkward remainders.
  37. //
  38. #define DMA_BCM2709_MAX_TRANSFER_SIZE 0x3FFFF000
  39. //
  40. // Define the maximum transfer size for one lite control block, rounded down to
  41. // the nearest page boundary to prevent awkward remainders.
  42. //
  43. #define DMA_BCM2709_MAX_LITE_TRANSFER_SIZE 0xF000
  44. //
  45. // Define the required byte alignment for control blocks.
  46. //
  47. #define DMA_BCM2709_CONTROL_BLOCK_ALIGNMENT 32
  48. //
  49. // Define the bits for the channel control and status register.
  50. //
  51. #define DMA_BCM2709_CHANNEL_STATUS_RESET (1 << 31)
  52. #define DMA_BCM2709_CHANNEL_STATUS_ABORT (1 << 30)
  53. #define DMA_BCM2709_CHANNEL_STATUS_DISABLE_DEBUG (1 << 29)
  54. #define DMA_BCM2709_CHANNEL_STATUS_WAIT_FOR_WRITES (1 << 28
  55. #define DMA_BCM2709_CHANNEL_STATUS_PANIC_PRIORITY_MASK (0xF << 20)
  56. #define DMA_BCM2709_CHANNEL_STATUS_PANIC_PRIORITY_SHIFT 20
  57. #define DMA_BCM2709_CHANNEL_STATUS_PRIORITY_MASK (0xF << 16)
  58. #define DMA_BCM2709_CHANNEL_STATUS_PRIORITY_SHIFT 16
  59. #define DMA_BCM2709_CHANNEL_STATUS_ERROR (1 << 8)
  60. #define DMA_BCM2709_CHANNEL_STATUS_WAITING_FOR_WRITES (1 << 6)
  61. #define DMA_BCM2709_CHANNEL_STATUS_DATA_REQUEST_PAUSED (1 << 5)
  62. #define DMA_BCM2709_CHANNEL_STATUS_PAUSED (1 << 4)
  63. #define DMA_BCM2709_CHANNEL_STATUS_DATA_REQUEST (1 << 3)
  64. #define DMA_BCM2709_CHANNEL_STATUS_INTERRUPT (1 << 2)
  65. #define DMA_BCM2709_CHANNEL_STATUS_END (1 << 1)
  66. #define DMA_BCM2709_CHANNEL_STATUS_ACTIVE (1 << 0)
  67. //
  68. // Define the bits for the control block transfer information register.
  69. //
  70. #define DMA_BCM2709_TRANSFER_INFORMATION_NO_WIDE_BURSTS (1 << 26)
  71. #define DMA_BCM2709_TRANSFER_INFORMATION_WAITS_MASK (0x1F << 21)
  72. #define DMA_BCM2709_TRANSFER_INFORMATION_WAITS_SHIFT 21
  73. #define DMA_BCM2709_TRANSFER_INFORMATION_PERIPHERAL_MAP_MASK (0x1F << 16)
  74. #define DMA_BCM2709_TRANSFER_INFORMATION_PERIPHERAL_MAP_SHIFT 16
  75. #define DMA_BCM2709_TRANSFER_INFORMATION_BURST_LENGTH_MASK (0xF << 12)
  76. #define DMA_BCM2709_TRANSFER_INFORMATION_BURST_LENGTH_SHIFT 12
  77. #define DMA_BCM2709_TRANSFER_INFORMATION_SOURCE_IGNORE (1 << 11)
  78. #define DMA_BCM2709_TRANSFER_INFORMATION_SOURCE_DATA_REQUEST (1 << 10)
  79. #define DMA_BCM2709_TRANSFER_INFORMATION_SOURCE_WIDTH_128 (1 << 9)
  80. #define DMA_BCM2709_TRANSFER_INFORMATION_SOURCE_WIDTH_32 (0 << 9)
  81. #define DMA_BCM2709_TRANSFER_INFORMATION_SOURCE_INCREMENT (1 << 8)
  82. #define DMA_BCM2709_TRANSFER_INFORMATION_DESTINATION_IGNORE (1 << 7)
  83. #define DMA_BCM2709_TRANSFER_INFORMATION_DESTINATION_DATA_REQUEST (1 << 6)
  84. #define DMA_BCM2709_TRANSFER_INFORMATION_DESTINATION_WIDTH_128 (1 << 5)
  85. #define DMA_BCM2709_TRANSFER_INFORMATION_DESTINATION_WIDTH_32 (0 << 5)
  86. #define DMA_BCM2709_TRANSFER_INFORMATION_DESTINATION_INCREMENT (1 << 4)
  87. #define DMA_BCM2709_TRANSFER_INFORMATION_WAIT_FOR_RESPONSE (1 << 3)
  88. #define DMA_BCM2709_TRANSFER_INFORMATION_2D_MODE (1 << 1)
  89. #define DMA_BCM2709_TRANSFER_INFORMATION_INTERRUPT_ENABLE (1 << 0)
  90. //
  91. // Define the bits for the control block transfer length register.
  92. //
  93. #define DMA_BCM2709_TRANSFER_LENGTH_2D_YLENGTH_MASK (0x3FFF << 16)
  94. #define DMA_BCM2709_TRANSFER_LENGTH_2D_YLENGTH_SHIFT 16
  95. #define DMA_BCM2709_TRANSFER_LENGTH_2D_XLENGTH_MASK (0xFFFF << 0)
  96. #define DMA_BCM2709_TRANSFER_LENGTH_2D_XLENGTH_SHIFT 0
  97. #define DMA_BCM2709_TRANSFER_LENGTH_XLENGTH_MASK (0x3FFFFFFF << 0)
  98. #define DMA_BCM2709_TRANSFER_LENGTH_XLENGTH_SHIFT 0
  99. //
  100. // Define the bits for the control block stride register.
  101. //
  102. #define DMA_BCM2709_STRIDE_DESTINATION_MASK (0xFFFF << 16)
  103. #define DMA_BCM2709_STRIDE_DESTINATION_SHIFT 16
  104. #define DMA_BCM2709_STRIDE_SOURCE_MASK (0xFFFF << 0)
  105. #define DMA_BCM2709_STRIDE_SOURCE_SHIFT 0
  106. //
  107. // Define the bits for the control block debug register.
  108. //
  109. #define DMA_BCM2709_DEBUG_LITE (1 << 28)
  110. #define DMA_BCM2709_DEBUG_VERSION_MASK (0x7 << 25)
  111. #define DMA_BCM2709_DEBUG_VERSION_SHIFT 25
  112. #define DMA_BCM2709_DEBUG_STATE_MASK (0x1FF << 16)
  113. #define DMA_BCM2709_DEBUG_STATE_SHIFT 16
  114. #define DMA_BCM2709_DEBUG_ID_MASK (0xFF << 8)
  115. #define DMA_BCM2709_DEBUG_ID_SHIFT 8
  116. #define DMA_BCM2709_DEBUG_OUTSTANDING_WRITES_MASK (0xF << 4)
  117. #define DMA_BCM2709_DEBUG_OUTSTANDING_WRITES_SHIFT 4
  118. #define DMA_BCM2709_DEBUG_READ_ERROR (1 << 2)
  119. #define DMA_BCM2709_DEBUG_FIFO_ERROR (1 << 1)
  120. #define DMA_BCM2709_DEBUG_READ_LAST_NOT_SET_ERROR (1 << 0)
  121. #define DMA_BCM2709_DEBUG_ERROR_MASK \
  122. (DMA_BCM2709_DEBUG_READ_ERROR | \
  123. DMA_BCM2709_DEBUG_FIFO_ERROR | \
  124. DMA_BCM2709_DEBUG_READ_LAST_NOT_SET_ERROR)
  125. //
  126. // Define the bits for the interrupt status regiter.
  127. //
  128. #define DMA_BCM2709_INTERRUPT_CHANNEL_15 (1 << 15)
  129. #define DMA_BCM2709_INTERRUPT_CHANNEL_14 (1 << 14)
  130. #define DMA_BCM2709_INTERRUPT_CHANNEL_13 (1 << 13)
  131. #define DMA_BCM2709_INTERRUPT_CHANNEL_12 (1 << 12)
  132. #define DMA_BCM2709_INTERRUPT_CHANNEL_11 (1 << 11)
  133. #define DMA_BCM2709_INTERRUPT_CHANNEL_10 (1 << 10)
  134. #define DMA_BCM2709_INTERRUPT_CHANNEL_9 (1 << 9)
  135. #define DMA_BCM2709_INTERRUPT_CHANNEL_8 (1 << 8)
  136. #define DMA_BCM2709_INTERRUPT_CHANNEL_7 (1 << 7)
  137. #define DMA_BCM2709_INTERRUPT_CHANNEL_6 (1 << 6)
  138. #define DMA_BCM2709_INTERRUPT_CHANNEL_5 (1 << 5)
  139. #define DMA_BCM2709_INTERRUPT_CHANNEL_4 (1 << 4)
  140. #define DMA_BCM2709_INTERRUPT_CHANNEL_3 (1 << 3)
  141. #define DMA_BCM2709_INTERRUPT_CHANNEL_2 (1 << 2)
  142. #define DMA_BCM2709_INTERRUPT_CHANNEL_1 (1 << 1)
  143. #define DMA_BCM2709_INTERRUPT_CHANNEL_0 (1 << 0)
  144. //
  145. // Define the bits for the enable register.
  146. //
  147. #define DMA_BCM2709_ENABLE_CHANNEL_15 (1 << 15)
  148. #define DMA_BCM2709_ENABLE_CHANNEL_14 (1 << 14)
  149. #define DMA_BCM2709_ENABLE_CHANNEL_13 (1 << 13)
  150. #define DMA_BCM2709_ENABLE_CHANNEL_12 (1 << 12)
  151. #define DMA_BCM2709_ENABLE_CHANNEL_11 (1 << 11)
  152. #define DMA_BCM2709_ENABLE_CHANNEL_10 (1 << 10)
  153. #define DMA_BCM2709_ENABLE_CHANNEL_9 (1 << 9)
  154. #define DMA_BCM2709_ENABLE_CHANNEL_8 (1 << 8)
  155. #define DMA_BCM2709_ENABLE_CHANNEL_7 (1 << 7)
  156. #define DMA_BCM2709_ENABLE_CHANNEL_6 (1 << 6)
  157. #define DMA_BCM2709_ENABLE_CHANNEL_5 (1 << 5)
  158. #define DMA_BCM2709_ENABLE_CHANNEL_4 (1 << 4)
  159. #define DMA_BCM2709_ENABLE_CHANNEL_3 (1 << 3)
  160. #define DMA_BCM2709_ENABLE_CHANNEL_2 (1 << 2)
  161. #define DMA_BCM2709_ENABLE_CHANNEL_1 (1 << 1)
  162. #define DMA_BCM2709_ENABLE_CHANNEL_0 (1 << 0)
  163. //
  164. // ------------------------------------------------------ Data Type Definitions
  165. //
  166. typedef enum _DMA_BCM27093_REGISTER {
  167. DmaBcm2709Channel0 = 0x000,
  168. DmaBcm2709Channel1 = 0x100,
  169. DmaBcm2709Channel2 = 0x200,
  170. DmaBcm2709Channel3 = 0x300,
  171. DmaBcm2709Channel4 = 0x400,
  172. DmaBcm2709Channel5 = 0x500,
  173. DmaBcm2709Channel6 = 0x600,
  174. DmaBcm2709Channel7 = 0x700,
  175. DmaBcm2709Channel8 = 0x800,
  176. DmaBcm2709Channel9 = 0x900,
  177. DmaBcm2709Channel10 = 0xA00,
  178. DmaBcm2709Channel11 = 0xB00,
  179. DmaBcm2709Channel12 = 0xC00,
  180. DmaBcm2709Channel13 = 0xD00,
  181. DmaBcm2709Channel14 = 0xE00,
  182. DmaBcm2709InterruptStatus = 0xFE0,
  183. DmaBcm2709Enable = 0xFF0
  184. } DMA_BCM27093_REGISTER, *PDMA_BCM27093_REGISTER;
  185. typedef enum _DMA_BCM2709_CHANNEL_REGISTER {
  186. DmaBcm2709ChannelStatus = 0x0,
  187. DmaBcm2709ChannelControlBlockAddress = 0x4,
  188. DmaBcm2709ChannelTransferInformation = 0x8,
  189. DmaBcm2709ChannelSourceAddress = 0xC,
  190. DmaBcm2709ChannelDestinationAddress = 0x10,
  191. DmaBcm2709ChannelTransferLength = 0x14,
  192. DmaBcm2709ChannelStride = 0x18,
  193. DmaBcm2709ChannelNextControlBlockAddress = 0x1C,
  194. DmaBcm2709ChannelDebug = 0x20
  195. } DMA_BCM2709_CHANNEL_REGISTER, *PDMA_BCM2709_CHANNEL_REGISTER;
  196. /*++
  197. Structure Description:
  198. This structure defines a DMA control block for the BCM2709 DMA controller.
  199. Members:
  200. TransferInformation - Stores a bitmask of transfer information.
  201. See DMA_BCM2709_TRANSFER_INFORMATION_* for definitions.
  202. SourceAddress - Stores the 32-bit source address for the DMA operation.
  203. DestinationAddress - Stores the 32-bit destination address for the DMA
  204. operation.
  205. TransferLength - Stores the number of bytes to transfer. In 2D mode this
  206. stores the how many transfers (Y) of a particular size (X) to complete.
  207. Stride - Stores the destination and source strides for 2D mode. The DMA
  208. engine will increment the source/destination by the stride after each
  209. of the Y transfers.
  210. NextAddress - Stores the address of the next control block to execute.
  211. Reserved - Stores 8 reserved bytes.
  212. --*/
  213. typedef struct _DMA_BCM2709_CONTROL_BLOCK {
  214. ULONG TransferInformation;
  215. ULONG SourceAddress;
  216. ULONG DestinationAddress;
  217. ULONG TransferLength;
  218. ULONG Stride;
  219. ULONG NextAddress;
  220. ULONG Reserved[2];
  221. } PACKED DMA_BCM2709_CONTROL_BLOCK, *PDMA_BCM2709_CONTROL_BLOCK;
  222. //
  223. // -------------------------------------------------------------------- Globals
  224. //
  225. //
  226. // -------------------------------------------------------- Function Prototypes
  227. //