1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 struct tl_type {
39 u_int16_t tl_vid;
40 u_int16_t tl_did;
41 char *tl_name;
42 };
43
44
45
46
47
48
49
50
51
52
53 #define TL_MAXFRAGS 10
54 #define TL_RX_LIST_CNT 20
55 #define TL_TX_LIST_CNT 64
56 #define TL_MIN_FRAMELEN 128
57
58 struct tl_frag {
59 u_int32_t tlist_dcnt;
60 u_int32_t tlist_dadr;
61 };
62
63 struct tl_list {
64 u_int32_t tlist_fptr;
65 u_int16_t tlist_cstat;
66 u_int16_t tlist_frsize;
67 struct tl_frag tl_frag[TL_MAXFRAGS];
68 };
69
70
71
72
73
74
75
76 struct tl_list_onefrag {
77 u_int32_t tlist_fptr;
78 u_int16_t tlist_cstat;
79 u_int16_t tlist_frsize;
80 struct tl_frag tl_frag;
81 };
82
83 struct tl_list_data {
84 struct tl_list_onefrag tl_rx_list[TL_RX_LIST_CNT];
85 struct tl_list tl_tx_list[TL_TX_LIST_CNT];
86 unsigned char tl_pad[TL_MIN_FRAMELEN];
87 };
88
89 struct tl_chain {
90 struct tl_list *tl_ptr;
91 struct mbuf *tl_mbuf;
92 struct tl_chain *tl_next;
93 };
94
95 struct tl_chain_onefrag {
96 struct tl_list_onefrag *tl_ptr;
97 struct mbuf *tl_mbuf;
98 struct tl_chain_onefrag *tl_next;
99 };
100
101 struct tl_chain_data {
102 struct tl_chain_onefrag tl_rx_chain[TL_RX_LIST_CNT];
103 struct tl_chain tl_tx_chain[TL_TX_LIST_CNT];
104
105 struct tl_chain_onefrag *tl_rx_head;
106 struct tl_chain_onefrag *tl_rx_tail;
107
108 struct tl_chain *tl_tx_head;
109 struct tl_chain *tl_tx_tail;
110 struct tl_chain *tl_tx_free;
111 };
112
113 struct tl_products {
114 u_int16_t tp_vend;
115 u_int16_t tp_prod;
116 u_int32_t tp_tlphymedia;
117 };
118
119 struct tl_softc {
120 struct device sc_dev;
121 void * sc_ih;
122 struct arpcom arpcom;
123 struct ifmedia ifmedia;
124 struct timeout tl_stats_tmo, tl_wait_tmo;
125 bus_space_handle_t tl_bhandle;
126 bus_space_tag_t tl_btag;
127 bus_dma_tag_t sc_dmat;
128 struct tl_type *tl_dinfo;
129 struct tl_type *tl_pinfo;
130 int tl_if_flags;
131 u_int8_t tl_ctlr;
132 u_int8_t tl_eeaddr;
133 struct tl_list_data *tl_ldata;
134 struct tl_chain_data tl_cdata;
135 u_int8_t tl_txeoc;
136 u_int8_t tl_bitrate;
137 struct mii_data sc_mii;
138 const struct tl_products *tl_product;
139 };
140
141
142
143
144 #define TX_THR 0x00000004
145
146
147
148
149
150
151
152
153
154 #define TI_VENDORID 0x104C
155 #define TI_DEVICEID_THUNDERLAN 0x0500
156
157
158
159
160
161 #define COMPAQ_VENDORID 0x0E11
162 #define COMPAQ_DEVICEID_NETEL_10_100 0xAE32
163 #define COMPAQ_DEVICEID_NETEL_UNKNOWN 0xAE33
164 #define COMPAQ_DEVICEID_NETEL_10 0xAE34
165 #define COMPAQ_DEVICEID_NETFLEX_3P_INTEGRATED 0xAE35
166 #define COMPAQ_DEVICEID_NETEL_10_100_DUAL 0xAE40
167 #define COMPAQ_DEVICEID_NETEL_10_100_PROLIANT 0xAE43
168 #define COMPAQ_DEVICEID_NETEL_10_100_EMBEDDED 0xB011
169 #define COMPAQ_DEVICEID_NETEL_10_T2_UTP_COAX 0xB012
170 #define COMPAQ_DEVICEID_NETEL_10_100_TX_UTP 0xB030
171 #define COMPAQ_DEVICEID_NETFLEX_3P 0xF130
172 #define COMPAQ_DEVICEID_NETFLEX_3P_BNC 0xF150
173
174
175
176
177
178 #define OLICOM_VENDORID 0x108D
179 #define OLICOM_DEVICEID_OC2183 0x0013
180 #define OLICOM_DEVICEID_OC2325 0x0012
181 #define OLICOM_DEVICEID_OC2326 0x0014
182
183
184
185
186 #define TL_PCI_LOIO 0x10
187 #define TL_PCI_LOMEM 0x14
188
189
190
191
192
193 #define TL_PCI_LATENCY_TIMER 0x0C
194
195 #define TL_DIO_ADDR_INC 0x8000
196 #define TL_DIO_RAM_SEL 0x4000
197 #define TL_DIO_ADDR_MASK 0x3FFF
198
199
200
201
202 #define TL_INTR_INVALID 0x0
203 #define TL_INTR_TXEOF 0x1
204 #define TL_INTR_STATOFLOW 0x2
205 #define TL_INTR_RXEOF 0x3
206 #define TL_INTR_DUMMY 0x4
207 #define TL_INTR_TXEOC 0x5
208 #define TL_INTR_ADCHK 0x6
209 #define TL_INTR_RXEOC 0x7
210
211 #define TL_INT_MASK 0x001C
212 #define TL_VEC_MASK 0x1FE0
213
214
215
216 #define TL_CMD_GO 0x80000000
217 #define TL_CMD_STOP 0x40000000
218 #define TL_CMD_ACK 0x20000000
219 #define TL_CMD_CHSEL7 0x10000000
220 #define TL_CMD_CHSEL6 0x08000000
221 #define TL_CMD_CHSEL5 0x04000000
222 #define TL_CMD_CHSEL4 0x02000000
223 #define TL_CMD_CHSEL3 0x01000000
224 #define TL_CMD_CHSEL2 0x00800000
225 #define TL_CMD_CHSEL1 0x00400000
226 #define TL_CMD_CHSEL0 0x00200000
227 #define TL_CMD_EOC 0x00100000
228 #define TL_CMD_RT 0x00080000
229 #define TL_CMD_NES 0x00040000
230 #define TL_CMD_ZERO0 0x00020000
231 #define TL_CMD_ZERO1 0x00010000
232 #define TL_CMD_ADRST 0x00008000
233 #define TL_CMD_LDTMR 0x00004000
234 #define TL_CMD_LDTHR 0x00002000
235 #define TL_CMD_REQINT 0x00001000
236 #define TL_CMD_INTSOFF 0x00000800
237 #define TL_CMD_INTSON 0x00000400
238 #define TL_CMD_RSVD0 0x00000200
239 #define TL_CMD_RSVD1 0x00000100
240 #define TL_CMD_ACK7 0x00000080
241 #define TL_CMD_ACK6 0x00000040
242 #define TL_CMD_ACK5 0x00000020
243 #define TL_CMD_ACK4 0x00000010
244 #define TL_CMD_ACK3 0x00000008
245 #define TL_CMD_ACK2 0x00000004
246 #define TL_CMD_ACK1 0x00000002
247 #define TL_CMD_ACK0 0x00000001
248
249 #define TL_CMD_CHSEL_MASK 0x01FE0000
250 #define TL_CMD_ACK_MASK 0xFF
251
252
253
254
255 #define TL_EEPROM_EADDR 0x83
256 #define TL_EEPROM_EADDR2 0x99
257 #define TL_EEPROM_EADDR3 0xAF
258 #define TL_EEPROM_EADDR_OC 0xF8
259
260
261
262
263
264 #define TL_HOSTCMD 0x00
265 #define TL_CH_PARM 0x04
266 #define TL_DIO_ADDR 0x08
267 #define TL_HOST_INT 0x0A
268 #define TL_DIO_DATA 0x0C
269
270
271
272
273 #define TL_NETCMD 0x00
274 #define TL_NETSIO 0x01
275 #define TL_NETSTS 0x02
276 #define TL_NETMASK 0x03
277
278 #define TL_NETCONFIG 0x04
279 #define TL_MANTEST 0x06
280
281 #define TL_VENID_LSB 0x08
282 #define TL_VENID_MSB 0x09
283 #define TL_DEVID_LSB 0x0A
284 #define TL_DEVID_MSB 0x0B
285
286 #define TL_REVISION 0x0C
287 #define TL_SUBCLASS 0x0D
288 #define TL_MINLAT 0x0E
289 #define TL_MAXLAT 0x0F
290
291 #define TL_AREG0_B5 0x10
292 #define TL_AREG0_B4 0x11
293 #define TL_AREG0_B3 0x12
294 #define TL_AREG0_B2 0x13
295
296 #define TL_AREG0_B1 0x14
297 #define TL_AREG0_B0 0x15
298 #define TL_AREG1_B5 0x16
299 #define TL_AREG1_B4 0x17
300
301 #define TL_AREG1_B3 0x18
302 #define TL_AREG1_B2 0x19
303 #define TL_AREG1_B1 0x1A
304 #define TL_AREG1_B0 0x1B
305
306 #define TL_AREG2_B5 0x1C
307 #define TL_AREG2_B4 0x1D
308 #define TL_AREG2_B3 0x1E
309 #define TL_AREG2_B2 0x1F
310
311 #define TL_AREG2_B1 0x20
312 #define TL_AREG2_B0 0x21
313 #define TL_AREG3_B5 0x22
314 #define TL_AREG3_B4 0x23
315
316 #define TL_AREG3_B3 0x24
317 #define TL_AREG3_B2 0x25
318 #define TL_AREG3_B1 0x26
319 #define TL_AREG3_B0 0x27
320
321 #define TL_HASH1 0x28
322 #define TL_HASH2 0x2C
323 #define TL_TXGOODFRAMES 0x30
324 #define TL_TXUNDERRUN 0x33
325 #define TL_RXGOODFRAMES 0x34
326 #define TL_RXOVERRUN 0x37
327 #define TL_DEFEREDTX 0x38
328 #define TL_CRCERROR 0x3A
329 #define TL_CODEERROR 0x3B
330 #define TL_MULTICOLTX 0x3C
331 #define TL_SINGLECOLTX 0x3E
332 #define TL_EXCESSIVECOL 0x40
333 #define TL_LATECOL 0x41
334 #define TL_CARRIERLOSS 0x42
335 #define TL_ACOMMIT 0x43
336 #define TL_LDREG 0x44
337 #define TL_BSIZEREG 0x45
338 #define TL_MAXRX 0x46
339
340
341
342
343 #define TL_SIO_MINTEN 0x80
344 #define TL_SIO_ECLOK 0x40
345 #define TL_SIO_ETXEN 0x20
346 #define TL_SIO_EDATA 0x10
347 #define TL_SIO_NMRST 0x08
348 #define TL_SIO_MCLK 0x04
349 #define TL_SIO_MTXEN 0x02
350 #define TL_SIO_MDATA 0x01
351
352
353
354
355 #define TL_CFG_RCLKTEST 0x8000
356 #define TL_CFG_TCLKTEST 0x4000
357 #define TL_CFG_BITRATE 0x2000
358 #define TL_CFG_RXCRC 0x1000
359 #define TL_CFG_PEF 0x0800
360 #define TL_CFG_ONEFRAG 0x0400
361 #define TL_CFG_ONECHAN 0x0200
362 #define TL_CFG_MTEST 0x0100
363 #define TL_CFG_PHYEN 0x0080
364 #define TL_CFG_MACSEL6 0x0040
365 #define TL_CFG_MACSEL5 0x0020
366 #define TL_CFG_MACSEL4 0x0010
367 #define TL_CFG_MACSEL3 0x0008
368 #define TL_CFG_MACSEL2 0x0004
369 #define TL_CFG_MACSEL1 0x0002
370 #define TL_CFG_MACSEL0 0x0001
371
372
373
374
375 #define TL_STS_MIRQ 0x80
376 #define TL_STS_HBEAT 0x40
377 #define TL_STS_TXSTOP 0x20
378 #define TL_STS_RXSTOP 0x10
379
380
381
382
383 #define TL_CMD_NRESET 0x80
384 #define TL_CMD_NWRAP 0x40
385 #define TL_CMD_CSF 0x20
386 #define TL_CMD_CAF 0x10
387 #define TL_CMD_NOBRX 0x08
388 #define TL_CMD_DUPLEX 0x04
389 #define TL_CMD_TRFRAM 0x02
390 #define TL_CMD_TXPACE 0x01
391
392
393
394
395 #define TL_MASK_MASK7 0x80
396 #define TL_MASK_MASK6 0x40
397 #define TL_MASK_MASK5 0x20
398 #define TL_MASK_MASK4 0x10
399
400
401
402
403 #ifdef ANSI_DOESNT_ALLOW_BITFIELDS
404 struct tl_mii_frame {
405 u_int16_t mii_stdelim:2,
406 mii_opcode:2,
407 mii_phyaddr:5,
408 mii_regaddr:5,
409 mii_turnaround:2;
410 u_int16_t mii_data;
411 };
412 #else
413 struct tl_mii_frame {
414 u_int8_t mii_stdelim;
415 u_int8_t mii_opcode;
416 u_int8_t mii_phyaddr;
417 u_int8_t mii_regaddr;
418 u_int8_t mii_turnaround;
419 u_int16_t mii_data;
420 };
421 #endif
422
423
424
425 #define TL_MII_STARTDELIM 0x01
426 #define TL_MII_READOP 0x02
427 #define TL_MII_WRITEOP 0x01
428 #define TL_MII_TURNAROUND 0x02
429
430 #define TL_LAST_FRAG 0x80000000
431 #define TL_CSTAT_UNUSED 0x8000
432 #define TL_CSTAT_FRAMECMP 0x4000
433 #define TL_CSTAT_READY 0x3000
434 #define TL_CSTAT_UNUSED13 0x2000
435 #define TL_CSTAT_UNUSED12 0x1000
436 #define TL_CSTAT_EOC 0x0800
437 #define TL_CSTAT_RXERROR 0x0400
438 #define TL_CSTAT_PASSCRC 0x0200
439 #define TL_CSTAT_DPRIO 0x0100
440
441 #define TL_FRAME_MASK 0x00FFFFFF
442 #define tl_tx_goodframes(x) (x.tl_txstat & TL_FRAME_MASK)
443 #define tl_tx_underrun(x) ((x.tl_txstat & ~TL_FRAME_MASK) >> 24)
444 #define tl_rx_goodframes(x) (x.tl_rxstat & TL_FRAME_MASK)
445 #define tl_rx_overrun(x) ((x.tl_rxstat & ~TL_FRAME_MASK) >> 24)
446
447 struct tl_stats {
448 u_int32_t tl_txstat;
449 u_int32_t tl_rxstat;
450 u_int16_t tl_deferred;
451 u_int8_t tl_crc_errors;
452 u_int8_t tl_code_errors;
453 u_int16_t tl_tx_multi_collision;
454 u_int16_t tl_tx_single_collision;
455 u_int8_t tl_excessive_collision;
456 u_int8_t tl_late_collision;
457 u_int8_t tl_carrier_loss;
458 u_int8_t acommit;
459 };
460
461
462
463
464
465 #define TL_AC_MTXER 0x01
466 #define TL_AC_MTXD1 0x02
467 #define TL_AC_MTXD2 0x04
468 #define TL_AC_MTXD3 0x08
469
470 #define TL_AC_TXTHRESH 0xF0
471 #define TL_AC_TXTHRESH_16LONG 0x00
472 #define TL_AC_TXTHRESH_32LONG 0x10
473 #define TL_AC_TXTHRESH_64LONG 0x20
474 #define TL_AC_TXTHRESH_128LONG 0x30
475 #define TL_AC_TXTHRESH_256LONG 0x40
476 #define TL_AC_TXTHRESH_WHOLEPKT 0x50
477
478
479
480
481 #define TL_RXBURST 0x0F
482 #define TL_TXBURST 0xF0
483
484 #define TL_RXBURST_4LONG 0x00
485 #define TL_RXBURST_8LONG 0x01
486 #define TL_RXBURST_16LONG 0x02
487 #define TL_RXBURST_32LONG 0x03
488 #define TL_RXBURST_64LONG 0x04
489 #define TL_RXBURST_128LONG 0x05
490
491 #define TL_TXBURST_4LONG 0x00
492 #define TL_TXBURST_8LONG 0x10
493 #define TL_TXBURST_16LONG 0x20
494 #define TL_TXBURST_32LONG 0x30
495 #define TL_TXBURST_64LONG 0x40
496 #define TL_TXBURST_128LONG 0x50
497
498
499
500
501 #define CSR_WRITE_4(sc, reg, val) \
502 bus_space_write_4(sc->tl_btag, sc->tl_bhandle, reg, val)
503 #define CSR_WRITE_2(sc, reg, val) \
504 bus_space_write_2(sc->tl_btag, sc->tl_bhandle, reg, val)
505 #define CSR_WRITE_1(sc, reg, val) \
506 bus_space_write_1(sc->tl_btag, sc->tl_bhandle, reg, val)
507
508 #define CSR_READ_4(sc, reg) \
509 bus_space_read_4(sc->tl_btag, sc->tl_bhandle, reg)
510 #define CSR_READ_2(sc, reg) \
511 bus_space_read_2(sc->tl_btag, sc->tl_bhandle, reg)
512 #define CSR_READ_1(sc, reg) \
513 bus_space_read_1(sc->tl_btag, sc->tl_bhandle, reg)
514
515 #define CMD_PUT(sc, x) CSR_WRITE_4(sc, TL_HOSTCMD, x)
516 #define CMD_SET(sc, x) \
517 CSR_WRITE_4(sc, TL_HOSTCMD, CSR_READ_4(sc, TL_HOSTCMD) | (x))
518 #define CMD_CLR(sc, x) \
519 CSR_WRITE_4(sc, TL_HOSTCMD, CSR_READ_4(sc, TL_HOSTCMD) & ~(x))
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572 #define EEPROM_START \
573 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ECLOK); \
574 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_EDATA); \
575 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ETXEN); \
576 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_EDATA); \
577 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ECLOK);
578
579
580
581
582
583 #define EEPROM_STOP \
584 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ETXEN); \
585 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_EDATA); \
586 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ECLOK); \
587 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ETXEN); \
588 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_EDATA); \
589 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ETXEN); \
590 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ECLOK);
591
592
593
594
595 #define EEPROM_CTL_READ 0xA1
596 #define EEPROM_CTL_WRITE 0xA0
597
598 #ifdef __alpha__
599 #undef vtophys
600 #define vtophys(va) alpha_XXX_dmamap((vaddr_t)va)
601 #endif