altera_msgdmahw.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* Altera TSE SGDMA and MSGDMA Linux driver
  2. * Copyright (C) 2014 Altera Corporation. All rights reserved
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __ALTERA_MSGDMAHW_H__
  17. #define __ALTERA_MSGDMAHW_H__
  18. /* mSGDMA extended descriptor format
  19. */
  20. struct msgdma_extended_desc {
  21. u32 read_addr_lo; /* data buffer source address low bits */
  22. u32 write_addr_lo; /* data buffer destination address low bits */
  23. u32 len; /* the number of bytes to transfer
  24. * per descriptor
  25. */
  26. u32 burst_seq_num; /* bit 31:24 write burst
  27. * bit 23:16 read burst
  28. * bit 15:0 sequence number
  29. */
  30. u32 stride; /* bit 31:16 write stride
  31. * bit 15:0 read stride
  32. */
  33. u32 read_addr_hi; /* data buffer source address high bits */
  34. u32 write_addr_hi; /* data buffer destination address high bits */
  35. u32 control; /* characteristics of the transfer */
  36. };
  37. /* mSGDMA descriptor control field bit definitions
  38. */
  39. #define MSGDMA_DESC_CTL_SET_CH(x) ((x) & 0xff)
  40. #define MSGDMA_DESC_CTL_GEN_SOP BIT(8)
  41. #define MSGDMA_DESC_CTL_GEN_EOP BIT(9)
  42. #define MSGDMA_DESC_CTL_PARK_READS BIT(10)
  43. #define MSGDMA_DESC_CTL_PARK_WRITES BIT(11)
  44. #define MSGDMA_DESC_CTL_END_ON_EOP BIT(12)
  45. #define MSGDMA_DESC_CTL_END_ON_LEN BIT(13)
  46. #define MSGDMA_DESC_CTL_TR_COMP_IRQ BIT(14)
  47. #define MSGDMA_DESC_CTL_EARLY_IRQ BIT(15)
  48. #define MSGDMA_DESC_CTL_TR_ERR_IRQ (0xff << 16)
  49. #define MSGDMA_DESC_CTL_EARLY_DONE BIT(24)
  50. /* Writing ‘1’ to the ‘go’ bit commits the entire descriptor into the
  51. * descriptor FIFO(s)
  52. */
  53. #define MSGDMA_DESC_CTL_GO BIT(31)
  54. /* Tx buffer control flags
  55. */
  56. #define MSGDMA_DESC_CTL_TX_FIRST (MSGDMA_DESC_CTL_GEN_SOP | \
  57. MSGDMA_DESC_CTL_GO)
  58. #define MSGDMA_DESC_CTL_TX_MIDDLE (MSGDMA_DESC_CTL_GO)
  59. #define MSGDMA_DESC_CTL_TX_LAST (MSGDMA_DESC_CTL_GEN_EOP | \
  60. MSGDMA_DESC_CTL_TR_COMP_IRQ | \
  61. MSGDMA_DESC_CTL_GO)
  62. #define MSGDMA_DESC_CTL_TX_SINGLE (MSGDMA_DESC_CTL_GEN_SOP | \
  63. MSGDMA_DESC_CTL_GEN_EOP | \
  64. MSGDMA_DESC_CTL_TR_COMP_IRQ | \
  65. MSGDMA_DESC_CTL_GO)
  66. #define MSGDMA_DESC_CTL_RX_SINGLE (MSGDMA_DESC_CTL_END_ON_EOP | \
  67. MSGDMA_DESC_CTL_END_ON_LEN | \
  68. MSGDMA_DESC_CTL_TR_COMP_IRQ | \
  69. MSGDMA_DESC_CTL_EARLY_IRQ | \
  70. MSGDMA_DESC_CTL_TR_ERR_IRQ | \
  71. MSGDMA_DESC_CTL_GO)
  72. /* mSGDMA extended descriptor stride definitions
  73. */
  74. #define MSGDMA_DESC_TX_STRIDE (0x00010001)
  75. #define MSGDMA_DESC_RX_STRIDE (0x00010001)
  76. /* mSGDMA dispatcher control and status register map
  77. */
  78. struct msgdma_csr {
  79. u32 status; /* Read/Clear */
  80. u32 control; /* Read/Write */
  81. u32 rw_fill_level; /* bit 31:16 - write fill level
  82. * bit 15:0 - read fill level
  83. */
  84. u32 resp_fill_level; /* bit 15:0 */
  85. u32 rw_seq_num; /* bit 31:16 - write sequence number
  86. * bit 15:0 - read sequence number
  87. */
  88. u32 pad[3]; /* reserved */
  89. };
  90. /* mSGDMA CSR status register bit definitions
  91. */
  92. #define MSGDMA_CSR_STAT_BUSY BIT(0)
  93. #define MSGDMA_CSR_STAT_DESC_BUF_EMPTY BIT(1)
  94. #define MSGDMA_CSR_STAT_DESC_BUF_FULL BIT(2)
  95. #define MSGDMA_CSR_STAT_RESP_BUF_EMPTY BIT(3)
  96. #define MSGDMA_CSR_STAT_RESP_BUF_FULL BIT(4)
  97. #define MSGDMA_CSR_STAT_STOPPED BIT(5)
  98. #define MSGDMA_CSR_STAT_RESETTING BIT(6)
  99. #define MSGDMA_CSR_STAT_STOPPED_ON_ERR BIT(7)
  100. #define MSGDMA_CSR_STAT_STOPPED_ON_EARLY BIT(8)
  101. #define MSGDMA_CSR_STAT_IRQ BIT(9)
  102. #define MSGDMA_CSR_STAT_MASK 0x3FF
  103. #define MSGDMA_CSR_STAT_MASK_WITHOUT_IRQ 0x1FF
  104. #define MSGDMA_CSR_STAT_BUSY_GET(v) GET_BIT_VALUE(v, 0)
  105. #define MSGDMA_CSR_STAT_DESC_BUF_EMPTY_GET(v) GET_BIT_VALUE(v, 1)
  106. #define MSGDMA_CSR_STAT_DESC_BUF_FULL_GET(v) GET_BIT_VALUE(v, 2)
  107. #define MSGDMA_CSR_STAT_RESP_BUF_EMPTY_GET(v) GET_BIT_VALUE(v, 3)
  108. #define MSGDMA_CSR_STAT_RESP_BUF_FULL_GET(v) GET_BIT_VALUE(v, 4)
  109. #define MSGDMA_CSR_STAT_STOPPED_GET(v) GET_BIT_VALUE(v, 5)
  110. #define MSGDMA_CSR_STAT_RESETTING_GET(v) GET_BIT_VALUE(v, 6)
  111. #define MSGDMA_CSR_STAT_STOPPED_ON_ERR_GET(v) GET_BIT_VALUE(v, 7)
  112. #define MSGDMA_CSR_STAT_STOPPED_ON_EARLY_GET(v) GET_BIT_VALUE(v, 8)
  113. #define MSGDMA_CSR_STAT_IRQ_GET(v) GET_BIT_VALUE(v, 9)
  114. /* mSGDMA CSR control register bit definitions
  115. */
  116. #define MSGDMA_CSR_CTL_STOP BIT(0)
  117. #define MSGDMA_CSR_CTL_RESET BIT(1)
  118. #define MSGDMA_CSR_CTL_STOP_ON_ERR BIT(2)
  119. #define MSGDMA_CSR_CTL_STOP_ON_EARLY BIT(3)
  120. #define MSGDMA_CSR_CTL_GLOBAL_INTR BIT(4)
  121. #define MSGDMA_CSR_CTL_STOP_DESCS BIT(5)
  122. /* mSGDMA CSR fill level bits
  123. */
  124. #define MSGDMA_CSR_WR_FILL_LEVEL_GET(v) (((v) & 0xffff0000) >> 16)
  125. #define MSGDMA_CSR_RD_FILL_LEVEL_GET(v) ((v) & 0x0000ffff)
  126. #define MSGDMA_CSR_RESP_FILL_LEVEL_GET(v) ((v) & 0x0000ffff)
  127. /* mSGDMA response register map
  128. */
  129. struct msgdma_response {
  130. u32 bytes_transferred;
  131. u32 status;
  132. };
  133. #define msgdma_respoffs(a) (offsetof(struct msgdma_response, a))
  134. #define msgdma_csroffs(a) (offsetof(struct msgdma_csr, a))
  135. #define msgdma_descroffs(a) (offsetof(struct msgdma_extended_desc, a))
  136. /* mSGDMA response register bit definitions
  137. */
  138. #define MSGDMA_RESP_EARLY_TERM BIT(8)
  139. #define MSGDMA_RESP_ERR_MASK 0xFF
  140. #endif /* __ALTERA_MSGDMA_H__*/