altera_msgdmahw.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Altera TSE SGDMA and MSGDMA Linux driver
  3. * Copyright (C) 2014 Altera Corporation. All rights reserved
  4. */
  5. #ifndef __ALTERA_MSGDMAHW_H__
  6. #define __ALTERA_MSGDMAHW_H__
  7. /* mSGDMA extended descriptor format
  8. */
  9. struct msgdma_extended_desc {
  10. u32 read_addr_lo; /* data buffer source address low bits */
  11. u32 write_addr_lo; /* data buffer destination address low bits */
  12. u32 len; /* the number of bytes to transfer
  13. * per descriptor
  14. */
  15. u32 burst_seq_num; /* bit 31:24 write burst
  16. * bit 23:16 read burst
  17. * bit 15:0 sequence number
  18. */
  19. u32 stride; /* bit 31:16 write stride
  20. * bit 15:0 read stride
  21. */
  22. u32 read_addr_hi; /* data buffer source address high bits */
  23. u32 write_addr_hi; /* data buffer destination address high bits */
  24. u32 control; /* characteristics of the transfer */
  25. };
  26. /* mSGDMA descriptor control field bit definitions
  27. */
  28. #define MSGDMA_DESC_CTL_SET_CH(x) ((x) & 0xff)
  29. #define MSGDMA_DESC_CTL_GEN_SOP BIT(8)
  30. #define MSGDMA_DESC_CTL_GEN_EOP BIT(9)
  31. #define MSGDMA_DESC_CTL_PARK_READS BIT(10)
  32. #define MSGDMA_DESC_CTL_PARK_WRITES BIT(11)
  33. #define MSGDMA_DESC_CTL_END_ON_EOP BIT(12)
  34. #define MSGDMA_DESC_CTL_END_ON_LEN BIT(13)
  35. #define MSGDMA_DESC_CTL_TR_COMP_IRQ BIT(14)
  36. #define MSGDMA_DESC_CTL_EARLY_IRQ BIT(15)
  37. #define MSGDMA_DESC_CTL_TR_ERR_IRQ (0xff << 16)
  38. #define MSGDMA_DESC_CTL_EARLY_DONE BIT(24)
  39. /* Writing ‘1’ to the ‘go’ bit commits the entire descriptor into the
  40. * descriptor FIFO(s)
  41. */
  42. #define MSGDMA_DESC_CTL_GO BIT(31)
  43. /* Tx buffer control flags
  44. */
  45. #define MSGDMA_DESC_CTL_TX_FIRST (MSGDMA_DESC_CTL_GEN_SOP | \
  46. MSGDMA_DESC_CTL_GO)
  47. #define MSGDMA_DESC_CTL_TX_MIDDLE (MSGDMA_DESC_CTL_GO)
  48. #define MSGDMA_DESC_CTL_TX_LAST (MSGDMA_DESC_CTL_GEN_EOP | \
  49. MSGDMA_DESC_CTL_TR_COMP_IRQ | \
  50. MSGDMA_DESC_CTL_GO)
  51. #define MSGDMA_DESC_CTL_TX_SINGLE (MSGDMA_DESC_CTL_GEN_SOP | \
  52. MSGDMA_DESC_CTL_GEN_EOP | \
  53. MSGDMA_DESC_CTL_TR_COMP_IRQ | \
  54. MSGDMA_DESC_CTL_GO)
  55. #define MSGDMA_DESC_CTL_RX_SINGLE (MSGDMA_DESC_CTL_END_ON_EOP | \
  56. MSGDMA_DESC_CTL_END_ON_LEN | \
  57. MSGDMA_DESC_CTL_TR_COMP_IRQ | \
  58. MSGDMA_DESC_CTL_EARLY_IRQ | \
  59. MSGDMA_DESC_CTL_TR_ERR_IRQ | \
  60. MSGDMA_DESC_CTL_GO)
  61. /* mSGDMA extended descriptor stride definitions
  62. */
  63. #define MSGDMA_DESC_TX_STRIDE (0x00010001)
  64. #define MSGDMA_DESC_RX_STRIDE (0x00010001)
  65. /* mSGDMA dispatcher control and status register map
  66. */
  67. struct msgdma_csr {
  68. u32 status; /* Read/Clear */
  69. u32 control; /* Read/Write */
  70. u32 rw_fill_level; /* bit 31:16 - write fill level
  71. * bit 15:0 - read fill level
  72. */
  73. u32 resp_fill_level; /* bit 15:0 */
  74. u32 rw_seq_num; /* bit 31:16 - write sequence number
  75. * bit 15:0 - read sequence number
  76. */
  77. u32 pad[3]; /* reserved */
  78. };
  79. /* mSGDMA CSR status register bit definitions
  80. */
  81. #define MSGDMA_CSR_STAT_BUSY BIT(0)
  82. #define MSGDMA_CSR_STAT_DESC_BUF_EMPTY BIT(1)
  83. #define MSGDMA_CSR_STAT_DESC_BUF_FULL BIT(2)
  84. #define MSGDMA_CSR_STAT_RESP_BUF_EMPTY BIT(3)
  85. #define MSGDMA_CSR_STAT_RESP_BUF_FULL BIT(4)
  86. #define MSGDMA_CSR_STAT_STOPPED BIT(5)
  87. #define MSGDMA_CSR_STAT_RESETTING BIT(6)
  88. #define MSGDMA_CSR_STAT_STOPPED_ON_ERR BIT(7)
  89. #define MSGDMA_CSR_STAT_STOPPED_ON_EARLY BIT(8)
  90. #define MSGDMA_CSR_STAT_IRQ BIT(9)
  91. #define MSGDMA_CSR_STAT_MASK 0x3FF
  92. #define MSGDMA_CSR_STAT_MASK_WITHOUT_IRQ 0x1FF
  93. #define MSGDMA_CSR_STAT_BUSY_GET(v) GET_BIT_VALUE(v, 0)
  94. #define MSGDMA_CSR_STAT_DESC_BUF_EMPTY_GET(v) GET_BIT_VALUE(v, 1)
  95. #define MSGDMA_CSR_STAT_DESC_BUF_FULL_GET(v) GET_BIT_VALUE(v, 2)
  96. #define MSGDMA_CSR_STAT_RESP_BUF_EMPTY_GET(v) GET_BIT_VALUE(v, 3)
  97. #define MSGDMA_CSR_STAT_RESP_BUF_FULL_GET(v) GET_BIT_VALUE(v, 4)
  98. #define MSGDMA_CSR_STAT_STOPPED_GET(v) GET_BIT_VALUE(v, 5)
  99. #define MSGDMA_CSR_STAT_RESETTING_GET(v) GET_BIT_VALUE(v, 6)
  100. #define MSGDMA_CSR_STAT_STOPPED_ON_ERR_GET(v) GET_BIT_VALUE(v, 7)
  101. #define MSGDMA_CSR_STAT_STOPPED_ON_EARLY_GET(v) GET_BIT_VALUE(v, 8)
  102. #define MSGDMA_CSR_STAT_IRQ_GET(v) GET_BIT_VALUE(v, 9)
  103. /* mSGDMA CSR control register bit definitions
  104. */
  105. #define MSGDMA_CSR_CTL_STOP BIT(0)
  106. #define MSGDMA_CSR_CTL_RESET BIT(1)
  107. #define MSGDMA_CSR_CTL_STOP_ON_ERR BIT(2)
  108. #define MSGDMA_CSR_CTL_STOP_ON_EARLY BIT(3)
  109. #define MSGDMA_CSR_CTL_GLOBAL_INTR BIT(4)
  110. #define MSGDMA_CSR_CTL_STOP_DESCS BIT(5)
  111. /* mSGDMA CSR fill level bits
  112. */
  113. #define MSGDMA_CSR_WR_FILL_LEVEL_GET(v) (((v) & 0xffff0000) >> 16)
  114. #define MSGDMA_CSR_RD_FILL_LEVEL_GET(v) ((v) & 0x0000ffff)
  115. #define MSGDMA_CSR_RESP_FILL_LEVEL_GET(v) ((v) & 0x0000ffff)
  116. /* mSGDMA response register map
  117. */
  118. struct msgdma_response {
  119. u32 bytes_transferred;
  120. u32 status;
  121. };
  122. #define msgdma_respoffs(a) (offsetof(struct msgdma_response, a))
  123. #define msgdma_csroffs(a) (offsetof(struct msgdma_csr, a))
  124. #define msgdma_descroffs(a) (offsetof(struct msgdma_extended_desc, a))
  125. /* mSGDMA response register bit definitions
  126. */
  127. #define MSGDMA_RESP_EARLY_TERM BIT(8)
  128. #define MSGDMA_RESP_ERR_MASK 0xFF
  129. #endif /* __ALTERA_MSGDMA_H__*/