ftmac110.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Faraday 10/100Mbps Ethernet Controller
  3. *
  4. * (C) Copyright 2010 Faraday Technology
  5. * Dante Su <dantesu@faraday-tech.com>
  6. *
  7. * This file is released under the terms of GPL v2 and any later version.
  8. * See the file COPYING in the root directory of the source tree for details.
  9. */
  10. #ifndef _FTMAC110_H
  11. #define _FTMAC110_H
  12. struct ftmac110_regs {
  13. uint32_t isr; /* 0x00: Interrups Status Register */
  14. uint32_t imr; /* 0x04: Interrupt Mask Register */
  15. uint32_t mac[2]; /* 0x08: MAC Address */
  16. uint32_t mht[2]; /* 0x10: Multicast Hash Table Register */
  17. uint32_t txpd; /* 0x18: Tx Poll Demand Register */
  18. uint32_t rxpd; /* 0x1c: Rx Poll Demand Register */
  19. uint32_t txba; /* 0x20: Tx Ring Base Address Register */
  20. uint32_t rxba; /* 0x24: Rx Ring Base Address Register */
  21. uint32_t itc; /* 0x28: Interrupt Timer Control Register */
  22. uint32_t aptc; /* 0x2C: Automatic Polling Timer Control Register */
  23. uint32_t dblac; /* 0x30: DMA Burst Length&Arbitration Control */
  24. uint32_t revr; /* 0x34: Revision Register */
  25. uint32_t fear; /* 0x38: Feature Register */
  26. uint32_t rsvd[19];
  27. uint32_t maccr; /* 0x88: MAC Control Register */
  28. uint32_t macsr; /* 0x8C: MAC Status Register */
  29. uint32_t phycr; /* 0x90: PHY Control Register */
  30. uint32_t phydr; /* 0x94: PHY Data Register */
  31. uint32_t fcr; /* 0x98: Flow Control Register */
  32. uint32_t bpr; /* 0x9C: Back Pressure Register */
  33. };
  34. /*
  35. * Interrupt status/mask register(ISR/IMR) bits
  36. */
  37. #define ISR_ALL 0x3ff
  38. #define ISR_PHYSTCHG (1 << 9) /* phy status change */
  39. #define ISR_AHBERR (1 << 8) /* bus error */
  40. #define ISR_RXLOST (1 << 7) /* rx lost */
  41. #define ISR_RXFIFO (1 << 6) /* rx to fifo */
  42. #define ISR_TXLOST (1 << 5) /* tx lost */
  43. #define ISR_TXOK (1 << 4) /* tx to ethernet */
  44. #define ISR_NOTXBUF (1 << 3) /* out of tx buffer */
  45. #define ISR_TXFIFO (1 << 2) /* tx to fifo */
  46. #define ISR_NORXBUF (1 << 1) /* out of rx buffer */
  47. #define ISR_RXOK (1 << 0) /* rx to buffer */
  48. /*
  49. * MACCR control bits
  50. */
  51. #define MACCR_100M (1 << 18) /* 100Mbps mode */
  52. #define MACCR_RXBCST (1 << 17) /* rx broadcast packet */
  53. #define MACCR_RXMCST (1 << 16) /* rx multicast packet */
  54. #define MACCR_FD (1 << 15) /* full duplex */
  55. #define MACCR_CRCAPD (1 << 14) /* tx crc append */
  56. #define MACCR_RXALL (1 << 12) /* rx all packets */
  57. #define MACCR_RXFTL (1 << 11) /* rx packet even it's > 1518 byte */
  58. #define MACCR_RXRUNT (1 << 10) /* rx packet even it's < 64 byte */
  59. #define MACCR_RXMCSTHT (1 << 9) /* rx multicast hash table */
  60. #define MACCR_RXEN (1 << 8) /* rx enable */
  61. #define MACCR_RXINHDTX (1 << 6) /* rx in half duplex tx */
  62. #define MACCR_TXEN (1 << 5) /* tx enable */
  63. #define MACCR_CRCDIS (1 << 4) /* tx packet even it's crc error */
  64. #define MACCR_LOOPBACK (1 << 3) /* loop-back */
  65. #define MACCR_RESET (1 << 2) /* reset */
  66. #define MACCR_RXDMAEN (1 << 1) /* rx dma enable */
  67. #define MACCR_TXDMAEN (1 << 0) /* tx dma enable */
  68. /*
  69. * PHYCR control bits
  70. */
  71. #define PHYCR_READ (1 << 26)
  72. #define PHYCR_WRITE (1 << 27)
  73. #define PHYCR_REG_SHIFT 21
  74. #define PHYCR_ADDR_SHIFT 16
  75. /*
  76. * ITC control bits
  77. */
  78. /* Tx Cycle Length */
  79. #define ITC_TX_CYCLONG (1 << 15) /* 100Mbps=81.92us; 10Mbps=819.2us */
  80. #define ITC_TX_CYCNORM (0 << 15) /* 100Mbps=5.12us; 10Mbps=51.2us */
  81. /* Tx Threshold: Aggregate n interrupts as 1 interrupt */
  82. #define ITC_TX_THR(n) (((n) & 0x7) << 12)
  83. /* Tx Interrupt Timeout = n * Tx Cycle */
  84. #define ITC_TX_ITMO(n) (((n) & 0xf) << 8)
  85. /* Rx Cycle Length */
  86. #define ITC_RX_CYCLONG (1 << 7) /* 100Mbps=81.92us; 10Mbps=819.2us */
  87. #define ITC_RX_CYCNORM (0 << 7) /* 100Mbps=5.12us; 10Mbps=51.2us */
  88. /* Rx Threshold: Aggregate n interrupts as 1 interrupt */
  89. #define ITC_RX_THR(n) (((n) & 0x7) << 4)
  90. /* Rx Interrupt Timeout = n * Rx Cycle */
  91. #define ITC_RX_ITMO(n) (((n) & 0xf) << 0)
  92. #define ITC_DEFAULT \
  93. (ITC_TX_THR(1) | ITC_TX_ITMO(0) | ITC_RX_THR(1) | ITC_RX_ITMO(0))
  94. /*
  95. * APTC contrl bits
  96. */
  97. /* Tx Cycle Length */
  98. #define APTC_TX_CYCLONG (1 << 12) /* 100Mbps=81.92us; 10Mbps=819.2us */
  99. #define APTC_TX_CYCNORM (0 << 12) /* 100Mbps=5.12us; 10Mbps=51.2us */
  100. /* Tx Poll Timeout = n * Tx Cycle, 0=No auto polling */
  101. #define APTC_TX_PTMO(n) (((n) & 0xf) << 8)
  102. /* Rx Cycle Length */
  103. #define APTC_RX_CYCLONG (1 << 4) /* 100Mbps=81.92us; 10Mbps=819.2us */
  104. #define APTC_RX_CYCNORM (0 << 4) /* 100Mbps=5.12us; 10Mbps=51.2us */
  105. /* Rx Poll Timeout = n * Rx Cycle, 0=No auto polling */
  106. #define APTC_RX_PTMO(n) (((n) & 0xf) << 0)
  107. #define APTC_DEFAULT (APTC_TX_PTMO(0) | APTC_RX_PTMO(1))
  108. /*
  109. * DBLAC contrl bits
  110. */
  111. #define DBLAC_BURST_MAX_ANY (0 << 14) /* un-limited */
  112. #define DBLAC_BURST_MAX_32X4 (2 << 14) /* max = 32 x 4 bytes */
  113. #define DBLAC_BURST_MAX_64X4 (3 << 14) /* max = 64 x 4 bytes */
  114. #define DBLAC_RXTHR_EN (1 << 9) /* enable rx threshold arbitration */
  115. #define DBLAC_RXTHR_HIGH(n) (((n) & 0x7) << 6) /* upper bound = n/8 fifo */
  116. #define DBLAC_RXTHR_LOW(n) (((n) & 0x7) << 3) /* lower bound = n/8 fifo */
  117. #define DBLAC_BURST_CAP16 (1 << 2) /* support burst 16 */
  118. #define DBLAC_BURST_CAP8 (1 << 1) /* support burst 8 */
  119. #define DBLAC_BURST_CAP4 (1 << 0) /* support burst 4 */
  120. #define DBLAC_DEFAULT \
  121. (DBLAC_RXTHR_EN | DBLAC_RXTHR_HIGH(6) | DBLAC_RXTHR_LOW(2))
  122. /*
  123. * descriptor structure
  124. */
  125. struct ftmac110_rxd {
  126. uint32_t ct[2];
  127. uint32_t buf;
  128. void *vbuf; /* reserved */
  129. };
  130. #define FTMAC110_RXCT0_OWNER BIT_MASK(31) /* owner: 1=HW, 0=SW */
  131. #define FTMAC110_RXCT0_FRS BIT_MASK(29) /* first pkt desc */
  132. #define FTMAC110_RXCT0_LRS BIT_MASK(28) /* last pkt desc */
  133. #define FTMAC110_RXCT0_ODDNB BIT_MASK(22) /* odd nibble */
  134. #define FTMAC110_RXCT0_RUNT BIT_MASK(21) /* runt pkt */
  135. #define FTMAC110_RXCT0_FTL BIT_MASK(20) /* frame too long */
  136. #define FTMAC110_RXCT0_CRC BIT_MASK(19) /* pkt crc error */
  137. #define FTMAC110_RXCT0_ERR BIT_MASK(18) /* bus error */
  138. #define FTMAC110_RXCT0_ERRMASK (0x1f << 18) /* all errors */
  139. #define FTMAC110_RXCT0_BCST BIT_MASK(17) /* Bcst pkt */
  140. #define FTMAC110_RXCT0_MCST BIT_MASK(16) /* Mcst pkt */
  141. #define FTMAC110_RXCT0_LEN(x) ((x) & 0x7ff)
  142. #define FTMAC110_RXCT1_END BIT_MASK(31)
  143. #define FTMAC110_RXCT1_BUFSZ(x) ((x) & 0x7ff)
  144. struct ftmac110_txd {
  145. uint32_t ct[2];
  146. uint32_t buf;
  147. void *vbuf; /* reserved */
  148. };
  149. #define FTMAC110_TXCT0_OWNER BIT_MASK(31) /* owner: 1=HW, 0=SW */
  150. #define FTMAC110_TXCT0_COL 0x00000003 /* collision */
  151. #define FTMAC110_TXCT1_END BIT_MASK(31) /* end of ring */
  152. #define FTMAC110_TXCT1_TXIC BIT_MASK(30) /* tx done interrupt */
  153. #define FTMAC110_TXCT1_TX2FIC BIT_MASK(29) /* tx fifo interrupt */
  154. #define FTMAC110_TXCT1_FTS BIT_MASK(28) /* first pkt desc */
  155. #define FTMAC110_TXCT1_LTS BIT_MASK(27) /* last pkt desc */
  156. #define FTMAC110_TXCT1_LEN(x) ((x) & 0x7ff)
  157. #endif /* FTMAC110_H */