pasemi_dma.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. /*
  2. * Copyright (C) 2006-2008 PA Semi, Inc
  3. *
  4. * Hardware register layout and descriptor formats for the on-board
  5. * DMA engine on PA Semi PWRficient. Used by ethernet, function and security
  6. * drivers.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #ifndef ASM_PASEMI_DMA_H
  22. #define ASM_PASEMI_DMA_H
  23. /* status register layout in IOB region, at 0xfb800000 */
  24. struct pasdma_status {
  25. u64 rx_sta[64]; /* RX channel status */
  26. u64 tx_sta[20]; /* TX channel status */
  27. };
  28. /* All these registers live in the PCI configuration space for the DMA PCI
  29. * device. Use the normal PCI config access functions for them.
  30. */
  31. enum {
  32. PAS_DMA_CAP_TXCH = 0x44, /* Transmit Channel Info */
  33. PAS_DMA_CAP_RXCH = 0x48, /* Transmit Channel Info */
  34. PAS_DMA_CAP_IFI = 0x4c, /* Interface Info */
  35. PAS_DMA_COM_TXCMD = 0x100, /* Transmit Command Register */
  36. PAS_DMA_COM_TXSTA = 0x104, /* Transmit Status Register */
  37. PAS_DMA_COM_RXCMD = 0x108, /* Receive Command Register */
  38. PAS_DMA_COM_RXSTA = 0x10c, /* Receive Status Register */
  39. PAS_DMA_COM_CFG = 0x114, /* Common config reg */
  40. PAS_DMA_TXF_SFLG0 = 0x140, /* Set flags */
  41. PAS_DMA_TXF_SFLG1 = 0x144, /* Set flags */
  42. PAS_DMA_TXF_CFLG0 = 0x148, /* Set flags */
  43. PAS_DMA_TXF_CFLG1 = 0x14c, /* Set flags */
  44. };
  45. #define PAS_DMA_CAP_TXCH_TCHN_M 0x00ff0000 /* # of TX channels */
  46. #define PAS_DMA_CAP_TXCH_TCHN_S 16
  47. #define PAS_DMA_CAP_RXCH_RCHN_M 0x00ff0000 /* # of RX channels */
  48. #define PAS_DMA_CAP_RXCH_RCHN_S 16
  49. #define PAS_DMA_CAP_IFI_IOFF_M 0xff000000 /* Cfg reg for intf pointers */
  50. #define PAS_DMA_CAP_IFI_IOFF_S 24
  51. #define PAS_DMA_CAP_IFI_NIN_M 0x00ff0000 /* # of interfaces */
  52. #define PAS_DMA_CAP_IFI_NIN_S 16
  53. #define PAS_DMA_COM_TXCMD_EN 0x00000001 /* enable */
  54. #define PAS_DMA_COM_TXSTA_ACT 0x00000001 /* active */
  55. #define PAS_DMA_COM_RXCMD_EN 0x00000001 /* enable */
  56. #define PAS_DMA_COM_RXSTA_ACT 0x00000001 /* active */
  57. /* Per-interface and per-channel registers */
  58. #define _PAS_DMA_RXINT_STRIDE 0x20
  59. #define PAS_DMA_RXINT_RCMDSTA(i) (0x200+(i)*_PAS_DMA_RXINT_STRIDE)
  60. #define PAS_DMA_RXINT_RCMDSTA_EN 0x00000001
  61. #define PAS_DMA_RXINT_RCMDSTA_ST 0x00000002
  62. #define PAS_DMA_RXINT_RCMDSTA_MBT 0x00000008
  63. #define PAS_DMA_RXINT_RCMDSTA_MDR 0x00000010
  64. #define PAS_DMA_RXINT_RCMDSTA_MOO 0x00000020
  65. #define PAS_DMA_RXINT_RCMDSTA_MBP 0x00000040
  66. #define PAS_DMA_RXINT_RCMDSTA_BT 0x00000800
  67. #define PAS_DMA_RXINT_RCMDSTA_DR 0x00001000
  68. #define PAS_DMA_RXINT_RCMDSTA_OO 0x00002000
  69. #define PAS_DMA_RXINT_RCMDSTA_BP 0x00004000
  70. #define PAS_DMA_RXINT_RCMDSTA_TB 0x00008000
  71. #define PAS_DMA_RXINT_RCMDSTA_ACT 0x00010000
  72. #define PAS_DMA_RXINT_RCMDSTA_DROPS_M 0xfffe0000
  73. #define PAS_DMA_RXINT_RCMDSTA_DROPS_S 17
  74. #define PAS_DMA_RXINT_CFG(i) (0x204+(i)*_PAS_DMA_RXINT_STRIDE)
  75. #define PAS_DMA_RXINT_CFG_RBP 0x80000000
  76. #define PAS_DMA_RXINT_CFG_ITRR 0x40000000
  77. #define PAS_DMA_RXINT_CFG_DHL_M 0x07000000
  78. #define PAS_DMA_RXINT_CFG_DHL_S 24
  79. #define PAS_DMA_RXINT_CFG_DHL(x) (((x) << PAS_DMA_RXINT_CFG_DHL_S) & \
  80. PAS_DMA_RXINT_CFG_DHL_M)
  81. #define PAS_DMA_RXINT_CFG_ITR 0x00400000
  82. #define PAS_DMA_RXINT_CFG_LW 0x00200000
  83. #define PAS_DMA_RXINT_CFG_L2 0x00100000
  84. #define PAS_DMA_RXINT_CFG_HEN 0x00080000
  85. #define PAS_DMA_RXINT_CFG_WIF 0x00000002
  86. #define PAS_DMA_RXINT_CFG_WIL 0x00000001
  87. #define PAS_DMA_RXINT_INCR(i) (0x210+(i)*_PAS_DMA_RXINT_STRIDE)
  88. #define PAS_DMA_RXINT_INCR_INCR_M 0x0000ffff
  89. #define PAS_DMA_RXINT_INCR_INCR_S 0
  90. #define PAS_DMA_RXINT_INCR_INCR(x) ((x) & 0x0000ffff)
  91. #define PAS_DMA_RXINT_BASEL(i) (0x218+(i)*_PAS_DMA_RXINT_STRIDE)
  92. #define PAS_DMA_RXINT_BASEL_BRBL(x) ((x) & ~0x3f)
  93. #define PAS_DMA_RXINT_BASEU(i) (0x21c+(i)*_PAS_DMA_RXINT_STRIDE)
  94. #define PAS_DMA_RXINT_BASEU_BRBH(x) ((x) & 0xfff)
  95. #define PAS_DMA_RXINT_BASEU_SIZ_M 0x3fff0000 /* # of cache lines worth of buffer ring */
  96. #define PAS_DMA_RXINT_BASEU_SIZ_S 16 /* 0 = 16K */
  97. #define PAS_DMA_RXINT_BASEU_SIZ(x) (((x) << PAS_DMA_RXINT_BASEU_SIZ_S) & \
  98. PAS_DMA_RXINT_BASEU_SIZ_M)
  99. #define _PAS_DMA_TXCHAN_STRIDE 0x20 /* Size per channel */
  100. #define _PAS_DMA_TXCHAN_TCMDSTA 0x300 /* Command / Status */
  101. #define _PAS_DMA_TXCHAN_CFG 0x304 /* Configuration */
  102. #define _PAS_DMA_TXCHAN_DSCRBU 0x308 /* Descriptor BU Allocation */
  103. #define _PAS_DMA_TXCHAN_INCR 0x310 /* Descriptor increment */
  104. #define _PAS_DMA_TXCHAN_CNT 0x314 /* Descriptor count/offset */
  105. #define _PAS_DMA_TXCHAN_BASEL 0x318 /* Descriptor ring base (low) */
  106. #define _PAS_DMA_TXCHAN_BASEU 0x31c /* (high) */
  107. #define PAS_DMA_TXCHAN_TCMDSTA(c) (0x300+(c)*_PAS_DMA_TXCHAN_STRIDE)
  108. #define PAS_DMA_TXCHAN_TCMDSTA_EN 0x00000001 /* Enabled */
  109. #define PAS_DMA_TXCHAN_TCMDSTA_ST 0x00000002 /* Stop interface */
  110. #define PAS_DMA_TXCHAN_TCMDSTA_ACT 0x00010000 /* Active */
  111. #define PAS_DMA_TXCHAN_TCMDSTA_SZ 0x00000800
  112. #define PAS_DMA_TXCHAN_TCMDSTA_DB 0x00000400
  113. #define PAS_DMA_TXCHAN_TCMDSTA_DE 0x00000200
  114. #define PAS_DMA_TXCHAN_TCMDSTA_DA 0x00000100
  115. #define PAS_DMA_TXCHAN_CFG(c) (0x304+(c)*_PAS_DMA_TXCHAN_STRIDE)
  116. #define PAS_DMA_TXCHAN_CFG_TY_IFACE 0x00000000 /* Type = interface */
  117. #define PAS_DMA_TXCHAN_CFG_TY_COPY 0x00000001 /* Type = copy only */
  118. #define PAS_DMA_TXCHAN_CFG_TY_FUNC 0x00000002 /* Type = function */
  119. #define PAS_DMA_TXCHAN_CFG_TY_XOR 0x00000003 /* Type = xor only */
  120. #define PAS_DMA_TXCHAN_CFG_TATTR_M 0x0000003c
  121. #define PAS_DMA_TXCHAN_CFG_TATTR_S 2
  122. #define PAS_DMA_TXCHAN_CFG_TATTR(x) (((x) << PAS_DMA_TXCHAN_CFG_TATTR_S) & \
  123. PAS_DMA_TXCHAN_CFG_TATTR_M)
  124. #define PAS_DMA_TXCHAN_CFG_LPDQ 0x00000800
  125. #define PAS_DMA_TXCHAN_CFG_LPSQ 0x00000400
  126. #define PAS_DMA_TXCHAN_CFG_WT_M 0x000003c0
  127. #define PAS_DMA_TXCHAN_CFG_WT_S 6
  128. #define PAS_DMA_TXCHAN_CFG_WT(x) (((x) << PAS_DMA_TXCHAN_CFG_WT_S) & \
  129. PAS_DMA_TXCHAN_CFG_WT_M)
  130. #define PAS_DMA_TXCHAN_CFG_TRD 0x00010000 /* translate data */
  131. #define PAS_DMA_TXCHAN_CFG_TRR 0x00008000 /* translate rings */
  132. #define PAS_DMA_TXCHAN_CFG_UP 0x00004000 /* update tx descr when sent */
  133. #define PAS_DMA_TXCHAN_CFG_CL 0x00002000 /* Clean last line */
  134. #define PAS_DMA_TXCHAN_CFG_CF 0x00001000 /* Clean first line */
  135. #define PAS_DMA_TXCHAN_INCR(c) (0x310+(c)*_PAS_DMA_TXCHAN_STRIDE)
  136. #define PAS_DMA_TXCHAN_BASEL(c) (0x318+(c)*_PAS_DMA_TXCHAN_STRIDE)
  137. #define PAS_DMA_TXCHAN_BASEL_BRBL_M 0xffffffc0
  138. #define PAS_DMA_TXCHAN_BASEL_BRBL_S 0
  139. #define PAS_DMA_TXCHAN_BASEL_BRBL(x) (((x) << PAS_DMA_TXCHAN_BASEL_BRBL_S) & \
  140. PAS_DMA_TXCHAN_BASEL_BRBL_M)
  141. #define PAS_DMA_TXCHAN_BASEU(c) (0x31c+(c)*_PAS_DMA_TXCHAN_STRIDE)
  142. #define PAS_DMA_TXCHAN_BASEU_BRBH_M 0x00000fff
  143. #define PAS_DMA_TXCHAN_BASEU_BRBH_S 0
  144. #define PAS_DMA_TXCHAN_BASEU_BRBH(x) (((x) << PAS_DMA_TXCHAN_BASEU_BRBH_S) & \
  145. PAS_DMA_TXCHAN_BASEU_BRBH_M)
  146. /* # of cache lines worth of buffer ring */
  147. #define PAS_DMA_TXCHAN_BASEU_SIZ_M 0x3fff0000
  148. #define PAS_DMA_TXCHAN_BASEU_SIZ_S 16 /* 0 = 16K */
  149. #define PAS_DMA_TXCHAN_BASEU_SIZ(x) (((x) << PAS_DMA_TXCHAN_BASEU_SIZ_S) & \
  150. PAS_DMA_TXCHAN_BASEU_SIZ_M)
  151. #define _PAS_DMA_RXCHAN_STRIDE 0x20 /* Size per channel */
  152. #define _PAS_DMA_RXCHAN_CCMDSTA 0x800 /* Command / Status */
  153. #define _PAS_DMA_RXCHAN_CFG 0x804 /* Configuration */
  154. #define _PAS_DMA_RXCHAN_INCR 0x810 /* Descriptor increment */
  155. #define _PAS_DMA_RXCHAN_CNT 0x814 /* Descriptor count/offset */
  156. #define _PAS_DMA_RXCHAN_BASEL 0x818 /* Descriptor ring base (low) */
  157. #define _PAS_DMA_RXCHAN_BASEU 0x81c /* (high) */
  158. #define PAS_DMA_RXCHAN_CCMDSTA(c) (0x800+(c)*_PAS_DMA_RXCHAN_STRIDE)
  159. #define PAS_DMA_RXCHAN_CCMDSTA_EN 0x00000001 /* Enabled */
  160. #define PAS_DMA_RXCHAN_CCMDSTA_ST 0x00000002 /* Stop interface */
  161. #define PAS_DMA_RXCHAN_CCMDSTA_ACT 0x00010000 /* Active */
  162. #define PAS_DMA_RXCHAN_CCMDSTA_DU 0x00020000
  163. #define PAS_DMA_RXCHAN_CCMDSTA_OD 0x00002000
  164. #define PAS_DMA_RXCHAN_CCMDSTA_FD 0x00001000
  165. #define PAS_DMA_RXCHAN_CCMDSTA_DT 0x00000800
  166. #define PAS_DMA_RXCHAN_CFG(c) (0x804+(c)*_PAS_DMA_RXCHAN_STRIDE)
  167. #define PAS_DMA_RXCHAN_CFG_CTR 0x00000400
  168. #define PAS_DMA_RXCHAN_CFG_HBU_M 0x00000380
  169. #define PAS_DMA_RXCHAN_CFG_HBU_S 7
  170. #define PAS_DMA_RXCHAN_CFG_HBU(x) (((x) << PAS_DMA_RXCHAN_CFG_HBU_S) & \
  171. PAS_DMA_RXCHAN_CFG_HBU_M)
  172. #define PAS_DMA_RXCHAN_INCR(c) (0x810+(c)*_PAS_DMA_RXCHAN_STRIDE)
  173. #define PAS_DMA_RXCHAN_BASEL(c) (0x818+(c)*_PAS_DMA_RXCHAN_STRIDE)
  174. #define PAS_DMA_RXCHAN_BASEL_BRBL_M 0xffffffc0
  175. #define PAS_DMA_RXCHAN_BASEL_BRBL_S 0
  176. #define PAS_DMA_RXCHAN_BASEL_BRBL(x) (((x) << PAS_DMA_RXCHAN_BASEL_BRBL_S) & \
  177. PAS_DMA_RXCHAN_BASEL_BRBL_M)
  178. #define PAS_DMA_RXCHAN_BASEU(c) (0x81c+(c)*_PAS_DMA_RXCHAN_STRIDE)
  179. #define PAS_DMA_RXCHAN_BASEU_BRBH_M 0x00000fff
  180. #define PAS_DMA_RXCHAN_BASEU_BRBH_S 0
  181. #define PAS_DMA_RXCHAN_BASEU_BRBH(x) (((x) << PAS_DMA_RXCHAN_BASEU_BRBH_S) & \
  182. PAS_DMA_RXCHAN_BASEU_BRBH_M)
  183. /* # of cache lines worth of buffer ring */
  184. #define PAS_DMA_RXCHAN_BASEU_SIZ_M 0x3fff0000
  185. #define PAS_DMA_RXCHAN_BASEU_SIZ_S 16 /* 0 = 16K */
  186. #define PAS_DMA_RXCHAN_BASEU_SIZ(x) (((x) << PAS_DMA_RXCHAN_BASEU_SIZ_S) & \
  187. PAS_DMA_RXCHAN_BASEU_SIZ_M)
  188. #define PAS_STATUS_PCNT_M 0x000000000000ffffull
  189. #define PAS_STATUS_PCNT_S 0
  190. #define PAS_STATUS_DCNT_M 0x00000000ffff0000ull
  191. #define PAS_STATUS_DCNT_S 16
  192. #define PAS_STATUS_BPCNT_M 0x0000ffff00000000ull
  193. #define PAS_STATUS_BPCNT_S 32
  194. #define PAS_STATUS_CAUSE_M 0xf000000000000000ull
  195. #define PAS_STATUS_TIMER 0x1000000000000000ull
  196. #define PAS_STATUS_ERROR 0x2000000000000000ull
  197. #define PAS_STATUS_SOFT 0x4000000000000000ull
  198. #define PAS_STATUS_INT 0x8000000000000000ull
  199. #define PAS_IOB_COM_PKTHDRCNT 0x120
  200. #define PAS_IOB_COM_PKTHDRCNT_PKTHDR1_M 0x0fff0000
  201. #define PAS_IOB_COM_PKTHDRCNT_PKTHDR1_S 16
  202. #define PAS_IOB_COM_PKTHDRCNT_PKTHDR0_M 0x00000fff
  203. #define PAS_IOB_COM_PKTHDRCNT_PKTHDR0_S 0
  204. #define PAS_IOB_DMA_RXCH_CFG(i) (0x1100 + (i)*4)
  205. #define PAS_IOB_DMA_RXCH_CFG_CNTTH_M 0x00000fff
  206. #define PAS_IOB_DMA_RXCH_CFG_CNTTH_S 0
  207. #define PAS_IOB_DMA_RXCH_CFG_CNTTH(x) (((x) << PAS_IOB_DMA_RXCH_CFG_CNTTH_S) & \
  208. PAS_IOB_DMA_RXCH_CFG_CNTTH_M)
  209. #define PAS_IOB_DMA_TXCH_CFG(i) (0x1200 + (i)*4)
  210. #define PAS_IOB_DMA_TXCH_CFG_CNTTH_M 0x00000fff
  211. #define PAS_IOB_DMA_TXCH_CFG_CNTTH_S 0
  212. #define PAS_IOB_DMA_TXCH_CFG_CNTTH(x) (((x) << PAS_IOB_DMA_TXCH_CFG_CNTTH_S) & \
  213. PAS_IOB_DMA_TXCH_CFG_CNTTH_M)
  214. #define PAS_IOB_DMA_RXCH_STAT(i) (0x1300 + (i)*4)
  215. #define PAS_IOB_DMA_RXCH_STAT_INTGEN 0x00001000
  216. #define PAS_IOB_DMA_RXCH_STAT_CNTDEL_M 0x00000fff
  217. #define PAS_IOB_DMA_RXCH_STAT_CNTDEL_S 0
  218. #define PAS_IOB_DMA_RXCH_STAT_CNTDEL(x) (((x) << PAS_IOB_DMA_RXCH_STAT_CNTDEL_S) &\
  219. PAS_IOB_DMA_RXCH_STAT_CNTDEL_M)
  220. #define PAS_IOB_DMA_TXCH_STAT(i) (0x1400 + (i)*4)
  221. #define PAS_IOB_DMA_TXCH_STAT_INTGEN 0x00001000
  222. #define PAS_IOB_DMA_TXCH_STAT_CNTDEL_M 0x00000fff
  223. #define PAS_IOB_DMA_TXCH_STAT_CNTDEL_S 0
  224. #define PAS_IOB_DMA_TXCH_STAT_CNTDEL(x) (((x) << PAS_IOB_DMA_TXCH_STAT_CNTDEL_S) &\
  225. PAS_IOB_DMA_TXCH_STAT_CNTDEL_M)
  226. #define PAS_IOB_DMA_RXCH_RESET(i) (0x1500 + (i)*4)
  227. #define PAS_IOB_DMA_RXCH_RESET_PCNT_M 0xffff0000
  228. #define PAS_IOB_DMA_RXCH_RESET_PCNT_S 16
  229. #define PAS_IOB_DMA_RXCH_RESET_PCNT(x) (((x) << PAS_IOB_DMA_RXCH_RESET_PCNT_S) & \
  230. PAS_IOB_DMA_RXCH_RESET_PCNT_M)
  231. #define PAS_IOB_DMA_RXCH_RESET_PCNTRST 0x00000020
  232. #define PAS_IOB_DMA_RXCH_RESET_DCNTRST 0x00000010
  233. #define PAS_IOB_DMA_RXCH_RESET_TINTC 0x00000008
  234. #define PAS_IOB_DMA_RXCH_RESET_DINTC 0x00000004
  235. #define PAS_IOB_DMA_RXCH_RESET_SINTC 0x00000002
  236. #define PAS_IOB_DMA_RXCH_RESET_PINTC 0x00000001
  237. #define PAS_IOB_DMA_TXCH_RESET(i) (0x1600 + (i)*4)
  238. #define PAS_IOB_DMA_TXCH_RESET_PCNT_M 0xffff0000
  239. #define PAS_IOB_DMA_TXCH_RESET_PCNT_S 16
  240. #define PAS_IOB_DMA_TXCH_RESET_PCNT(x) (((x) << PAS_IOB_DMA_TXCH_RESET_PCNT_S) & \
  241. PAS_IOB_DMA_TXCH_RESET_PCNT_M)
  242. #define PAS_IOB_DMA_TXCH_RESET_PCNTRST 0x00000020
  243. #define PAS_IOB_DMA_TXCH_RESET_DCNTRST 0x00000010
  244. #define PAS_IOB_DMA_TXCH_RESET_TINTC 0x00000008
  245. #define PAS_IOB_DMA_TXCH_RESET_DINTC 0x00000004
  246. #define PAS_IOB_DMA_TXCH_RESET_SINTC 0x00000002
  247. #define PAS_IOB_DMA_TXCH_RESET_PINTC 0x00000001
  248. #define PAS_IOB_DMA_COM_TIMEOUTCFG 0x1700
  249. #define PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_M 0x00ffffff
  250. #define PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_S 0
  251. #define PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT(x) (((x) << PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_S) & \
  252. PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_M)
  253. /* Transmit descriptor fields */
  254. #define XCT_MACTX_T 0x8000000000000000ull
  255. #define XCT_MACTX_ST 0x4000000000000000ull
  256. #define XCT_MACTX_NORES 0x0000000000000000ull
  257. #define XCT_MACTX_8BRES 0x1000000000000000ull
  258. #define XCT_MACTX_24BRES 0x2000000000000000ull
  259. #define XCT_MACTX_40BRES 0x3000000000000000ull
  260. #define XCT_MACTX_I 0x0800000000000000ull
  261. #define XCT_MACTX_O 0x0400000000000000ull
  262. #define XCT_MACTX_E 0x0200000000000000ull
  263. #define XCT_MACTX_VLAN_M 0x0180000000000000ull
  264. #define XCT_MACTX_VLAN_NOP 0x0000000000000000ull
  265. #define XCT_MACTX_VLAN_REMOVE 0x0080000000000000ull
  266. #define XCT_MACTX_VLAN_INSERT 0x0100000000000000ull
  267. #define XCT_MACTX_VLAN_REPLACE 0x0180000000000000ull
  268. #define XCT_MACTX_CRC_M 0x0060000000000000ull
  269. #define XCT_MACTX_CRC_NOP 0x0000000000000000ull
  270. #define XCT_MACTX_CRC_INSERT 0x0020000000000000ull
  271. #define XCT_MACTX_CRC_PAD 0x0040000000000000ull
  272. #define XCT_MACTX_CRC_REPLACE 0x0060000000000000ull
  273. #define XCT_MACTX_SS 0x0010000000000000ull
  274. #define XCT_MACTX_LLEN_M 0x00007fff00000000ull
  275. #define XCT_MACTX_LLEN_S 32ull
  276. #define XCT_MACTX_LLEN(x) ((((long)(x)) << XCT_MACTX_LLEN_S) & \
  277. XCT_MACTX_LLEN_M)
  278. #define XCT_MACTX_IPH_M 0x00000000f8000000ull
  279. #define XCT_MACTX_IPH_S 27ull
  280. #define XCT_MACTX_IPH(x) ((((long)(x)) << XCT_MACTX_IPH_S) & \
  281. XCT_MACTX_IPH_M)
  282. #define XCT_MACTX_IPO_M 0x0000000007c00000ull
  283. #define XCT_MACTX_IPO_S 22ull
  284. #define XCT_MACTX_IPO(x) ((((long)(x)) << XCT_MACTX_IPO_S) & \
  285. XCT_MACTX_IPO_M)
  286. #define XCT_MACTX_CSUM_M 0x0000000000000060ull
  287. #define XCT_MACTX_CSUM_NOP 0x0000000000000000ull
  288. #define XCT_MACTX_CSUM_TCP 0x0000000000000040ull
  289. #define XCT_MACTX_CSUM_UDP 0x0000000000000060ull
  290. #define XCT_MACTX_V6 0x0000000000000010ull
  291. #define XCT_MACTX_C 0x0000000000000004ull
  292. #define XCT_MACTX_AL2 0x0000000000000002ull
  293. /* Receive descriptor fields */
  294. #define XCT_MACRX_T 0x8000000000000000ull
  295. #define XCT_MACRX_ST 0x4000000000000000ull
  296. #define XCT_MACRX_RR_M 0x3000000000000000ull
  297. #define XCT_MACRX_RR_NORES 0x0000000000000000ull
  298. #define XCT_MACRX_RR_8BRES 0x1000000000000000ull
  299. #define XCT_MACRX_O 0x0400000000000000ull
  300. #define XCT_MACRX_E 0x0200000000000000ull
  301. #define XCT_MACRX_FF 0x0100000000000000ull
  302. #define XCT_MACRX_PF 0x0080000000000000ull
  303. #define XCT_MACRX_OB 0x0040000000000000ull
  304. #define XCT_MACRX_OD 0x0020000000000000ull
  305. #define XCT_MACRX_FS 0x0010000000000000ull
  306. #define XCT_MACRX_NB_M 0x000fc00000000000ull
  307. #define XCT_MACRX_NB_S 46ULL
  308. #define XCT_MACRX_NB(x) ((((long)(x)) << XCT_MACRX_NB_S) & \
  309. XCT_MACRX_NB_M)
  310. #define XCT_MACRX_LLEN_M 0x00003fff00000000ull
  311. #define XCT_MACRX_LLEN_S 32ULL
  312. #define XCT_MACRX_LLEN(x) ((((long)(x)) << XCT_MACRX_LLEN_S) & \
  313. XCT_MACRX_LLEN_M)
  314. #define XCT_MACRX_CRC 0x0000000080000000ull
  315. #define XCT_MACRX_LEN_M 0x0000000060000000ull
  316. #define XCT_MACRX_LEN_TOOSHORT 0x0000000020000000ull
  317. #define XCT_MACRX_LEN_BELOWMIN 0x0000000040000000ull
  318. #define XCT_MACRX_LEN_TRUNC 0x0000000060000000ull
  319. #define XCT_MACRX_CAST_M 0x0000000018000000ull
  320. #define XCT_MACRX_CAST_UNI 0x0000000000000000ull
  321. #define XCT_MACRX_CAST_MULTI 0x0000000008000000ull
  322. #define XCT_MACRX_CAST_BROAD 0x0000000010000000ull
  323. #define XCT_MACRX_CAST_PAUSE 0x0000000018000000ull
  324. #define XCT_MACRX_VLC_M 0x0000000006000000ull
  325. #define XCT_MACRX_FM 0x0000000001000000ull
  326. #define XCT_MACRX_HTY_M 0x0000000000c00000ull
  327. #define XCT_MACRX_HTY_IPV4_OK 0x0000000000000000ull
  328. #define XCT_MACRX_HTY_IPV6 0x0000000000400000ull
  329. #define XCT_MACRX_HTY_IPV4_BAD 0x0000000000800000ull
  330. #define XCT_MACRX_HTY_NONIP 0x0000000000c00000ull
  331. #define XCT_MACRX_IPP_M 0x00000000003f0000ull
  332. #define XCT_MACRX_IPP_S 16
  333. #define XCT_MACRX_CSUM_M 0x000000000000ffffull
  334. #define XCT_MACRX_CSUM_S 0
  335. #define XCT_PTR_T 0x8000000000000000ull
  336. #define XCT_PTR_LEN_M 0x7ffff00000000000ull
  337. #define XCT_PTR_LEN_S 44
  338. #define XCT_PTR_LEN(x) ((((long)(x)) << XCT_PTR_LEN_S) & \
  339. XCT_PTR_LEN_M)
  340. #define XCT_PTR_ADDR_M 0x00000fffffffffffull
  341. #define XCT_PTR_ADDR_S 0
  342. #define XCT_PTR_ADDR(x) ((((long)(x)) << XCT_PTR_ADDR_S) & \
  343. XCT_PTR_ADDR_M)
  344. /* Receive interface 8byte result fields */
  345. #define XCT_RXRES_8B_L4O_M 0xff00000000000000ull
  346. #define XCT_RXRES_8B_L4O_S 56
  347. #define XCT_RXRES_8B_RULE_M 0x00ffff0000000000ull
  348. #define XCT_RXRES_8B_RULE_S 40
  349. #define XCT_RXRES_8B_EVAL_M 0x000000ffff000000ull
  350. #define XCT_RXRES_8B_EVAL_S 24
  351. #define XCT_RXRES_8B_HTYPE_M 0x0000000000f00000ull
  352. #define XCT_RXRES_8B_HASH_M 0x00000000000fffffull
  353. #define XCT_RXRES_8B_HASH_S 0
  354. /* Receive interface buffer fields */
  355. #define XCT_RXB_LEN_M 0x0ffff00000000000ull
  356. #define XCT_RXB_LEN_S 44
  357. #define XCT_RXB_LEN(x) ((((long)(x)) << XCT_RXB_LEN_S) & \
  358. XCT_RXB_LEN_M)
  359. #define XCT_RXB_ADDR_M 0x00000fffffffffffull
  360. #define XCT_RXB_ADDR_S 0
  361. #define XCT_RXB_ADDR(x) ((((long)(x)) << XCT_RXB_ADDR_S) & \
  362. XCT_RXB_ADDR_M)
  363. /* Copy descriptor fields */
  364. #define XCT_COPY_T 0x8000000000000000ull
  365. #define XCT_COPY_ST 0x4000000000000000ull
  366. #define XCT_COPY_RR_M 0x3000000000000000ull
  367. #define XCT_COPY_RR_NORES 0x0000000000000000ull
  368. #define XCT_COPY_RR_8BRES 0x1000000000000000ull
  369. #define XCT_COPY_RR_24BRES 0x2000000000000000ull
  370. #define XCT_COPY_RR_40BRES 0x3000000000000000ull
  371. #define XCT_COPY_I 0x0800000000000000ull
  372. #define XCT_COPY_O 0x0400000000000000ull
  373. #define XCT_COPY_E 0x0200000000000000ull
  374. #define XCT_COPY_STY_ZERO 0x01c0000000000000ull
  375. #define XCT_COPY_DTY_PREF 0x0038000000000000ull
  376. #define XCT_COPY_LLEN_M 0x0007ffff00000000ull
  377. #define XCT_COPY_LLEN_S 32
  378. #define XCT_COPY_LLEN(x) ((((long)(x)) << XCT_COPY_LLEN_S) & \
  379. XCT_COPY_LLEN_M)
  380. #define XCT_COPY_SE 0x0000000000000001ull
  381. /* Function descriptor fields */
  382. #define XCT_FUN_T 0x8000000000000000ull
  383. #define XCT_FUN_ST 0x4000000000000000ull
  384. #define XCT_FUN_RR_M 0x3000000000000000ull
  385. #define XCT_FUN_RR_NORES 0x0000000000000000ull
  386. #define XCT_FUN_RR_8BRES 0x1000000000000000ull
  387. #define XCT_FUN_RR_24BRES 0x2000000000000000ull
  388. #define XCT_FUN_RR_40BRES 0x3000000000000000ull
  389. #define XCT_FUN_I 0x0800000000000000ull
  390. #define XCT_FUN_O 0x0400000000000000ull
  391. #define XCT_FUN_E 0x0200000000000000ull
  392. #define XCT_FUN_FUN_M 0x01c0000000000000ull
  393. #define XCT_FUN_FUN_S 54
  394. #define XCT_FUN_FUN(x) ((((long)(x)) << XCT_FUN_FUN_S) & XCT_FUN_FUN_M)
  395. #define XCT_FUN_CRM_M 0x0038000000000000ull
  396. #define XCT_FUN_CRM_NOP 0x0000000000000000ull
  397. #define XCT_FUN_CRM_SIG 0x0008000000000000ull
  398. #define XCT_FUN_LLEN_M 0x0007ffff00000000ull
  399. #define XCT_FUN_LLEN_S 32
  400. #define XCT_FUN_LLEN(x) ((((long)(x)) << XCT_FUN_LLEN_S) & XCT_FUN_LLEN_M)
  401. #define XCT_FUN_SHL_M 0x00000000f8000000ull
  402. #define XCT_FUN_SHL_S 27
  403. #define XCT_FUN_SHL(x) ((((long)(x)) << XCT_FUN_SHL_S) & XCT_FUN_SHL_M)
  404. #define XCT_FUN_CHL_M 0x0000000007c00000ull
  405. #define XCT_FUN_HSZ_M 0x00000000003c0000ull
  406. #define XCT_FUN_ALG_M 0x0000000000038000ull
  407. #define XCT_FUN_HP 0x0000000000004000ull
  408. #define XCT_FUN_BCM_M 0x0000000000003800ull
  409. #define XCT_FUN_BCP_M 0x0000000000000600ull
  410. #define XCT_FUN_SIG_M 0x00000000000001f0ull
  411. #define XCT_FUN_SIG_TCP4 0x0000000000000140ull
  412. #define XCT_FUN_SIG_TCP6 0x0000000000000150ull
  413. #define XCT_FUN_SIG_UDP4 0x0000000000000160ull
  414. #define XCT_FUN_SIG_UDP6 0x0000000000000170ull
  415. #define XCT_FUN_A 0x0000000000000008ull
  416. #define XCT_FUN_C 0x0000000000000004ull
  417. #define XCT_FUN_AL2 0x0000000000000002ull
  418. #define XCT_FUN_SE 0x0000000000000001ull
  419. /* Function descriptor 8byte result fields */
  420. #define XCT_FUNRES_8B_CS_M 0x0000ffff00000000ull
  421. #define XCT_FUNRES_8B_CS_S 32
  422. #define XCT_FUNRES_8B_CRC_M 0x00000000ffffffffull
  423. #define XCT_FUNRES_8B_CRC_S 0
  424. /* Control descriptor fields */
  425. #define CTRL_CMD_T 0x8000000000000000ull
  426. #define CTRL_CMD_META_EVT 0x2000000000000000ull
  427. #define CTRL_CMD_O 0x0400000000000000ull
  428. #define CTRL_CMD_ETYPE_M 0x0038000000000000ull
  429. #define CTRL_CMD_ETYPE_EXT 0x0000000000000000ull
  430. #define CTRL_CMD_ETYPE_WSET 0x0020000000000000ull
  431. #define CTRL_CMD_ETYPE_WCLR 0x0028000000000000ull
  432. #define CTRL_CMD_ETYPE_SET 0x0030000000000000ull
  433. #define CTRL_CMD_ETYPE_CLR 0x0038000000000000ull
  434. #define CTRL_CMD_REG_M 0x000000000000007full
  435. #define CTRL_CMD_REG_S 0
  436. #define CTRL_CMD_REG(x) ((((long)(x)) << CTRL_CMD_REG_S) & \
  437. CTRL_CMD_REG_M)
  438. /* Prototypes for the shared DMA functions in the platform code. */
  439. /* DMA TX Channel type. Right now only limitations used are event types 0/1,
  440. * for event-triggered DMA transactions.
  441. */
  442. enum pasemi_dmachan_type {
  443. RXCHAN = 0, /* Any RX chan */
  444. TXCHAN = 1, /* Any TX chan */
  445. TXCHAN_EVT0 = 0x1001, /* TX chan in event class 0 (chan 0-9) */
  446. TXCHAN_EVT1 = 0x2001, /* TX chan in event class 1 (chan 10-19) */
  447. };
  448. struct pasemi_dmachan {
  449. int chno; /* Channel number */
  450. enum pasemi_dmachan_type chan_type; /* TX / RX */
  451. u64 *status; /* Ptr to cacheable status */
  452. int irq; /* IRQ used by channel */
  453. unsigned int ring_size; /* size of allocated ring */
  454. dma_addr_t ring_dma; /* DMA address for ring */
  455. u64 *ring_virt; /* Virt address for ring */
  456. void *priv; /* Ptr to start of client struct */
  457. };
  458. /* Read/write the different registers in the I/O Bridge, Ethernet
  459. * and DMA Controller
  460. */
  461. extern unsigned int pasemi_read_iob_reg(unsigned int reg);
  462. extern void pasemi_write_iob_reg(unsigned int reg, unsigned int val);
  463. extern unsigned int pasemi_read_mac_reg(int intf, unsigned int reg);
  464. extern void pasemi_write_mac_reg(int intf, unsigned int reg, unsigned int val);
  465. extern unsigned int pasemi_read_dma_reg(unsigned int reg);
  466. extern void pasemi_write_dma_reg(unsigned int reg, unsigned int val);
  467. /* Channel management routines */
  468. extern void *pasemi_dma_alloc_chan(enum pasemi_dmachan_type type,
  469. int total_size, int offset);
  470. extern void pasemi_dma_free_chan(struct pasemi_dmachan *chan);
  471. extern void pasemi_dma_start_chan(const struct pasemi_dmachan *chan,
  472. const u32 cmdsta);
  473. extern int pasemi_dma_stop_chan(const struct pasemi_dmachan *chan);
  474. /* Common routines to allocate rings and buffers */
  475. extern int pasemi_dma_alloc_ring(struct pasemi_dmachan *chan, int ring_size);
  476. extern void pasemi_dma_free_ring(struct pasemi_dmachan *chan);
  477. extern void *pasemi_dma_alloc_buf(struct pasemi_dmachan *chan, int size,
  478. dma_addr_t *handle);
  479. extern void pasemi_dma_free_buf(struct pasemi_dmachan *chan, int size,
  480. dma_addr_t *handle);
  481. /* Routines to allocate flags (events) for channel synchronization */
  482. extern int pasemi_dma_alloc_flag(void);
  483. extern void pasemi_dma_free_flag(int flag);
  484. extern void pasemi_dma_set_flag(int flag);
  485. extern void pasemi_dma_clear_flag(int flag);
  486. /* Routines to allocate function engines */
  487. extern int pasemi_dma_alloc_fun(void);
  488. extern void pasemi_dma_free_fun(int fun);
  489. /* Initialize the library, must be called before any other functions */
  490. extern int pasemi_dma_init(void);
  491. #endif /* ASM_PASEMI_DMA_H */