This source file includes following definitions.
- rtl80x9_mediachange
- rtl80x9_mediastatus
- rtl80x9_init_card
- rtl80x9_media_init
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
39
40
41 #include "bpfilter.h"
42
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/mbuf.h>
46 #include <sys/syslog.h>
47 #include <sys/socket.h>
48 #include <sys/device.h>
49
50 #include <net/if.h>
51 #include <net/if_media.h>
52
53 #ifdef INET
54 #include <netinet/in.h>
55 #include <netinet/if_ether.h>
56 #endif
57
58 #include <machine/bus.h>
59
60 #include <dev/ic/dp8390reg.h>
61 #include <dev/ic/dp8390var.h>
62
63 #include <dev/ic/ne2000reg.h>
64 #include <dev/ic/ne2000var.h>
65
66 #include <dev/ic/rtl80x9reg.h>
67 #include <dev/ic/rtl80x9var.h>
68
69 int
70 rtl80x9_mediachange(dsc)
71 struct dp8390_softc *dsc;
72 {
73
74
75
76
77
78
79 dp8390_reset(dsc);
80 return (0);
81 }
82
83 void
84 rtl80x9_mediastatus(sc, ifmr)
85 struct dp8390_softc *sc;
86 struct ifmediareq *ifmr;
87 {
88 struct ifnet *ifp = &sc->sc_arpcom.ac_if;
89 u_int8_t cr_proto = sc->cr_proto |
90 ((ifp->if_flags & IFF_RUNNING) ? ED_CR_STA : ED_CR_STP);
91
92
93
94
95
96
97
98 NIC_PUT(sc->sc_regt, sc->sc_regh, ED_P0_CR, cr_proto | ED_CR_PAGE_3);
99
100 if (NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG0) &
101 RTL3_CONFIG0_BNC)
102 ifmr->ifm_active = IFM_ETHER|IFM_10_2;
103 else {
104 ifmr->ifm_active = IFM_ETHER|IFM_10_T;
105 if (NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3) &
106 RTL3_CONFIG3_FUDUP)
107 ifmr->ifm_active |= IFM_FDX;
108 }
109
110
111 NIC_PUT(sc->sc_regt, sc->sc_regh, ED_P0_CR, cr_proto | ED_CR_PAGE_0);
112 }
113
114 void
115 rtl80x9_init_card(sc)
116 struct dp8390_softc *sc;
117 {
118 struct ifmedia *ifm = &sc->sc_media;
119 struct ifnet *ifp = &sc->sc_arpcom.ac_if;
120 u_int8_t cr_proto = sc->cr_proto |
121 ((ifp->if_flags & IFF_RUNNING) ? ED_CR_STA : ED_CR_STP);
122 u_int8_t reg;
123
124
125 NIC_PUT(sc->sc_regt, sc->sc_regh, ED_P0_CR, cr_proto | ED_CR_PAGE_3);
126
127
128 NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_EECR,
129 RTL3_EECR_EEM1|RTL3_EECR_EEM0);
130
131
132 reg = NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG2);
133 reg &= ~(RTL3_CONFIG2_PL1|RTL3_CONFIG2_PL0);
134 switch (IFM_SUBTYPE(ifm->ifm_cur->ifm_media)) {
135 case IFM_AUTO:
136
137 break;
138
139 case IFM_10_T:
140
141
142
143
144
145 break;
146
147 case IFM_10_2:
148 reg |= RTL3_CONFIG2_PL1|RTL3_CONFIG2_PL0;
149 break;
150 }
151 NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG2, reg);
152
153
154 reg = NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3);
155 if (ifm->ifm_cur->ifm_media & IFM_FDX)
156 reg |= RTL3_CONFIG3_FUDUP;
157 else
158 reg &= ~RTL3_CONFIG3_FUDUP;
159 NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3, reg);
160
161
162 NIC_PUT(sc->sc_regt, sc->sc_regh, NERTL_RTL3_EECR, 0);
163
164
165 NIC_PUT(sc->sc_regt, sc->sc_regh, ED_P0_CR, cr_proto | ED_CR_PAGE_0);
166 }
167
168 void
169 rtl80x9_media_init(sc)
170 struct dp8390_softc *sc;
171 {
172 static int rtl80x9_media[] = {
173 IFM_ETHER|IFM_AUTO,
174 IFM_ETHER|IFM_10_T,
175 IFM_ETHER|IFM_10_T|IFM_FDX,
176 IFM_ETHER|IFM_10_2,
177 };
178 static const int rtl80x9_nmedia =
179 sizeof(rtl80x9_media) / sizeof(rtl80x9_media[0]);
180
181 int i, defmedia;
182 u_int8_t conf2, conf3;
183
184
185 bus_space_write_1(sc->sc_regt, sc->sc_regh, ED_P0_CR, ED_CR_PAGE_3);
186
187 conf2 = bus_space_read_1(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG2);
188 conf3 = bus_space_read_1(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3);
189
190 conf2 &= RTL3_CONFIG2_PL1|RTL3_CONFIG2_PL0;
191
192 switch (conf2) {
193 case 0:
194 defmedia = IFM_ETHER|IFM_AUTO;
195 break;
196
197 case RTL3_CONFIG2_PL1|RTL3_CONFIG2_PL0:
198 case RTL3_CONFIG2_PL1:
199 defmedia = IFM_ETHER|IFM_10_2;
200 break;
201
202 case RTL3_CONFIG2_PL0:
203 if (conf3 & RTL3_CONFIG3_FUDUP)
204 defmedia = IFM_ETHER|IFM_10_T|IFM_FDX;
205 else
206 defmedia = IFM_ETHER|IFM_10_T;
207 break;
208 }
209
210
211 bus_space_write_1(sc->sc_regt, sc->sc_regh, ED_P0_CR, ED_CR_PAGE_0);
212
213 ifmedia_init(&sc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus);
214 for (i = 0; i < rtl80x9_nmedia; i++)
215 ifmedia_add(&sc->sc_media, rtl80x9_media[i], 0, NULL);
216 ifmedia_set(&sc->sc_media, defmedia);
217 }