zuma_pbb.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. #ifndef ZUMA_PBB_H
  2. #define ZUMA_PBB_H
  3. #define MAX_NUM_BUFFER_PER_RING 32
  4. #ifdef __BIG_ENDIAN
  5. #define cpu_bits _be_s_bits /* use with le32_to_cpu only */
  6. #define pci_bits _be_bits /* may contain swapped bytes,
  7. but dont need le32_to_cpu */
  8. #endif
  9. #ifdef __LITTLE_ENDIAN
  10. #define cpu_bits _le_bits
  11. #define pci_bits _le_bits
  12. #endif
  13. #define VENDOR_ID_ZUMA 0x1172
  14. #define DEVICE_ID_ZUMA_PBB 0x0004
  15. #define RXDBP(chan) (&sip->rx_desc[chan].base) /* ch*8 */
  16. #define RXDP(chan) (&sip->rx_desc[chan].current) /* ch*8 + 4 */
  17. #define TXDBP(chan) (&sip->tx_desc[chan].base) /* ch*8 + 64 */
  18. #define TXDP(chan) (&sip->tx_desc[chan].current) /* ch*8 + 68 */
  19. #define PBB_DMA_OWN_BIT 0x80000000
  20. #define PBB_DMA_LAST_BIT 0x40000000
  21. #define EOF_RX_FLAG 1 /* bit 0 */
  22. #define EOB_RX_FLAG 2 /* bit 1 */
  23. #define EOF_TX_FLAG 4 /* bit 2 */
  24. #define EOB_TX_FLAG 8 /* bit 3 */
  25. #define TX_MODE(m) (((m)&7) << 16)
  26. #define RX_DESC(i) (cs->rx_desc[i])
  27. #define TX_DESC(i) (cs->tx_desc[i])
  28. #define RX_CONTROL(i) (RX_DESC(i).control.word)
  29. #define RX_CONTROL_SIZE(i) (RX_DESC(i).control.rx.size)
  30. #define TX_CONTROL(i) (TX_DESC(i).control.word)
  31. #define RX_DATA_P(i) (&RX_DESC(i).ptr)
  32. #define TX_DATA_P(i) (&TX_DESC(i).ptr)
  33. typedef volatile unsigned char V8;
  34. typedef volatile unsigned short V16;
  35. typedef volatile unsigned int V32;
  36. /* RAM descriptor layout */
  37. typedef struct _tag_dma_descriptor {
  38. V32 ptr;
  39. union {
  40. struct {
  41. V32 owner:1;
  42. V32 last:1;
  43. V32 reserved0: 10;
  44. V32 tx_mode: 4;
  45. V32 reserved1: 5;
  46. V32 size: 11;
  47. } tx;
  48. struct {
  49. V32 owner:1;
  50. V32 last:1;
  51. V32 reserved0: 14;
  52. V32 reserved1: 5;
  53. V32 size: 11;
  54. } rx;
  55. V32 word;
  56. } control;
  57. } DMA_DESCRIPTOR;
  58. /*
  59. * NOTE: DO NOT USE structure to write non-word values... all registers
  60. * MUST be written 4 bytes at a time in SI version 0.
  61. * Non-word writes will result in "unaccessed" bytes written as zero.
  62. *
  63. * Byte reads are allowed.
  64. *
  65. * V32 pads are because the registers are spaced every 8 bytes (64 bits)
  66. *
  67. */
  68. /* NOTE!!! 4 dwords */
  69. typedef struct _tag_dma_descriptor_ring {
  70. DMA_DESCRIPTOR *base;
  71. V32 pad1; /* skip high dword */
  72. volatile DMA_DESCRIPTOR *current;
  73. V32 pad3; /* skip high dword */
  74. } DMA_DESCRIPTOR_RING;
  75. /* 1 dword */
  76. typedef union _tag_dma_generic {
  77. struct { /* byte 3 2 1 0 */
  78. V32 chan7:4; /* bits 31-28 */
  79. V32 chan6:4; /* bits 27-24 */
  80. V32 chan5:4; /* bits 23-20 */
  81. V32 chan4:4; /* bits 19-16 */
  82. V32 chan3:4; /* bits 15-12 */
  83. V32 chan2:4; /* bits 11-8 */
  84. V32 chan1:4; /* bits 7-4 */
  85. V32 chan0:4; /* bits 3-0 */
  86. } _be_s_bits;
  87. struct { /* byte 0 1 2 3 */
  88. V32 chan1:4; /* bits 7-4 */
  89. V32 chan0:4; /* bits 3-0 */
  90. V32 chan3:4; /* bits 15-12 */
  91. V32 chan2:4; /* bits 11-8 */
  92. V32 chan5:4; /* bits 23-20 */
  93. V32 chan4:4; /* bits 19-16 */
  94. V32 chan7:4; /* bits 31-28 */
  95. V32 chan6:4; /* bits 27-24 */
  96. } _be_bits;
  97. struct { /* byte 0 1 2 3 */
  98. V32 chan0:4; /* bits 0-3 */
  99. V32 chan1:4; /* bits 4-7 */
  100. V32 chan2:4; /* bits 8-11 */
  101. V32 chan3:4; /* bits 12-15 */
  102. V32 chan4:4; /* bits 16-19 */
  103. V32 chan5:4; /* bits 20-23 */
  104. V32 chan6:4; /* bits 24-27 */
  105. V32 chan7:4; /* bits 28-31 */
  106. } _le_bits;
  107. V8 byte[4];
  108. V32 word;
  109. } DMA_RXTX_ENABLE, DMA_RX_DELETE,
  110. DMA_INT_STATUS, DMA_INT_MASK,
  111. DMA_RX_LEVEL_STATUS, DMA_RX_LEVEL_INT_MASK;
  112. /* 1 dword */
  113. typedef union _tag_dma_rx_timer{
  114. struct {
  115. V32 res0:8; /* bits 32-24 */
  116. V32 res1:7; /* bits 23-17 */
  117. V32 enable:1; /* bit 16 */
  118. V32 value:16; /* bits 15-0 */
  119. } _be_s_bits;
  120. struct {
  121. /* crosses byte boundary. must use swap. */
  122. V32 s_value:16; /* bits 7-0,15-8 */
  123. V32 enable:1; /* bit 16 */
  124. V32 res1:7; /* bits 23-17 */
  125. V32 res0:8; /* bits 32-24 */
  126. } _be_bits;
  127. struct {
  128. V32 value:16; /* bits 0-15 */
  129. V32 enable:1; /* bit 16 */
  130. V32 res1:7; /* bits 17-23 */
  131. V32 res0:8; /* bits 24-32 */
  132. } _le_bits;
  133. V8 byte[4];
  134. V32 word;
  135. } DMA_RX_TIMER;
  136. /* NOTE!!!: 2 dwords */
  137. typedef struct _tag_dma_desc_level{
  138. union {
  139. struct {
  140. V32 res1:8; /* bits 31-24 */
  141. V32 res0:7; /* bits 23-17 */
  142. V32 write:1; /* bit 16 */
  143. V32 thresh:8; /* bits 15-8 */
  144. V32 level:8; /* bits 7-0 */
  145. } _be_s_bits;
  146. struct {
  147. V32 level:8; /* bits 7-0 */
  148. V32 thresh:8; /* bits 15-8 */
  149. V32 res0:7; /* bits 30-17 */
  150. V32 write:1; /* bit 16 */
  151. V32 res1:8; /* bits 31-24 */
  152. } _be_bits;
  153. struct {
  154. V32 level:8; /* bits 0-7 */
  155. V32 thresh:8; /* bits 8-15 */
  156. V32 write:1; /* bit 16 */
  157. V32 res0:7; /* bit 17-30 */
  158. V32 res1:8; /* bits 24-31 */
  159. } _le_bits;
  160. V8 byte[4];
  161. V32 word;
  162. } desc;
  163. V32 pad1;
  164. } DMA_DESC_LEVEL;
  165. typedef struct _tag_pbb_dma_reg_map {
  166. /* 0-15 (0x000-0x078) */
  167. DMA_DESCRIPTOR_RING rx_desc[8]; /* 4 dwords each, 128 bytes tot. */
  168. /* 16-31 (0x080-0x0f8) */
  169. DMA_DESCRIPTOR_RING tx_desc[8]; /* 4 dwords each, 128 bytes tot. */
  170. /* 32/33 (0x100/0x108) */
  171. V32 reserved_32;
  172. V32 pad_32;
  173. V32 reserved_33;
  174. V32 pad_33;
  175. /* 34 (0x110) */
  176. DMA_RXTX_ENABLE rxtx_enable;
  177. V32 pad_34;
  178. /* 35 (0x118) */
  179. DMA_RX_DELETE rx_delete;
  180. V32 pad_35;
  181. /* 36-38 (0x120-0x130) */
  182. DMA_INT_STATUS status;
  183. V32 pad_36;
  184. DMA_INT_STATUS last_status;
  185. V32 pad_37;
  186. DMA_INT_MASK int_mask;
  187. V32 pad_38;
  188. /* 39/40 (0x138/0x140) */
  189. union {
  190. /* NOTE!! 4 dwords */
  191. struct {
  192. V32 channel_3:8;
  193. V32 channel_2:8;
  194. V32 channel_1:8;
  195. V32 channel_0:8;
  196. V32 pad1;
  197. V32 channel_7:8;
  198. V32 channel_6:8;
  199. V32 channel_5:8;
  200. V32 channel_4:8;
  201. V32 pad3;
  202. } _be_s_bits;
  203. struct {
  204. V32 channel_0:8;
  205. V32 channel_1:8;
  206. V32 channel_2:8;
  207. V32 channel_3:8;
  208. V32 pad1;
  209. V32 channel_4:8;
  210. V32 channel_5:8;
  211. V32 channel_6:8;
  212. V32 channel_7:8;
  213. V32 pad3;
  214. } _be_bits, _le_bits;
  215. V8 byte[16];
  216. V32 word[4];
  217. } rx_size;
  218. /* 41/42 (0x148/0x150) */
  219. V32 reserved_41;
  220. V32 pad_41;
  221. V32 reserved_42;
  222. V32 pad_42;
  223. /* 43/44 (0x158/0x160) */
  224. DMA_RX_LEVEL_STATUS rx_level_status;
  225. V32 pad_43;
  226. DMA_RX_LEVEL_INT_MASK rx_level_int_mask;
  227. V32 pad_44;
  228. /* 45 (0x168) */
  229. DMA_RX_TIMER rx_timer;
  230. V32 pad_45;
  231. /* 46 (0x170) */
  232. V32 reserved_46;
  233. V32 pad_46;
  234. /* 47 (0x178) */
  235. V32 mbox_status;
  236. V32 pad_47;
  237. /* 48/49 (0x180/0x188) */
  238. V32 mbox_out;
  239. V32 pad_48;
  240. V32 mbox_in;
  241. V32 pad_49;
  242. /* 50 (0x190) */
  243. V32 config;
  244. V32 pad_50;
  245. /* 51/52 (0x198/0x1a0) */
  246. V32 c2a_ctr;
  247. V32 pad_51;
  248. V32 a2c_ctr;
  249. V32 pad_52;
  250. /* 53 (0x1a8) */
  251. union {
  252. struct {
  253. V32 rev_major:8; /* bits 31-24 */
  254. V32 rev_minor:8; /* bits 23-16 */
  255. V32 reserved:16; /* bits 15-0 */
  256. } _be_s_bits;
  257. struct {
  258. V32 s_reserved:16; /* bits 7-0, 15-8 */
  259. V32 rev_minor:8; /* bits 23-16 */
  260. V32 rev_major:8; /* bits 31-24 */
  261. } _be_bits;
  262. struct {
  263. V32 reserved:16; /* bits 0-15 */
  264. V32 rev_minor:8; /* bits 16-23 */
  265. V32 rev_major:8; /* bits 24-31 */
  266. } _le_bits;
  267. V8 byte[4];
  268. V32 word;
  269. } version;
  270. V32 pad_53;
  271. /* 54-59 (0x1b0-0x1d8) */
  272. V32 debug_54;
  273. V32 pad_54;
  274. V32 debug_55;
  275. V32 pad_55;
  276. V32 debug_56;
  277. V32 pad_56;
  278. V32 debug_57;
  279. V32 pad_57;
  280. V32 debug_58;
  281. V32 pad_58;
  282. V32 debug_59;
  283. V32 pad_59;
  284. /* 60 (0x1e0) */
  285. V32 timestamp;
  286. V32 pad_60;
  287. /* 61-63 (0x1e8-0x1f8) */
  288. V32 debug_61;
  289. V32 pad_61;
  290. V32 debug_62;
  291. V32 pad_62;
  292. V32 debug_63;
  293. V32 pad_63;
  294. /* 64-71 (0x200 - 0x238) */
  295. DMA_DESC_LEVEL rx_desc_level[8]; /* 2 dwords each, 32 bytes tot. */
  296. /* 72-98 (0x240 - 0x2f8) */
  297. /* reserved */
  298. /* 96-127 (0x300 - 0x3f8) */
  299. /* mirrors (0x100 - 0x1f8) */
  300. } PBB_DMA_REG_MAP;
  301. #endif /* ZUMA_PBB_H */