ftmac100.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Faraday FTMAC100 10/100 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 __FTMAC100_H
  22. #define __FTMAC100_H
  23. #define FTMAC100_OFFSET_ISR 0x00
  24. #define FTMAC100_OFFSET_IMR 0x04
  25. #define FTMAC100_OFFSET_MAC_MADR 0x08
  26. #define FTMAC100_OFFSET_MAC_LADR 0x0c
  27. #define FTMAC100_OFFSET_MAHT0 0x10
  28. #define FTMAC100_OFFSET_MAHT1 0x14
  29. #define FTMAC100_OFFSET_TXPD 0x18
  30. #define FTMAC100_OFFSET_RXPD 0x1c
  31. #define FTMAC100_OFFSET_TXR_BADR 0x20
  32. #define FTMAC100_OFFSET_RXR_BADR 0x24
  33. #define FTMAC100_OFFSET_ITC 0x28
  34. #define FTMAC100_OFFSET_APTC 0x2c
  35. #define FTMAC100_OFFSET_DBLAC 0x30
  36. #define FTMAC100_OFFSET_MACCR 0x88
  37. #define FTMAC100_OFFSET_MACSR 0x8c
  38. #define FTMAC100_OFFSET_PHYCR 0x90
  39. #define FTMAC100_OFFSET_PHYWDATA 0x94
  40. #define FTMAC100_OFFSET_FCR 0x98
  41. #define FTMAC100_OFFSET_BPR 0x9c
  42. #define FTMAC100_OFFSET_TS 0xc4
  43. #define FTMAC100_OFFSET_DMAFIFOS 0xc8
  44. #define FTMAC100_OFFSET_TM 0xcc
  45. #define FTMAC100_OFFSET_TX_MCOL_SCOL 0xd4
  46. #define FTMAC100_OFFSET_RPF_AEP 0xd8
  47. #define FTMAC100_OFFSET_XM_PG 0xdc
  48. #define FTMAC100_OFFSET_RUNT_TLCC 0xe0
  49. #define FTMAC100_OFFSET_CRCER_FTL 0xe4
  50. #define FTMAC100_OFFSET_RLC_RCC 0xe8
  51. #define FTMAC100_OFFSET_BROC 0xec
  52. #define FTMAC100_OFFSET_MULCA 0xf0
  53. #define FTMAC100_OFFSET_RP 0xf4
  54. #define FTMAC100_OFFSET_XP 0xf8
  55. /*
  56. * Interrupt status register & interrupt mask register
  57. */
  58. #define FTMAC100_INT_RPKT_FINISH (1 << 0)
  59. #define FTMAC100_INT_NORXBUF (1 << 1)
  60. #define FTMAC100_INT_XPKT_FINISH (1 << 2)
  61. #define FTMAC100_INT_NOTXBUF (1 << 3)
  62. #define FTMAC100_INT_XPKT_OK (1 << 4)
  63. #define FTMAC100_INT_XPKT_LOST (1 << 5)
  64. #define FTMAC100_INT_RPKT_SAV (1 << 6)
  65. #define FTMAC100_INT_RPKT_LOST (1 << 7)
  66. #define FTMAC100_INT_AHB_ERR (1 << 8)
  67. #define FTMAC100_INT_PHYSTS_CHG (1 << 9)
  68. /*
  69. * Interrupt timer control register
  70. */
  71. #define FTMAC100_ITC_RXINT_CNT(x) (((x) & 0xf) << 0)
  72. #define FTMAC100_ITC_RXINT_THR(x) (((x) & 0x7) << 4)
  73. #define FTMAC100_ITC_RXINT_TIME_SEL (1 << 7)
  74. #define FTMAC100_ITC_TXINT_CNT(x) (((x) & 0xf) << 8)
  75. #define FTMAC100_ITC_TXINT_THR(x) (((x) & 0x7) << 12)
  76. #define FTMAC100_ITC_TXINT_TIME_SEL (1 << 15)
  77. /*
  78. * Automatic polling timer control register
  79. */
  80. #define FTMAC100_APTC_RXPOLL_CNT(x) (((x) & 0xf) << 0)
  81. #define FTMAC100_APTC_RXPOLL_TIME_SEL (1 << 4)
  82. #define FTMAC100_APTC_TXPOLL_CNT(x) (((x) & 0xf) << 8)
  83. #define FTMAC100_APTC_TXPOLL_TIME_SEL (1 << 12)
  84. /*
  85. * DMA burst length and arbitration control register
  86. */
  87. #define FTMAC100_DBLAC_INCR4_EN (1 << 0)
  88. #define FTMAC100_DBLAC_INCR8_EN (1 << 1)
  89. #define FTMAC100_DBLAC_INCR16_EN (1 << 2)
  90. #define FTMAC100_DBLAC_RXFIFO_LTHR(x) (((x) & 0x7) << 3)
  91. #define FTMAC100_DBLAC_RXFIFO_HTHR(x) (((x) & 0x7) << 6)
  92. #define FTMAC100_DBLAC_RX_THR_EN (1 << 9)
  93. /*
  94. * MAC control register
  95. */
  96. #define FTMAC100_MACCR_XDMA_EN (1 << 0)
  97. #define FTMAC100_MACCR_RDMA_EN (1 << 1)
  98. #define FTMAC100_MACCR_SW_RST (1 << 2)
  99. #define FTMAC100_MACCR_LOOP_EN (1 << 3)
  100. #define FTMAC100_MACCR_CRC_DIS (1 << 4)
  101. #define FTMAC100_MACCR_XMT_EN (1 << 5)
  102. #define FTMAC100_MACCR_ENRX_IN_HALFTX (1 << 6)
  103. #define FTMAC100_MACCR_RCV_EN (1 << 8)
  104. #define FTMAC100_MACCR_HT_MULTI_EN (1 << 9)
  105. #define FTMAC100_MACCR_RX_RUNT (1 << 10)
  106. #define FTMAC100_MACCR_RX_FTL (1 << 11)
  107. #define FTMAC100_MACCR_RCV_ALL (1 << 12)
  108. #define FTMAC100_MACCR_CRC_APD (1 << 14)
  109. #define FTMAC100_MACCR_FULLDUP (1 << 15)
  110. #define FTMAC100_MACCR_RX_MULTIPKT (1 << 16)
  111. #define FTMAC100_MACCR_RX_BROADPKT (1 << 17)
  112. /*
  113. * PHY control register
  114. */
  115. #define FTMAC100_PHYCR_MIIRDATA 0xffff
  116. #define FTMAC100_PHYCR_PHYAD(x) (((x) & 0x1f) << 16)
  117. #define FTMAC100_PHYCR_REGAD(x) (((x) & 0x1f) << 21)
  118. #define FTMAC100_PHYCR_MIIRD (1 << 26)
  119. #define FTMAC100_PHYCR_MIIWR (1 << 27)
  120. /*
  121. * PHY write data register
  122. */
  123. #define FTMAC100_PHYWDATA_MIIWDATA(x) ((x) & 0xffff)
  124. /*
  125. * Transmit descriptor, aligned to 16 bytes
  126. */
  127. struct ftmac100_txdes {
  128. unsigned int txdes0;
  129. unsigned int txdes1;
  130. unsigned int txdes2; /* TXBUF_BADR */
  131. unsigned int txdes3; /* not used by HW */
  132. } __attribute__ ((aligned(16)));
  133. #define FTMAC100_TXDES0_TXPKT_LATECOL (1 << 0)
  134. #define FTMAC100_TXDES0_TXPKT_EXSCOL (1 << 1)
  135. #define FTMAC100_TXDES0_TXDMA_OWN (1 << 31)
  136. #define FTMAC100_TXDES1_TXBUF_SIZE(x) ((x) & 0x7ff)
  137. #define FTMAC100_TXDES1_LTS (1 << 27)
  138. #define FTMAC100_TXDES1_FTS (1 << 28)
  139. #define FTMAC100_TXDES1_TX2FIC (1 << 29)
  140. #define FTMAC100_TXDES1_TXIC (1 << 30)
  141. #define FTMAC100_TXDES1_EDOTR (1 << 31)
  142. /*
  143. * Receive descriptor, aligned to 16 bytes
  144. */
  145. struct ftmac100_rxdes {
  146. unsigned int rxdes0;
  147. unsigned int rxdes1;
  148. unsigned int rxdes2; /* RXBUF_BADR */
  149. unsigned int rxdes3; /* not used by HW */
  150. } __attribute__ ((aligned(16)));
  151. #define FTMAC100_RXDES0_RFL 0x7ff
  152. #define FTMAC100_RXDES0_MULTICAST (1 << 16)
  153. #define FTMAC100_RXDES0_BROADCAST (1 << 17)
  154. #define FTMAC100_RXDES0_RX_ERR (1 << 18)
  155. #define FTMAC100_RXDES0_CRC_ERR (1 << 19)
  156. #define FTMAC100_RXDES0_FTL (1 << 20)
  157. #define FTMAC100_RXDES0_RUNT (1 << 21)
  158. #define FTMAC100_RXDES0_RX_ODD_NB (1 << 22)
  159. #define FTMAC100_RXDES0_LRS (1 << 28)
  160. #define FTMAC100_RXDES0_FRS (1 << 29)
  161. #define FTMAC100_RXDES0_RXDMA_OWN (1 << 31)
  162. #define FTMAC100_RXDES1_RXBUF_SIZE(x) ((x) & 0x7ff)
  163. #define FTMAC100_RXDES1_EDORR (1 << 31)
  164. #endif /* __FTMAC100_H */