tsec.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  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. * Copyright 2004, 2007, 2009 Freescale Semiconductor, Inc.
  11. * (C) Copyright 2003, Motorola, Inc.
  12. * maintained by Xianghua Xiao (x.xiao@motorola.com)
  13. * author Andy Fleming
  14. *
  15. */
  16. #ifndef __TSEC_H
  17. #define __TSEC_H
  18. #include <net.h>
  19. #include <config.h>
  20. #define TSEC_SIZE 0x01000
  21. #define TSEC_MDIO_OFFSET 0x01000
  22. #define STD_TSEC_INFO(num) \
  23. { \
  24. .regs = (tsec_t *)(TSEC_BASE_ADDR + ((num - 1) * TSEC_SIZE)), \
  25. .miiregs = (tsec_mdio_t *)(MDIO_BASE_ADDR), \
  26. .miiregs_sgmii = (tsec_mdio_t *)(MDIO_BASE_ADDR \
  27. + (num - 1) * TSEC_MDIO_OFFSET), \
  28. .devname = CONFIG_TSEC##num##_NAME, \
  29. .phyaddr = TSEC##num##_PHY_ADDR, \
  30. .flags = TSEC##num##_FLAGS \
  31. }
  32. #define SET_STD_TSEC_INFO(x, num) \
  33. { \
  34. x.regs = (tsec_t *)(TSEC_BASE_ADDR + ((num - 1) * TSEC_SIZE)); \
  35. x.miiregs = (tsec_mdio_t *)(MDIO_BASE_ADDR); \
  36. x.miiregs_sgmii = (tsec_mdio_t *)(MDIO_BASE_ADDR \
  37. + (num - 1) * TSEC_MDIO_OFFSET); \
  38. x.devname = CONFIG_TSEC##num##_NAME; \
  39. x.phyaddr = TSEC##num##_PHY_ADDR; \
  40. x.flags = TSEC##num##_FLAGS;\
  41. }
  42. #define MAC_ADDR_LEN 6
  43. /* #define TSEC_TIMEOUT 1000000 */
  44. #define TSEC_TIMEOUT 1000
  45. #define TOUT_LOOP 1000000
  46. #define PHY_AUTONEGOTIATE_TIMEOUT 5000 /* in ms */
  47. /* TBI register addresses */
  48. #define TBI_CR 0x00
  49. #define TBI_SR 0x01
  50. #define TBI_ANA 0x04
  51. #define TBI_ANLPBPA 0x05
  52. #define TBI_ANEX 0x06
  53. #define TBI_TBICON 0x11
  54. /* TBI MDIO register bit fields*/
  55. #define TBICON_CLK_SELECT 0x0020
  56. #define TBIANA_ASYMMETRIC_PAUSE 0x0100
  57. #define TBIANA_SYMMETRIC_PAUSE 0x0080
  58. #define TBIANA_HALF_DUPLEX 0x0040
  59. #define TBIANA_FULL_DUPLEX 0x0020
  60. #define TBICR_PHY_RESET 0x8000
  61. #define TBICR_ANEG_ENABLE 0x1000
  62. #define TBICR_RESTART_ANEG 0x0200
  63. #define TBICR_FULL_DUPLEX 0x0100
  64. #define TBICR_SPEED1_SET 0x0040
  65. /* MAC register bits */
  66. #define MACCFG1_SOFT_RESET 0x80000000
  67. #define MACCFG1_RESET_RX_MC 0x00080000
  68. #define MACCFG1_RESET_TX_MC 0x00040000
  69. #define MACCFG1_RESET_RX_FUN 0x00020000
  70. #define MACCFG1_RESET_TX_FUN 0x00010000
  71. #define MACCFG1_LOOPBACK 0x00000100
  72. #define MACCFG1_RX_FLOW 0x00000020
  73. #define MACCFG1_TX_FLOW 0x00000010
  74. #define MACCFG1_SYNCD_RX_EN 0x00000008
  75. #define MACCFG1_RX_EN 0x00000004
  76. #define MACCFG1_SYNCD_TX_EN 0x00000002
  77. #define MACCFG1_TX_EN 0x00000001
  78. #define MACCFG2_INIT_SETTINGS 0x00007205
  79. #define MACCFG2_FULL_DUPLEX 0x00000001
  80. #define MACCFG2_IF 0x00000300
  81. #define MACCFG2_GMII 0x00000200
  82. #define MACCFG2_MII 0x00000100
  83. #define ECNTRL_INIT_SETTINGS 0x00001000
  84. #define ECNTRL_TBI_MODE 0x00000020
  85. #define ECNTRL_R100 0x00000008
  86. #define ECNTRL_SGMII_MODE 0x00000002
  87. #define miim_end -2
  88. #define miim_read -1
  89. #ifndef CONFIG_SYS_TBIPA_VALUE
  90. #define CONFIG_SYS_TBIPA_VALUE 0x1f
  91. #endif
  92. #define MIIMCFG_INIT_VALUE 0x00000003
  93. #define MIIMCFG_RESET 0x80000000
  94. #define MIIMIND_BUSY 0x00000001
  95. #define MIIMIND_NOTVALID 0x00000004
  96. #define MIIM_CONTROL 0x00
  97. #define MIIM_CONTROL_RESET 0x00009140
  98. #define MIIM_CONTROL_INIT 0x00001140
  99. #define MIIM_CONTROL_RESTART 0x00001340
  100. #define MIIM_ANEN 0x00001000
  101. #define MIIM_CR 0x00
  102. #define MIIM_CR_RST 0x00008000
  103. #define MIIM_CR_INIT 0x00001000
  104. #define MIIM_STATUS 0x1
  105. #define MIIM_STATUS_AN_DONE 0x00000020
  106. #define MIIM_STATUS_LINK 0x0004
  107. #define PHY_BMSR_AUTN_ABLE 0x0008
  108. #define PHY_BMSR_AUTN_COMP 0x0020
  109. #define MIIM_PHYIR1 0x2
  110. #define MIIM_PHYIR2 0x3
  111. #define MIIM_ANAR 0x4
  112. #define MIIM_ANAR_INIT 0x1e1
  113. #define MIIM_TBI_ANLPBPA 0x5
  114. #define MIIM_TBI_ANLPBPA_HALF 0x00000040
  115. #define MIIM_TBI_ANLPBPA_FULL 0x00000020
  116. #define MIIM_TBI_ANEX 0x6
  117. #define MIIM_TBI_ANEX_NP 0x00000004
  118. #define MIIM_TBI_ANEX_PRX 0x00000002
  119. #define MIIM_GBIT_CONTROL 0x9
  120. #define MIIM_GBIT_CONTROL_INIT 0xe00
  121. #define MIIM_EXT_PAGE_ACCESS 0x1f
  122. /* Broadcom BCM54xx -- taken from linux sungem_phy */
  123. #define MIIM_BCM54xx_AUXCNTL 0x18
  124. #define MIIM_BCM54xx_AUXCNTL_ENCODE(val) ((val & 0x7) << 12)|(val & 0x7)
  125. #define MIIM_BCM54xx_AUXSTATUS 0x19
  126. #define MIIM_BCM54xx_AUXSTATUS_LINKMODE_MASK 0x0700
  127. #define MIIM_BCM54xx_AUXSTATUS_LINKMODE_SHIFT 8
  128. #define MIIM_BCM54XX_SHD 0x1c /* 0x1c shadow registers */
  129. #define MIIM_BCM54XX_SHD_WRITE 0x8000
  130. #define MIIM_BCM54XX_SHD_VAL(x) ((x & 0x1f) << 10)
  131. #define MIIM_BCM54XX_SHD_DATA(x) ((x & 0x3ff) << 0)
  132. #define MIIM_BCM54XX_SHD_WR_ENCODE(val, data) \
  133. (MIIM_BCM54XX_SHD_WRITE | MIIM_BCM54XX_SHD_VAL(val) | \
  134. MIIM_BCM54XX_SHD_DATA(data))
  135. #define MIIM_BCM54XX_EXP_DATA 0x15 /* Expansion register data */
  136. #define MIIM_BCM54XX_EXP_SEL 0x17 /* Expansion register select */
  137. #define MIIM_BCM54XX_EXP_SEL_SSD 0x0e00 /* Secondary SerDes select */
  138. #define MIIM_BCM54XX_EXP_SEL_ER 0x0f00 /* Expansion register select */
  139. /* Cicada Auxiliary Control/Status Register */
  140. #define MIIM_CIS8201_AUX_CONSTAT 0x1c
  141. #define MIIM_CIS8201_AUXCONSTAT_INIT 0x0004
  142. #define MIIM_CIS8201_AUXCONSTAT_DUPLEX 0x0020
  143. #define MIIM_CIS8201_AUXCONSTAT_SPEED 0x0018
  144. #define MIIM_CIS8201_AUXCONSTAT_GBIT 0x0010
  145. #define MIIM_CIS8201_AUXCONSTAT_100 0x0008
  146. /* Cicada Extended Control Register 1 */
  147. #define MIIM_CIS8201_EXT_CON1 0x17
  148. #define MIIM_CIS8201_EXTCON1_INIT 0x0000
  149. /* Cicada 8204 Extended PHY Control Register 1 */
  150. #define MIIM_CIS8204_EPHY_CON 0x17
  151. #define MIIM_CIS8204_EPHYCON_INIT 0x0006
  152. #define MIIM_CIS8204_EPHYCON_RGMII 0x1100
  153. /* Cicada 8204 Serial LED Control Register */
  154. #define MIIM_CIS8204_SLED_CON 0x1b
  155. #define MIIM_CIS8204_SLEDCON_INIT 0x1115
  156. #define MIIM_GBIT_CON 0x09
  157. #define MIIM_GBIT_CON_ADVERT 0x0e00
  158. /* Entry for Vitesse VSC8244 regs starts here */
  159. /* Vitesse VSC8244 Auxiliary Control/Status Register */
  160. #define MIIM_VSC8244_AUX_CONSTAT 0x1c
  161. #define MIIM_VSC8244_AUXCONSTAT_INIT 0x0000
  162. #define MIIM_VSC8244_AUXCONSTAT_DUPLEX 0x0020
  163. #define MIIM_VSC8244_AUXCONSTAT_SPEED 0x0018
  164. #define MIIM_VSC8244_AUXCONSTAT_GBIT 0x0010
  165. #define MIIM_VSC8244_AUXCONSTAT_100 0x0008
  166. #define MIIM_CONTROL_INIT_LOOPBACK 0x4000
  167. /* Vitesse VSC8244 Extended PHY Control Register 1 */
  168. #define MIIM_VSC8244_EPHY_CON 0x17
  169. #define MIIM_VSC8244_EPHYCON_INIT 0x0006
  170. /* Vitesse VSC8244 Serial LED Control Register */
  171. #define MIIM_VSC8244_LED_CON 0x1b
  172. #define MIIM_VSC8244_LEDCON_INIT 0xF011
  173. /* Entry for Vitesse VSC8601 regs starts here (Not complete) */
  174. /* Vitesse VSC8601 Extended PHY Control Register 1 */
  175. #define MIIM_VSC8601_EPHY_CON 0x17
  176. #define MIIM_VSC8601_EPHY_CON_INIT_SKEW 0x1120
  177. #define MIIM_VSC8601_SKEW_CTRL 0x1c
  178. /* 88E1011 PHY Status Register */
  179. #define MIIM_88E1011_PHY_STATUS 0x11
  180. #define MIIM_88E1011_PHYSTAT_SPEED 0xc000
  181. #define MIIM_88E1011_PHYSTAT_GBIT 0x8000
  182. #define MIIM_88E1011_PHYSTAT_100 0x4000
  183. #define MIIM_88E1011_PHYSTAT_DUPLEX 0x2000
  184. #define MIIM_88E1011_PHYSTAT_SPDDONE 0x0800
  185. #define MIIM_88E1011_PHYSTAT_LINK 0x0400
  186. #define MIIM_88E1011_PHY_SCR 0x10
  187. #define MIIM_88E1011_PHY_MDI_X_AUTO 0x0060
  188. /* 88E1111 PHY LED Control Register */
  189. #define MIIM_88E1111_PHY_LED_CONTROL 24
  190. #define MIIM_88E1111_PHY_LED_DIRECT 0x4100
  191. #define MIIM_88E1111_PHY_LED_COMBINE 0x411C
  192. /* 88E1121 PHY LED Control Register */
  193. #define MIIM_88E1121_PHY_LED_CTRL 16
  194. #define MIIM_88E1121_PHY_LED_PAGE 3
  195. #define MIIM_88E1121_PHY_LED_DEF 0x0030
  196. /* 88E1121 PHY IRQ Enable/Status Register */
  197. #define MIIM_88E1121_PHY_IRQ_EN 18
  198. #define MIIM_88E1121_PHY_IRQ_STATUS 19
  199. #define MIIM_88E1121_PHY_PAGE 22
  200. /* 88E1145 Extended PHY Specific Control Register */
  201. #define MIIM_88E1145_PHY_EXT_CR 20
  202. #define MIIM_M88E1145_RGMII_RX_DELAY 0x0080
  203. #define MIIM_M88E1145_RGMII_TX_DELAY 0x0002
  204. #define MIIM_88E1145_PHY_PAGE 29
  205. #define MIIM_88E1145_PHY_CAL_OV 30
  206. /* RTL8211B PHY Status Register */
  207. #define MIIM_RTL8211B_PHY_STATUS 0x11
  208. #define MIIM_RTL8211B_PHYSTAT_SPEED 0xc000
  209. #define MIIM_RTL8211B_PHYSTAT_GBIT 0x8000
  210. #define MIIM_RTL8211B_PHYSTAT_100 0x4000
  211. #define MIIM_RTL8211B_PHYSTAT_DUPLEX 0x2000
  212. #define MIIM_RTL8211B_PHYSTAT_SPDDONE 0x0800
  213. #define MIIM_RTL8211B_PHYSTAT_LINK 0x0400
  214. /* DM9161 Control register values */
  215. #define MIIM_DM9161_CR_STOP 0x0400
  216. #define MIIM_DM9161_CR_RSTAN 0x1200
  217. #define MIIM_DM9161_SCR 0x10
  218. #define MIIM_DM9161_SCR_INIT 0x0610
  219. /* DM9161 Specified Configuration and Status Register */
  220. #define MIIM_DM9161_SCSR 0x11
  221. #define MIIM_DM9161_SCSR_100F 0x8000
  222. #define MIIM_DM9161_SCSR_100H 0x4000
  223. #define MIIM_DM9161_SCSR_10F 0x2000
  224. #define MIIM_DM9161_SCSR_10H 0x1000
  225. /* DM9161 10BT Configuration/Status */
  226. #define MIIM_DM9161_10BTCSR 0x12
  227. #define MIIM_DM9161_10BTCSR_INIT 0x7800
  228. /* LXT971 Status 2 registers */
  229. #define MIIM_LXT971_SR2 0x11 /* Status Register 2 */
  230. #define MIIM_LXT971_SR2_SPEED_MASK 0x4200
  231. #define MIIM_LXT971_SR2_10HDX 0x0000 /* 10 Mbit half duplex selected */
  232. #define MIIM_LXT971_SR2_10FDX 0x0200 /* 10 Mbit full duplex selected */
  233. #define MIIM_LXT971_SR2_100HDX 0x4000 /* 100 Mbit half duplex selected */
  234. #define MIIM_LXT971_SR2_100FDX 0x4200 /* 100 Mbit full duplex selected */
  235. /* DP83865 Control register values */
  236. #define MIIM_DP83865_CR_INIT 0x9200
  237. /* DP83865 Link and Auto-Neg Status Register */
  238. #define MIIM_DP83865_LANR 0x11
  239. #define MIIM_DP83865_SPD_MASK 0x0018
  240. #define MIIM_DP83865_SPD_1000 0x0010
  241. #define MIIM_DP83865_SPD_100 0x0008
  242. #define MIIM_DP83865_DPX_FULL 0x0002
  243. #define MIIM_READ_COMMAND 0x00000001
  244. #define MRBLR_INIT_SETTINGS PKTSIZE_ALIGN
  245. #define MINFLR_INIT_SETTINGS 0x00000040
  246. #define DMACTRL_INIT_SETTINGS 0x000000c3
  247. #define DMACTRL_GRS 0x00000010
  248. #define DMACTRL_GTS 0x00000008
  249. #define TSTAT_CLEAR_THALT 0x80000000
  250. #define RSTAT_CLEAR_RHALT 0x00800000
  251. #define IEVENT_INIT_CLEAR 0xffffffff
  252. #define IEVENT_BABR 0x80000000
  253. #define IEVENT_RXC 0x40000000
  254. #define IEVENT_BSY 0x20000000
  255. #define IEVENT_EBERR 0x10000000
  256. #define IEVENT_MSRO 0x04000000
  257. #define IEVENT_GTSC 0x02000000
  258. #define IEVENT_BABT 0x01000000
  259. #define IEVENT_TXC 0x00800000
  260. #define IEVENT_TXE 0x00400000
  261. #define IEVENT_TXB 0x00200000
  262. #define IEVENT_TXF 0x00100000
  263. #define IEVENT_IE 0x00080000
  264. #define IEVENT_LC 0x00040000
  265. #define IEVENT_CRL 0x00020000
  266. #define IEVENT_XFUN 0x00010000
  267. #define IEVENT_RXB0 0x00008000
  268. #define IEVENT_GRSC 0x00000100
  269. #define IEVENT_RXF0 0x00000080
  270. #define IMASK_INIT_CLEAR 0x00000000
  271. #define IMASK_TXEEN 0x00400000
  272. #define IMASK_TXBEN 0x00200000
  273. #define IMASK_TXFEN 0x00100000
  274. #define IMASK_RXFEN0 0x00000080
  275. /* Default Attribute fields */
  276. #define ATTR_INIT_SETTINGS 0x000000c0
  277. #define ATTRELI_INIT_SETTINGS 0x00000000
  278. /* TxBD status field bits */
  279. #define TXBD_READY 0x8000
  280. #define TXBD_PADCRC 0x4000
  281. #define TXBD_WRAP 0x2000
  282. #define TXBD_INTERRUPT 0x1000
  283. #define TXBD_LAST 0x0800
  284. #define TXBD_CRC 0x0400
  285. #define TXBD_DEF 0x0200
  286. #define TXBD_HUGEFRAME 0x0080
  287. #define TXBD_LATECOLLISION 0x0080
  288. #define TXBD_RETRYLIMIT 0x0040
  289. #define TXBD_RETRYCOUNTMASK 0x003c
  290. #define TXBD_UNDERRUN 0x0002
  291. #define TXBD_STATS 0x03ff
  292. /* RxBD status field bits */
  293. #define RXBD_EMPTY 0x8000
  294. #define RXBD_RO1 0x4000
  295. #define RXBD_WRAP 0x2000
  296. #define RXBD_INTERRUPT 0x1000
  297. #define RXBD_LAST 0x0800
  298. #define RXBD_FIRST 0x0400
  299. #define RXBD_MISS 0x0100
  300. #define RXBD_BROADCAST 0x0080
  301. #define RXBD_MULTICAST 0x0040
  302. #define RXBD_LARGE 0x0020
  303. #define RXBD_NONOCTET 0x0010
  304. #define RXBD_SHORT 0x0008
  305. #define RXBD_CRCERR 0x0004
  306. #define RXBD_OVERRUN 0x0002
  307. #define RXBD_TRUNCATED 0x0001
  308. #define RXBD_STATS 0x003f
  309. typedef struct txbd8
  310. {
  311. ushort status; /* Status Fields */
  312. ushort length; /* Buffer length */
  313. uint bufPtr; /* Buffer Pointer */
  314. } txbd8_t;
  315. typedef struct rxbd8
  316. {
  317. ushort status; /* Status Fields */
  318. ushort length; /* Buffer Length */
  319. uint bufPtr; /* Buffer Pointer */
  320. } rxbd8_t;
  321. typedef struct rmon_mib
  322. {
  323. /* Transmit and Receive Counters */
  324. uint tr64; /* Transmit and Receive 64-byte Frame Counter */
  325. uint tr127; /* Transmit and Receive 65-127 byte Frame Counter */
  326. uint tr255; /* Transmit and Receive 128-255 byte Frame Counter */
  327. uint tr511; /* Transmit and Receive 256-511 byte Frame Counter */
  328. uint tr1k; /* Transmit and Receive 512-1023 byte Frame Counter */
  329. uint trmax; /* Transmit and Receive 1024-1518 byte Frame Counter */
  330. uint trmgv; /* Transmit and Receive 1519-1522 byte Good VLAN Frame */
  331. /* Receive Counters */
  332. uint rbyt; /* Receive Byte Counter */
  333. uint rpkt; /* Receive Packet Counter */
  334. uint rfcs; /* Receive FCS Error Counter */
  335. uint rmca; /* Receive Multicast Packet (Counter) */
  336. uint rbca; /* Receive Broadcast Packet */
  337. uint rxcf; /* Receive Control Frame Packet */
  338. uint rxpf; /* Receive Pause Frame Packet */
  339. uint rxuo; /* Receive Unknown OP Code */
  340. uint raln; /* Receive Alignment Error */
  341. uint rflr; /* Receive Frame Length Error */
  342. uint rcde; /* Receive Code Error */
  343. uint rcse; /* Receive Carrier Sense Error */
  344. uint rund; /* Receive Undersize Packet */
  345. uint rovr; /* Receive Oversize Packet */
  346. uint rfrg; /* Receive Fragments */
  347. uint rjbr; /* Receive Jabber */
  348. uint rdrp; /* Receive Drop */
  349. /* Transmit Counters */
  350. uint tbyt; /* Transmit Byte Counter */
  351. uint tpkt; /* Transmit Packet */
  352. uint tmca; /* Transmit Multicast Packet */
  353. uint tbca; /* Transmit Broadcast Packet */
  354. uint txpf; /* Transmit Pause Control Frame */
  355. uint tdfr; /* Transmit Deferral Packet */
  356. uint tedf; /* Transmit Excessive Deferral Packet */
  357. uint tscl; /* Transmit Single Collision Packet */
  358. /* (0x2_n700) */
  359. uint tmcl; /* Transmit Multiple Collision Packet */
  360. uint tlcl; /* Transmit Late Collision Packet */
  361. uint txcl; /* Transmit Excessive Collision Packet */
  362. uint tncl; /* Transmit Total Collision */
  363. uint res2;
  364. uint tdrp; /* Transmit Drop Frame */
  365. uint tjbr; /* Transmit Jabber Frame */
  366. uint tfcs; /* Transmit FCS Error */
  367. uint txcf; /* Transmit Control Frame */
  368. uint tovr; /* Transmit Oversize Frame */
  369. uint tund; /* Transmit Undersize Frame */
  370. uint tfrg; /* Transmit Fragments Frame */
  371. /* General Registers */
  372. uint car1; /* Carry Register One */
  373. uint car2; /* Carry Register Two */
  374. uint cam1; /* Carry Register One Mask */
  375. uint cam2; /* Carry Register Two Mask */
  376. } rmon_mib_t;
  377. typedef struct tsec_hash_regs
  378. {
  379. uint iaddr0; /* Individual Address Register 0 */
  380. uint iaddr1; /* Individual Address Register 1 */
  381. uint iaddr2; /* Individual Address Register 2 */
  382. uint iaddr3; /* Individual Address Register 3 */
  383. uint iaddr4; /* Individual Address Register 4 */
  384. uint iaddr5; /* Individual Address Register 5 */
  385. uint iaddr6; /* Individual Address Register 6 */
  386. uint iaddr7; /* Individual Address Register 7 */
  387. uint res1[24];
  388. uint gaddr0; /* Group Address Register 0 */
  389. uint gaddr1; /* Group Address Register 1 */
  390. uint gaddr2; /* Group Address Register 2 */
  391. uint gaddr3; /* Group Address Register 3 */
  392. uint gaddr4; /* Group Address Register 4 */
  393. uint gaddr5; /* Group Address Register 5 */
  394. uint gaddr6; /* Group Address Register 6 */
  395. uint gaddr7; /* Group Address Register 7 */
  396. uint res2[24];
  397. } tsec_hash_t;
  398. typedef struct tsec_mdio {
  399. uint res1[4];
  400. uint ieventm;
  401. uint imaskm;
  402. uint res2;
  403. uint emapm;
  404. uint res3[320];
  405. uint miimcfg; /* MII Management: Configuration */
  406. uint miimcom; /* MII Management: Command */
  407. uint miimadd; /* MII Management: Address */
  408. uint miimcon; /* MII Management: Control */
  409. uint miimstat; /* MII Management: Status */
  410. uint miimind; /* MII Management: Indicators */
  411. uint res4[690];
  412. } tsec_mdio_t;
  413. typedef struct tsec
  414. {
  415. /* General Control and Status Registers (0x2_n000) */
  416. uint res000[4];
  417. uint ievent; /* Interrupt Event */
  418. uint imask; /* Interrupt Mask */
  419. uint edis; /* Error Disabled */
  420. uint res01c;
  421. uint ecntrl; /* Ethernet Control */
  422. uint minflr; /* Minimum Frame Length */
  423. uint ptv; /* Pause Time Value */
  424. uint dmactrl; /* DMA Control */
  425. uint tbipa; /* TBI PHY Address */
  426. uint res034[3];
  427. uint res040[48];
  428. /* Transmit Control and Status Registers (0x2_n100) */
  429. uint tctrl; /* Transmit Control */
  430. uint tstat; /* Transmit Status */
  431. uint res108;
  432. uint tbdlen; /* Tx BD Data Length */
  433. uint res110[5];
  434. uint ctbptr; /* Current TxBD Pointer */
  435. uint res128[23];
  436. uint tbptr; /* TxBD Pointer */
  437. uint res188[30];
  438. /* (0x2_n200) */
  439. uint res200;
  440. uint tbase; /* TxBD Base Address */
  441. uint res208[42];
  442. uint ostbd; /* Out of Sequence TxBD */
  443. uint ostbdp; /* Out of Sequence Tx Data Buffer Pointer */
  444. uint res2b8[18];
  445. /* Receive Control and Status Registers (0x2_n300) */
  446. uint rctrl; /* Receive Control */
  447. uint rstat; /* Receive Status */
  448. uint res308;
  449. uint rbdlen; /* RxBD Data Length */
  450. uint res310[4];
  451. uint res320;
  452. uint crbptr; /* Current Receive Buffer Pointer */
  453. uint res328[6];
  454. uint mrblr; /* Maximum Receive Buffer Length */
  455. uint res344[16];
  456. uint rbptr; /* RxBD Pointer */
  457. uint res388[30];
  458. /* (0x2_n400) */
  459. uint res400;
  460. uint rbase; /* RxBD Base Address */
  461. uint res408[62];
  462. /* MAC Registers (0x2_n500) */
  463. uint maccfg1; /* MAC Configuration #1 */
  464. uint maccfg2; /* MAC Configuration #2 */
  465. uint ipgifg; /* Inter Packet Gap/Inter Frame Gap */
  466. uint hafdup; /* Half-duplex */
  467. uint maxfrm; /* Maximum Frame */
  468. uint res514;
  469. uint res518;
  470. uint res51c;
  471. uint resmdio[6];
  472. uint res538;
  473. uint ifstat; /* Interface Status */
  474. uint macstnaddr1; /* Station Address, part 1 */
  475. uint macstnaddr2; /* Station Address, part 2 */
  476. uint res548[46];
  477. /* (0x2_n600) */
  478. uint res600[32];
  479. /* RMON MIB Registers (0x2_n680-0x2_n73c) */
  480. rmon_mib_t rmon;
  481. uint res740[48];
  482. /* Hash Function Registers (0x2_n800) */
  483. tsec_hash_t hash;
  484. uint res900[128];
  485. /* Pattern Registers (0x2_nb00) */
  486. uint resb00[62];
  487. uint attr; /* Default Attribute Register */
  488. uint attreli; /* Default Attribute Extract Length and Index */
  489. /* TSEC Future Expansion Space (0x2_nc00-0x2_nffc) */
  490. uint resc00[256];
  491. } tsec_t;
  492. #define TSEC_GIGABIT (1)
  493. /* This flag currently only has
  494. * meaning if we're using the eTSEC */
  495. #define TSEC_REDUCED (1 << 1) /* MAC-PHY interface uses RGMII */
  496. #define TSEC_SGMII (1 << 2) /* MAC-PHY interface uses SGMII */
  497. #define TSEC_FIBER (1 << 3) /* PHY uses fiber, eg 1000 Base-X */
  498. struct tsec_private {
  499. volatile tsec_t *regs;
  500. volatile tsec_mdio_t *phyregs;
  501. volatile tsec_mdio_t *phyregs_sgmii;
  502. struct phy_info *phyinfo;
  503. uint phyaddr;
  504. u32 flags;
  505. uint link;
  506. uint duplexity;
  507. uint speed;
  508. };
  509. /*
  510. * struct phy_cmd: A command for reading or writing a PHY register
  511. *
  512. * mii_reg: The register to read or write
  513. *
  514. * mii_data: For writes, the value to put in the register.
  515. * A value of -1 indicates this is a read.
  516. *
  517. * funct: A function pointer which is invoked for each command.
  518. * For reads, this function will be passed the value read
  519. * from the PHY, and process it.
  520. * For writes, the result of this function will be written
  521. * to the PHY register
  522. */
  523. struct phy_cmd {
  524. uint mii_reg;
  525. uint mii_data;
  526. uint (*funct) (uint mii_reg, struct tsec_private * priv);
  527. };
  528. /* struct phy_info: a structure which defines attributes for a PHY
  529. *
  530. * id will contain a number which represents the PHY. During
  531. * startup, the driver will poll the PHY to find out what its
  532. * UID--as defined by registers 2 and 3--is. The 32-bit result
  533. * gotten from the PHY will be shifted right by "shift" bits to
  534. * discard any bits which may change based on revision numbers
  535. * unimportant to functionality
  536. *
  537. * The struct phy_cmd entries represent pointers to an arrays of
  538. * commands which tell the driver what to do to the PHY.
  539. */
  540. struct phy_info {
  541. uint id;
  542. char *name;
  543. uint shift;
  544. /* Called to configure the PHY, and modify the controller
  545. * based on the results */
  546. struct phy_cmd *config;
  547. /* Called when starting up the controller */
  548. struct phy_cmd *startup;
  549. /* Called when bringing down the controller */
  550. struct phy_cmd *shutdown;
  551. };
  552. struct tsec_info_struct {
  553. tsec_t *regs;
  554. tsec_mdio_t *miiregs;
  555. tsec_mdio_t *miiregs_sgmii;
  556. char *devname;
  557. unsigned int phyaddr;
  558. u32 flags;
  559. };
  560. int tsec_standard_init(bd_t *bis);
  561. int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsec_info, int num);
  562. #endif /* __TSEC_H */