4 * Driver for the Motorola Triple Speed Ethernet Controller
6 * This software may be used and distributed according to the
7 * terms of the GNU Public License, Version 2, incorporated
10 * Copyright 2004, 2007 Freescale Semiconductor, Inc.
11 * (C) Copyright 2003, Motorola, Inc.
12 * maintained by Xianghua Xiao (x.xiao@motorola.com)
23 #ifndef CFG_TSEC1_OFFSET
24 #define CFG_TSEC1_OFFSET (0x24000)
27 #define TSEC_SIZE 0x01000
29 /* FIXME: Should these be pushed back to 83xx and 85xx config files? */
30 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
31 #define TSEC_BASE_ADDR (CFG_IMMR + CFG_TSEC1_OFFSET)
32 #elif defined(CONFIG_MPC83XX)
33 #define TSEC_BASE_ADDR (CFG_IMMR + CFG_TSEC1_OFFSET)
37 #define MAC_ADDR_LEN 6
39 /* #define TSEC_TIMEOUT 1000000 */
40 #define TSEC_TIMEOUT 1000
41 #define TOUT_LOOP 1000000
43 #define PHY_AUTONEGOTIATE_TIMEOUT 5000 /* in ms */
45 /* MAC register bits */
46 #define MACCFG1_SOFT_RESET 0x80000000
47 #define MACCFG1_RESET_RX_MC 0x00080000
48 #define MACCFG1_RESET_TX_MC 0x00040000
49 #define MACCFG1_RESET_RX_FUN 0x00020000
50 #define MACCFG1_RESET_TX_FUN 0x00010000
51 #define MACCFG1_LOOPBACK 0x00000100
52 #define MACCFG1_RX_FLOW 0x00000020
53 #define MACCFG1_TX_FLOW 0x00000010
54 #define MACCFG1_SYNCD_RX_EN 0x00000008
55 #define MACCFG1_RX_EN 0x00000004
56 #define MACCFG1_SYNCD_TX_EN 0x00000002
57 #define MACCFG1_TX_EN 0x00000001
59 #define MACCFG2_INIT_SETTINGS 0x00007205
60 #define MACCFG2_FULL_DUPLEX 0x00000001
61 #define MACCFG2_IF 0x00000300
62 #define MACCFG2_GMII 0x00000200
63 #define MACCFG2_MII 0x00000100
65 #define ECNTRL_INIT_SETTINGS 0x00001000
66 #define ECNTRL_TBI_MODE 0x00000020
67 #define ECNTRL_R100 0x00000008
68 #define ECNTRL_SGMII_MODE 0x00000002
73 #ifndef CFG_TBIPA_VALUE
74 #define CFG_TBIPA_VALUE 0x1f
76 #define MIIMCFG_INIT_VALUE 0x00000003
77 #define MIIMCFG_RESET 0x80000000
79 #define MIIMIND_BUSY 0x00000001
80 #define MIIMIND_NOTVALID 0x00000004
82 #define MIIM_CONTROL 0x00
83 #define MIIM_CONTROL_RESET 0x00009140
84 #define MIIM_CONTROL_INIT 0x00001140
85 #define MIIM_CONTROL_RESTART 0x00001340
86 #define MIIM_ANEN 0x00001000
89 #define MIIM_CR_RST 0x00008000
90 #define MIIM_CR_INIT 0x00001000
92 #define MIIM_STATUS 0x1
93 #define MIIM_STATUS_AN_DONE 0x00000020
94 #define MIIM_STATUS_LINK 0x0004
95 #define PHY_BMSR_AUTN_ABLE 0x0008
96 #define PHY_BMSR_AUTN_COMP 0x0020
98 #define MIIM_PHYIR1 0x2
99 #define MIIM_PHYIR2 0x3
101 #define MIIM_ANAR 0x4
102 #define MIIM_ANAR_INIT 0x1e1
104 #define MIIM_TBI_ANLPBPA 0x5
105 #define MIIM_TBI_ANLPBPA_HALF 0x00000040
106 #define MIIM_TBI_ANLPBPA_FULL 0x00000020
108 #define MIIM_TBI_ANEX 0x6
109 #define MIIM_TBI_ANEX_NP 0x00000004
110 #define MIIM_TBI_ANEX_PRX 0x00000002
112 #define MIIM_GBIT_CONTROL 0x9
113 #define MIIM_GBIT_CONTROL_INIT 0xe00
115 /* Broadcom BCM54xx -- taken from linux sungem_phy */
116 #define MIIM_BCM54xx_AUXSTATUS 0x19
117 #define MIIM_BCM54xx_AUXSTATUS_LINKMODE_MASK 0x0700
118 #define MIIM_BCM54xx_AUXSTATUS_LINKMODE_SHIFT 8
120 /* Cicada Auxiliary Control/Status Register */
121 #define MIIM_CIS8201_AUX_CONSTAT 0x1c
122 #define MIIM_CIS8201_AUXCONSTAT_INIT 0x0004
123 #define MIIM_CIS8201_AUXCONSTAT_DUPLEX 0x0020
124 #define MIIM_CIS8201_AUXCONSTAT_SPEED 0x0018
125 #define MIIM_CIS8201_AUXCONSTAT_GBIT 0x0010
126 #define MIIM_CIS8201_AUXCONSTAT_100 0x0008
128 /* Cicada Extended Control Register 1 */
129 #define MIIM_CIS8201_EXT_CON1 0x17
130 #define MIIM_CIS8201_EXTCON1_INIT 0x0000
132 /* Cicada 8204 Extended PHY Control Register 1 */
133 #define MIIM_CIS8204_EPHY_CON 0x17
134 #define MIIM_CIS8204_EPHYCON_INIT 0x0006
135 #define MIIM_CIS8204_EPHYCON_RGMII 0x1100
137 /* Cicada 8204 Serial LED Control Register */
138 #define MIIM_CIS8204_SLED_CON 0x1b
139 #define MIIM_CIS8204_SLEDCON_INIT 0x1115
141 #define MIIM_GBIT_CON 0x09
142 #define MIIM_GBIT_CON_ADVERT 0x0e00
144 /* Entry for Vitesse VSC8244 regs starts here */
145 /* Vitesse VSC8244 Auxiliary Control/Status Register */
146 #define MIIM_VSC8244_AUX_CONSTAT 0x1c
147 #define MIIM_VSC8244_AUXCONSTAT_INIT 0x0000
148 #define MIIM_VSC8244_AUXCONSTAT_DUPLEX 0x0020
149 #define MIIM_VSC8244_AUXCONSTAT_SPEED 0x0018
150 #define MIIM_VSC8244_AUXCONSTAT_GBIT 0x0010
151 #define MIIM_VSC8244_AUXCONSTAT_100 0x0008
152 #define MIIM_CONTROL_INIT_LOOPBACK 0x4000
154 /* Vitesse VSC8244 Extended PHY Control Register 1 */
155 #define MIIM_VSC8244_EPHY_CON 0x17
156 #define MIIM_VSC8244_EPHYCON_INIT 0x0006
158 /* Vitesse VSC8244 Serial LED Control Register */
159 #define MIIM_VSC8244_LED_CON 0x1b
160 #define MIIM_VSC8244_LEDCON_INIT 0xF011
162 /* 88E1011 PHY Status Register */
163 #define MIIM_88E1011_PHY_STATUS 0x11
164 #define MIIM_88E1011_PHYSTAT_SPEED 0xc000
165 #define MIIM_88E1011_PHYSTAT_GBIT 0x8000
166 #define MIIM_88E1011_PHYSTAT_100 0x4000
167 #define MIIM_88E1011_PHYSTAT_DUPLEX 0x2000
168 #define MIIM_88E1011_PHYSTAT_SPDDONE 0x0800
169 #define MIIM_88E1011_PHYSTAT_LINK 0x0400
171 #define MIIM_88E1011_PHY_SCR 0x10
172 #define MIIM_88E1011_PHY_MDI_X_AUTO 0x0060
174 /* 88E1111 PHY LED Control Register */
175 #define MIIM_88E1111_PHY_LED_CONTROL 24
176 #define MIIM_88E1111_PHY_LED_DIRECT 0x4100
177 #define MIIM_88E1111_PHY_LED_COMBINE 0x411C
179 /* 88E1145 Extended PHY Specific Control Register */
180 #define MIIM_88E1145_PHY_EXT_CR 20
181 #define MIIM_M88E1145_RGMII_RX_DELAY 0x0080
182 #define MIIM_M88E1145_RGMII_TX_DELAY 0x0002
184 #define MIIM_88E1145_PHY_PAGE 29
185 #define MIIM_88E1145_PHY_CAL_OV 30
187 /* RTL8211B PHY Status Register */
188 #define MIIM_RTL8211B_PHY_STATUS 0x11
189 #define MIIM_RTL8211B_PHYSTAT_SPEED 0xc000
190 #define MIIM_RTL8211B_PHYSTAT_GBIT 0x8000
191 #define MIIM_RTL8211B_PHYSTAT_100 0x4000
192 #define MIIM_RTL8211B_PHYSTAT_DUPLEX 0x2000
193 #define MIIM_RTL8211B_PHYSTAT_SPDDONE 0x0800
194 #define MIIM_RTL8211B_PHYSTAT_LINK 0x0400
196 /* DM9161 Control register values */
197 #define MIIM_DM9161_CR_STOP 0x0400
198 #define MIIM_DM9161_CR_RSTAN 0x1200
200 #define MIIM_DM9161_SCR 0x10
201 #define MIIM_DM9161_SCR_INIT 0x0610
203 /* DM9161 Specified Configuration and Status Register */
204 #define MIIM_DM9161_SCSR 0x11
205 #define MIIM_DM9161_SCSR_100F 0x8000
206 #define MIIM_DM9161_SCSR_100H 0x4000
207 #define MIIM_DM9161_SCSR_10F 0x2000
208 #define MIIM_DM9161_SCSR_10H 0x1000
210 /* DM9161 10BT Configuration/Status */
211 #define MIIM_DM9161_10BTCSR 0x12
212 #define MIIM_DM9161_10BTCSR_INIT 0x7800
214 /* LXT971 Status 2 registers */
215 #define MIIM_LXT971_SR2 0x11 /* Status Register 2 */
216 #define MIIM_LXT971_SR2_SPEED_MASK 0x4200
217 #define MIIM_LXT971_SR2_10HDX 0x0000 /* 10 Mbit half duplex selected */
218 #define MIIM_LXT971_SR2_10FDX 0x0200 /* 10 Mbit full duplex selected */
219 #define MIIM_LXT971_SR2_100HDX 0x4000 /* 100 Mbit half duplex selected */
220 #define MIIM_LXT971_SR2_100FDX 0x4200 /* 100 Mbit full duplex selected */
222 /* DP83865 Control register values */
223 #define MIIM_DP83865_CR_INIT 0x9200
225 /* DP83865 Link and Auto-Neg Status Register */
226 #define MIIM_DP83865_LANR 0x11
227 #define MIIM_DP83865_SPD_MASK 0x0018
228 #define MIIM_DP83865_SPD_1000 0x0010
229 #define MIIM_DP83865_SPD_100 0x0008
230 #define MIIM_DP83865_DPX_FULL 0x0002
232 #define MIIM_READ_COMMAND 0x00000001
234 #define MRBLR_INIT_SETTINGS PKTSIZE_ALIGN
236 #define MINFLR_INIT_SETTINGS 0x00000040
238 #define DMACTRL_INIT_SETTINGS 0x000000c3
239 #define DMACTRL_GRS 0x00000010
240 #define DMACTRL_GTS 0x00000008
242 #define TSTAT_CLEAR_THALT 0x80000000
243 #define RSTAT_CLEAR_RHALT 0x00800000
246 #define IEVENT_INIT_CLEAR 0xffffffff
247 #define IEVENT_BABR 0x80000000
248 #define IEVENT_RXC 0x40000000
249 #define IEVENT_BSY 0x20000000
250 #define IEVENT_EBERR 0x10000000
251 #define IEVENT_MSRO 0x04000000
252 #define IEVENT_GTSC 0x02000000
253 #define IEVENT_BABT 0x01000000
254 #define IEVENT_TXC 0x00800000
255 #define IEVENT_TXE 0x00400000
256 #define IEVENT_TXB 0x00200000
257 #define IEVENT_TXF 0x00100000
258 #define IEVENT_IE 0x00080000
259 #define IEVENT_LC 0x00040000
260 #define IEVENT_CRL 0x00020000
261 #define IEVENT_XFUN 0x00010000
262 #define IEVENT_RXB0 0x00008000
263 #define IEVENT_GRSC 0x00000100
264 #define IEVENT_RXF0 0x00000080
266 #define IMASK_INIT_CLEAR 0x00000000
267 #define IMASK_TXEEN 0x00400000
268 #define IMASK_TXBEN 0x00200000
269 #define IMASK_TXFEN 0x00100000
270 #define IMASK_RXFEN0 0x00000080
273 /* Default Attribute fields */
274 #define ATTR_INIT_SETTINGS 0x000000c0
275 #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
293 /* RxBD status field bits */
294 #define RXBD_EMPTY 0x8000
295 #define RXBD_RO1 0x4000
296 #define RXBD_WRAP 0x2000
297 #define RXBD_INTERRUPT 0x1000
298 #define RXBD_LAST 0x0800
299 #define RXBD_FIRST 0x0400
300 #define RXBD_MISS 0x0100
301 #define RXBD_BROADCAST 0x0080
302 #define RXBD_MULTICAST 0x0040
303 #define RXBD_LARGE 0x0020
304 #define RXBD_NONOCTET 0x0010
305 #define RXBD_SHORT 0x0008
306 #define RXBD_CRCERR 0x0004
307 #define RXBD_OVERRUN 0x0002
308 #define RXBD_TRUNCATED 0x0001
309 #define RXBD_STATS 0x003f
313 ushort status; /* Status Fields */
314 ushort length; /* Buffer length */
315 uint bufPtr; /* Buffer Pointer */
320 ushort status; /* Status Fields */
321 ushort length; /* Buffer Length */
322 uint bufPtr; /* Buffer Pointer */
325 typedef struct rmon_mib
327 /* Transmit and Receive Counters */
328 uint tr64; /* Transmit and Receive 64-byte Frame Counter */
329 uint tr127; /* Transmit and Receive 65-127 byte Frame Counter */
330 uint tr255; /* Transmit and Receive 128-255 byte Frame Counter */
331 uint tr511; /* Transmit and Receive 256-511 byte Frame Counter */
332 uint tr1k; /* Transmit and Receive 512-1023 byte Frame Counter */
333 uint trmax; /* Transmit and Receive 1024-1518 byte Frame Counter */
334 uint trmgv; /* Transmit and Receive 1519-1522 byte Good VLAN Frame */
335 /* Receive Counters */
336 uint rbyt; /* Receive Byte Counter */
337 uint rpkt; /* Receive Packet Counter */
338 uint rfcs; /* Receive FCS Error Counter */
339 uint rmca; /* Receive Multicast Packet (Counter) */
340 uint rbca; /* Receive Broadcast Packet */
341 uint rxcf; /* Receive Control Frame Packet */
342 uint rxpf; /* Receive Pause Frame Packet */
343 uint rxuo; /* Receive Unknown OP Code */
344 uint raln; /* Receive Alignment Error */
345 uint rflr; /* Receive Frame Length Error */
346 uint rcde; /* Receive Code Error */
347 uint rcse; /* Receive Carrier Sense Error */
348 uint rund; /* Receive Undersize Packet */
349 uint rovr; /* Receive Oversize Packet */
350 uint rfrg; /* Receive Fragments */
351 uint rjbr; /* Receive Jabber */
352 uint rdrp; /* Receive Drop */
353 /* Transmit Counters */
354 uint tbyt; /* Transmit Byte Counter */
355 uint tpkt; /* Transmit Packet */
356 uint tmca; /* Transmit Multicast Packet */
357 uint tbca; /* Transmit Broadcast Packet */
358 uint txpf; /* Transmit Pause Control Frame */
359 uint tdfr; /* Transmit Deferral Packet */
360 uint tedf; /* Transmit Excessive Deferral Packet */
361 uint tscl; /* Transmit Single Collision Packet */
363 uint tmcl; /* Transmit Multiple Collision Packet */
364 uint tlcl; /* Transmit Late Collision Packet */
365 uint txcl; /* Transmit Excessive Collision Packet */
366 uint tncl; /* Transmit Total Collision */
370 uint tdrp; /* Transmit Drop Frame */
371 uint tjbr; /* Transmit Jabber Frame */
372 uint tfcs; /* Transmit FCS Error */
373 uint txcf; /* Transmit Control Frame */
374 uint tovr; /* Transmit Oversize Frame */
375 uint tund; /* Transmit Undersize Frame */
376 uint tfrg; /* Transmit Fragments Frame */
377 /* General Registers */
378 uint car1; /* Carry Register One */
379 uint car2; /* Carry Register Two */
380 uint cam1; /* Carry Register One Mask */
381 uint cam2; /* Carry Register Two Mask */
384 typedef struct tsec_hash_regs
386 uint iaddr0; /* Individual Address Register 0 */
387 uint iaddr1; /* Individual Address Register 1 */
388 uint iaddr2; /* Individual Address Register 2 */
389 uint iaddr3; /* Individual Address Register 3 */
390 uint iaddr4; /* Individual Address Register 4 */
391 uint iaddr5; /* Individual Address Register 5 */
392 uint iaddr6; /* Individual Address Register 6 */
393 uint iaddr7; /* Individual Address Register 7 */
395 uint gaddr0; /* Group Address Register 0 */
396 uint gaddr1; /* Group Address Register 1 */
397 uint gaddr2; /* Group Address Register 2 */
398 uint gaddr3; /* Group Address Register 3 */
399 uint gaddr4; /* Group Address Register 4 */
400 uint gaddr5; /* Group Address Register 5 */
401 uint gaddr6; /* Group Address Register 6 */
402 uint gaddr7; /* Group Address Register 7 */
408 /* General Control and Status Registers (0x2_n000) */
411 uint ievent; /* Interrupt Event */
412 uint imask; /* Interrupt Mask */
413 uint edis; /* Error Disabled */
415 uint ecntrl; /* Ethernet Control */
416 uint minflr; /* Minimum Frame Length */
417 uint ptv; /* Pause Time Value */
418 uint dmactrl; /* DMA Control */
419 uint tbipa; /* TBI PHY Address */
424 /* Transmit Control and Status Registers (0x2_n100) */
425 uint tctrl; /* Transmit Control */
426 uint tstat; /* Transmit Status */
428 uint tbdlen; /* Tx BD Data Length */
430 uint ctbptr; /* Current TxBD Pointer */
432 uint tbptr; /* TxBD Pointer */
436 uint tbase; /* TxBD Base Address */
438 uint ostbd; /* Out of Sequence TxBD */
439 uint ostbdp; /* Out of Sequence Tx Data Buffer Pointer */
442 /* Receive Control and Status Registers (0x2_n300) */
443 uint rctrl; /* Receive Control */
444 uint rstat; /* Receive Status */
446 uint rbdlen; /* RxBD Data Length */
449 uint crbptr; /* Current Receive Buffer Pointer */
451 uint mrblr; /* Maximum Receive Buffer Length */
453 uint rbptr; /* RxBD Pointer */
457 uint rbase; /* RxBD Base Address */
460 /* MAC Registers (0x2_n500) */
461 uint maccfg1; /* MAC Configuration #1 */
462 uint maccfg2; /* MAC Configuration #2 */
463 uint ipgifg; /* Inter Packet Gap/Inter Frame Gap */
464 uint hafdup; /* Half-duplex */
465 uint maxfrm; /* Maximum Frame */
471 uint miimcfg; /* MII Management: Configuration */
472 uint miimcom; /* MII Management: Command */
473 uint miimadd; /* MII Management: Address */
474 uint miimcon; /* MII Management: Control */
475 uint miimstat; /* MII Management: Status */
476 uint miimind; /* MII Management: Indicators */
480 uint ifstat; /* Interface Status */
481 uint macstnaddr1; /* Station Address, part 1 */
482 uint macstnaddr2; /* Station Address, part 2 */
488 /* RMON MIB Registers (0x2_n680-0x2_n73c) */
492 /* Hash Function Registers (0x2_n800) */
497 /* Pattern Registers (0x2_nb00) */
499 uint attr; /* Default Attribute Register */
500 uint attreli; /* Default Attribute Extract Length and Index */
502 /* TSEC Future Expansion Space (0x2_nc00-0x2_nffc) */
506 #define TSEC_GIGABIT (1)
508 /* This flag currently only has
509 * meaning if we're using the eTSEC */
510 #define TSEC_REDUCED (1 << 1)
512 struct tsec_private {
513 volatile tsec_t *regs;
514 volatile tsec_t *phyregs;
515 struct phy_info *phyinfo;
525 * struct phy_cmd: A command for reading or writing a PHY register
527 * mii_reg: The register to read or write
529 * mii_data: For writes, the value to put in the register.
530 * A value of -1 indicates this is a read.
532 * funct: A function pointer which is invoked for each command.
533 * For reads, this function will be passed the value read
534 * from the PHY, and process it.
535 * For writes, the result of this function will be written
536 * to the PHY register
541 uint (*funct) (uint mii_reg, struct tsec_private* priv);
544 /* struct phy_info: a structure which defines attributes for a PHY
546 * id will contain a number which represents the PHY. During
547 * startup, the driver will poll the PHY to find out what its
548 * UID--as defined by registers 2 and 3--is. The 32-bit result
549 * gotten from the PHY will be shifted right by "shift" bits to
550 * discard any bits which may change based on revision numbers
551 * unimportant to functionality
553 * The struct phy_cmd entries represent pointers to an arrays of
554 * commands which tell the driver what to do to the PHY.
560 /* Called to configure the PHY, and modify the controller
561 * based on the results */
562 struct phy_cmd *config;
564 /* Called when starting up the controller */
565 struct phy_cmd *startup;
567 /* Called when bringing down the controller */
568 struct phy_cmd *shutdown;
571 #endif /* __TSEC_H */