tsec.h 18 KB

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