1/*
2 * Register and bit definitions for the Intel 8255x 10/100 Ethernet
3 *   Controller Family
4 * Reference:
5 *   Intel 8255x 10/100 Mbps Ethernet Controller Family Open Source
6 *     Software Developer Manual, Revision 1.0.
7 *   Intel, January 2003
8 */
9#ifndef _I82559_H_
10#define _I82559_H_
11
12#define _DD_MAKEMASK1(n) (1 << (n))
13#define _DD_MAKEMASK(v,n) ((((1)<<(v))-1) << (n))
14#define _DD_MAKEVALUE(v,n) ((v) << (n))
15#define _DD_GETVALUE(v,n,m) (((v) & (m)) >> (n))
16
17
18/* PCI Vendor and Device Ids */
19
20#define K_PCI_VENDOR_INTEL    0x8086
21#define K_PCI_ID_I82557       0x1229    /* also I82558, some I82559 */
22#define K_PCI_ID_I82559ER     0x1209
23#define K_PCI_ID_INBUSINESS   0x1030
24
25
26/*  i8255x Control and Status Register offsets.
27
28    Note: Several of the CSRs are intended to be accessed as bytes or
29    half words to avoid side effects on other registers packed in the
30    same word.  The offsets and bit fields of such CSRs are defined
31    relative to their byte/half word addresses.
32*/
33
34#define R_SCB_STAT            0x00       /* 8 bits */
35#define R_SCB_STATACK         0x01       /* 8 bits */
36#define R_SCB_CMD             0x02       /* 8 bits */
37#define R_SCB_IC              0x03       /* 8 bits */
38#define R_SCB_PTR             0x04
39#define R_PORT                0x08
40#define R_EEPROM_CTL          0x0E       /* 16 bits */
41#define R_MDI_CTL             0x10
42#define R_RXBC                0x14
43
44/* Following in i82558 and later */
45#define R_ERX_INT             0x18       /* 8 bits */
46#define R_FC_THRESH           0x19       /* 8 bits */
47#define R_FC_CMD              0x20       /* 8 bits */
48#define R_PMDR                0x21       /* 8 bits */
49
50/* Following in i82559 and later */
51#define R_GEN_CTL             0x1C       /* 8 bits */
52#define R_GEN_STAT            0x1D       /* 8 bits */
53#define R_FUNC_EVENT          0x30
54#define R_FUNC_MASK           0x34
55#define R_FUNC_STATE          0x38
56#define R_FORCE_EVENT         0x3C
57
58
59/* 0x00  SCB: SCB Status Register (8 bits) */
60
61#define S_SCB_RUS               2
62#define M_SCB_RUS               _DD_MAKEMASK(4,S_SCB_RUS)
63#define V_SCB_RUS(x)            _DD_MAKEVALUE(x,S_SCB_RUS)
64#define G_SCB_RUS(x)            _DD_GETVALUE(x,S_SCB_RUS,M_SCB_RUS)
65#define K_RUS_IDLE              0x0
66#define K_RUS_SUSPENDED         0x1
67#define K_RUS_BLOCKED           0x2
68#define K_RUS_READY             0x4
69
70#define S_SCB_CUS               6
71#define M_SCB_CUS               _DD_MAKEMASK(2,S_SCB_CUS)
72#define V_SCB_CUS(x)            _DD_MAKEVALUE(x,S_SCB_CUS)
73#define G_SCB_CUS(x)            _DD_GETVALUE(x,S_SCB_CUS,M_SCB_CUS)
74#define K_CUS_IDLE              0x0
75#define K_CUS_SUSPENDED         0x1
76#define K_CUS_LPQ               0x2
77#define K_CUS_HPQ               0x3
78
79
80/* 0x01  SCB: SCB STAT/ACK Register (8 bits, R/C) */
81
82#define M_SCB_FCP               _DD_MAKEMASK1(0)   /* not i82557 */
83#define M_SCB_SWI               _DD_MAKEMASK1(2)
84#define M_SCB_MDI               _DD_MAKEMASK1(3)
85#define M_SCB_RNR               _DD_MAKEMASK1(4)
86#define M_SCB_CNA               _DD_MAKEMASK1(5)   /* CNA or CI */
87#define M_SCB_FR                _DD_MAKEMASK1(6)   /* FR  or ER */
88#define M_SCB_CX                _DD_MAKEMASK1(7)   /* also TNO, i82557 */
89
90
91/* 0x02  SCB: SCB Command Byte Register (8 bits) */
92
93#define S_SCB_RUC               0
94#define M_SCB_RUC               _DD_MAKEMASK(3,S_SCB_RUC)
95#define V_SCB_RUC(x)            _DD_MAKEVALUE(x,S_SCB_RUC)
96#define G_SCB_RUC(x)            _DD_GETVALUE(x,S_SCB_RUC,M_SCB_RUC)
97#define K_RUC_NOP               0x0
98#define K_RUC_START             0x1
99#define K_RUC_RESUME            0x2
100#define K_RUC_REDIRECT          0x3   /* not i82557 */
101#define K_RUC_ABORT             0x4
102#define K_RUC_HDS               0x5
103#define K_RUC_BASE              0x6
104
105#define S_SCB_CUC               4
106#define M_SCB_CUC               _DD_MAKEMASK(4,S_SCB_CUC)
107#define V_SCB_CUC(x)            _DD_MAKEVALUE(x,S_SCB_CUC)
108#define G_SCB_CUC(x)            _DD_GETVALUE(x,S_SCB_CUC,M_SCB_CUC)
109#define K_CUC_NOP               0x0
110#define K_CUC_START             0x1
111#define K_CUC_RESUME            0x2
112#define K_CUC_CTR_ADDR          0x4
113#define K_CUC_CTR_DUMP          0x5
114#define K_CUC_BASE              0x6
115#define K_CUC_CTR_DUMP_RESET    0x7
116#define K_CUC_STATIC_RESUME     0xA   /* not i82557 */
117
118#define K_CMD_ACCEPTED          0x00
119
120
121/* 0x03  SCB: SCB Interrupt Control Byte Register (8 bits) */
122
123#define M_SCB_M                 _DD_MAKEMASK1(0)
124#define M_SCB_SI                _DD_MAKEMASK1(1)
125#define M_SCB_FCP_M             _DD_MAKEMASK1(2)   /* not i82557 */
126#define M_SCB_ER_M              _DD_MAKEMASK1(3)   /* not i82557 */
127#define M_SCB_RNR_M             _DD_MAKEMASK1(4)   /* not i82557 */
128#define M_SCB_CNA_M             _DD_MAKEMASK1(5)   /* not i82557 */
129#define M_SCB_FR_M              _DD_MAKEMASK1(6)   /* not i82557 */
130#define M_SCB_CX_M              _DD_MAKEMASK1(7)   /* not i82557 */
131
132
133/* 0x04  SCB: SCB General Pointer Register */
134
135
136/* 0x08  PORT: Port Interface Register */
137
138#define S_PORT_FUNC              0
139#define M_PORT_FUNC              _DD_MAKEMASK(4,S_PORT_FUNC)
140#define V_PORT_FUNC(x)           _DD_MAKEVALUE(x,S_PORT_FUNC)
141#define G_PORT_FUNC(x)           _DD_GETVALUE(x,S_PORT_FUNC,M_PORT_FUNC)
142#define K_PORT_FUNC_SWRESET      0x0
143#define K_PORT_FUNC_SELFTEST     0x1
144#define K_PORT_FUNC_SELRESET     0x2
145#define K_PORT_FUNC_DUMP         0x3
146#define K_PORT_FUNC_DUMP_WKUP    0x7
147
148#define S_PORT_ADDR              4
149#define M_PORT_ADDR              _DD_MAKEMASK(28,S_PORT_ADDR)
150#define V_PORT_ADDR(x)           _DD_MAKEVALUE(x,S_PORT_ADDR)
151#define G_PORT_ADDR(x)           _DD_GETVALUE(x,S_PORT_ADDR,M_PORT_ADDR)
152
153
154/* 0x0E  PROM: EEPROM Control Register (16 bits) */
155
156#define M_PROM_EESK             _DD_MAKEMASK1(0)
157#define M_PROM_EECS             _DD_MAKEMASK1(1)
158#define M_PROM_EEDI             _DD_MAKEMASK1(2)
159#define M_PROM_EEDO             _DD_MAKEMASK1(3)
160
161
162/* 0x10  MDI: MDI Control Register */
163
164#define S_MDI_DATA              0
165#define M_MDI_DATA              _DD_MAKEMASK(16,S_MDI_DATA)
166#define V_MDI_DATA(x)           _DD_MAKEVALUE(x,S_MDI_DATA)
167#define G_MDI_DATA(x)           _DD_GETVALUE(x,S_MDI_DATA,M_MDI_DATA)
168
169#define S_MDI_REGADD            16
170#define M_MDI_REGADD            _DD_MAKEMASK(5,S_MDI_REGADD)
171#define V_MDI_REGADD(x)         _DD_MAKEVALUE(x,S_MDI_REGADD)
172#define G_MDI_REGADD(x)         _DD_GETVALUE(x,S_MDI_REGADD,M_MDI_DATA)
173
174#define S_MDI_PHYADD            21
175#define M_MDI_PHYADD            _DD_MAKEMASK(5,S_MDI_PHYADD)
176#define V_MDI_PHYADD(x)         _DD_MAKEVALUE(x,S_MDI_PHYADD)
177#define G_MDI_PHYADD(x)         _DD_GETVALUE(x,S_MDI_PHYADD,M_MDI_PHYADD)
178
179#define S_MDI_OP                26
180#define M_MDI_OP                _DD_MAKEMASK(2,S_MDI_OP)
181#define V_MDI_OP(x)             _DD_MAKEVALUE(x,S_MDI_OP)
182#define G_MDI_OP(x)             _DD_GETVALUE(x,S_MDI_OP,M_MDI_OP)
183#define K_MDI_OP_WRITE          0x1
184#define K_MDI_OP_READ           0x2
185
186#define M_MDI_R                _DD_MAKEMASK1(28)
187#define M_MDI_IE               _DD_MAKEMASK1(29)
188
189
190/* 0x14  RXBC: RX DMA Byte Count Register */
191
192
193/* 0x18  FLOW: Flow Control Threshold and Power Management Driver Register */
194
195
196/* 0x1C  General Control Register (8 bits, not i82557, i82558) */
197
198#define M_GCTL_NOCLKRUN         _DD_MAKEMASK1(0)
199#define M_GCTL_DEEPPWRDN        _DD_MAKEMASK1(1)
200
201
202/* 0x1D  General Status Register (8 bits, RO, not i82557, i82558) */
203
204#define M_GSTAT_LINKUP          _DD_MAKEMASK1(0)
205#define M_GSTAT_100             _DD_MAKEMASK1(1)
206#define M_GSTAT_FDX             _DD_MAKEMASK1(2)
207
208
209/* i8255x-specific Constants (recognized by hardware) */
210
211#define NULL_LINK               0xFFFFFFFF
212
213
214/* i8255x Action Command Block (CB) formats. */
215
216/* CB Halfword 0: Status */
217
218#define M_CB0_OK               _DD_MAKEMASK1(13)
219#define M_CB0_C                _DD_MAKEMASK1(15)
220
221/* CB Halfword 1: Command */
222
223#define S_CB0_CMD              0
224#define M_CB0_CMD              _DD_MAKEMASK(3,S_CB0_CMD)
225#define V_CB0_CMD(x)           _DD_MAKEVALUE(x,S_CB0_CMD)
226#define G_CB0_CMD(x)           _DD_GETVALUE(x,S_CB0_CMD,M_CB0_CMD)
227#define K_CB_NOP               0x0
228#define K_CB_ADDRSETUP         0x1
229#define K_CB_CONFIGURE         0x2
230#define K_CB_MCASTSETUP        0x3
231#define K_CB_TRANSMIT          0x4
232#define K_CB_LOADUCODE         0x5
233#define K_CB_DUMP              0x6
234#define K_CB_DIAGNOSE          0x7
235#define K_CB_IPTRANSMIT        0x9    /* i82550, i82551 only */
236
237#define M_CB0_I                _DD_MAKEMASK1(13)
238#define M_CB0_S                _DD_MAKEMASK1(14)
239#define M_CB0_EL               _DD_MAKEMASK1(15)
240
241/* CB Word 1: Link Address */
242
243/* CB Word 2-n: command dependent extensions */
244
245#define CB_HDR_WORDS           2
246#define CB_HDR_BYTES           8
247
248/* Transmit Control Block (TCB) extension format */
249
250/* TCB Word 0: Additional Command fields */
251
252#define M_TCB0_SF              _DD_MAKEMASK1(3)
253#define M_TCB0_NC              _DD_MAKEMASK1(4)
254
255#define S_TCB0_CID             8
256#define M_TCB0_CID             _DD_MAKEMASK(5,S_TCB0_CID)
257#define V_TCB0_CID(x)          _DD_MAKEVALUE(x,S_TCB0_CID)
258#define G_TCB0_CID(x)          _DD_GETVALUE(x,S_TCB0_CID,M_TCB0_CID)
259
260
261/* TCB Word 2: Transmit Buffer Descriptor (TBD) Array Address */
262
263/* TCB Word 3: Transmit Command */
264
265#define S_TCB3_COUNT           0
266#define M_TCB3_COUNT           _DD_MAKEMASK(14,S_TCB3_COUNT)
267#define V_TCB3_COUNT(x)        _DD_MAKEVALUE(x,S_TCB3_COUNT)
268#define G_TCB3_COUNT(x)        _DD_GETVALUE(x,S_TCB3_COUNT,M_TCB3_COUNT)
269
270#define M_TCB3_EOF             _DD_MAKEMASK1(15)
271
272#define S_TCB3_THRESH          16
273#define M_TCB3_THRESH          _DD_MAKEMASK(8,S_TCB3_THRESH)
274#define V_TCB3_THRESH(x)       _DD_MAKEVALUE(x,S_TCB3_THRESH)
275#define G_TCB3_THRESH(x)       _DD_GETVALUE(x,S_TCB3_THRESH,M_TCB3_THRESH)
276
277#define S_TCB3_TBDNUM          24
278#define M_TCB3_TBDNUM          _DD_MAKEMASK(8,S_TCB3_TBDNUM)
279#define V_TCB3_TBDNUM(x)       _DD_MAKEVALUE(x,S_TCB3_TBDNUM)
280#define G_TCB3_TBDNUM(x)       _DD_GETVALUE(x,S_TCB3_TBDNUM,M_TCB3_TBDNUM)
281
282
283/* i8255x Transmit Buffer Descriptor (TBD) formats. */
284
285/* TBD Word 0: Buffer Address */
286
287#define K_TBD0_NV              0x00000000
288
289/* TBD Word 1: Buffer Size */
290
291#define S_TBD1_COUNT           0
292#define M_TBD1_COUNT           _DD_MAKEMASK(14,S_TBD1_COUNT)
293#define V_TBD1_COUNT(x)        _DD_MAKEVALUE(x,S_TBD1_COUNT)
294#define G_TBD1_COUNT(x)        _DD_GETVALUE(x,S_TBD1_COUNT,M_TBD1_COUNT)
295
296#define M_TBD1_EL              _DD_MAKEMASK1(16)    /* not i82557 */
297
298
299/* i8255x Receive Frame Descriptor (RFD) formats. */
300
301/* RFD Halfword 0: Status */
302
303#define S_RFD0_STATUS         0
304#define M_RFD0_STATUS         _DD_MAKEMASK(13,S_RFD0_STATUS)
305#define V_RFD0_STATUS(x)      _DD_MAKEVALUE(x,S_RFD0_STATUS)
306#define G_RFD0_STATUS(x)      _DD_GETVALUE(x,S_RFD0_STATUS,M_RFD0_STATUS)
307
308/* Bit assignments within RFD0_STATUS */
309#define M_STAT_RXCOL          _DD_MAKEMASK1(0)
310#define M_STAT_IAMATCH        _DD_MAKEMASK1(1)
311#define M_STAT_NOMATCH        _DD_MAKEMASK1(2)
312#define M_STAT_RXERR          _DD_MAKEMASK1(4)
313#define M_STAT_TYPELEN        _DD_MAKEMASK1(5)
314#define M_STAT_RUNTERR        _DD_MAKEMASK1(7)
315#define M_STAT_DMAOVRRUN      _DD_MAKEMASK1(8)
316#define M_STAT_BUFOVRRUN      _DD_MAKEMASK1(9)
317#define M_STAT_ALIGNERR       _DD_MAKEMASK1(10)
318#define M_STAT_CRCERR         _DD_MAKEMASK1(11)
319
320#define M_RFD0_ERRS           ((M_STAT_CRCERR | M_STAT_ALIGNERR | \
321                                M_STAT_BUFOVRRUN | M_STAT_DMAOVRRUN | \
322                                M_STAT_RUNTERR | M_STAT_RXERR \
323                               ) << S_RFD0_STATUS)
324
325#define M_RFD0_OK             _DD_MAKEMASK1(13)
326#define M_RFD0_C              _DD_MAKEMASK1(15)
327
328/* RFD Halfword 1: Command */
329
330#define M_RFD0_SF             _DD_MAKEMASK1(3)
331#define M_RFD0_H              _DD_MAKEMASK1(4)
332#define M_RFD0_S              _DD_MAKEMASK1(14)
333#define M_RFD0_EL             _DD_MAKEMASK1(15)
334
335/* RFD Word 1: Link Address */
336
337/* RFD Word 2: Reserved */
338
339/* RFD Word 3: Count and Size */
340
341#define S_RFD3_COUNT          0
342#define M_RFD3_COUNT          _DD_MAKEMASK(14,S_RFD3_COUNT)
343#define V_RFD3_COUNT(x)       _DD_MAKEVALUE(x,S_RFD3_COUNT)
344#define G_RFD3_COUNT(x)       _DD_GETVALUE(x,S_RFD3_COUNT,M_RFD3_COUNT)
345
346#define M_RFD3_F              _DD_MAKEMASK1(14)
347#define M_RFD3_EOF            _DD_MAKEMASK1(15)
348
349#define S_RFD3_SIZE           16
350#define M_RFD3_SIZE           _DD_MAKEMASK(14,S_RFD3_SIZE)
351#define V_RFD3_SIZE(x)        _DD_MAKEVALUE(x,S_RFD3_SIZE)
352#define G_RFD3_SIZE(x)        _DD_GETVALUE(x,S_RFD3_SIZE,M_RFD3_SIZE)
353
354
355/* Offsets (words) of Statistical Counters */
356
357#define STAT_TX_GOOD_FRAMES    0
358#define STAT_TX_MAX_COL        1
359#define STAT_TX_LATE_COL       2
360#define STAT_TX_UNDERRUN       3
361#define STAT_TX_LOST_CRS       4
362#define STAT_TX_DEFERRED       5
363#define STAT_TX_1_COL          6
364#define STAT_TX_MULT_COL       7
365#define STAT_TX_TOTAL_COL      8
366
367#define STAT_RX_GOOD_FRAMES    9
368#define STAT_RX_CRC_ERRS       10
369#define STAT_RX_ALGN_ERRS      11
370#define STAT_RX_RSRC_ERRS      12
371#define STAT_RX_OVERRUN        13
372#define STAT_RX_CDT            14
373#define STAT_RX_RUNT_FRAMES    15
374
375#define STAT_MARKER_557        16
376
377/* Following only for i82558 and later */
378#define STAT_FC_TX_PAUSE       16
379#define STAT_FC_RX_PAUSE       17
380#define STAT_FC_RX_UNSUPPORTED 18
381
382#define STAT_MARKER_558        19
383
384/* Following only for i82559 and later */
385#define STAT_TX_TCO_FRAMES     19
386#define STAT_RX_TCO_FRAMES     20
387
388#define STAT_MARKER_559        24
389
390/* Codes written in the STAT_MARKER slots */
391
392#define K_STAT_COMPLETE        0xA005
393#define K_STAT_ZERO_COMPLETE   0xA007
394
395#endif /* _I82559_H_ */
396