fsl_dtsec.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * Copyright 2009-2011 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17. * MA 02111-1307 USA
  18. */
  19. #ifndef __DTSEC_H__
  20. #define __DTSEC_H__
  21. #include <asm/types.h>
  22. struct dtsec {
  23. u32 tsec_id; /* controller ID and version */
  24. u32 tsec_id2; /* controller ID and configuration */
  25. u32 ievent; /* interrupt event */
  26. u32 imask; /* interrupt mask */
  27. u32 res0;
  28. u32 ecntrl; /* ethernet control and configuration */
  29. u32 ptv; /* pause time value */
  30. u32 tbipa; /* TBI PHY address */
  31. u32 res1[8];
  32. u32 tctrl; /* Transmit control register */
  33. u32 res2[3];
  34. u32 rctrl; /* Receive control register */
  35. u32 res3[11];
  36. u32 igaddr[8]; /* Individual group address */
  37. u32 gaddr[8]; /* group address */
  38. u32 res4[16];
  39. u32 maccfg1; /* MAC configuration register 1 */
  40. u32 maccfg2; /* MAC configuration register 2 */
  41. u32 ipgifg; /* inter-packet/inter-frame gap */
  42. u32 hafdup; /* half-duplex control */
  43. u32 maxfrm; /* Maximum frame size */
  44. u32 res5[3];
  45. u32 miimcfg; /* MII management configuration */
  46. u32 miimcom; /* MII management command */
  47. u32 miimadd; /* MII management address */
  48. u32 miimcon; /* MII management control */
  49. u32 miimstat; /* MII management status */
  50. u32 miimind; /* MII management indicator */
  51. u32 res6;
  52. u32 ifstat; /* Interface status */
  53. u32 macstnaddr1; /* MAC station address 1 */
  54. u32 macstnaddr2; /* MAC station address 2 */
  55. u32 res7[46];
  56. /* transmit and receive counter */
  57. u32 tr64; /* Tx and Rx 64 bytes frame */
  58. u32 tr127; /* Tx and Rx 65 to 127 bytes frame */
  59. u32 tr255; /* Tx and Rx 128 to 255 bytes frame */
  60. u32 tr511; /* Tx and Rx 256 to 511 bytes frame */
  61. u32 tr1k; /* Tx and Rx 512 to 1023 bytes frame */
  62. u32 trmax; /* Tx and Rx 1024 to 1518 bytes frame */
  63. u32 trmgv; /* Tx and Rx 1519 to 1522 good VLAN frame */
  64. /* receive counters */
  65. u32 rbyt; /* Receive byte counter */
  66. u32 rpkt; /* Receive packet counter */
  67. u32 rfcs; /* Receive FCS error */
  68. u32 rmca; /* Receive multicast packet */
  69. u32 rbca; /* Receive broadcast packet */
  70. u32 rxcf; /* Receive control frame */
  71. u32 rxpf; /* Receive pause frame */
  72. u32 rxuo; /* Receive unknown OP code */
  73. u32 raln; /* Receive alignment error */
  74. u32 rflr; /* Receive frame length error */
  75. u32 rcde; /* Receive code error */
  76. u32 rcse; /* Receive carrier sense error */
  77. u32 rund; /* Receive undersize packet */
  78. u32 rovr; /* Receive oversize packet */
  79. u32 rfrg; /* Receive fragments counter */
  80. u32 rjbr; /* Receive jabber counter */
  81. u32 rdrp; /* Receive drop counter */
  82. /* transmit counters */
  83. u32 tbyt; /* Transmit byte counter */
  84. u32 tpkt; /* Transmit packet */
  85. u32 tmca; /* Transmit multicast packet */
  86. u32 tbca; /* Transmit broadcast packet */
  87. u32 txpf; /* Transmit pause control frame */
  88. u32 tdfr; /* Transmit deferral packet */
  89. u32 tedf; /* Transmit excessive deferral pkt */
  90. u32 tscl; /* Transmit single collision pkt */
  91. u32 tmcl; /* Transmit multiple collision pkt */
  92. u32 tlcl; /* Transmit late collision pkt */
  93. u32 txcl; /* Transmit excessive collision */
  94. u32 tncl; /* Transmit total collision */
  95. u32 res8;
  96. u32 tdrp; /* Transmit drop frame */
  97. u32 tjbr; /* Transmit jabber frame */
  98. u32 tfcs; /* Transmit FCS error */
  99. u32 txcf; /* Transmit control frame */
  100. u32 tovr; /* Transmit oversize frame */
  101. u32 tund; /* Transmit undersize frame */
  102. u32 tfrg; /* Transmit fragments frame */
  103. /* counter controls */
  104. u32 car1; /* carry register 1 */
  105. u32 car2; /* carry register 2 */
  106. u32 cam1; /* carry register 1 mask */
  107. u32 cam2; /* carry register 2 mask */
  108. u32 res9[80];
  109. };
  110. /* TBI register addresses */
  111. #define TBI_CR 0x00
  112. #define TBI_SR 0x01
  113. #define TBI_ANA 0x04
  114. #define TBI_ANLPBPA 0x05
  115. #define TBI_ANEX 0x06
  116. #define TBI_TBICON 0x11
  117. /* TBI MDIO register bit fields*/
  118. #define TBICON_CLK_SELECT 0x0020
  119. #define TBIANA_ASYMMETRIC_PAUSE 0x0100
  120. #define TBIANA_SYMMETRIC_PAUSE 0x0080
  121. #define TBIANA_HALF_DUPLEX 0x0040
  122. #define TBIANA_FULL_DUPLEX 0x0020
  123. #define TBICR_PHY_RESET 0x8000
  124. #define TBICR_ANEG_ENABLE 0x1000
  125. #define TBICR_RESTART_ANEG 0x0200
  126. #define TBICR_FULL_DUPLEX 0x0100
  127. #define TBICR_SPEED1_SET 0x0040
  128. /* IEVENT - interrupt events register */
  129. #define IEVENT_BABR 0x80000000 /* Babbling receive error */
  130. #define IEVENT_RXC 0x40000000 /* pause control frame received */
  131. #define IEVENT_MSRO 0x04000000 /* MIB counter overflow */
  132. #define IEVENT_GTSC 0x02000000 /* Graceful transmit stop complete */
  133. #define IEVENT_BABT 0x01000000 /* Babbling transmit error */
  134. #define IEVENT_TXC 0x00800000 /* control frame transmitted */
  135. #define IEVENT_TXE 0x00400000 /* Transmit channel error */
  136. #define IEVENT_LC 0x00040000 /* Late collision occurred */
  137. #define IEVENT_CRL 0x00020000 /* Collision retry exceed limit */
  138. #define IEVENT_XFUN 0x00010000 /* Transmit FIFO underrun */
  139. #define IEVENT_ABRT 0x00008000 /* Transmit packet abort */
  140. #define IEVENT_MMRD 0x00000400 /* MII management read complete */
  141. #define IEVENT_MMWR 0x00000200 /* MII management write complete */
  142. #define IEVENT_GRSC 0x00000100 /* Graceful stop complete */
  143. #define IEVENT_TDPE 0x00000002 /* Internal data parity error on Tx */
  144. #define IEVENT_RDPE 0x00000001 /* Internal data parity error on Rx */
  145. #define IEVENT_CLEAR_ALL 0xffffffff
  146. /* IMASK - interrupt mask register */
  147. #define IMASK_BREN 0x80000000 /* Babbling receive enable */
  148. #define IMASK_RXCEN 0x40000000 /* receive control enable */
  149. #define IMASK_MSROEN 0x04000000 /* MIB counter overflow enable */
  150. #define IMASK_GTSCEN 0x02000000 /* Graceful Tx stop complete enable */
  151. #define IMASK_BTEN 0x01000000 /* Babbling transmit error enable */
  152. #define IMASK_TXCEN 0x00800000 /* control frame transmitted enable */
  153. #define IMASK_TXEEN 0x00400000 /* Transmit channel error enable */
  154. #define IMASK_LCEN 0x00040000 /* Late collision interrupt enable */
  155. #define IMASK_CRLEN 0x00020000 /* Collision retry exceed limit */
  156. #define IMASK_XFUNEN 0x00010000 /* Transmit FIFO underrun enable */
  157. #define IMASK_ABRTEN 0x00008000 /* Transmit packet abort enable */
  158. #define IMASK_MMRDEN 0x00000400 /* MII management read complete enable */
  159. #define IMASK_MMWREN 0x00000200 /* MII management write complete enable */
  160. #define IMASK_GRSCEN 0x00000100 /* Graceful stop complete interrupt enable */
  161. #define IMASK_TDPEEN 0x00000002 /* Internal data parity error on Tx enable */
  162. #define IMASK_RDPEEN 0x00000001 /* Internal data parity error on Rx enable */
  163. #define IMASK_MASK_ALL 0x00000000
  164. /* ECNTRL - ethernet control register */
  165. #define ECNTRL_CFG_RO 0x80000000 /* GMIIM, RPM, R100M, SGMIIM bits are RO */
  166. #define ECNTRL_CLRCNT 0x00004000 /* clear all statistics */
  167. #define ECNTRL_AUTOZ 0x00002000 /* auto zero MIB counter */
  168. #define ECNTRL_STEN 0x00001000 /* enable internal counters to update */
  169. #define ECNTRL_GMIIM 0x00000040 /* 1- GMII or RGMII interface mode */
  170. #define ECNTRL_TBIM 0x00000020 /* 1- Ten-bit interface mode */
  171. #define ECNTRL_RPM 0x00000010 /* 1- RGMII reduced-pin mode */
  172. #define ECNTRL_R100M 0x00000008 /* 1- RGMII 100 Mbps, SGMII 100 Mbps
  173. 0- RGMII 10 Mbps, SGMII 10 Mbps */
  174. #define ECNTRL_SGMIIM 0x00000002 /* 1- SGMII interface mode */
  175. #define ECNTRL_TBIM 0x00000020 /* 1- TBI Interface mode (for SGMII) */
  176. #define ECNTRL_DEFAULT (ECNTRL_TBIM | ECNTRL_R100M | ECNTRL_SGMIIM)
  177. /* TCTRL - Transmit control register */
  178. #define TCTRL_THDF 0x00000800 /* Transmit half-duplex flow control */
  179. #define TCTRL_TTSE 0x00000040 /* Transmit time-stamp enable */
  180. #define TCTRL_GTS 0x00000020 /* Graceful transmit stop */
  181. #define TCTRL_RFC_PAUSE 0x00000010 /* Receive flow control pause frame */
  182. /* RCTRL - Receive control register */
  183. #define RCTRL_PAL_MASK 0x001f0000 /* packet alignment padding length */
  184. #define RCTRL_PAL_SHIFT 16
  185. #define RCTRL_CFA 0x00008000 /* control frame accept enable */
  186. #define RCTRL_GHTX 0x00000800 /* group address hash table extend */
  187. #define RCTRL_RTSE 0x00000040 /* receive 1588 time-stamp enable */
  188. #define RCTRL_GRS 0x00000020 /* graceful receive stop */
  189. #define RCTRL_BC_REJ 0x00000010 /* broadcast frame reject */
  190. #define RCTRL_BC_MPROM 0x00000008 /* all multicast/broadcast frames received */
  191. #define RCTRL_RSF 0x00000004 /* receive short frame(17~63 bytes) enable */
  192. #define RCTRL_EMEN 0x00000002 /* Exact match MAC address enable */
  193. #define RCTRL_UPROM 0x00000001 /* all unicast frame received */
  194. /* MACCFG1 - MAC configuration 1 register */
  195. #define MACCFG1_SOFT_RST 0x80000000 /* place the MAC in reset */
  196. #define MACCFG1_RST_RXMAC 0x00080000 /* reset receive MAC control block */
  197. #define MACCFG1_RST_TXMAC 0x00040000 /* reet transmit MAC control block */
  198. #define MACCFG1_RST_RXFUN 0x00020000 /* reset receive function block */
  199. #define MACCFG1_RST_TXFUN 0x00010000 /* reset transmit function block */
  200. #define MACCFG1_LOOPBACK 0x00000100 /* MAC loopback */
  201. #define MACCFG1_RX_FLOW 0x00000020 /* Receive flow */
  202. #define MACCFG1_TX_FLOW 0x00000010 /* Transmit flow */
  203. #define MACCFG1_SYNC_RXEN 0x00000008 /* Frame reception enabled */
  204. #define MACCFG1_RX_EN 0x00000004 /* Rx enable */
  205. #define MACCFG1_SYNC_TXEN 0x00000002 /* Frame transmission is enabled */
  206. #define MACCFG1_TX_EN 0x00000001 /* Tx enable */
  207. #define MACCFG1_RXTX_EN (MACCFG1_RX_EN | MACCFG1_TX_EN)
  208. /* MACCFG2 - MAC configuration 2 register */
  209. #define MACCFG2_PRE_LEN_MASK 0x0000f000 /* preamble length */
  210. #define MACCFG2_PRE_LEN(x) ((x << 12) & MACCFG2_PRE_LEN_MASK)
  211. #define MACCFG2_IF_MODE_MASK 0x00000300
  212. #define MACCFG2_IF_MODE_NIBBLE 0x00000100 /* MII, 10/100 Mbps MII/RMII */
  213. #define MACCFG2_IF_MODE_BYTE 0x00000200 /* GMII/TBI, 1000 GMII/TBI */
  214. #define MACCFG2_PRE_RX_EN 0x00000080 /* receive preamble enable */
  215. #define MACCFG2_PRE_TX_EN 0x00000040 /* tx preable enable */
  216. #define MACCFG2_HUGE_FRAME 0x00000020 /* >= max frame len enable */
  217. #define MACCFG2_LEN_CHECK 0x00000010 /* MAC check frame's length Rx */
  218. #define MACCFG2_MAG_EN 0x00000008 /* magic packet enable */
  219. #define MACCFG2_PAD_CRC 0x00000004 /* pad and append CRC */
  220. #define MACCFG2_CRC_EN 0x00000002 /* MAC appends a CRC on all frames */
  221. #define MACCFG2_FULL_DUPLEX 0x00000001 /* Full deplex mode */
  222. struct fsl_enet_mac;
  223. void init_dtsec(struct fsl_enet_mac *mac, void *base, void *phyregs,
  224. int max_rx_len);
  225. #endif