xref: /minix3/minix/drivers/net/fxp/mii.c (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc /*
2*433d6423SLionel Sambuc ibm/mii.c
3*433d6423SLionel Sambuc 
4*433d6423SLionel Sambuc Created:	Nov 2004 by Philip Homburg <philip@f-mnx.phicoh.com>
5*433d6423SLionel Sambuc 
6*433d6423SLionel Sambuc Media Independent (Ethernet) Interface functions
7*433d6423SLionel Sambuc */
8*433d6423SLionel Sambuc 
9*433d6423SLionel Sambuc #include <minix/drivers.h>
10*433d6423SLionel Sambuc #if __minix_vmd
11*433d6423SLionel Sambuc #include "config.h"
12*433d6423SLionel Sambuc #endif
13*433d6423SLionel Sambuc 
14*433d6423SLionel Sambuc #include "mii.h"
15*433d6423SLionel Sambuc 
16*433d6423SLionel Sambuc /*===========================================================================*
17*433d6423SLionel Sambuc  *				mii_print_stat_speed			     *
18*433d6423SLionel Sambuc  *===========================================================================*/
mii_print_stat_speed(u16_t stat,u16_t extstat)19*433d6423SLionel Sambuc void mii_print_stat_speed(u16_t stat, u16_t extstat)
20*433d6423SLionel Sambuc {
21*433d6423SLionel Sambuc 	int fs, ft;
22*433d6423SLionel Sambuc 
23*433d6423SLionel Sambuc 	fs= 1;
24*433d6423SLionel Sambuc 	if (stat & MII_STATUS_EXT_STAT)
25*433d6423SLionel Sambuc 	{
26*433d6423SLionel Sambuc 		if (extstat & (MII_ESTAT_1000XFD | MII_ESTAT_1000XHD |
27*433d6423SLionel Sambuc 			MII_ESTAT_1000TFD | MII_ESTAT_1000THD))
28*433d6423SLionel Sambuc 		{
29*433d6423SLionel Sambuc 			printf("1000 Mbps: ");
30*433d6423SLionel Sambuc 			fs= 0;
31*433d6423SLionel Sambuc 			ft= 1;
32*433d6423SLionel Sambuc 			if (extstat & (MII_ESTAT_1000XFD | MII_ESTAT_1000XHD))
33*433d6423SLionel Sambuc 			{
34*433d6423SLionel Sambuc 				ft= 0;
35*433d6423SLionel Sambuc 				printf("X-");
36*433d6423SLionel Sambuc 				switch(extstat &
37*433d6423SLionel Sambuc 					(MII_ESTAT_1000XFD|MII_ESTAT_1000XHD))
38*433d6423SLionel Sambuc 				{
39*433d6423SLionel Sambuc 				case MII_ESTAT_1000XFD:	printf("FD"); break;
40*433d6423SLionel Sambuc 				case MII_ESTAT_1000XHD:	printf("HD"); break;
41*433d6423SLionel Sambuc 				default:		printf("FD/HD"); break;
42*433d6423SLionel Sambuc 				}
43*433d6423SLionel Sambuc 			}
44*433d6423SLionel Sambuc 			if (extstat & (MII_ESTAT_1000TFD | MII_ESTAT_1000THD))
45*433d6423SLionel Sambuc 			{
46*433d6423SLionel Sambuc 				if (!ft)
47*433d6423SLionel Sambuc 					printf(", ");
48*433d6423SLionel Sambuc 				ft= 0;
49*433d6423SLionel Sambuc 				printf("T-");
50*433d6423SLionel Sambuc 				switch(extstat &
51*433d6423SLionel Sambuc 					(MII_ESTAT_1000TFD|MII_ESTAT_1000THD))
52*433d6423SLionel Sambuc 				{
53*433d6423SLionel Sambuc 				case MII_ESTAT_1000TFD:	printf("FD"); break;
54*433d6423SLionel Sambuc 				case MII_ESTAT_1000THD:	printf("HD"); break;
55*433d6423SLionel Sambuc 				default:		printf("FD/HD"); break;
56*433d6423SLionel Sambuc 				}
57*433d6423SLionel Sambuc 			}
58*433d6423SLionel Sambuc 		}
59*433d6423SLionel Sambuc 	}
60*433d6423SLionel Sambuc 	if (stat & (MII_STATUS_100T4 |
61*433d6423SLionel Sambuc 		MII_STATUS_100XFD | MII_STATUS_100XHD |
62*433d6423SLionel Sambuc 		MII_STATUS_100T2FD | MII_STATUS_100T2HD))
63*433d6423SLionel Sambuc 	{
64*433d6423SLionel Sambuc 		if (!fs)
65*433d6423SLionel Sambuc 			printf(", ");
66*433d6423SLionel Sambuc 		fs= 0;
67*433d6423SLionel Sambuc 		printf("100 Mbps: ");
68*433d6423SLionel Sambuc 		ft= 1;
69*433d6423SLionel Sambuc 		if (stat & MII_STATUS_100T4)
70*433d6423SLionel Sambuc 		{
71*433d6423SLionel Sambuc 			printf("T4");
72*433d6423SLionel Sambuc 			ft= 0;
73*433d6423SLionel Sambuc 		}
74*433d6423SLionel Sambuc 		if (stat & (MII_STATUS_100XFD | MII_STATUS_100XHD))
75*433d6423SLionel Sambuc 		{
76*433d6423SLionel Sambuc 			if (!ft)
77*433d6423SLionel Sambuc 				printf(", ");
78*433d6423SLionel Sambuc 			ft= 0;
79*433d6423SLionel Sambuc 			printf("TX-");
80*433d6423SLionel Sambuc 			switch(stat & (MII_STATUS_100XFD|MII_STATUS_100XHD))
81*433d6423SLionel Sambuc 			{
82*433d6423SLionel Sambuc 			case MII_STATUS_100XFD:	printf("FD"); break;
83*433d6423SLionel Sambuc 			case MII_STATUS_100XHD:	printf("HD"); break;
84*433d6423SLionel Sambuc 			default:		printf("FD/HD"); break;
85*433d6423SLionel Sambuc 			}
86*433d6423SLionel Sambuc 		}
87*433d6423SLionel Sambuc 		if (stat & (MII_STATUS_100T2FD | MII_STATUS_100T2HD))
88*433d6423SLionel Sambuc 		{
89*433d6423SLionel Sambuc 			if (!ft)
90*433d6423SLionel Sambuc 				printf(", ");
91*433d6423SLionel Sambuc 			ft= 0;
92*433d6423SLionel Sambuc 			printf("T2-");
93*433d6423SLionel Sambuc 			switch(stat & (MII_STATUS_100T2FD|MII_STATUS_100T2HD))
94*433d6423SLionel Sambuc 			{
95*433d6423SLionel Sambuc 			case MII_STATUS_100T2FD:	printf("FD"); break;
96*433d6423SLionel Sambuc 			case MII_STATUS_100T2HD:	printf("HD"); break;
97*433d6423SLionel Sambuc 			default:		printf("FD/HD"); break;
98*433d6423SLionel Sambuc 			}
99*433d6423SLionel Sambuc 		}
100*433d6423SLionel Sambuc 	}
101*433d6423SLionel Sambuc 	if (stat & (MII_STATUS_10FD | MII_STATUS_10HD))
102*433d6423SLionel Sambuc 	{
103*433d6423SLionel Sambuc 		if (!fs)
104*433d6423SLionel Sambuc 			printf(", ");
105*433d6423SLionel Sambuc 		printf("10 Mbps: ");
106*433d6423SLionel Sambuc 		fs= 0;
107*433d6423SLionel Sambuc 		printf("T-");
108*433d6423SLionel Sambuc 		switch(stat & (MII_STATUS_10FD|MII_STATUS_10HD))
109*433d6423SLionel Sambuc 		{
110*433d6423SLionel Sambuc 		case MII_STATUS_10FD:	printf("FD"); break;
111*433d6423SLionel Sambuc 		case MII_STATUS_10HD:	printf("HD"); break;
112*433d6423SLionel Sambuc 		default:		printf("FD/HD"); break;
113*433d6423SLionel Sambuc 		}
114*433d6423SLionel Sambuc 	}
115*433d6423SLionel Sambuc }
116*433d6423SLionel Sambuc 
117*433d6423SLionel Sambuc /*===========================================================================*
118*433d6423SLionel Sambuc  *				mii_print_techab			     *
119*433d6423SLionel Sambuc  *===========================================================================*/
mii_print_techab(u16_t techab)120*433d6423SLionel Sambuc void mii_print_techab(u16_t techab)
121*433d6423SLionel Sambuc {
122*433d6423SLionel Sambuc 	int fs, ft;
123*433d6423SLionel Sambuc 
124*433d6423SLionel Sambuc 	if ((techab & MII_ANA_SEL_M) != MII_ANA_SEL_802_3)
125*433d6423SLionel Sambuc 	{
126*433d6423SLionel Sambuc 		printf("strange selector 0x%x, value 0x%x",
127*433d6423SLionel Sambuc 			techab & MII_ANA_SEL_M,
128*433d6423SLionel Sambuc 			(techab & MII_ANA_TAF_M) >> MII_ANA_TAF_S);
129*433d6423SLionel Sambuc 		return;
130*433d6423SLionel Sambuc 	}
131*433d6423SLionel Sambuc 	fs= 1;
132*433d6423SLionel Sambuc 	if (techab & (MII_ANA_100T4 | MII_ANA_100TXFD | MII_ANA_100TXHD))
133*433d6423SLionel Sambuc 	{
134*433d6423SLionel Sambuc 		printf("100 Mbps: ");
135*433d6423SLionel Sambuc 		fs= 0;
136*433d6423SLionel Sambuc 		ft= 1;
137*433d6423SLionel Sambuc 		if (techab & MII_ANA_100T4)
138*433d6423SLionel Sambuc 		{
139*433d6423SLionel Sambuc 			printf("T4");
140*433d6423SLionel Sambuc 			ft= 0;
141*433d6423SLionel Sambuc 		}
142*433d6423SLionel Sambuc 		if (techab & (MII_ANA_100TXFD | MII_ANA_100TXHD))
143*433d6423SLionel Sambuc 		{
144*433d6423SLionel Sambuc 			if (!ft)
145*433d6423SLionel Sambuc 				printf(", ");
146*433d6423SLionel Sambuc 			ft= 0;
147*433d6423SLionel Sambuc 			printf("TX-");
148*433d6423SLionel Sambuc 			switch(techab & (MII_ANA_100TXFD|MII_ANA_100TXHD))
149*433d6423SLionel Sambuc 			{
150*433d6423SLionel Sambuc 			case MII_ANA_100TXFD:	printf("FD"); break;
151*433d6423SLionel Sambuc 			case MII_ANA_100TXHD:	printf("HD"); break;
152*433d6423SLionel Sambuc 			default:		printf("FD/HD"); break;
153*433d6423SLionel Sambuc 			}
154*433d6423SLionel Sambuc 		}
155*433d6423SLionel Sambuc 	}
156*433d6423SLionel Sambuc 	if (techab & (MII_ANA_10TFD | MII_ANA_10THD))
157*433d6423SLionel Sambuc 	{
158*433d6423SLionel Sambuc 		if (!fs)
159*433d6423SLionel Sambuc 			printf(", ");
160*433d6423SLionel Sambuc 		printf("10 Mbps: ");
161*433d6423SLionel Sambuc 		fs= 0;
162*433d6423SLionel Sambuc 		printf("T-");
163*433d6423SLionel Sambuc 		switch(techab & (MII_ANA_10TFD|MII_ANA_10THD))
164*433d6423SLionel Sambuc 		{
165*433d6423SLionel Sambuc 		case MII_ANA_10TFD:	printf("FD"); break;
166*433d6423SLionel Sambuc 		case MII_ANA_10THD:	printf("HD"); break;
167*433d6423SLionel Sambuc 		default:		printf("FD/HD"); break;
168*433d6423SLionel Sambuc 		}
169*433d6423SLionel Sambuc 	}
170*433d6423SLionel Sambuc 	if (techab & MII_ANA_PAUSE_SYM)
171*433d6423SLionel Sambuc 	{
172*433d6423SLionel Sambuc 		if (!fs)
173*433d6423SLionel Sambuc 			printf(", ");
174*433d6423SLionel Sambuc 		fs= 0;
175*433d6423SLionel Sambuc 		printf("pause(SYM)");
176*433d6423SLionel Sambuc 	}
177*433d6423SLionel Sambuc 	if (techab & MII_ANA_PAUSE_ASYM)
178*433d6423SLionel Sambuc 	{
179*433d6423SLionel Sambuc 		if (!fs)
180*433d6423SLionel Sambuc 			printf(", ");
181*433d6423SLionel Sambuc 		fs= 0;
182*433d6423SLionel Sambuc 		printf("pause(ASYM)");
183*433d6423SLionel Sambuc 	}
184*433d6423SLionel Sambuc 	if (techab & MII_ANA_TAF_RES)
185*433d6423SLionel Sambuc 	{
186*433d6423SLionel Sambuc 		if (!fs)
187*433d6423SLionel Sambuc 			printf(", ");
188*433d6423SLionel Sambuc 		fs= 0;
189*433d6423SLionel Sambuc 		printf("0x%x", (techab & MII_ANA_TAF_RES) >> MII_ANA_TAF_S);
190*433d6423SLionel Sambuc 	}
191*433d6423SLionel Sambuc }
192*433d6423SLionel Sambuc 
193*433d6423SLionel Sambuc /*
194*433d6423SLionel Sambuc  * $PchId: mii.c,v 1.2 2005/01/31 22:17:26 philip Exp $
195*433d6423SLionel Sambuc  */
196