ftgmac100.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * Faraday FTGMAC100 Gigabit Ethernet
  3. *
  4. * (C) Copyright 2009-2011 Faraday Technology
  5. * Po-Yu Chuang <ratbert@faraday-tech.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  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., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #ifndef __FTGMAC100_H
  22. #define __FTGMAC100_H
  23. #define FTGMAC100_OFFSET_ISR 0x00
  24. #define FTGMAC100_OFFSET_IER 0x04
  25. #define FTGMAC100_OFFSET_MAC_MADR 0x08
  26. #define FTGMAC100_OFFSET_MAC_LADR 0x0c
  27. #define FTGMAC100_OFFSET_MAHT0 0x10
  28. #define FTGMAC100_OFFSET_MAHT1 0x14
  29. #define FTGMAC100_OFFSET_NPTXPD 0x18
  30. #define FTGMAC100_OFFSET_RXPD 0x1c
  31. #define FTGMAC100_OFFSET_NPTXR_BADR 0x20
  32. #define FTGMAC100_OFFSET_RXR_BADR 0x24
  33. #define FTGMAC100_OFFSET_HPTXPD 0x28
  34. #define FTGMAC100_OFFSET_HPTXR_BADR 0x2c
  35. #define FTGMAC100_OFFSET_ITC 0x30
  36. #define FTGMAC100_OFFSET_APTC 0x34
  37. #define FTGMAC100_OFFSET_DBLAC 0x38
  38. #define FTGMAC100_OFFSET_DMAFIFOS 0x3c
  39. #define FTGMAC100_OFFSET_REVR 0x40
  40. #define FTGMAC100_OFFSET_FEAR 0x44
  41. #define FTGMAC100_OFFSET_TPAFCR 0x48
  42. #define FTGMAC100_OFFSET_RBSR 0x4c
  43. #define FTGMAC100_OFFSET_MACCR 0x50
  44. #define FTGMAC100_OFFSET_MACSR 0x54
  45. #define FTGMAC100_OFFSET_TM 0x58
  46. #define FTGMAC100_OFFSET_PHYCR 0x60
  47. #define FTGMAC100_OFFSET_PHYDATA 0x64
  48. #define FTGMAC100_OFFSET_FCR 0x68
  49. #define FTGMAC100_OFFSET_BPR 0x6c
  50. #define FTGMAC100_OFFSET_WOLCR 0x70
  51. #define FTGMAC100_OFFSET_WOLSR 0x74
  52. #define FTGMAC100_OFFSET_WFCRC 0x78
  53. #define FTGMAC100_OFFSET_WFBM1 0x80
  54. #define FTGMAC100_OFFSET_WFBM2 0x84
  55. #define FTGMAC100_OFFSET_WFBM3 0x88
  56. #define FTGMAC100_OFFSET_WFBM4 0x8c
  57. #define FTGMAC100_OFFSET_NPTXR_PTR 0x90
  58. #define FTGMAC100_OFFSET_HPTXR_PTR 0x94
  59. #define FTGMAC100_OFFSET_RXR_PTR 0x98
  60. #define FTGMAC100_OFFSET_TX 0xa0
  61. #define FTGMAC100_OFFSET_TX_MCOL_SCOL 0xa4
  62. #define FTGMAC100_OFFSET_TX_ECOL_FAIL 0xa8
  63. #define FTGMAC100_OFFSET_TX_LCOL_UND 0xac
  64. #define FTGMAC100_OFFSET_RX 0xb0
  65. #define FTGMAC100_OFFSET_RX_BC 0xb4
  66. #define FTGMAC100_OFFSET_RX_MC 0xb8
  67. #define FTGMAC100_OFFSET_RX_PF_AEP 0xbc
  68. #define FTGMAC100_OFFSET_RX_RUNT 0xc0
  69. #define FTGMAC100_OFFSET_RX_CRCER_FTL 0xc4
  70. #define FTGMAC100_OFFSET_RX_COL_LOST 0xc8
  71. /*
  72. * Interrupt status register & interrupt enable register
  73. */
  74. #define FTGMAC100_INT_RPKT_BUF (1 << 0)
  75. #define FTGMAC100_INT_RPKT_FIFO (1 << 1)
  76. #define FTGMAC100_INT_NO_RXBUF (1 << 2)
  77. #define FTGMAC100_INT_RPKT_LOST (1 << 3)
  78. #define FTGMAC100_INT_XPKT_ETH (1 << 4)
  79. #define FTGMAC100_INT_XPKT_FIFO (1 << 5)
  80. #define FTGMAC100_INT_NO_NPTXBUF (1 << 6)
  81. #define FTGMAC100_INT_XPKT_LOST (1 << 7)
  82. #define FTGMAC100_INT_AHB_ERR (1 << 8)
  83. #define FTGMAC100_INT_PHYSTS_CHG (1 << 9)
  84. #define FTGMAC100_INT_NO_HPTXBUF (1 << 10)
  85. /*
  86. * Interrupt timer control register
  87. */
  88. #define FTGMAC100_ITC_RXINT_CNT(x) (((x) & 0xf) << 0)
  89. #define FTGMAC100_ITC_RXINT_THR(x) (((x) & 0x7) << 4)
  90. #define FTGMAC100_ITC_RXINT_TIME_SEL (1 << 7)
  91. #define FTGMAC100_ITC_TXINT_CNT(x) (((x) & 0xf) << 8)
  92. #define FTGMAC100_ITC_TXINT_THR(x) (((x) & 0x7) << 12)
  93. #define FTGMAC100_ITC_TXINT_TIME_SEL (1 << 15)
  94. /*
  95. * Automatic polling timer control register
  96. */
  97. #define FTGMAC100_APTC_RXPOLL_CNT(x) (((x) & 0xf) << 0)
  98. #define FTGMAC100_APTC_RXPOLL_TIME_SEL (1 << 4)
  99. #define FTGMAC100_APTC_TXPOLL_CNT(x) (((x) & 0xf) << 8)
  100. #define FTGMAC100_APTC_TXPOLL_TIME_SEL (1 << 12)
  101. /*
  102. * DMA burst length and arbitration control register
  103. */
  104. #define FTGMAC100_DBLAC_RXFIFO_LTHR(x) (((x) & 0x7) << 0)
  105. #define FTGMAC100_DBLAC_RXFIFO_HTHR(x) (((x) & 0x7) << 3)
  106. #define FTGMAC100_DBLAC_RX_THR_EN (1 << 6)
  107. #define FTGMAC100_DBLAC_RXBURST_SIZE(x) (((x) & 0x3) << 8)
  108. #define FTGMAC100_DBLAC_TXBURST_SIZE(x) (((x) & 0x3) << 10)
  109. #define FTGMAC100_DBLAC_RXDES_SIZE(x) (((x) & 0xf) << 12)
  110. #define FTGMAC100_DBLAC_TXDES_SIZE(x) (((x) & 0xf) << 16)
  111. #define FTGMAC100_DBLAC_IFG_CNT(x) (((x) & 0x7) << 20)
  112. #define FTGMAC100_DBLAC_IFG_INC (1 << 23)
  113. /*
  114. * DMA FIFO status register
  115. */
  116. #define FTGMAC100_DMAFIFOS_RXDMA1_SM(dmafifos) ((dmafifos) & 0xf)
  117. #define FTGMAC100_DMAFIFOS_RXDMA2_SM(dmafifos) (((dmafifos) >> 4) & 0xf)
  118. #define FTGMAC100_DMAFIFOS_RXDMA3_SM(dmafifos) (((dmafifos) >> 8) & 0x7)
  119. #define FTGMAC100_DMAFIFOS_TXDMA1_SM(dmafifos) (((dmafifos) >> 12) & 0xf)
  120. #define FTGMAC100_DMAFIFOS_TXDMA2_SM(dmafifos) (((dmafifos) >> 16) & 0x3)
  121. #define FTGMAC100_DMAFIFOS_TXDMA3_SM(dmafifos) (((dmafifos) >> 18) & 0xf)
  122. #define FTGMAC100_DMAFIFOS_RXFIFO_EMPTY (1 << 26)
  123. #define FTGMAC100_DMAFIFOS_TXFIFO_EMPTY (1 << 27)
  124. #define FTGMAC100_DMAFIFOS_RXDMA_GRANT (1 << 28)
  125. #define FTGMAC100_DMAFIFOS_TXDMA_GRANT (1 << 29)
  126. #define FTGMAC100_DMAFIFOS_RXDMA_REQ (1 << 30)
  127. #define FTGMAC100_DMAFIFOS_TXDMA_REQ (1 << 31)
  128. /*
  129. * Receive buffer size register
  130. */
  131. #define FTGMAC100_RBSR_SIZE(x) ((x) & 0x3fff)
  132. /*
  133. * MAC control register
  134. */
  135. #define FTGMAC100_MACCR_TXDMA_EN (1 << 0)
  136. #define FTGMAC100_MACCR_RXDMA_EN (1 << 1)
  137. #define FTGMAC100_MACCR_TXMAC_EN (1 << 2)
  138. #define FTGMAC100_MACCR_RXMAC_EN (1 << 3)
  139. #define FTGMAC100_MACCR_RM_VLAN (1 << 4)
  140. #define FTGMAC100_MACCR_HPTXR_EN (1 << 5)
  141. #define FTGMAC100_MACCR_LOOP_EN (1 << 6)
  142. #define FTGMAC100_MACCR_ENRX_IN_HALFTX (1 << 7)
  143. #define FTGMAC100_MACCR_FULLDUP (1 << 8)
  144. #define FTGMAC100_MACCR_GIGA_MODE (1 << 9)
  145. #define FTGMAC100_MACCR_CRC_APD (1 << 10)
  146. #define FTGMAC100_MACCR_RX_RUNT (1 << 12)
  147. #define FTGMAC100_MACCR_JUMBO_LF (1 << 13)
  148. #define FTGMAC100_MACCR_RX_ALL (1 << 14)
  149. #define FTGMAC100_MACCR_HT_MULTI_EN (1 << 15)
  150. #define FTGMAC100_MACCR_RX_MULTIPKT (1 << 16)
  151. #define FTGMAC100_MACCR_RX_BROADPKT (1 << 17)
  152. #define FTGMAC100_MACCR_DISCARD_CRCERR (1 << 18)
  153. #define FTGMAC100_MACCR_FAST_MODE (1 << 19)
  154. #define FTGMAC100_MACCR_SW_RST (1 << 31)
  155. /*
  156. * PHY control register
  157. */
  158. #define FTGMAC100_PHYCR_MDC_CYCTHR_MASK 0x3f
  159. #define FTGMAC100_PHYCR_MDC_CYCTHR(x) ((x) & 0x3f)
  160. #define FTGMAC100_PHYCR_PHYAD(x) (((x) & 0x1f) << 16)
  161. #define FTGMAC100_PHYCR_REGAD(x) (((x) & 0x1f) << 21)
  162. #define FTGMAC100_PHYCR_MIIRD (1 << 26)
  163. #define FTGMAC100_PHYCR_MIIWR (1 << 27)
  164. /*
  165. * PHY data register
  166. */
  167. #define FTGMAC100_PHYDATA_MIIWDATA(x) ((x) & 0xffff)
  168. #define FTGMAC100_PHYDATA_MIIRDATA(phydata) (((phydata) >> 16) & 0xffff)
  169. /*
  170. * Transmit descriptor, aligned to 16 bytes
  171. */
  172. struct ftgmac100_txdes {
  173. unsigned int txdes0;
  174. unsigned int txdes1;
  175. unsigned int txdes2; /* not used by HW */
  176. unsigned int txdes3; /* TXBUF_BADR */
  177. } __attribute__ ((aligned(16)));
  178. #define FTGMAC100_TXDES0_TXBUF_SIZE(x) ((x) & 0x3fff)
  179. #define FTGMAC100_TXDES0_EDOTR (1 << 15)
  180. #define FTGMAC100_TXDES0_CRC_ERR (1 << 19)
  181. #define FTGMAC100_TXDES0_LTS (1 << 28)
  182. #define FTGMAC100_TXDES0_FTS (1 << 29)
  183. #define FTGMAC100_TXDES0_TXDMA_OWN (1 << 31)
  184. #define FTGMAC100_TXDES1_VLANTAG_CI(x) ((x) & 0xffff)
  185. #define FTGMAC100_TXDES1_INS_VLANTAG (1 << 16)
  186. #define FTGMAC100_TXDES1_TCP_CHKSUM (1 << 17)
  187. #define FTGMAC100_TXDES1_UDP_CHKSUM (1 << 18)
  188. #define FTGMAC100_TXDES1_IP_CHKSUM (1 << 19)
  189. #define FTGMAC100_TXDES1_LLC (1 << 22)
  190. #define FTGMAC100_TXDES1_TX2FIC (1 << 30)
  191. #define FTGMAC100_TXDES1_TXIC (1 << 31)
  192. /*
  193. * Receive descriptor, aligned to 16 bytes
  194. */
  195. struct ftgmac100_rxdes {
  196. unsigned int rxdes0;
  197. unsigned int rxdes1;
  198. unsigned int rxdes2; /* not used by HW */
  199. unsigned int rxdes3; /* RXBUF_BADR */
  200. } __attribute__ ((aligned(16)));
  201. #define FTGMAC100_RXDES0_VDBC 0x3fff
  202. #define FTGMAC100_RXDES0_EDORR (1 << 15)
  203. #define FTGMAC100_RXDES0_MULTICAST (1 << 16)
  204. #define FTGMAC100_RXDES0_BROADCAST (1 << 17)
  205. #define FTGMAC100_RXDES0_RX_ERR (1 << 18)
  206. #define FTGMAC100_RXDES0_CRC_ERR (1 << 19)
  207. #define FTGMAC100_RXDES0_FTL (1 << 20)
  208. #define FTGMAC100_RXDES0_RUNT (1 << 21)
  209. #define FTGMAC100_RXDES0_RX_ODD_NB (1 << 22)
  210. #define FTGMAC100_RXDES0_FIFO_FULL (1 << 23)
  211. #define FTGMAC100_RXDES0_PAUSE_OPCODE (1 << 24)
  212. #define FTGMAC100_RXDES0_PAUSE_FRAME (1 << 25)
  213. #define FTGMAC100_RXDES0_LRS (1 << 28)
  214. #define FTGMAC100_RXDES0_FRS (1 << 29)
  215. #define FTGMAC100_RXDES0_RXPKT_RDY (1 << 31)
  216. #define FTGMAC100_RXDES1_VLANTAG_CI 0xffff
  217. #define FTGMAC100_RXDES1_PROT_MASK (0x3 << 20)
  218. #define FTGMAC100_RXDES1_PROT_NONIP (0x0 << 20)
  219. #define FTGMAC100_RXDES1_PROT_IP (0x1 << 20)
  220. #define FTGMAC100_RXDES1_PROT_TCPIP (0x2 << 20)
  221. #define FTGMAC100_RXDES1_PROT_UDPIP (0x3 << 20)
  222. #define FTGMAC100_RXDES1_LLC (1 << 22)
  223. #define FTGMAC100_RXDES1_DF (1 << 23)
  224. #define FTGMAC100_RXDES1_VLANTAG_AVAIL (1 << 24)
  225. #define FTGMAC100_RXDES1_TCP_CHKSUM_ERR (1 << 25)
  226. #define FTGMAC100_RXDES1_UDP_CHKSUM_ERR (1 << 26)
  227. #define FTGMAC100_RXDES1_IP_CHKSUM_ERR (1 << 27)
  228. #endif /* __FTGMAC100_H */