1 /* libmii.c: MII diagnostic and setup library.
3 Copyright 1997-2003 by Donald Becker.
4 This version released under the Gnu General Public License,
5 incorporated herein by reference.
6 This source code may be distributed without modification using the
7 existing notice. Any modification to this source code must include a
8 full notice as described in the GPL
9 Contact the author for use under other terms.
11 The author may be reached as becker@scyld.com, or C/O
12 Scyld Computing Corporation
13 914 Bay Ridge Road, Suite 220
17 http://www.scyld.com/expert/NWay.html
18 http://www.national.com/pf/DP/DP83840A.html
21 static const char version_msg
[] =
22 "libmii.c:v2.11 2/28/2005 Donald Becker (becker@scyld.com)\n"
23 " http://www.scyld.com/diag/index.html\n";
25 /* This library exports the following functions:
26 IOADDR: A token passed to the mdio_read() function.
27 PHY_ID: The MII transceiver address, passed uninterpreted to mdio_read().
29 void show_mii_details(long ioaddr
, int phy_id
);
30 int monitor_mii(long ioaddr
, int phy_id
);
32 /* This library expects to be able to call the following functions: */
33 extern int mdio_read(long ioaddr
, int phy_id
, int mii_reg_num
);
40 #include <sys/types.h>
41 typedef u_int32_t u32
;
42 typedef u_int16_t u16
;
45 static const char *media_names
[] = {
46 "10baseT", "10baseT-FD", "100baseTx", "100baseTx-FD", "100baseT4",
50 static void ns83843(long ioaddr
, int phy_id
);
51 static void qs6612(long ioaddr
, int phy_id
);
52 static void smsc83c180(long ioaddr
, int phy_id
);
53 static void tdk78q2120(long ioaddr
, int phy_id
);
54 static void davicom_dm9101(long ioaddr
, int phy_id
);
55 static void intel_i553(long ioaddr
, int phy_id
);
56 static void enablesemi(long ioaddr
, int phy_id
);
57 static void amd_pna(long ioaddr
, int phy_id
);
58 static void amd_tx(long ioaddr
, int phy_id
);
59 static void admtek(long ioaddr
, int phy_id
);
60 static void lu3x31(long ioaddr
, int phy_id
);
61 static void myson981(long ioaddr
, int phy_id
);
62 static void via_tahoe(long ioaddr
, int phy_id
);
63 static void via_vt6103(long ioaddr
, int phy_id
);
64 static void via_vt6105(long ioaddr
, int phy_id
);
65 static void intel(long ioaddr
, int phy_id
);
68 const char *vendor
; /* Vendor name. */
69 u16 phy_id0
; /* Vendor ID (alternate ver. of ieee_oui[]) */
70 u16 phy_id1
; /* Vendor ID (alternate ver. of ieee_oui[]) */
71 unsigned char ieee_oui
[3]; /* IEEE-assigned organizationally unique ID */
73 void (*(func
))(long xcvr_if
, int phy_id
);/* Function to emit more info. */
74 } static oui_map
[] = {
75 {"Unknown transceiver type", 0x0000, 0x0000, {0,}, 0, NULL
,},
76 {"National Semiconductor 83840A", 0x2000, 0x5c01, {0,}, 0, NULL
,},
77 {"National Semiconductor 83843", 0x2000, 0x5c10, {0,}, 0, ns83843
, },
78 {"Level One LXT970", 0x7810, 0x0000, {0,}, 0, NULL
, },
79 {"Level One LXT971", 0x7810, 0x0001, {0,}, 0, NULL
, },
80 {"Level One LXT971A",0x7810, 0x0003, {0,}, 0, NULL
, },
81 {"Level One (unknown type)", 0, 0, {0x1e,0x04,0x00}, 0, NULL
, },
82 {"Davicom DM9101", 0x0181, 0xB800, {0,}, 0, davicom_dm9101
, },
83 {"Davicom (unknown type)", 0, 0, {0x00, 0x60, 0x6e}, 0, davicom_dm9101
, },
84 {"Quality Semiconductor QS6612", 0x0181, 0x4410, {0,}, 0, qs6612
},
85 {"Quality Semiconductor (unknown type)", 0,0, {0x00, 0x60, 0x51}, 0, NULL
},
86 {"SMSC 83c180", 0x0282, 0x1C51, {0}, 0, smsc83c180
, },
87 {"TDK Semi 78Q2120 rev. 2", 0x0300, 0xE542, {0,}, 0, tdk78q2120
, },
88 {"TDK Semi 78Q2120 rev. 3", 0x0300, 0xE543, {0,}, 0, tdk78q2120
, },
89 {"TDK Semi 78Q2120 rev. 11", 0x0300, 0xE54B, {0,}, 0, tdk78q2120
, },
90 {"TDK transceiver (unknown type)", 0,0, {0x00, 0xc0, 0x39}, 0, tdk78q2120
},
91 {"Intel (unknown type)", 0,0, {0x00, 0xf8, 0x00}, 0, intel_i553
},
92 {"Enable Semiconductor EL40-331", 0x0043, 0x7411, {0,}, 0, enablesemi
},
93 {"AMD 79c901A.1 HomePNA", 0x0000, 0x6B91, {0,}, 0, amd_pna
},
94 {"AMD 79c901A.2 HomePNA", 0x0000, 0x6B92, {0,}, 0, amd_pna
},
95 {"AMD 79c901A.3 HomePNA", 0x0000, 0x6B93, {0,}, 0, amd_pna
},
96 {"AMD 79c901A.3 10baseT", 0x0000, 0x6B71, {0,}, 0, amd_tx
},
97 {"AdHoc Technology AH101LF", 0x0022, 0x561B, {0,}, 0, tdk78q2120
},
98 {"Altimata Communications AC101LF", 0x0022, 0x5523, {0,}, 0, tdk78q2120
},
99 {"Altimata Comm (unknown type)", 0, 0, {0x00,0x10,0xA9}, 0, tdk78q2120
},
100 {"ASIX (unknown type)", 0, 0, {0x00,0xC0,0xB4}, 0, tdk78q2120
},
101 {"ADMtek AN983 Comet", 0x0022, 0x5410, {0,}, 0, admtek
},
102 {"ADMtek AN985 Comet", 0x0022, 0x5513, {0,}, 0, admtek
},
103 {"ADMtek (unknown type)", 0, 0, {0x00,0xe0,0x92}, 0, admtek
},
104 {"Lucent LU6612", 0x0180, 0x7641, {0,}, 0, qs6612
},
105 {"Lucent LU3X31", 0x0043, 0x7411, {0,}, 0, lu3x31
},
106 {"LSI Logic (Seeq) 80225", 0, 0, {0x00,0xA0,0x7D}, 0, NULL
},
107 {"Myson MTD981", 0x0302, 0xD000, {0,}, 0, myson981
},
108 {"Myson (unknown type)", 0, 0, {0x00,0xC0,0xB4,}, 0, myson981
},
109 {"Alta/Kendin Sundance", 0x0022, 0x1720, {0,}, 0, NULL
},
110 {"Alta/Kendin Sundance", 0, 0, {0x00,0x08,0x85}, 0, NULL
},
111 {"VIA Tahoe VT6103", 0x0101, 0x8f20, {0,}, 0, via_vt6103
},
112 {"VIA Tahoe VT6104", 0x0101, 0x8f30, {0,}, 0, via_tahoe
},
113 {"VIA Rhine VT6105", 0x0101, 0x8f22, {0,}, 0, via_vt6105
},
114 {"Intel 82557 series", 0x02a8, 0x0150, {0,}, 0, intel
},
115 {"Intel 82555 rev 1", 0x02a8, 0x0151, {0,}, 0, intel
},
116 {"Intel 82559 transceiver", 0x02a8, 0x0154, {0,}, 0, intel
},
117 {"Intel 82555 series transceiver", 0,0, {0x00,0xaa,0x00}, 0, intel
},
121 static u16 mii_val
[32];
123 void show_mii_details(long ioaddr
, int phy_id
)
125 int mii_reg
, i
, vendor
= 0;
126 u16 bmcr
, bmsr
, new_bmsr
;
128 /* This may not be omitted from the output. */
129 printf("%s", version_msg
);
130 printf(" MII PHY #%d transceiver registers:", phy_id
);
131 for (mii_reg
= 0; mii_reg
< 32; mii_reg
++) {
132 mii_val
[mii_reg
] = mdio_read(ioaddr
, phy_id
, mii_reg
);
133 printf("%s %4.4x", (mii_reg
% 8) == 0 ? "\n " : "",
137 if (mii_val
[0] == 0xffff) {
138 printf(" No MII transceiver present!.\n");
143 printf(" Basic mode control register 0x%4.4x:", bmcr
);
145 printf(" Auto-negotiation enabled.\n");
147 printf(" Auto-negotiation disabled!\n"
148 " Speed fixed at 10%s mbps, %s-duplex.\n",
149 bmcr
& 0x2000 ? "0" : "",
150 bmcr
& 0x0100 ? "full":"half");
152 printf(" Transceiver currently being reset!\n");
154 printf(" Transceiver in loopback mode!\n");
156 printf(" Transceiver powered down!\n");
158 printf(" Transceiver isolated from the MII!\n");
160 printf(" Restarted auto-negotiation in progress!\n");
162 printf(" Internal Collision-Test enabled!\n");
164 new_bmsr
= mdio_read(ioaddr
, phy_id
, 1);
165 printf(" Basic mode status register 0x%4.4x ... %4.4x.\n"
166 " Link status: %sestablished.\n"
170 (new_bmsr
& 0x0004) ? "previously broken, but now re" : "not ");
172 for (i
= 15; i
>= 11; i
--)
174 printf(" %s", media_names
[i
-11]);
176 printf("<Warning! No media capabilities>");
179 " %s to perform Auto-negotiation, negotiation %scomplete.\n",
180 bmsr
& 0x0008 ? "Able" : "Unable",
181 bmsr
& 0x0020 ? "" : "not ");
184 printf(" Remote fault detected!\n");
186 printf(" *** Link Jabber! ***\n");
188 if (mii_val
[2] ^ mii_val
[3]) { /* Eliminate 0x0000 and 0xffff IDs. */
189 unsigned char oui_0
= mii_val
[2] >> 10;
190 unsigned char oui_1
= mii_val
[2] >> 2;
191 unsigned char oui_2
= (mii_val
[2] << 6) | (mii_val
[3] >> 10);
193 printf(" Vendor ID is %2.2x:%2.2x:%2.2x:--:--:--, model %d rev. %d.\n",
195 ((mii_val
[3] >> 4) & 0x3f), mii_val
[3] & 0x0f);
196 for ( i
= 0; oui_map
[i
].vendor
; i
++)
197 /* We match either the Phy ID or the IEEE OUI. */
198 if ((oui_map
[i
].phy_id0
== mii_val
[2] &&
199 oui_map
[i
].phy_id1
== mii_val
[3]) ||
200 (oui_map
[i
].ieee_oui
[0] == oui_0
&&
201 oui_map
[i
].ieee_oui
[1] == oui_1
&&
202 oui_map
[i
].ieee_oui
[2] == oui_2
)) {
203 printf(" Vendor/Part: %s.\n", oui_map
[i
].vendor
);
207 if (oui_map
[i
].vendor
== NULL
)
208 printf(" No specific information is known about this transceiver"
211 printf(" This transceiver has no vendor identification.\n");
214 int nway_advert
= mii_val
[4];
215 int lkpar
= mii_val
[5];
216 printf(" I'm advertising %4.4x:", nway_advert
);
217 for (i
= 10; i
>= 5; i
--)
218 if (nway_advert
& (1<<i
))
219 printf(" %s", media_names
[i
-5]);
220 printf("\n Advertising %sadditional info pages.\n",
221 nway_advert
& 0x8000 ? "" : "no ");
222 if ((nway_advert
& 31) == 1)
223 printf(" IEEE 802.3 CSMA/CD protocol.\n");
225 printf(" Using an unknown (non 802.3) encapsulation.\n");
226 printf(" Link partner capability is %4.4x:",
228 for (i
= 10; i
>= 5; i
--)
230 printf(" %s", media_names
[i
-5]);
231 printf(".\n Negotiation %s.\n",
232 lkpar
& 0x4000 ? " completed" : "did not complete");
234 if (oui_map
[vendor
].func
)
235 oui_map
[vendor
].func(ioaddr
, phy_id
);
239 int monitor_mii(long ioaddr
, int phy_id
)
241 int i
, last_event
= 0;
242 unsigned short new_1
, baseline_1
= mdio_read(ioaddr
, phy_id
, 1);
243 struct timeval tv
, sleepval
;
247 if (baseline_1
== 0xffff) {
248 fprintf(stderr
, "No MII transceiver present to monitor.\n");
252 gettimeofday(&tv
, NULL
);
253 cur_time
= tv
.tv_sec
;
254 strftime(timebuf
, sizeof(timebuf
), "%H:%M:%S", localtime(&cur_time
));
256 printf("Monitoring the MII transceiver status.\n"
257 "%s.%03d Baseline value of MII BMSR (basic mode status register)"
258 " is %4.4x.\n", timebuf
, (int)tv
.tv_usec
/1000, baseline_1
);
260 new_1
= mdio_read(ioaddr
, phy_id
, 1);
261 if (new_1
== 0xffff) {
262 fprintf(stderr
, "The MII transceiver is no longer accessable!\n");
265 if (new_1
!= baseline_1
) {
266 gettimeofday(&tv
, NULL
);
267 cur_time
= tv
.tv_sec
;
268 strftime(timebuf
, sizeof(timebuf
), "%H:%M:%S",
269 localtime(&cur_time
));
270 printf("%s.%03d MII BMSR now %4.4x: %4s link, NWay %s, "
271 "%3sJabber%s (%4.4x).\n",
272 timebuf
, (int)tv
.tv_usec
/1000, new_1
,
273 new_1
& 0x04 ? "Good" : "no",
274 new_1
& 0x20 ? "done" : "busy",
275 new_1
& 0x02 ? "" : "No ",
276 new_1
& 0x10 ? ", remote fault" : "",
277 mdio_read(ioaddr
, phy_id
, 5)
279 if (!(baseline_1
& 0x20) && (new_1
& 0x20)) {
280 int lkpar
= mdio_read(ioaddr
, phy_id
, 5);
281 printf(" New link partner capability is %4.4x %4.4x:",
282 lkpar
, mdio_read(ioaddr
, phy_id
, 6));
284 case 0x45e1: printf(" 10/100 switch w/ flow control"); break;
285 case 0x41e1: printf(" 10/100 HD+FD switch"); break;
286 case 0x40a1: printf(" 10/100 bridged repeater"); break;
287 case 0x4081: printf(" 100baseTx repeater w/autonegotation");
289 case 0x0081: printf(" 100baseTx (no autonegotation)"); break;
290 case 0x4021: printf(" 10baseT repeater w/autonegotation");
292 case 0x0021: printf(" 10baseT (no autonegotation)"); break;
294 for (i
= 9; i
>= 5; i
--)
296 printf(" %s", media_names
[i
-5]);
305 sleepval
.tv_usec
= last_event
++ > 30 ? 200000 : 1000;
306 select(0, 0, 0, 0, &sleepval
); /* Or just sleep(1); */
308 printf(" Value of MII BMSR (basic mode status register) is %4.4x.\n",
309 mdio_read(ioaddr
, phy_id
, 1));
313 /* Emit transceiver-specific info. */
315 struct msg_tbl
{ int bitmask
; char *msg
; };
317 static void msg_if_set(const int val
, const struct msg_tbl msg_tbl
[])
320 for (i
= 0; msg_tbl
[i
].bitmask
; i
++)
321 if (msg_tbl
[i
].bitmask
& val
)
322 printf(" %s\n", msg_tbl
[i
].msg
);
325 static void msg_if_set_fmt(const int val
, const struct msg_tbl msg_tbl
[],
329 for (i
= 0; msg_tbl
[i
].bitmask
; i
++)
330 if (msg_tbl
[i
].bitmask
& val
)
331 printf(fmt
, msg_tbl
[i
].msg
);
334 static void qs6612(long ioaddr
, int phy_id
)
336 printf(" QS6612 extra registers: Mode %4.4x.\n"
337 " Interrupt source %4.4x, mask %4.4x.\n"
338 " PHY control %4.4x.\n",
339 mii_val
[17], mii_val
[29], mii_val
[30], mii_val
[31]);
343 static void ns83843(long ioaddr
, int phy_id
)
345 printf(" NatSemi 83843 extra registers:\n"
346 " PHY status %4.4x\n"
347 " %s link, %d Mb/sec %s duplex\n"
348 " MII interrupts %sabled, %s pending.\n"
349 " Events since last read\n"
350 " Link disconnects %d\n"
351 " False carriers %d\n"
352 " Receive errors %d\n"
353 " Link beat is currently %sstable\n",
355 mii_val
[10] & 0x0001 ? "Valid" : "Invalid",
356 mii_val
[10] & 0x0002 ? 10 : 100,
357 mii_val
[10] & 0x0004 ? "full" : "half",
358 mii_val
[0x11] & 0x0002 ? "en":"dis",
359 mii_val
[0x10] & 0x0100 ? "interrupt": "none",
360 mii_val
[0x13], mii_val
[0x14], mii_val
[0x15],
361 mii_val
[0x16] & 0x0010 ? "UN" : "");
364 static void smsc83c180(long ioaddr
, int phy_id
)
366 int mii_reg25
= mii_val
[25];
367 printf(" SMSC 83c180 extra registers:\n"
368 " Auto-negotiation status 0x%4.4x.\n"
369 " 10baseT polarity is %s.\n"
370 " PHY address is %d.\n"
371 " Auto-negotiation %scomplete, 1%s0Mbps %s duplex.\n"
372 " Rx symbol errors since last read %d.\n",
374 mii_reg25
& 0x2000 ? "normal" : "reversed",
375 (mii_reg25
>>8) & 0x1F,
376 mii_reg25
& 0x0080 ? "did not " : "",
377 mii_reg25
& 0x0020 ? "0" : "",
378 mii_reg25
& 0x0040 ? "full" : "half",
379 mdio_read(ioaddr
, phy_id
, 26));
383 static const char *tdk_events
[8] = {
384 "Jabber", "Rx error", "Negotiation page received", "Link detection fault",
385 "Link partner acknowledge", "Link status change", "Remote partner fault",
386 "Auto-Negotiation complete"};
388 static const struct msg_tbl tdk_reg16
[] = {
389 {0x8000, " Transceiver is in repeater mode!"},
390 {0x4000, " Interrupt pin set to active high."},
391 {0x2000, " Reserved bit 12 is unexpectedly set."},
392 {0x1000, " Transmit pins are internally disconnected."},
393 {0x0800, " 10baseT signal quality test is disabled."},
394 {0x0400, " 10baseT loopback mode."},
398 static void tdk78q2120(long ioaddr
, int phy_id
)
400 int mii_reg16
= mii_val
[16];
401 int mii_reg17
= mii_val
[17];
402 int mii_reg18
= mii_val
[18];
404 printf(" TDK format vendor-specific registers 16..18 are "
405 "0x%4.4x 0x%4.4x 0x%4.4x\n", mii_reg16
, mii_reg17
, mii_reg18
);
406 printf(" Link polarity is %s %s.\n"
408 " Auto-negotiation %s, 1%s0Mbps %s duplex.\n"
409 " Rx link in %s state, PLL %s.\n",
410 mii_reg16
& 0x0020 ? "OVERRIDDEN to" : "detected as",
411 mii_reg16
& 0x0010 ? "reversed" : "normal",
413 " 100baseTx Coding and scrambling is disabled!\n":"",
414 mii_reg16
& 0x0001 ? " Rx_CLK power-save mode is enabled!\n":"",
415 mii_reg18
& 0x1000 ? "had no common media" : "complete",
416 mii_reg18
& 0x0400 ? "0" : "",
417 mii_reg18
& 0x0800 ? "full" : "half",
418 mii_reg18
& 0x0200 ? "pass" : "fail",
419 mii_reg18
& 0x0100 ? "slipped since last read" : "locked");
421 msg_if_set(mii_reg16
, tdk_reg16
);
422 if (mii_reg17
& 0x00ff) {
423 printf(" Events since last read:");
424 for (i
= 0; i
< 8; i
++)
425 if (mii_reg17
& (1 << i
))
426 printf(" %s", tdk_events
[i
]);
428 printf(" No new link status events.");
430 if (mii_reg17
& 0xff00) {
431 printf("\n Events that will raise an interrupt:");
432 for (i
= 0; i
< 8; i
++)
433 if (mii_reg17
& (0x100 << i
))
434 printf(" %s", tdk_events
[i
]);
440 static void davicom_dm9101(long ioaddr
, int phy_id
)
442 printf(" Davicom vendor specific registers: 0x%4.4x 0x%4.4x 0x%4.4x.\n",
443 mii_val
[16], mii_val
[17], mii_val
[18]);
445 static void intel_i553(long ioaddr
, int phy_id
)
447 printf(" This transceiver is 100baseT4 only! Register 16 is %4.4x.\n",
450 /* http://www.enablesemi.com/cgi-bin/byteserve/Products/Docs/3VCardBus.pdf */
451 static void enablesemi(long ioaddr
, int phy_id
)
453 printf(" Isolated %d times, %d false carrier events, %d Rx errors.\n",
454 mii_val
[18], mii_val
[19], mii_val
[21]);
455 printf(" Cable polarity is %s, 100Mb PLL is %slocked.\n",
456 mii_val
[28]&0x8000 ? "reversed" : "normal",
457 mii_val
[27]&0x2000 ? "" : "un");
459 /* The amd79c901 contains both PNA and 10/100 management registers.
460 http://www.amd.com/products/npd/techdocs/22304.pdf
462 static void amd_pna(long ioaddr
, int phy_id
)
464 printf(" HomePNA transceiver in %s speed, %s power mode.\n",
465 mii_val
[16] & 4 ? "high" : "low",
466 mii_val
[16] & 2 ? "high" : "low");
467 printf(" HomePNA noise level %d, peak power %d..\n",
468 mii_val
[25] >> 8, mii_val
[25] & 0xff);
470 static void amd_tx(long ioaddr
, int phy_id
)
472 int mii_reg25
= mii_val
[25];
473 printf(" AMD vendor specific registers: 0x%4.4x 0x%4.4x 0x%4.4x.\n",
474 mii_val
[16], mii_val
[17], mii_val
[18]);
475 printf(" The link is %s in 10%s %s duplex mode, autonegotiation state "
477 mii_reg25
& 8 ? "up" : "down",
478 mii_reg25
& 1 ? "0baseTx" : "baseT",
479 mii_reg25
& 4 ? "full" : "half",
480 mii_reg25
& 2 ? "" : " not");
483 static const struct msg_tbl admtek_reg21
[] = {
484 {0x4000, " Link test diabled: Ignoring lack of 10baseT link beat."},
485 {0x2000, " Link forced up."},
486 {0x1000, " Tx jabber check disabled."},
487 {0x0080, " Transmitting 'Far End Fault'!"},
488 {0x0040, " Rx error count full."},
489 {0x0008, " Remote loop back enabled."},
493 static void admtek(long ioaddr
, int phy_id
)
496 printf(" ADMtek vendor specific registers information:\n"
497 " Cable length is approximately %d meters.\n"
498 " The receiver has lost lock %d times since last check and "
499 "had %d error events.\n",
500 ((mii_val
[20] & 0x00f0) >> 4)*10,
501 mii_val
[23], mii_val
[23]);
502 msg_if_set(mii_val
[21], admtek_reg21
);
503 tdk78q2120(ioaddr
, phy_id
);
506 static void lu3x31(long ioaddr
, int phy_id
)
508 printf(" Lucent vendor specific registers 17: 0x%4.4x"
509 " 29: 0x%4.4x 30: 0x%4.4x 31: 0x%4.4x.\n",
510 mii_val
[17], mii_val
[29], mii_val
[30], mii_val
[31]);
513 static const struct msg_tbl myson_reg16
[] = {
514 {0x0080, " Far end fault enabled."},
515 {0x0040, " Transformer ratio 1.25:1."},
516 {0x0020, " Polarity correction diabled."},
517 {0x0010, " Link is forced up regardless of link beat."},
518 {0x0004, " Bypass Jabber check."},
519 {0x0001, " 100baseFx mode selected."},
523 static void myson981(long ioaddr
, int phy_id
)
525 int i
, mii_reg17
= mii_val
[17];
527 printf(" Myson mtd981 extra registers: %4.4x %4.4x %4.4x %4.4x.\n",
528 mii_val
[16], mii_val
[17], mii_val
[18], mii_val
[19]);
529 msg_if_set(mii_val
[16] & 0xC800, tdk_reg16
);
530 msg_if_set(mii_val
[16], myson_reg16
);
532 if (mii_reg17
& 0x00ff) {
533 printf(" Events since last read:");
534 for (i
= 0; i
< 8; i
++)
535 if (mii_reg17
& (1 << i
))
536 printf(" %s", tdk_events
[i
]);
538 printf(" No new link status events.");
539 if (mii_reg17
& 0xff00) {
540 printf("\n Events that will raise an interrupt:");
541 for (i
= 0; i
< 8; i
++)
542 if (mii_reg17
& (0x100 << i
))
543 printf(" %s", tdk_events
[i
]);
550 /* These are much like the TDK events in reversed order. */
551 static const struct msg_tbl via_reg17
[] = {
552 {0x0001, "Auto-Negotiation complete"},
553 {0x0002, "Remote fault detected"},
554 {0x0004, "Link failure detected"},
555 {0x0008, "Bad Start Stream detected"},
556 {0x0010, "Parallel detection fault"},
557 {0x0020, "Extended negotiation page received"},
558 {0x0040, "5B/4B code error detected"},
559 {0x0080, "Jabber detected"},
563 static void via_tahoe(long ioaddr
, int phy_id
)
565 int mii_reg16
= mii_val
[16];
566 int mii_reg17
= mii_val
[17];
567 int mii_reg18
= mii_val
[18];
569 printf(" VIA Tahoe extended registers: 16 %4.4x #17 %4.4x #18 %4.4x.\n",
570 mii_reg16
, mii_reg17
, mii_reg18
);
571 msg_if_set_fmt(mii_reg17
, via_reg17
, " %s\n");
572 printf(" Link %s 10%s Mbps %s duplex\n",
573 mii_reg18
& 0x2000 ? "up" : "down",
574 mii_reg18
& 0x0400 ? "0" : "",
575 mii_reg18
& 0x0800 ? "full" : "half");
579 http://www.via.com.tw/en/datasheet/DS6103110.pdf
582 static void via_vt6103(long ioaddr
, int phy_id
)
584 printf(" VIA vt6103 error counts since the last check:\n"
585 " The link has failed %d times.\n"
586 " The receiver has lost lock %d times.\n"
587 " There have been %d false carrier/SQE error.\n",
588 mii_val
[21], mii_val
[22], mii_val
[23]);
592 http://www.via.com.tw/en/Networking/DS6105LOM100.pdf
595 static void via_vt6105(long ioaddr
, int phy_id
)
597 printf(" VIA vt6105 PHY status:\n"
598 " Duplex %s speed %s\n",
599 mii_val
[20] & 0x0001 ? "full" : "half",
600 mii_val
[20] & 0x0002 ? "100" : "10");
604 http://www.via.com.tw/en/Networking/DS6105LOM100.pdf
606 static void intel(long ioaddr
, int phy_id
)
608 printf(" Intel 8255* PHY #%d extended management registers:\n"
609 " Error counts, cleared when read:\n"
610 " False carriers %d\n"
611 " Link disconnects %d\n"
612 " Receive errors %d\n"
613 " Rx symbol errors %d.\n"
614 " Rx 10Mbps Early End-Of-Frame errors %d.\n"
615 " Rx 100Mbps Early End-Of-Frame errors %d.\n"
616 " Tx jabber errors %d.\n",
618 mii_val
[19], mii_val
[20], mii_val
[21], mii_val
[22], mii_val
[23],
619 mii_val
[24], mii_val
[25]);
625 * compile-command: "cc -O -Wall -c libmii.c"