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