FreeBSD/Linux Kernel Cross Reference
sys/pci/if_tlreg.h
1 /*
2 * Copyright (c) 1997, 1998
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $FreeBSD: src/sys/pci/if_tlreg.h,v 1.6.2.4 1999/09/05 08:21:12 peter Exp $
33 */
34
35
36 struct tl_type {
37 u_int16_t tl_vid;
38 u_int16_t tl_did;
39 char *tl_name;
40 };
41
42 /*
43 * ThunderLAN TX/RX list format. The TX and RX lists are pretty much
44 * identical: the list begins with a 32-bit forward pointer which points
45 * at the next list in the chain, followed by 16 bits for the total
46 * frame size, and a 16 bit status field. This is followed by a series
47 * of 10 32-bit data count/data address pairs that point to the fragments
48 * that make up the complete frame.
49 */
50
51 #define TL_MAXFRAGS 10
52 #define TL_RX_LIST_CNT 20
53 #define TL_TX_LIST_CNT 20
54 #define TL_MIN_FRAMELEN 64
55
56 struct tl_frag {
57 u_int32_t tlist_dcnt;
58 u_int32_t tlist_dadr;
59 };
60
61 struct tl_list {
62 u_int32_t tlist_fptr; /* phys address of next list */
63 u_int16_t tlist_cstat; /* status word */
64 u_int16_t tlist_frsize; /* size of data in frame */
65 struct tl_frag tl_frag[TL_MAXFRAGS];
66 };
67
68 /*
69 * This is a special case of an RX list. By setting the One_Frag
70 * bit in the NETCONFIG register, the driver can force the ThunderLAN
71 * chip to use only one fragment when DMAing RX frames.
72 */
73
74 struct tl_list_onefrag {
75 u_int32_t tlist_fptr;
76 u_int16_t tlist_cstat;
77 u_int16_t tlist_frsize;
78 struct tl_frag tl_frag;
79 };
80
81 struct tl_list_data {
82 struct tl_list_onefrag tl_rx_list[TL_RX_LIST_CNT];
83 struct tl_list tl_tx_list[TL_TX_LIST_CNT];
84 unsigned char tl_pad[TL_MIN_FRAMELEN];
85 };
86
87 struct tl_chain {
88 struct tl_list *tl_ptr;
89 struct mbuf *tl_mbuf;
90 struct tl_chain *tl_next;
91 };
92
93 struct tl_chain_onefrag {
94 struct tl_list_onefrag *tl_ptr;
95 struct mbuf *tl_mbuf;
96 struct tl_chain_onefrag *tl_next;
97 };
98
99 struct tl_chain_data {
100 struct tl_chain_onefrag tl_rx_chain[TL_RX_LIST_CNT];
101 struct tl_chain tl_tx_chain[TL_TX_LIST_CNT];
102
103 struct tl_chain_onefrag *tl_rx_head;
104 struct tl_chain_onefrag *tl_rx_tail;
105
106 struct tl_chain *tl_tx_head;
107 struct tl_chain *tl_tx_tail;
108 struct tl_chain *tl_tx_free;
109 };
110
111 struct tl_softc {
112 struct arpcom arpcom; /* interface info */
113 struct ifmedia ifmedia; /* media info */
114 #ifdef TL_USEIOSPACE
115 u_int32_t iobase;
116 #else
117 volatile caddr_t csr; /* pointer to register map */
118 #endif
119 struct tl_type *tl_dinfo; /* ThunderLAN adapter info */
120 struct tl_type *tl_pinfo; /* PHY info struct */
121 u_int8_t tl_ctlr; /* chip number */
122 u_int8_t tl_unit; /* interface number */
123 u_int8_t tl_eeaddr;
124 u_int8_t tl_phy_addr; /* PHY address */
125 u_int8_t tl_tx_pend; /* TX pending */
126 u_int8_t tl_want_auto; /* autoneg scheduled */
127 u_int8_t tl_autoneg; /* autoneg in progress */
128 u_int16_t tl_phy_sts; /* PHY status */
129 u_int16_t tl_phy_vid; /* PHY vendor ID */
130 u_int16_t tl_phy_did; /* PHY device ID */
131 caddr_t tl_ldata_ptr;
132 struct tl_list_data *tl_ldata; /* TX/RX lists and mbufs */
133 struct tl_chain_data tl_cdata;
134 int tl_txeoc;
135 #ifdef TL_DEBUG
136 u_int8_t tl_event[20];
137 #endif
138 };
139
140 /*
141 * Transmit interrupt threshold.
142 */
143 #define TX_THR 0x00000004
144
145 #define TL_FLAG_FORCEDELAY 1
146 #define TL_FLAG_SCHEDDELAY 2
147 #define TL_FLAG_DELAYTIMEO 3
148
149 /*
150 * The ThunderLAN supports up to 32 PHYs.
151 */
152 #define TL_PHYADDR_MIN 0x00
153 #define TL_PHYADDR_MAX 0x1F
154
155 #define PHY_UNKNOWN 6
156
157 #define TL_PHYS_IDLE -1
158
159 /*
160 * General constants that are fun to know.
161 *
162 * The ThunderLAN controller is made by Texas Instruments. The
163 * manual indicates that if the EEPROM checksum fails, the PCI
164 * vendor and device ID registers will be loaded with TI-specific
165 * values.
166 */
167 #define TI_VENDORID 0x104C
168 #define TI_DEVICEID_THUNDERLAN 0x0500
169
170 /*
171 * Known PHY Ids. According to the Level 1 documentation (which is
172 * very nice, incidentally), here's how they work:
173 *
174 * The PHY identifier register #1 is composed of bits 3 through 18
175 * of the OUI. (First 16-bit word.)
176 * The PHY identifier register #2 is composed of bits 19 through 24
177 * if the OUI.
178 * This is followed by 6 bits containing the manufacturer's model
179 * number.
180 * Lastly, there are 4 bits for the manufacturer's revision number.
181 *
182 * Honestly, there are a lot of these that don't make any sense; the
183 * only way to be really sure is to look at the data sheets.
184 */
185
186 /*
187 * Texas Instruments PHY identifiers
188 *
189 * The ThunderLAN manual has a curious and confusing error in it.
190 * In chapter 7, which describes PHYs, it says that TI PHYs have
191 * the following ID codes, where xx denotes a revision:
192 *
193 * 0x4000501xx internal 10baseT PHY
194 * 0x4000502xx TNETE211 100VG-AnyLan PMI
195 *
196 * The problem here is that these are not valid 32-bit hex numbers:
197 * there's one digit too many. My guess is that they mean the internal
198 * 10baseT PHY is 0x4000501x and the TNETE211 is 0x4000502x since these
199 * are the only numbers that make sense.
200 */
201 #define TI_PHY_VENDORID 0x4000
202 #define TI_PHY_10BT 0x501F
203 #define TI_PHY_100VGPMI 0x502F
204
205 /*
206 * These ID values are for the NS DP83840A 10/100 PHY
207 */
208 #define NS_PHY_VENDORID 0x2000
209 #define NS_PHY_83840A 0x5C0F
210
211 /*
212 * Level 1 10/100 PHY
213 */
214 #define LEVEL1_PHY_VENDORID 0x7810
215 #define LEVEL1_PHY_LXT970 0x000F
216
217 /*
218 * Intel 82555 10/100 PHY
219 */
220 #define INTEL_PHY_VENDORID 0x0A28
221 #define INTEL_PHY_82555 0x015F
222
223 /*
224 * SEEQ 80220 10/100 PHY
225 */
226 #define SEEQ_PHY_VENDORID 0x0016
227 #define SEEQ_PHY_80220 0xF83F
228
229 /*
230 * These are the PCI vendor and device IDs for Compaq ethernet
231 * adapters based on the ThunderLAN controller.
232 */
233 #define COMPAQ_VENDORID 0x0E11
234 #define COMPAQ_DEVICEID_NETEL_10_100 0xAE32
235 #define COMPAQ_DEVICEID_NETEL_UNKNOWN 0xAE33
236 #define COMPAQ_DEVICEID_NETEL_10 0xAE34
237 #define COMPAQ_DEVICEID_NETFLEX_3P_INTEGRATED 0xAE35
238 #define COMPAQ_DEVICEID_NETEL_10_100_DUAL 0xAE40
239 #define COMPAQ_DEVICEID_NETEL_10_100_PROLIANT 0xAE43
240 #define COMPAQ_DEVICEID_NETEL_10_100_EMBEDDED 0xB011
241 #define COMPAQ_DEVICEID_NETEL_10_T2_UTP_COAX 0xB012
242 #define COMPAQ_DEVICEID_NETEL_10_100_TX_UTP 0xB030
243 #define COMPAQ_DEVICEID_NETFLEX_3P 0xF130
244 #define COMPAQ_DEVICEID_NETFLEX_3P_BNC 0xF150
245
246 /*
247 * These are the PCI vendor and device IDs for Olicom
248 * adapters based on the ThunderLAN controller.
249 */
250 #define OLICOM_VENDORID 0x108D
251 #define OLICOM_DEVICEID_OC2183 0x0013
252 #define OLICOM_DEVICEID_OC2325 0x0012
253 #define OLICOM_DEVICEID_OC2326 0x0014
254
255 /*
256 * PCI low memory base and low I/O base
257 */
258 #define TL_PCI_LOIO 0x10
259 #define TL_PCI_LOMEM 0x14
260
261 /*
262 * PCI latency timer (it's actually 0x0D, but we want a value
263 * that's longword aligned).
264 */
265 #define TL_PCI_LATENCY_TIMER 0x0C
266
267 #define TL_DIO_ADDR_INC 0x8000 /* Increment addr on each read */
268 #define TL_DIO_RAM_SEL 0x4000 /* RAM address select */
269 #define TL_DIO_ADDR_MASK 0x3FFF /* address bits mask */
270
271 /*
272 * Interrupt types
273 */
274 #define TL_INTR_INVALID 0x0
275 #define TL_INTR_TXEOF 0x1
276 #define TL_INTR_STATOFLOW 0x2
277 #define TL_INTR_RXEOF 0x3
278 #define TL_INTR_DUMMY 0x4
279 #define TL_INTR_TXEOC 0x5
280 #define TL_INTR_ADCHK 0x6
281 #define TL_INTR_RXEOC 0x7
282
283 #define TL_INT_MASK 0x001C
284 #define TL_VEC_MASK 0x1FE0
285 /*
286 * Host command register bits
287 */
288 #define TL_CMD_GO 0x80000000
289 #define TL_CMD_STOP 0x40000000
290 #define TL_CMD_ACK 0x20000000
291 #define TL_CMD_CHSEL7 0x10000000
292 #define TL_CMD_CHSEL6 0x08000000
293 #define TL_CMD_CHSEL5 0x04000000
294 #define TL_CMD_CHSEL4 0x02000000
295 #define TL_CMD_CHSEL3 0x01000000
296 #define TL_CMD_CHSEL2 0x00800000
297 #define TL_CMD_CHSEL1 0x00400000
298 #define TL_CMD_CHSEL0 0x00200000
299 #define TL_CMD_EOC 0x00100000
300 #define TL_CMD_RT 0x00080000
301 #define TL_CMD_NES 0x00040000
302 #define TL_CMD_ZERO0 0x00020000
303 #define TL_CMD_ZERO1 0x00010000
304 #define TL_CMD_ADRST 0x00008000
305 #define TL_CMD_LDTMR 0x00004000
306 #define TL_CMD_LDTHR 0x00002000
307 #define TL_CMD_REQINT 0x00001000
308 #define TL_CMD_INTSOFF 0x00000800
309 #define TL_CMD_INTSON 0x00000400
310 #define TL_CMD_RSVD0 0x00000200
311 #define TL_CMD_RSVD1 0x00000100
312 #define TL_CMD_ACK7 0x00000080
313 #define TL_CMD_ACK6 0x00000040
314 #define TL_CMD_ACK5 0x00000020
315 #define TL_CMD_ACK4 0x00000010
316 #define TL_CMD_ACK3 0x00000008
317 #define TL_CMD_ACK2 0x00000004
318 #define TL_CMD_ACK1 0x00000002
319 #define TL_CMD_ACK0 0x00000001
320
321 #define TL_CMD_CHSEL_MASK 0x01FE0000
322 #define TL_CMD_ACK_MASK 0xFF
323
324 /*
325 * EEPROM address where station address resides.
326 */
327 #define TL_EEPROM_EADDR 0x83
328 #define TL_EEPROM_EADDR2 0x99
329 #define TL_EEPROM_EADDR3 0xAF
330 #define TL_EEPROM_EADDR_OC 0xF8 /* Olicom cards use a different
331 address than Compaqs. */
332 /*
333 * ThunderLAN host command register offsets.
334 * (Can be accessed either by IO ports or memory map.)
335 */
336 #define TL_HOSTCMD 0x00
337 #define TL_CH_PARM 0x04
338 #define TL_DIO_ADDR 0x08
339 #define TL_HOST_INT 0x0A
340 #define TL_DIO_DATA 0x0C
341
342 /*
343 * ThunderLAN internal registers
344 */
345 #define TL_NETCMD 0x00
346 #define TL_NETSIO 0x01
347 #define TL_NETSTS 0x02
348 #define TL_NETMASK 0x03
349
350 #define TL_NETCONFIG 0x04
351 #define TL_MANTEST 0x06
352
353 #define TL_VENID_LSB 0x08
354 #define TL_VENID_MSB 0x09
355 #define TL_DEVID_LSB 0x0A
356 #define TL_DEVID_MSB 0x0B
357
358 #define TL_REVISION 0x0C
359 #define TL_SUBCLASS 0x0D
360 #define TL_MINLAT 0x0E
361 #define TL_MAXLAT 0x0F
362
363 #define TL_AREG0_B5 0x10
364 #define TL_AREG0_B4 0x11
365 #define TL_AREG0_B3 0x12
366 #define TL_AREG0_B2 0x13
367
368 #define TL_AREG0_B1 0x14
369 #define TL_AREG0_B0 0x15
370 #define TL_AREG1_B5 0x16
371 #define TL_AREG1_B4 0x17
372
373 #define TL_AREG1_B3 0x18
374 #define TL_AREG1_B2 0x19
375 #define TL_AREG1_B1 0x1A
376 #define TL_AREG1_B0 0x1B
377
378 #define TL_AREG2_B5 0x1C
379 #define TL_AREG2_B4 0x1D
380 #define TL_AREG2_B3 0x1E
381 #define TL_AREG2_B2 0x1F
382
383 #define TL_AREG2_B1 0x20
384 #define TL_AREG2_B0 0x21
385 #define TL_AREG3_B5 0x22
386 #define TL_AREG3_B4 0x23
387
388 #define TL_AREG3_B3 0x24
389 #define TL_AREG3_B2 0x25
390 #define TL_AREG3_B1 0x26
391 #define TL_AREG3_B0 0x27
392
393 #define TL_HASH1 0x28
394 #define TL_HASH2 0x2C
395 #define TL_TXGOODFRAMES 0x30
396 #define TL_TXUNDERRUN 0x33
397 #define TL_RXGOODFRAMES 0x34
398 #define TL_RXOVERRUN 0x37
399 #define TL_DEFEREDTX 0x38
400 #define TL_CRCERROR 0x3A
401 #define TL_CODEERROR 0x3B
402 #define TL_MULTICOLTX 0x3C
403 #define TL_SINGLECOLTX 0x3E
404 #define TL_EXCESSIVECOL 0x40
405 #define TL_LATECOL 0x41
406 #define TL_CARRIERLOSS 0x42
407 #define TL_ACOMMIT 0x43
408 #define TL_LDREG 0x44
409 #define TL_BSIZEREG 0x45
410 #define TL_MAXRX 0x46
411
412 /*
413 * ThunderLAN SIO register bits
414 */
415 #define TL_SIO_MINTEN 0x80
416 #define TL_SIO_ECLOK 0x40
417 #define TL_SIO_ETXEN 0x20
418 #define TL_SIO_EDATA 0x10
419 #define TL_SIO_NMRST 0x08
420 #define TL_SIO_MCLK 0x04
421 #define TL_SIO_MTXEN 0x02
422 #define TL_SIO_MDATA 0x01
423
424 /*
425 * Thunderlan NETCONFIG bits
426 */
427 #define TL_CFG_RCLKTEST 0x8000
428 #define TL_CFG_TCLKTEST 0x4000
429 #define TL_CFG_BITRATE 0x2000
430 #define TL_CFG_RXCRC 0x1000
431 #define TL_CFG_PEF 0x0800
432 #define TL_CFG_ONEFRAG 0x0400
433 #define TL_CFG_ONECHAN 0x0200
434 #define TL_CFG_MTEST 0x0100
435 #define TL_CFG_PHYEN 0x0080
436 #define TL_CFG_MACSEL6 0x0040
437 #define TL_CFG_MACSEL5 0x0020
438 #define TL_CFG_MACSEL4 0x0010
439 #define TL_CFG_MACSEL3 0x0008
440 #define TL_CFG_MACSEL2 0x0004
441 #define TL_CFG_MACSEL1 0x0002
442 #define TL_CFG_MACSEL0 0x0001
443
444 /*
445 * ThunderLAN NETSTS bits
446 */
447 #define TL_STS_MIRQ 0x80
448 #define TL_STS_HBEAT 0x40
449 #define TL_STS_TXSTOP 0x20
450 #define TL_STS_RXSTOP 0x10
451
452 /*
453 * ThunderLAN NETCMD bits
454 */
455 #define TL_CMD_NRESET 0x80
456 #define TL_CMD_NWRAP 0x40
457 #define TL_CMD_CSF 0x20
458 #define TL_CMD_CAF 0x10
459 #define TL_CMD_NOBRX 0x08
460 #define TL_CMD_DUPLEX 0x04
461 #define TL_CMD_TRFRAM 0x02
462 #define TL_CMD_TXPACE 0x01
463
464 /*
465 * ThunderLAN NETMASK bits
466 */
467 #define TL_MASK_MASK7 0x80
468 #define TL_MASK_MASK6 0x40
469 #define TL_MASK_MASK5 0x20
470 #define TL_MASK_MASK4 0x10
471
472 /*
473 * MII frame format
474 */
475 #ifdef ANSI_DOESNT_ALLOW_BITFIELDS
476 struct tl_mii_frame {
477 u_int16_t mii_stdelim:2,
478 mii_opcode:2,
479 mii_phyaddr:5,
480 mii_regaddr:5,
481 mii_turnaround:2;
482 u_int16_t mii_data;
483 };
484 #else
485 struct tl_mii_frame {
486 u_int8_t mii_stdelim;
487 u_int8_t mii_opcode;
488 u_int8_t mii_phyaddr;
489 u_int8_t mii_regaddr;
490 u_int8_t mii_turnaround;
491 u_int16_t mii_data;
492 };
493 #endif
494 /*
495 * MII constants
496 */
497 #define TL_MII_STARTDELIM 0x01
498 #define TL_MII_READOP 0x02
499 #define TL_MII_WRITEOP 0x01
500 #define TL_MII_TURNAROUND 0x02
501
502 #define TL_LAST_FRAG 0x80000000
503 #define TL_CSTAT_UNUSED 0x8000
504 #define TL_CSTAT_FRAMECMP 0x4000
505 #define TL_CSTAT_READY 0x3000
506 #define TL_CSTAT_UNUSED13 0x2000
507 #define TL_CSTAT_UNUSED12 0x1000
508 #define TL_CSTAT_EOC 0x0800
509 #define TL_CSTAT_RXERROR 0x0400
510 #define TL_CSTAT_PASSCRC 0x0200
511 #define TL_CSTAT_DPRIO 0x0100
512
513 #define TL_FRAME_MASK 0x00FFFFFF
514 #define tl_tx_goodframes(x) (x.tl_txstat & TL_FRAME_MASK)
515 #define tl_tx_underrun(x) ((x.tl_txstat & ~TL_FRAME_MASK) >> 24)
516 #define tl_rx_goodframes(x) (x.tl_rxstat & TL_FRAME_MASK)
517 #define tl_rx_overrun(x) ((x.tl_rxstat & ~TL_FRAME_MASK) >> 24)
518
519 struct tl_stats {
520 u_int32_t tl_txstat;
521 u_int32_t tl_rxstat;
522 u_int16_t tl_deferred;
523 u_int8_t tl_crc_errors;
524 u_int8_t tl_code_errors;
525 u_int16_t tl_tx_multi_collision;
526 u_int16_t tl_tx_single_collision;
527 u_int8_t tl_excessive_collision;
528 u_int8_t tl_late_collision;
529 u_int8_t tl_carrier_loss;
530 u_int8_t acommit;
531 };
532
533 /*
534 * register space access macros
535 */
536 #ifdef TL_USEIOSPACE
537 #define CSR_WRITE_4(sc, reg, val) \
538 outl(sc->iobase + (u_int32_t)(reg), val)
539 #define CSR_WRITE_2(sc, reg, val) \
540 outw(sc->iobase + (u_int32_t)(reg), val)
541 #define CSR_WRITE_1(sc, reg, val) \
542 outb(sc->iobase + (u_int32_t)(reg), val)
543
544 #define CSR_READ_4(sc, reg) \
545 inl(sc->iobase + (u_int32_t)(reg))
546 #define CSR_READ_2(sc, reg) \
547 inw(sc->iobase + (u_int32_t)(reg))
548 #define CSR_READ_1(sc, reg) \
549 inb(sc->iobase + (u_int32_t)(reg))
550 #else
551 #define CSR_WRITE_4(sc, reg, val) \
552 ((*(u_int32_t*)((sc)->csr + (u_int32_t)(reg))) = (u_int32_t)(val))
553 #define CSR_WRITE_2(sc, reg, val) \
554 ((*(u_int16_t*)((sc)->csr + (u_int32_t)(reg))) = (u_int16_t)(val))
555 #define CSR_WRITE_1(sc, reg, val) \
556 ((*(u_int8_t*)((sc)->csr + (u_int32_t)(reg))) = (u_int8_t)(val))
557
558 #define CSR_READ_4(sc, reg) \
559 (*(u_int32_t *)((sc)->csr + (u_int32_t)(reg)))
560 #define CSR_READ_2(sc, reg) \
561 (*(u_int16_t *)((sc)->csr + (u_int32_t)(reg)))
562 #define CSR_READ_1(sc, reg) \
563 (*(u_int8_t *)((sc)->csr + (u_int32_t)(reg)))
564 #endif
565
566
567 #define CMD_PUT(sc, x) CSR_WRITE_4(sc, TL_HOSTCMD, x)
568 #define CMD_SET(sc, x) \
569 CSR_WRITE_4(sc, TL_HOSTCMD, CSR_READ_4(sc, TL_HOSTCMD) | (x))
570 #define CMD_CLR(sc, x) \
571 CSR_WRITE_4(sc, TL_HOSTCMD, CSR_READ_4(sc, TL_HOSTCMD) & ~(x))
572
573 /*
574 * ThunderLAN adapters typically have a serial EEPROM containing
575 * configuration information. The main reason we're interested in
576 * it is because it also contains the adapters's station address.
577 *
578 * Access to the EEPROM is a bit goofy since it is a serial device:
579 * you have to do reads and writes one bit at a time. The state of
580 * the DATA bit can only change while the CLOCK line is held low.
581 * Transactions work basically like this:
582 *
583 * 1) Send the EEPROM_START sequence to prepare the EEPROM for
584 * accepting commands. This pulls the clock high, sets
585 * the data bit to 0, enables transmission to the EEPROM,
586 * pulls the data bit up to 1, then pulls the clock low.
587 * The idea is to do a 0 to 1 transition of the data bit
588 * while the clock pin is held high.
589 *
590 * 2) To write a bit to the EEPROM, set the TXENABLE bit, then
591 * set the EDATA bit to send a 1 or clear it to send a 0.
592 * Finally, set and then clear ECLOK. Strobing the clock
593 * transmits the bit. After 8 bits have been written, the
594 * EEPROM should respond with an ACK, which should be read.
595 *
596 * 3) To read a bit from the EEPROM, clear the TXENABLE bit,
597 * then set ECLOK. The bit can then be read by reading EDATA.
598 * ECLOCK should then be cleared again. This can be repeated
599 * 8 times to read a whole byte, after which the
600 *
601 * 4) We need to send the address byte to the EEPROM. For this
602 * we have to send the write control byte to the EEPROM to
603 * tell it to accept data. The byte is 0xA0. The EEPROM should
604 * ack this. The address byte can be send after that.
605 *
606 * 5) Now we have to tell the EEPROM to send us data. For that we
607 * have to transmit the read control byte, which is 0xA1. This
608 * byte should also be acked. We can then read the data bits
609 * from the EEPROM.
610 *
611 * 6) When we're all finished, send the EEPROM_STOP sequence.
612 *
613 * Note that we use the ThunderLAN's NetSio register to access the
614 * EEPROM, however there is an alternate method. There is a PCI NVRAM
615 * register at PCI offset 0xB4 which can also be used with minor changes.
616 * The difference is that access to PCI registers via pci_conf_read()
617 * and pci_conf_write() is done using programmed I/O, which we want to
618 * avoid.
619 */
620
621 /*
622 * Note that EEPROM_START leaves transmission enabled.
623 */
624 #define EEPROM_START \
625 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ECLOK); /* Pull clock pin high */\
626 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_EDATA); /* Set DATA bit to 1 */ \
627 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ETXEN); /* Enable xmit to write bit */\
628 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_EDATA); /* Pull DATA bit to 0 again */\
629 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ECLOK); /* Pull clock low again */
630
631 /*
632 * EEPROM_STOP ends access to the EEPROM and clears the ETXEN bit so
633 * that no further data can be written to the EEPROM I/O pin.
634 */
635 #define EEPROM_STOP \
636 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ETXEN); /* Disable xmit */ \
637 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_EDATA); /* Pull DATA to 0 */ \
638 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ECLOK); /* Pull clock high */ \
639 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ETXEN); /* Enable xmit */ \
640 tl_dio_setbit(sc, TL_NETSIO, TL_SIO_EDATA); /* Toggle DATA to 1 */ \
641 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ETXEN); /* Disable xmit. */ \
642 tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ECLOK); /* Pull clock low again */
643
644
645 /*
646 * These are the register definitions for the PHY (physical layer
647 * interface chip).
648 * The ThunderLAN chip has a built-in 10Mb/sec PHY which may be used
649 * in some configurations. The Compaq 10/100 cards based on the ThunderLAN
650 * use a National Semiconductor DP83840A PHY. The generic BMCR and BMSR
651 * layouts for both PHYs are identical, however some of the bits are not
652 * used by the ThunderLAN's internal PHY (most notably those dealing with
653 * switching between 10 and 100Mb/sec speeds). Since Both PHYs use the
654 * same bits, we #define them with generic names here.
655 */
656 /*
657 * PHY BMCR Basic Mode Control Register
658 */
659 #define PHY_BMCR 0x00
660 #define PHY_BMCR_RESET 0x8000
661 #define PHY_BMCR_LOOPBK 0x4000
662 #define PHY_BMCR_SPEEDSEL 0x2000
663 #define PHY_BMCR_AUTONEGENBL 0x1000
664 #define PHY_BMCR_RSVD0 0x0800 /* write as zero */
665 #define PHY_BMCR_PWRDOWN 0x0800 /* tlan internal PHY only */
666 #define PHY_BMCR_ISOLATE 0x0400
667 #define PHY_BMCR_AUTONEGRSTR 0x0200
668 #define PHY_BMCR_DUPLEX 0x0100
669 #define PHY_BMCR_COLLTEST 0x0080
670 #define PHY_BMCR_RSVD1 0x0040 /* write as zero, don't care */
671 #define PHY_BMCR_RSVD2 0x0020 /* write as zero, don't care */
672 #define PHY_BMCR_RSVD3 0x0010 /* write as zero, don't care */
673 #define PHY_BMCR_RSVD4 0x0008 /* write as zero, don't care */
674 #define PHY_BMCR_RSVD5 0x0004 /* write as zero, don't care */
675 #define PHY_BMCR_RSVD6 0x0002 /* write as zero, don't care */
676 #define PHY_BMCR_RSVD7 0x0001 /* write as zero, don't care */
677 /*
678 * RESET: 1 == software reset, 0 == normal operation
679 * Resets status and control registers to default values.
680 * Relatches all hardware config values.
681 *
682 * LOOPBK: 1 == loopback operation enabled, 0 == normal operation
683 *
684 * SPEEDSEL: 1 == 100Mb/s, 0 == 10Mb/s
685 * Link speed is selected byt his bit or if auto-negotiation if bit
686 * 12 (AUTONEGENBL) is set (in which case the value of this register
687 * is ignored).
688 *
689 * AUTONEGENBL: 1 == Autonegotiation enabled, 0 == Autonegotiation disabled
690 * Bits 8 and 13 are ignored when autoneg is set, otherwise bits 8 and 13
691 * determine speed and mode. Should be cleared and then set if PHY configured
692 * for no autoneg on startup.
693 *
694 * ISOLATE: 1 == isolate PHY from MII, 0 == normal operation
695 *
696 * AUTONEGRSTR: 1 == restart autonegotiation, 0 = normal operation
697 *
698 * DUPLEX: 1 == full duplex mode, 0 == half duplex mode
699 *
700 * COLLTEST: 1 == collision test enabled, 0 == normal operation
701 */
702
703 /*
704 * PHY, BMSR Basic Mode Status Register
705 */
706 #define PHY_BMSR 0x01
707 #define PHY_BMSR_100BT4 0x8000
708 #define PHY_BMSR_100BTXFULL 0x4000
709 #define PHY_BMSR_100BTXHALF 0x2000
710 #define PHY_BMSR_10BTFULL 0x1000
711 #define PHY_BMSR_10BTHALF 0x0800
712 #define PHY_BMSR_RSVD1 0x0400 /* write as zero, don't care */
713 #define PHY_BMSR_RSVD2 0x0200 /* write as zero, don't care */
714 #define PHY_BMSR_RSVD3 0x0100 /* write as zero, don't care */
715 #define PHY_BMSR_RSVD4 0x0080 /* write as zero, don't care */
716 #define PHY_BMSR_MFPRESUP 0x0040
717 #define PHY_BMSR_AUTONEGCOMP 0x0020
718 #define PHY_BMSR_REMFAULT 0x0010
719 #define PHY_BMSR_CANAUTONEG 0x0008
720 #define PHY_BMSR_LINKSTAT 0x0004
721 #define PHY_BMSR_JABBER 0x0002
722 #define PHY_BMSR_EXTENDED 0x0001
723
724 #define PHY_CTL_IGLINK 0x8000
725 #define PHY_CTL_SWAPOL 0x4000
726 #define PHY_CTL_AUISEL 0x2000
727 #define PHY_CTL_SQEEN 0x1000
728 #define PHY_CTL_MTEST 0x0800
729 #define PHY_CTL_NFEW 0x0004
730 #define PHY_CTL_INTEN 0x0002
731 #define PHY_CTL_TINT 0x0001
732
733 #define TL_PHY_GENCTL 0x00
734 #define TL_PHY_GENSTS 0x01
735
736 /*
737 * PHY Generic Identifier Register, hi bits
738 */
739 #define TL_PHY_VENID 0x02
740
741 /*
742 * PHY Generic Identifier Register, lo bits
743 */
744 #define TL_PHY_DEVID 0x03
745
746 #define TL_PHY_ANAR 0x04
747 #define TL_PHY_LPAR 0x05
748 #define TL_PHY_ANEXP 0x06
749
750 #define TL_PHY_PHYID 0x10
751 #define TL_PHY_CTL 0x11
752 #define TL_PHY_STS 0x12
753
754 #define TL_LPAR_RMFLT 0x2000
755 #define TL_LPAR_RSVD0 0x1000
756 #define TL_LPAR_RSVD1 0x0800
757 #define TL_LPAR_100BT4 0x0400
758 #define TL_LPAR_100BTXFULL 0x0200
759 #define TL_LPAR_100BTXHALF 0x0100
760 #define TL_LPAR_10BTFULL 0x0080
761 #define TL_LPAR_10BTHALF 0x0040
762
763 /*
764 * PHY Antoneg advertisement register.
765 */
766 #define PHY_ANAR TL_PHY_ANAR
767 #define PHY_ANAR_NEXTPAGE 0x8000
768 #define PHY_ANAR_RSVD0 0x4000
769 #define PHY_ANAR_TLRFLT 0x2000
770 #define PHY_ANAR_RSVD1 0x1000
771 #define PHY_RSVD_RSDV2 0x0800
772 #define PHY_RSVD_RSVD3 0x0400
773 #define PHY_ANAR_100BT4 0x0200
774 #define PHY_ANAR_100BTXFULL 0x0100
775 #define PHY_ANAR_100BTXHALF 0x0080
776 #define PHY_ANAR_10BTFULL 0x0040
777 #define PHY_ANAR_10BTHALF 0x0020
778 #define PHY_ANAR_PROTO4 0x0010
779 #define PHY_ANAR_PROTO3 0x0008
780 #define PHY_ANAR_PROTO2 0x0004
781 #define PHY_AHAR_PROTO1 0x0002
782 #define PHY_AHAR_PROTO0 0x0001
783
784 /*
785 * DP83840 PHY, PCS Confifguration Register
786 */
787 #define TL_DP83840_PCS 0x17
788 #define TL_DP83840_PCS_LED4_MODE 0x0002
789 #define TL_DP83840_PCS_F_CONNECT 0x0020
790 #define TL_DP83840_PCS_BIT8 0x0100
791 #define TL_DP83840_PCS_BIT10 0x0400
792
793 /*
794 * DP83840 PHY, PAR register
795 */
796 #define TL_DP83840_PAR 0x19
797
798 #define PAR_RSVD0 0x8000
799 #define PAR_RSVD1 0x4000
800 #define PAR_RSVD2 0x2000
801 #define PAR_RSVD3 0x1000
802 #define PAR_DIS_CRS_JAB 0x0800
803 #define PAR_AN_EN_STAT 0x0400
804 #define PAR_RSVD4 0x0200
805 #define PAR_FEFI_EN 0x0100
806 #define PAR_DUPLEX_STAT 0x0080
807 #define PAR_SPEED_10 0x0040
808 #define PAR_CIM_STATUS 0x0020
809 #define PAR_PHYADDR4 0x0010
810 #define PAR_PHYADDR3 0x0008
811 #define PAR_PHYADDR2 0x0004
812 #define PAR_PHYADDR1 0x0002
813 #define PAR_PHYADDR0 0x0001
814
815
816 /*
817 * Microchip Technology 24Cxx EEPROM control bytes
818 */
819 #define EEPROM_CTL_READ 0xA1 /* 0101 0001 */
820 #define EEPROM_CTL_WRITE 0xA0 /* 0101 0000 */
Cache object: f87dccfe1b41b59cd4999b0bfbc4c79e
|