Deleted Added
full compact
if_ep.c (111119) if_ep.c (112822)
1/*
2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
3 * 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

--- 24 unchanged lines hidden (view full) ---

33/*
34 * Modified from the FreeBSD 1.1.5.1 version by:
35 * Andres Vega Garcia
36 * INRIA - Sophia Antipolis, France
37 * avega@sophia.inria.fr
38 */
39
40/*
1/*
2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
3 * 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

--- 24 unchanged lines hidden (view full) ---

33/*
34 * Modified from the FreeBSD 1.1.5.1 version by:
35 * Andres Vega Garcia
36 * INRIA - Sophia Antipolis, France
37 * avega@sophia.inria.fr
38 */
39
40/*
41 * $FreeBSD: head/sys/dev/ep/if_ep.c 111119 2003-02-19 05:47:46Z imp $
41 * $FreeBSD: head/sys/dev/ep/if_ep.c 112822 2003-03-29 21:44:46Z mdodd $
42 *
43 * Promiscuous mode added and interrupt logic slightly changed
44 * to reduce the number of adapter failures. Transceiver select
45 * logic changed to use value from EEPROM. Autoconfiguration
46 * features added.
47 * Done by:
48 * Serge Babkin
49 * Chelindbank (Chelyabinsk, Russia)

--- 68 unchanged lines hidden (view full) ---

118{
119 int i;
120
121 for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++) {
122 DELAY(100);
123 }
124 if (i >= MAX_EEPROMBUSY) {
125 printf("ep%d: eeprom failed to come ready.\n", sc->unit);
42 *
43 * Promiscuous mode added and interrupt logic slightly changed
44 * to reduce the number of adapter failures. Transceiver select
45 * logic changed to use value from EEPROM. Autoconfiguration
46 * features added.
47 * Done by:
48 * Serge Babkin
49 * Chelindbank (Chelyabinsk, Russia)

--- 68 unchanged lines hidden (view full) ---

118{
119 int i;
120
121 for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++) {
122 DELAY(100);
123 }
124 if (i >= MAX_EEPROMBUSY) {
125 printf("ep%d: eeprom failed to come ready.\n", sc->unit);
126 return (0);
126 return (ENXIO);
127 }
127 }
128 return (1);
128 return (0);
129}
130
131/*
132 * get_e: gets a 16 bits word from the EEPROM. we must have set the window
133 * before
134 */
129}
130
131/*
132 * get_e: gets a 16 bits word from the EEPROM. we must have set the window
133 * before
134 */
135u_int16_t
136get_e(sc, offset)
137 struct ep_softc *sc;
138 u_int16_t offset;
135int
136get_e(sc, offset, result)
137 struct ep_softc *sc;
138 u_int16_t offset;
139 u_int16_t *result;
139{
140{
140 if (!eeprom_rdy(sc))
141
142 if (eeprom_rdy(sc))
143 return (ENXIO);
144 outw(BASE + EP_W0_EEPROM_COMMAND,
145 (EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
146 if (eeprom_rdy(sc))
147 return (ENXIO);
148 (*result) = inw(BASE + EP_W0_EEPROM_DATA);
149
141 return (0);
150 return (0);
142 outw(BASE + EP_W0_EEPROM_COMMAND, (EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
143 if (!eeprom_rdy(sc))
144 return (0);
145 return (inw(BASE + EP_W0_EEPROM_DATA));
146}
147
151}
152
148void
153int
149ep_get_macaddr(sc, addr)
150 struct ep_softc * sc;
151 u_char * addr;
152{
153 int i;
154ep_get_macaddr(sc, addr)
155 struct ep_softc * sc;
156 u_char * addr;
157{
158 int i;
154 u_int16_t * macaddr = (u_int16_t *)addr;
159 u_int16_t result;
160 int error;
161 u_int16_t * macaddr;
155
162
163 macaddr = (u_int16_t *)addr;
164
156 GO_WINDOW(0);
157 for(i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) {
165 GO_WINDOW(0);
166 for(i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) {
158 macaddr[i] = htons(get_e(sc, i));
167 error = get_e(sc, i, &result);
168 if (error)
169 return (error);
170 macaddr[i] = htons(result);
159 }
160
171 }
172
161 return;
173 return (0);
162}
163
164int
165ep_alloc(device_t dev)
166{
167 struct ep_softc * sc = device_get_softc(dev);
168 int rid;
169 int error = 0;
174}
175
176int
177ep_alloc(device_t dev)
178{
179 struct ep_softc * sc = device_get_softc(dev);
180 int rid;
181 int error = 0;
182 u_int16_t result;
170
171 rid = 0;
172 sc->iobase = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
173 0, ~0, 1, RF_ACTIVE);
174 if (!sc->iobase) {
175 device_printf(dev, "No I/O space?!\n");
176 error = ENXIO;
177 goto bad;

--- 17 unchanged lines hidden (view full) ---

195 sc->ep_btag = rman_get_bustag(sc->iobase);
196 sc->ep_bhandle = rman_get_bushandle(sc->iobase);
197
198 sc->ep_connectors = 0;
199 sc->ep_connector = 0;
200
201 GO_WINDOW(0);
202 sc->epb.cmd_off = 0;
183
184 rid = 0;
185 sc->iobase = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
186 0, ~0, 1, RF_ACTIVE);
187 if (!sc->iobase) {
188 device_printf(dev, "No I/O space?!\n");
189 error = ENXIO;
190 goto bad;

--- 17 unchanged lines hidden (view full) ---

208 sc->ep_btag = rman_get_bustag(sc->iobase);
209 sc->ep_bhandle = rman_get_bushandle(sc->iobase);
210
211 sc->ep_connectors = 0;
212 sc->ep_connector = 0;
213
214 GO_WINDOW(0);
215 sc->epb.cmd_off = 0;
203 sc->epb.prod_id = get_e(sc, EEPROM_PROD_ID);
204 sc->epb.res_cfg = get_e(sc, EEPROM_RESOURCE_CFG);
205
216
217 error = get_e(sc, EEPROM_PROD_ID, &result);
218 if (error)
219 goto bad;
220 sc->epb.prod_id = result;
221
222 error = get_e(sc, EEPROM_RESOURCE_CFG, &result);
223 if (error)
224 goto bad;
225 sc->epb.res_cfg = result;
226
206bad:
207 return (error);
208}
209
210void
211ep_get_media(sc)
212 struct ep_softc * sc;
213{

--- 40 unchanged lines hidden (view full) ---

254ep_attach(sc)
255 struct ep_softc * sc;
256{
257 struct ifnet * ifp = NULL;
258 struct ifmedia * ifm = NULL;
259 u_short * p;
260 int i;
261 int attached;
227bad:
228 return (error);
229}
230
231void
232ep_get_media(sc)
233 struct ep_softc * sc;
234{

--- 40 unchanged lines hidden (view full) ---

275ep_attach(sc)
276 struct ep_softc * sc;
277{
278 struct ifnet * ifp = NULL;
279 struct ifmedia * ifm = NULL;
280 u_short * p;
281 int i;
282 int attached;
283 int error;
262
263 sc->gone = 0;
264
284
285 sc->gone = 0;
286
265 ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr);
287 error = ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr);
288 if (error) {
289 device_printf(sc->dev, "Unable to retrieve Ethernet address!\n");
290 return (ENXIO);
291 }
266
267 /*
268 * Setup the station address
269 */
270 p = (u_short *)&sc->arpcom.ac_enaddr;
271 GO_WINDOW(2);
272 for (i = 0; i < 3; i++) {
273 outw(BASE + EP_W2_ADDR_0 + (i * 2), ntohs(p[i]));

--- 674 unchanged lines hidden ---
292
293 /*
294 * Setup the station address
295 */
296 p = (u_short *)&sc->arpcom.ac_enaddr;
297 GO_WINDOW(2);
298 for (i = 0; i < 3; i++) {
299 outw(BASE + EP_W2_ADDR_0 + (i * 2), ntohs(p[i]));

--- 674 unchanged lines hidden ---