ftgmac100.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /*
  2. * Faraday FTGMAC100 Ethernet
  3. *
  4. * (C) Copyright 2010 Faraday Technology
  5. * Po-Yu Chuang <ratbert@faraday-tech.com>
  6. *
  7. * (C) Copyright 2010 Andes Technology
  8. * Macpaul Lin <macpaul@andestech.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23. */
  24. #ifndef __FTGMAC100_H
  25. #define __FTGMAC100_H
  26. /* The registers offset table of ftgmac100 */
  27. struct ftgmac100 {
  28. unsigned int isr; /* 0x00 */
  29. unsigned int ier; /* 0x04 */
  30. unsigned int mac_madr; /* 0x08 */
  31. unsigned int mac_ladr; /* 0x0c */
  32. unsigned int maht0; /* 0x10 */
  33. unsigned int maht1; /* 0x14 */
  34. unsigned int txpd; /* 0x18 */
  35. unsigned int rxpd; /* 0x1c */
  36. unsigned int txr_badr; /* 0x20 */
  37. unsigned int rxr_badr; /* 0x24 */
  38. unsigned int hptxpd; /* 0x28 */
  39. unsigned int hptxpd_badr; /* 0x2c */
  40. unsigned int itc; /* 0x30 */
  41. unsigned int aptc; /* 0x34 */
  42. unsigned int dblac; /* 0x38 */
  43. unsigned int dmafifos; /* 0x3c */
  44. unsigned int revr; /* 0x40 */
  45. unsigned int fear; /* 0x44 */
  46. unsigned int tpafcr; /* 0x48 */
  47. unsigned int rbsr; /* 0x4c */
  48. unsigned int maccr; /* 0x50 */
  49. unsigned int macsr; /* 0x54 */
  50. unsigned int tm; /* 0x58 */
  51. unsigned int resv1; /* 0x5c */ /* not defined in spec */
  52. unsigned int phycr; /* 0x60 */
  53. unsigned int phydata; /* 0x64 */
  54. unsigned int fcr; /* 0x68 */
  55. unsigned int bpr; /* 0x6c */
  56. unsigned int wolcr; /* 0x70 */
  57. unsigned int wolsr; /* 0x74 */
  58. unsigned int wfcrc; /* 0x78 */
  59. unsigned int resv2; /* 0x7c */ /* not defined in spec */
  60. unsigned int wfbm1; /* 0x80 */
  61. unsigned int wfbm2; /* 0x84 */
  62. unsigned int wfbm3; /* 0x88 */
  63. unsigned int wfbm4; /* 0x8c */
  64. unsigned int nptxr_ptr; /* 0x90 */
  65. unsigned int hptxr_ptr; /* 0x94 */
  66. unsigned int rxr_ptr; /* 0x98 */
  67. unsigned int resv3; /* 0x9c */ /* not defined in spec */
  68. unsigned int tx; /* 0xa0 */
  69. unsigned int tx_mcol_scol; /* 0xa4 */
  70. unsigned int tx_ecol_fail; /* 0xa8 */
  71. unsigned int tx_lcol_und; /* 0xac */
  72. unsigned int rx; /* 0xb0 */
  73. unsigned int rx_bc; /* 0xb4 */
  74. unsigned int rx_mc; /* 0xb8 */
  75. unsigned int rx_pf_aep; /* 0xbc */
  76. unsigned int rx_runt; /* 0xc0 */
  77. unsigned int rx_crcer_ftl; /* 0xc4 */
  78. unsigned int rx_col_lost; /* 0xc8 */
  79. };
  80. /*
  81. * Interrupt status register & interrupt enable register
  82. */
  83. #define FTGMAC100_INT_RPKT_BUF (1 << 0)
  84. #define FTGMAC100_INT_RPKT_FIFO (1 << 1)
  85. #define FTGMAC100_INT_NO_RXBUF (1 << 2)
  86. #define FTGMAC100_INT_RPKT_LOST (1 << 3)
  87. #define FTGMAC100_INT_XPKT_ETH (1 << 4)
  88. #define FTGMAC100_INT_XPKT_FIFO (1 << 5)
  89. #define FTGMAC100_INT_NO_NPTXBUF (1 << 6)
  90. #define FTGMAC100_INT_XPKT_LOST (1 << 7)
  91. #define FTGMAC100_INT_AHB_ERR (1 << 8)
  92. #define FTGMAC100_INT_PHYSTS_CHG (1 << 9)
  93. #define FTGMAC100_INT_NO_HPTXBUF (1 << 10)
  94. /*
  95. * Interrupt timer control register
  96. */
  97. #define FTGMAC100_ITC_RXINT_CNT(x) (((x) & 0xf) << 0)
  98. #define FTGMAC100_ITC_RXINT_THR(x) (((x) & 0x7) << 4)
  99. #define FTGMAC100_ITC_RXINT_TIME_SEL (1 << 7)
  100. #define FTGMAC100_ITC_TXINT_CNT(x) (((x) & 0xf) << 8)
  101. #define FTGMAC100_ITC_TXINT_THR(x) (((x) & 0x7) << 12)
  102. #define FTGMAC100_ITC_TXINT_TIME_SEL (1 << 15)
  103. /*
  104. * Automatic polling timer control register
  105. */
  106. #define FTGMAC100_APTC_RXPOLL_CNT(x) (((x) & 0xf) << 0)
  107. #define FTGMAC100_APTC_RXPOLL_TIME_SEL (1 << 4)
  108. #define FTGMAC100_APTC_TXPOLL_CNT(x) (((x) & 0xf) << 8)
  109. #define FTGMAC100_APTC_TXPOLL_TIME_SEL (1 << 12)
  110. /*
  111. * DMA burst length and arbitration control register
  112. */
  113. #define FTGMAC100_DBLAC_RXFIFO_LTHR(x) (((x) & 0x7) << 0)
  114. #define FTGMAC100_DBLAC_RXFIFO_HTHR(x) (((x) & 0x7) << 3)
  115. #define FTGMAC100_DBLAC_RX_THR_EN (1 << 6)
  116. #define FTGMAC100_DBLAC_RXBURST_SIZE(x) (((x) & 0x3) << 8)
  117. #define FTGMAC100_DBLAC_TXBURST_SIZE(x) (((x) & 0x3) << 10)
  118. #define FTGMAC100_DBLAC_RXDES_SIZE(x) (((x) & 0xf) << 12)
  119. #define FTGMAC100_DBLAC_TXDES_SIZE(x) (((x) & 0xf) << 16)
  120. #define FTGMAC100_DBLAC_IFG_CNT(x) (((x) & 0x7) << 20)
  121. #define FTGMAC100_DBLAC_IFG_INC (1 << 23)
  122. /*
  123. * DMA FIFO status register
  124. */
  125. #define FTGMAC100_DMAFIFOS_RXDMA1_SM(dmafifos) ((dmafifos) & 0xf)
  126. #define FTGMAC100_DMAFIFOS_RXDMA2_SM(dmafifos) (((dmafifos) >> 4) & 0xf)
  127. #define FTGMAC100_DMAFIFOS_RXDMA3_SM(dmafifos) (((dmafifos) >> 8) & 0x7)
  128. #define FTGMAC100_DMAFIFOS_TXDMA1_SM(dmafifos) (((dmafifos) >> 12) & 0xf)
  129. #define FTGMAC100_DMAFIFOS_TXDMA2_SM(dmafifos) (((dmafifos) >> 16) & 0x3)
  130. #define FTGMAC100_DMAFIFOS_TXDMA3_SM(dmafifos) (((dmafifos) >> 18) & 0xf)
  131. #define FTGMAC100_DMAFIFOS_RXFIFO_EMPTY (1 << 26)
  132. #define FTGMAC100_DMAFIFOS_TXFIFO_EMPTY (1 << 27)
  133. #define FTGMAC100_DMAFIFOS_RXDMA_GRANT (1 << 28)
  134. #define FTGMAC100_DMAFIFOS_TXDMA_GRANT (1 << 29)
  135. #define FTGMAC100_DMAFIFOS_RXDMA_REQ (1 << 30)
  136. #define FTGMAC100_DMAFIFOS_TXDMA_REQ (1 << 31)
  137. /*
  138. * Receive buffer size register
  139. */
  140. #define FTGMAC100_RBSR_SIZE(x) ((x) & 0x3fff)
  141. /*
  142. * MAC control register
  143. */
  144. #define FTGMAC100_MACCR_TXDMA_EN (1 << 0)
  145. #define FTGMAC100_MACCR_RXDMA_EN (1 << 1)
  146. #define FTGMAC100_MACCR_TXMAC_EN (1 << 2)
  147. #define FTGMAC100_MACCR_RXMAC_EN (1 << 3)
  148. #define FTGMAC100_MACCR_RM_VLAN (1 << 4)
  149. #define FTGMAC100_MACCR_HPTXR_EN (1 << 5)
  150. #define FTGMAC100_MACCR_LOOP_EN (1 << 6)
  151. #define FTGMAC100_MACCR_ENRX_IN_HALFTX (1 << 7)
  152. #define FTGMAC100_MACCR_FULLDUP (1 << 8)
  153. #define FTGMAC100_MACCR_GIGA_MODE (1 << 9)
  154. #define FTGMAC100_MACCR_CRC_APD (1 << 10)
  155. #define FTGMAC100_MACCR_RX_RUNT (1 << 12)
  156. #define FTGMAC100_MACCR_JUMBO_LF (1 << 13)
  157. #define FTGMAC100_MACCR_RX_ALL (1 << 14)
  158. #define FTGMAC100_MACCR_HT_MULTI_EN (1 << 15)
  159. #define FTGMAC100_MACCR_RX_MULTIPKT (1 << 16)
  160. #define FTGMAC100_MACCR_RX_BROADPKT (1 << 17)
  161. #define FTGMAC100_MACCR_DISCARD_CRCERR (1 << 18)
  162. #define FTGMAC100_MACCR_FAST_MODE (1 << 19)
  163. #define FTGMAC100_MACCR_SW_RST (1 << 31)
  164. /*
  165. * PHY control register
  166. */
  167. #define FTGMAC100_PHYCR_MDC_CYCTHR_MASK 0x3f
  168. #define FTGMAC100_PHYCR_MDC_CYCTHR(x) ((x) & 0x3f)
  169. #define FTGMAC100_PHYCR_PHYAD(x) (((x) & 0x1f) << 16)
  170. #define FTGMAC100_PHYCR_REGAD(x) (((x) & 0x1f) << 21)
  171. #define FTGMAC100_PHYCR_MIIRD (1 << 26)
  172. #define FTGMAC100_PHYCR_MIIWR (1 << 27)
  173. /*
  174. * PHY data register
  175. */
  176. #define FTGMAC100_PHYDATA_MIIWDATA(x) ((x) & 0xffff)
  177. #define FTGMAC100_PHYDATA_MIIRDATA(phydata) (((phydata) >> 16) & 0xffff)
  178. /*
  179. * Transmit descriptor, aligned to 16 bytes
  180. */
  181. struct ftgmac100_txdes {
  182. unsigned int txdes0;
  183. unsigned int txdes1;
  184. unsigned int txdes2; /* not used by HW */
  185. unsigned int txdes3; /* TXBUF_BADR */
  186. } __attribute__ ((aligned(16)));
  187. #define FTGMAC100_TXDES0_TXBUF_SIZE(x) ((x) & 0x3fff)
  188. #define FTGMAC100_TXDES0_EDOTR (1 << 15)
  189. #define FTGMAC100_TXDES0_CRC_ERR (1 << 19)
  190. #define FTGMAC100_TXDES0_LTS (1 << 28)
  191. #define FTGMAC100_TXDES0_FTS (1 << 29)
  192. #define FTGMAC100_TXDES0_TXDMA_OWN (1 << 31)
  193. #define FTGMAC100_TXDES1_VLANTAG_CI(x) ((x) & 0xffff)
  194. #define FTGMAC100_TXDES1_INS_VLANTAG (1 << 16)
  195. #define FTGMAC100_TXDES1_TCP_CHKSUM (1 << 17)
  196. #define FTGMAC100_TXDES1_UDP_CHKSUM (1 << 18)
  197. #define FTGMAC100_TXDES1_IP_CHKSUM (1 << 19)
  198. #define FTGMAC100_TXDES1_LLC (1 << 22)
  199. #define FTGMAC100_TXDES1_TX2FIC (1 << 30)
  200. #define FTGMAC100_TXDES1_TXIC (1 << 31)
  201. /*
  202. * Receive descriptor, aligned to 16 bytes
  203. */
  204. struct ftgmac100_rxdes {
  205. unsigned int rxdes0;
  206. unsigned int rxdes1;
  207. unsigned int rxdes2; /* not used by HW */
  208. unsigned int rxdes3; /* RXBUF_BADR */
  209. } __attribute__ ((aligned(16)));
  210. #define FTGMAC100_RXDES0_VDBC(x) ((x) & 0x3fff)
  211. #define FTGMAC100_RXDES0_EDORR (1 << 15)
  212. #define FTGMAC100_RXDES0_MULTICAST (1 << 16)
  213. #define FTGMAC100_RXDES0_BROADCAST (1 << 17)
  214. #define FTGMAC100_RXDES0_RX_ERR (1 << 18)
  215. #define FTGMAC100_RXDES0_CRC_ERR (1 << 19)
  216. #define FTGMAC100_RXDES0_FTL (1 << 20)
  217. #define FTGMAC100_RXDES0_RUNT (1 << 21)
  218. #define FTGMAC100_RXDES0_RX_ODD_NB (1 << 22)
  219. #define FTGMAC100_RXDES0_FIFO_FULL (1 << 23)
  220. #define FTGMAC100_RXDES0_PAUSE_OPCODE (1 << 24)
  221. #define FTGMAC100_RXDES0_PAUSE_FRAME (1 << 25)
  222. #define FTGMAC100_RXDES0_LRS (1 << 28)
  223. #define FTGMAC100_RXDES0_FRS (1 << 29)
  224. #define FTGMAC100_RXDES0_RXPKT_RDY (1 << 31)
  225. #define FTGMAC100_RXDES1_VLANTAG_CI 0xffff
  226. #define FTGMAC100_RXDES1_PROT_MASK (0x3 << 20)
  227. #define FTGMAC100_RXDES1_PROT_NONIP (0x0 << 20)
  228. #define FTGMAC100_RXDES1_PROT_IP (0x1 << 20)
  229. #define FTGMAC100_RXDES1_PROT_TCPIP (0x2 << 20)
  230. #define FTGMAC100_RXDES1_PROT_UDPIP (0x3 << 20)
  231. #define FTGMAC100_RXDES1_LLC (1 << 22)
  232. #define FTGMAC100_RXDES1_DF (1 << 23)
  233. #define FTGMAC100_RXDES1_VLANTAG_AVAIL (1 << 24)
  234. #define FTGMAC100_RXDES1_TCP_CHKSUM_ERR (1 << 25)
  235. #define FTGMAC100_RXDES1_UDP_CHKSUM_ERR (1 << 26)
  236. #define FTGMAC100_RXDES1_IP_CHKSUM_ERR (1 << 27)
  237. #endif /* __FTGMAC100_H */