tsec.h 12 KB

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