tsec.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. /*
  2. * tsec.h
  3. *
  4. * Driver for the Motorola Triple Speed Ethernet Controller
  5. *
  6. * This software may be used and distributed according to the
  7. * terms of the GNU Public License, Version 2, incorporated
  8. * herein by reference.
  9. *
  10. * (C) Copyright 2003, Motorola, Inc.
  11. * maintained by Xianghua Xiao (x.xiao@motorola.com)
  12. * author Andy Fleming
  13. *
  14. */
  15. #ifndef __TSEC_H
  16. #define __TSEC_H
  17. #include <net.h>
  18. #include <mpc85xx.h>
  19. #define TSEC_BASE_ADDR (CFG_IMMR + 0x24000)
  20. #define TSEC_MEM_SIZE 0x01000
  21. #define MAC_ADDR_LEN 6
  22. #define TSEC_TIMEOUT 1000000
  23. #define TOUT_LOOP 1000000
  24. /* MAC register bits */
  25. #define MACCFG1_SOFT_RESET 0x80000000
  26. #define MACCFG1_RESET_RX_MC 0x00080000
  27. #define MACCFG1_RESET_TX_MC 0x00040000
  28. #define MACCFG1_RESET_RX_FUN 0x00020000
  29. #define MACCFG1_RESET_TX_FUN 0x00010000
  30. #define MACCFG1_LOOPBACK 0x00000100
  31. #define MACCFG1_RX_FLOW 0x00000020
  32. #define MACCFG1_TX_FLOW 0x00000010
  33. #define MACCFG1_SYNCD_RX_EN 0x00000008
  34. #define MACCFG1_RX_EN 0x00000004
  35. #define MACCFG1_SYNCD_TX_EN 0x00000002
  36. #define MACCFG1_TX_EN 0x00000001
  37. #define MACCFG2_INIT_SETTINGS 0x00007205
  38. #define MACCFG2_FULL_DUPLEX 0x00000001
  39. #define MACCFG2_IF 0x00000300
  40. #define MACCFG2_MII 0x00000100
  41. #define ECNTRL_INIT_SETTINGS 0x00001000
  42. #define ECNTRL_TBI_MODE 0x00000020
  43. #define TBIPA_VALUE 0x1f
  44. #define MIIMCFG_INIT_VALUE 0x00000003
  45. #define MIIMCFG_RESET 0x80000000
  46. #define MIIMIND_BUSY 0x00000001
  47. #define MIIMIND_NOTVALID 0x00000004
  48. #define MIIM_TBICON 0x11
  49. #define MIIM_TBICON_GMII 0x00000010
  50. #define MIIM_TBICON_AN 0x00000100
  51. #define MIIM_CONTROL 0x00
  52. #define MIIM_CONTROL_INIT 0x00001140
  53. #define MIIM_ANEN 0x00001000
  54. #define MIIM_TBI_STATUS 0x1
  55. #define MIIM_TBI_STATUS_AN_DONE 0x00000020
  56. #define MIIM_TBI_ANEX 0x6
  57. #define MIIM_TBI_ANEX_NP 0x00000004
  58. #define MIIM_TBI_ANEX_PRX 0x00000002
  59. #define MIIM_TBI_ANLPBPA 0x5
  60. #define MIIM_TBI_ANLPBPA_HALF 0x00000040
  61. #define MIIM_TBI_ANLPBPA_FULL 0x00000020
  62. #ifdef CONFIG_PHY_CIS8201
  63. #define MIIM_AUX_CONSTAT 0x1c
  64. #define MIIM_AUXCONSTAT_INIT 0x0004
  65. #define MIIM_AUXCONSTAT_DUPLEX 0x0020
  66. #define MIIM_AUXCONSTAT_SPEED 0x0018
  67. #define MIIM_AUXCONSTAT_GBIT 0x0010
  68. #define MIIM_AUXCONSTAT_100 0x0008
  69. #define MIIM_EXT_CON1 0x17
  70. #define MIIM_EXTCON1_INIT 0x0000
  71. #endif
  72. #ifdef CONFIG_PHY_M88E1011
  73. #define MIIM_ANAR 0x04
  74. #define MIIM_ANAR_ADVERTISEMENT 0x01e1
  75. #define MIIM_GBIT_CON 0x09
  76. #define MIIM_GBIT_CON_ADVERT 0x1e00
  77. #define MIIM_PHY_STATUS 0x11
  78. #define MIIM_PHYSTAT_SPEED 0xc000
  79. #define MIIM_PHYSTAT_GBIT 0x8000
  80. #define MIIM_PHYSTAT_100 0x4000
  81. #define MIIM_PHYSTAT_DUPLEX 0x2000
  82. #define MIIM_PHYSTAT_SPDDONE 0x0800
  83. #define MIIM_PHYSTAT_LINK 0x0400
  84. #endif
  85. #define MIIM_READ_COMMAND 0x00000001
  86. #define MRBLR_INIT_SETTINGS PKTSIZE_ALIGN
  87. #define MINFLR_INIT_SETTINGS 0x00000040
  88. #define DMACTRL_INIT_SETTINGS 0x000000c3
  89. #define DMACTRL_GRS 0x00000010
  90. #define DMACTRL_GTS 0x00000008
  91. #define TSTAT_CLEAR_THALT 0x80000000
  92. #define RSTAT_CLEAR_RHALT 0x00800000
  93. /* Write value to the PHY at phyid to the register at offset, */
  94. /* using the register space defined in regbase. Note that */
  95. /* miimcfg needs to have the clock speed setup correctly. This */
  96. /* macro will wait until the write is done before it finishes */
  97. #define write_phy_reg(regbase, phyid, offset, value) do { \
  98. int timeout=1000000; \
  99. regbase->miimadd = (phyid << 8) | offset; \
  100. regbase->miimcon = value; \
  101. asm("msync"); \
  102. while((regbase->miimind & MIIMIND_BUSY) && timeout--); \
  103. } while(0)
  104. #define IEVENT_INIT_CLEAR 0xffffffff
  105. #define IEVENT_BABR 0x80000000
  106. #define IEVENT_RXC 0x40000000
  107. #define IEVENT_BSY 0x20000000
  108. #define IEVENT_EBERR 0x10000000
  109. #define IEVENT_MSRO 0x04000000
  110. #define IEVENT_GTSC 0x02000000
  111. #define IEVENT_BABT 0x01000000
  112. #define IEVENT_TXC 0x00800000
  113. #define IEVENT_TXE 0x00400000
  114. #define IEVENT_TXB 0x00200000
  115. #define IEVENT_TXF 0x00100000
  116. #define IEVENT_IE 0x00080000
  117. #define IEVENT_LC 0x00040000
  118. #define IEVENT_CRL 0x00020000
  119. #define IEVENT_XFUN 0x00010000
  120. #define IEVENT_RXB0 0x00008000
  121. #define IEVENT_GRSC 0x00000100
  122. #define IEVENT_RXF0 0x00000080
  123. #define IMASK_INIT_CLEAR 0x00000000
  124. #define IMASK_TXEEN 0x00400000
  125. #define IMASK_TXBEN 0x00200000
  126. #define IMASK_TXFEN 0x00100000
  127. #define IMASK_RXFEN0 0x00000080
  128. /* Default Attribute fields */
  129. #define ATTR_INIT_SETTINGS 0x000000c0
  130. #define ATTRELI_INIT_SETTINGS 0x00000000
  131. /* TxBD status field bits */
  132. #define TXBD_READY 0x8000
  133. #define TXBD_PADCRC 0x4000
  134. #define TXBD_WRAP 0x2000
  135. #define TXBD_INTERRUPT 0x1000
  136. #define TXBD_LAST 0x0800
  137. #define TXBD_CRC 0x0400
  138. #define TXBD_DEF 0x0200
  139. #define TXBD_HUGEFRAME 0x0080
  140. #define TXBD_LATECOLLISION 0x0080
  141. #define TXBD_RETRYLIMIT 0x0040
  142. #define TXBD_RETRYCOUNTMASK 0x003c
  143. #define TXBD_UNDERRUN 0x0002
  144. #define TXBD_STATS 0x03ff
  145. /* RxBD status field bits */
  146. #define RXBD_EMPTY 0x8000
  147. #define RXBD_RO1 0x4000
  148. #define RXBD_WRAP 0x2000
  149. #define RXBD_INTERRUPT 0x1000
  150. #define RXBD_LAST 0x0800
  151. #define RXBD_FIRST 0x0400
  152. #define RXBD_MISS 0x0100
  153. #define RXBD_BROADCAST 0x0080
  154. #define RXBD_MULTICAST 0x0040
  155. #define RXBD_LARGE 0x0020
  156. #define RXBD_NONOCTET 0x0010
  157. #define RXBD_SHORT 0x0008
  158. #define RXBD_CRCERR 0x0004
  159. #define RXBD_OVERRUN 0x0002
  160. #define RXBD_TRUNCATED 0x0001
  161. #define RXBD_STATS 0x003f
  162. typedef struct txbd8
  163. {
  164. ushort status; /* Status Fields */
  165. ushort length; /* Buffer length */
  166. uint bufPtr; /* Buffer Pointer */
  167. } txbd8_t;
  168. typedef struct rxbd8
  169. {
  170. ushort status; /* Status Fields */
  171. ushort length; /* Buffer Length */
  172. uint bufPtr; /* Buffer Pointer */
  173. } rxbd8_t;
  174. typedef struct rmon_mib
  175. {
  176. /* Transmit and Receive Counters */
  177. uint tr64; /* Transmit and Receive 64-byte Frame Counter */
  178. uint tr127; /* Transmit and Receive 65-127 byte Frame Counter */
  179. uint tr255; /* Transmit and Receive 128-255 byte Frame Counter */
  180. uint tr511; /* Transmit and Receive 256-511 byte Frame Counter */
  181. uint tr1k; /* Transmit and Receive 512-1023 byte Frame Counter */
  182. uint trmax; /* Transmit and Receive 1024-1518 byte Frame Counter */
  183. uint trmgv; /* Transmit and Receive 1519-1522 byte Good VLAN Frame */
  184. /* Receive Counters */
  185. uint rbyt; /* Receive Byte Counter */
  186. uint rpkt; /* Receive Packet Counter */
  187. uint rfcs; /* Receive FCS Error Counter */
  188. uint rmca; /* Receive Multicast Packet (Counter) */
  189. uint rbca; /* Receive Broadcast Packet */
  190. uint rxcf; /* Receive Control Frame Packet */
  191. uint rxpf; /* Receive Pause Frame Packet */
  192. uint rxuo; /* Receive Unknown OP Code */
  193. uint raln; /* Receive Alignment Error */
  194. uint rflr; /* Receive Frame Length Error */
  195. uint rcde; /* Receive Code Error */
  196. uint rcse; /* Receive Carrier Sense Error */
  197. uint rund; /* Receive Undersize Packet */
  198. uint rovr; /* Receive Oversize Packet */
  199. uint rfrg; /* Receive Fragments */
  200. uint rjbr; /* Receive Jabber */
  201. uint rdrp; /* Receive Drop */
  202. /* Transmit Counters */
  203. uint tbyt; /* Transmit Byte Counter */
  204. uint tpkt; /* Transmit Packet */
  205. uint tmca; /* Transmit Multicast Packet */
  206. uint tbca; /* Transmit Broadcast Packet */
  207. uint txpf; /* Transmit Pause Control Frame */
  208. uint tdfr; /* Transmit Deferral Packet */
  209. uint tedf; /* Transmit Excessive Deferral Packet */
  210. uint tscl; /* Transmit Single Collision Packet */
  211. /* (0x2_n700) */
  212. uint tmcl; /* Transmit Multiple Collision Packet */
  213. uint tlcl; /* Transmit Late Collision Packet */
  214. uint txcl; /* Transmit Excessive Collision Packet */
  215. uint tncl; /* Transmit Total Collision */
  216. uint res2;
  217. uint tdrp; /* Transmit Drop Frame */
  218. uint tjbr; /* Transmit Jabber Frame */
  219. uint tfcs; /* Transmit FCS Error */
  220. uint txcf; /* Transmit Control Frame */
  221. uint tovr; /* Transmit Oversize Frame */
  222. uint tund; /* Transmit Undersize Frame */
  223. uint tfrg; /* Transmit Fragments Frame */
  224. /* General Registers */
  225. uint car1; /* Carry Register One */
  226. uint car2; /* Carry Register Two */
  227. uint cam1; /* Carry Register One Mask */
  228. uint cam2; /* Carry Register Two Mask */
  229. } rmon_mib_t;
  230. typedef struct tsec_hash_regs
  231. {
  232. uint iaddr0; /* Individual Address Register 0 */
  233. uint iaddr1; /* Individual Address Register 1 */
  234. uint iaddr2; /* Individual Address Register 2 */
  235. uint iaddr3; /* Individual Address Register 3 */
  236. uint iaddr4; /* Individual Address Register 4 */
  237. uint iaddr5; /* Individual Address Register 5 */
  238. uint iaddr6; /* Individual Address Register 6 */
  239. uint iaddr7; /* Individual Address Register 7 */
  240. uint res1[24];
  241. uint gaddr0; /* Group Address Register 0 */
  242. uint gaddr1; /* Group Address Register 1 */
  243. uint gaddr2; /* Group Address Register 2 */
  244. uint gaddr3; /* Group Address Register 3 */
  245. uint gaddr4; /* Group Address Register 4 */
  246. uint gaddr5; /* Group Address Register 5 */
  247. uint gaddr6; /* Group Address Register 6 */
  248. uint gaddr7; /* Group Address Register 7 */
  249. uint res2[24];
  250. } tsec_hash_t;
  251. typedef struct tsec
  252. {
  253. /* General Control and Status Registers (0x2_n000) */
  254. uint res000[4];
  255. uint ievent; /* Interrupt Event */
  256. uint imask; /* Interrupt Mask */
  257. uint edis; /* Error Disabled */
  258. uint res01c;
  259. uint ecntrl; /* Ethernet Control */
  260. uint minflr; /* Minimum Frame Length */
  261. uint ptv; /* Pause Time Value */
  262. uint dmactrl; /* DMA Control */
  263. uint tbipa; /* TBI PHY Address */
  264. uint res034[3];
  265. uint res040[48];
  266. /* Transmit Control and Status Registers (0x2_n100) */
  267. uint tctrl; /* Transmit Control */
  268. uint tstat; /* Transmit Status */
  269. uint res108;
  270. uint tbdlen; /* Tx BD Data Length */
  271. uint res110[5];
  272. uint ctbptr; /* Current TxBD Pointer */
  273. uint res128[23];
  274. uint tbptr; /* TxBD Pointer */
  275. uint res188[30];
  276. /* (0x2_n200) */
  277. uint res200;
  278. uint tbase; /* TxBD Base Address */
  279. uint res208[42];
  280. uint ostbd; /* Out of Sequence TxBD */
  281. uint ostbdp; /* Out of Sequence Tx Data Buffer Pointer */
  282. uint res2b8[18];
  283. /* Receive Control and Status Registers (0x2_n300) */
  284. uint rctrl; /* Receive Control */
  285. uint rstat; /* Receive Status */
  286. uint res308;
  287. uint rbdlen; /* RxBD Data Length */
  288. uint res310[4];
  289. uint res320;
  290. uint crbptr; /* Current Receive Buffer Pointer */
  291. uint res328[6];
  292. uint mrblr; /* Maximum Receive Buffer Length */
  293. uint res344[16];
  294. uint rbptr; /* RxBD Pointer */
  295. uint res388[30];
  296. /* (0x2_n400) */
  297. uint res400;
  298. uint rbase; /* RxBD Base Address */
  299. uint res408[62];
  300. /* MAC Registers (0x2_n500) */
  301. uint maccfg1; /* MAC Configuration #1 */
  302. uint maccfg2; /* MAC Configuration #2 */
  303. uint ipgifg; /* Inter Packet Gap/Inter Frame Gap */
  304. uint hafdup; /* Half-duplex */
  305. uint maxfrm; /* Maximum Frame */
  306. uint res514;
  307. uint res518;
  308. uint res51c;
  309. uint miimcfg; /* MII Management: Configuration */
  310. uint miimcom; /* MII Management: Command */
  311. uint miimadd; /* MII Management: Address */
  312. uint miimcon; /* MII Management: Control */
  313. uint miimstat; /* MII Management: Status */
  314. uint miimind; /* MII Management: Indicators */
  315. uint res538;
  316. uint ifstat; /* Interface Status */
  317. uint macstnaddr1; /* Station Address, part 1 */
  318. uint macstnaddr2; /* Station Address, part 2 */
  319. uint res548[46];
  320. /* (0x2_n600) */
  321. uint res600[32];
  322. /* RMON MIB Registers (0x2_n680-0x2_n73c) */
  323. rmon_mib_t rmon;
  324. uint res740[48];
  325. /* Hash Function Registers (0x2_n800) */
  326. tsec_hash_t hash;
  327. uint res900[128];
  328. /* Pattern Registers (0x2_nb00) */
  329. uint resb00[62];
  330. uint attr; /* Default Attribute Register */
  331. uint attreli; /* Default Attribute Extract Length and Index */
  332. /* TSEC Future Expansion Space (0x2_nc00-0x2_nffc) */
  333. uint resc00[256];
  334. } tsec_t;
  335. #endif /* __TSEC_H */