Deleted Added
full compact
if_ed_pccard.c (148022) if_ed_pccard.c (149558)
1/*-
2 * Copyright (c) 1995, David Greenman
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

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

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*-
2 * Copyright (c) 1995, David Greenman
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

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

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/dev/ed/if_ed_pccard.c 148022 2005-07-15 01:54:59Z imp $
27 * $FreeBSD: head/sys/dev/ed/if_ed_pccard.c 149558 2005-08-28 23:56:25Z imp $
28 */
29
30#include "opt_ed.h"
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/socket.h>
35#include <sys/kernel.h>

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

75 * large number of NE-2000ish PC Cards that don't do this. Nearly all
76 * of them store the MAC address at a fixed offset into attribute
77 * memory, without any reference at all appearing in the CIS. And
78 * nearly all of those store it at the same location.
79 */
80#define ED_DEFAULT_MAC_OFFSET 0xff0
81
82/*
28 */
29
30#include "opt_ed.h"
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/socket.h>
35#include <sys/kernel.h>

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

75 * large number of NE-2000ish PC Cards that don't do this. Nearly all
76 * of them store the MAC address at a fixed offset into attribute
77 * memory, without any reference at all appearing in the CIS. And
78 * nearly all of those store it at the same location.
79 */
80#define ED_DEFAULT_MAC_OFFSET 0xff0
81
82/*
83 * PC-Card (PCMCIA) specific code.
83 * PC Card (PCMCIA) specific code.
84 */
84 */
85static int ed_pccard_match(device_t);
86static int ed_pccard_probe(device_t);
87static int ed_pccard_attach(device_t);
88
89static int ed_pccard_ax88x90(device_t dev);
90
91static void ax88x90_geteprom(struct ed_softc *);
92static int ed_pccard_memread(device_t dev, off_t offset, u_char *byte);
93static int ed_pccard_memwrite(device_t dev, off_t offset, u_char byte);

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

193 { PCMCIA_CARD(TELECOMDEVICE, LM5LT), 0 },
194 { PCMCIA_CARD(TELECOMDEVICE, TCD_HPC100), NE2000DVF_AX88X90 },
195 { PCMCIA_CARD(XIRCOM, CFE_10), 0},
196 { PCMCIA_CARD(ZONET, ZEN), 0},
197 { { NULL } }
198};
199
200static int
85static int ed_pccard_probe(device_t);
86static int ed_pccard_attach(device_t);
87
88static int ed_pccard_ax88x90(device_t dev);
89
90static void ax88x90_geteprom(struct ed_softc *);
91static int ed_pccard_memread(device_t dev, off_t offset, u_char *byte);
92static int ed_pccard_memwrite(device_t dev, off_t offset, u_char byte);

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

192 { PCMCIA_CARD(TELECOMDEVICE, LM5LT), 0 },
193 { PCMCIA_CARD(TELECOMDEVICE, TCD_HPC100), NE2000DVF_AX88X90 },
194 { PCMCIA_CARD(XIRCOM, CFE_10), 0},
195 { PCMCIA_CARD(ZONET, ZEN), 0},
196 { { NULL } }
197};
198
199static int
201ed_pccard_match(device_t dev)
200ed_pccard_probe(device_t dev)
202{
203 const struct ed_product *pp;
204 int error;
205 uint32_t fcn = PCCARD_FUNCTION_UNSPEC;
206
207 /* Make sure we're a network function */
208 error = pccard_get_function(dev, &fcn);
209 if (error != 0)

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

221 if (!(pp->flags & NE2000DVF_ANYFUNC) &&
222 fcn != PCCARD_FUNCTION_NETWORK)
223 return (ENXIO);
224 return (0);
225 }
226 return (ENXIO);
227}
228
201{
202 const struct ed_product *pp;
203 int error;
204 uint32_t fcn = PCCARD_FUNCTION_UNSPEC;
205
206 /* Make sure we're a network function */
207 error = pccard_get_function(dev, &fcn);
208 if (error != 0)

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

220 if (!(pp->flags & NE2000DVF_ANYFUNC) &&
221 fcn != PCCARD_FUNCTION_NETWORK)
222 return (ENXIO);
223 return (0);
224 }
225 return (ENXIO);
226}
227
229/*
230 * Probe framework for pccards. Replicates the standard framework,
231 * minus the pccard driver registration and ignores the ether address
232 * supplied (from the CIS), relying on the probe to find it instead.
233 */
234static int
228static int
235ed_pccard_probe(device_t dev)
236{
237 const struct ed_product *pp;
238 int error;
239 struct ed_softc *sc = device_get_softc(dev);
240
241 if ((pp = (const struct ed_product *) pccard_product_lookup(dev,
242 (const struct pccard_product *) ed_pccard_products,
243 sizeof(ed_pccard_products[0]), NULL)) == NULL)
244 return (ENXIO);
245 sc->port_rid = pp->edrid;
246 if (pp->flags & NE2000DVF_DL100XX) {
247 error = ed_probe_Novell(dev, sc->port_rid, 0);
248 if (error == 0)
249 error = ed_pccard_Linksys(dev);
250 ed_release_resources(dev);
251 if (error == 0)
252 goto end2;
253 }
254 if (pp->flags & NE2000DVF_AX88X90) {
255 error = ed_pccard_ax88x90(dev);
256 if (error == 0)
257 goto end2;
258 }
259 error = ed_probe_Novell(dev, sc->port_rid, 0);
260end2:
261 if (error == 0)
262 error = ed_alloc_irq(dev, 0, 0);
263
264 ed_release_resources(dev);
265 return (error);
266}
267
268static int
269ed_pccard_rom_mac(device_t dev, uint8_t *enaddr)
270{
271 struct ed_softc *sc = device_get_softc(dev);
272 uint8_t romdata[16];
273 int i;
274
275 /*
276 * Read in the rom data at location 0. We should see one of

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

295{
296 device_printf(dev, "Need to write this code: modem rid is %d\n", rid);
297 return 0;
298}
299
300static int
301ed_pccard_attach(device_t dev)
302{
229ed_pccard_rom_mac(device_t dev, uint8_t *enaddr)
230{
231 struct ed_softc *sc = device_get_softc(dev);
232 uint8_t romdata[16];
233 int i;
234
235 /*
236 * Read in the rom data at location 0. We should see one of

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

255{
256 device_printf(dev, "Need to write this code: modem rid is %d\n", rid);
257 return 0;
258}
259
260static int
261ed_pccard_attach(device_t dev)
262{
303 int error, i;
304 struct ed_softc *sc = device_get_softc(dev);
305 u_char sum;
306 u_char enaddr[ETHER_ADDR_LEN];
307 const struct ed_product *pp;
263 u_char sum;
264 u_char enaddr[ETHER_ADDR_LEN];
265 const struct ed_product *pp;
308
266 int error, i;
267 struct ed_softc *sc = device_get_softc(dev);
268
309 if ((pp = (const struct ed_product *) pccard_product_lookup(dev,
310 (const struct pccard_product *) ed_pccard_products,
311 sizeof(ed_pccard_products[0]), NULL)) == NULL)
312 return (ENXIO);
313 sc->port_rid = pp->edrid;
269 if ((pp = (const struct ed_product *) pccard_product_lookup(dev,
270 (const struct pccard_product *) ed_pccard_products,
271 sizeof(ed_pccard_products[0]), NULL)) == NULL)
272 return (ENXIO);
273 sc->port_rid = pp->edrid;
314 if (sc->port_used > 0)
315 ed_alloc_port(dev, sc->port_rid, sc->port_used);
316 if (sc->mem_used)
317 ed_alloc_memory(dev, sc->mem_rid, sc->mem_used);
318 ed_alloc_irq(dev, sc->irq_rid, 0);
319
320 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, edintr, sc,
321 &sc->irq_handle);
274 if (pp->flags & NE2000DVF_DL100XX) {
275 error = ed_probe_Novell(dev, sc->port_rid, 0);
276 if (error == 0)
277 error = ed_pccard_Linksys(dev);
278 ed_release_resources(dev);
279 if (error == 0)
280 goto end2;
281 }
282 if (pp->flags & NE2000DVF_AX88X90) {
283 error = ed_pccard_ax88x90(dev);
284 if (error == 0)
285 goto end2;
286 }
287 error = ed_probe_Novell(dev, sc->port_rid, 0);
288end2:
322 if (error) {
289 if (error) {
290 ed_release_resources(dev);
291 return (error);
292 }
293 error = ed_alloc_irq(dev, 0, 0);
294 if (error) {
295 ed_release_resources(dev);
296 return (error);
297 }
298
299 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE,
300 edintr, sc, &sc->irq_handle);
301 if (error) {
323 device_printf(dev, "setup intr failed %d \n", error);
324 ed_release_resources(dev);
325 return (error);
326 }
327
328 /*
329 * For the older cards, we have to get the MAC address from
330 * the card in some way. Let's try the standard PCMCIA way

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

371 device_printf(dev, "Cannot extract MAC address.\n");
372 ed_release_resources(dev);
373 return (ENXIO);
374 }
375 bcopy(enaddr, sc->enaddr, ETHER_ADDR_LEN);
376 }
377
378 error = ed_attach(dev);
302 device_printf(dev, "setup intr failed %d \n", error);
303 ed_release_resources(dev);
304 return (error);
305 }
306
307 /*
308 * For the older cards, we have to get the MAC address from
309 * the card in some way. Let's try the standard PCMCIA way

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

350 device_printf(dev, "Cannot extract MAC address.\n");
351 ed_release_resources(dev);
352 return (ENXIO);
353 }
354 bcopy(enaddr, sc->enaddr, ETHER_ADDR_LEN);
355 }
356
357 error = ed_attach(dev);
358 if (error) {
359 ed_release_resources(dev);
360 return (error);
361 }
379#ifndef ED_NO_MIIBUS
362#ifndef ED_NO_MIIBUS
380 if (error == 0 && (sc->chip_type == ED_CHIP_TYPE_DL10019 ||
381 sc->chip_type == ED_CHIP_TYPE_DL10022)) {
363 if (sc->chip_type == ED_CHIP_TYPE_DL10019 ||
364 sc->chip_type == ED_CHIP_TYPE_DL10022) {
382 /* Probe for an MII bus, but ignore errors. */
383 ed_pccard_dlink_mii_reset(sc);
384 sc->mii_readbits = ed_pccard_dlink_mii_readbits;
385 sc->mii_writebits = ed_pccard_dlink_mii_writebits;
386 mii_phy_probe(dev, &sc->miibus, ed_ifmedia_upd,
387 ed_ifmedia_sts);
388 }
389#endif
390 if (pp->flags & NE2000DVF_MODEM)
391 ed_pccard_add_modem(dev, pp->siorid);
365 /* Probe for an MII bus, but ignore errors. */
366 ed_pccard_dlink_mii_reset(sc);
367 sc->mii_readbits = ed_pccard_dlink_mii_readbits;
368 sc->mii_writebits = ed_pccard_dlink_mii_writebits;
369 mii_phy_probe(dev, &sc->miibus, ed_ifmedia_upd,
370 ed_ifmedia_sts);
371 }
372#endif
373 if (pp->flags & NE2000DVF_MODEM)
374 ed_pccard_add_modem(dev, pp->siorid);
392 return (error);
375 return (0);
393}
394
395static void
396ax88x90_geteprom(struct ed_softc *sc)
397{
398 int prom[16],i;
399 u_char tmp;
400 struct {

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

645 }
646
647 return val;
648}
649#endif
650
651static device_method_t ed_pccard_methods[] = {
652 /* Device interface */
376}
377
378static void
379ax88x90_geteprom(struct ed_softc *sc)
380{
381 int prom[16],i;
382 u_char tmp;
383 struct {

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

628 }
629
630 return val;
631}
632#endif
633
634static device_method_t ed_pccard_methods[] = {
635 /* Device interface */
653 DEVMETHOD(device_probe, pccard_compat_probe),
654 DEVMETHOD(device_attach, pccard_compat_attach),
636 DEVMETHOD(device_probe, ed_pccard_probe),
637 DEVMETHOD(device_attach, ed_pccard_attach),
655 DEVMETHOD(device_detach, ed_detach),
656
657#ifndef ED_NO_MIIBUS
658 /* Bus interface */
659 DEVMETHOD(bus_child_detached, ed_child_detached),
660
661 /* MII interface */
662 DEVMETHOD(miibus_readreg, ed_miibus_readreg),
663 DEVMETHOD(miibus_writereg, ed_miibus_writereg),
664#endif
665
638 DEVMETHOD(device_detach, ed_detach),
639
640#ifndef ED_NO_MIIBUS
641 /* Bus interface */
642 DEVMETHOD(bus_child_detached, ed_child_detached),
643
644 /* MII interface */
645 DEVMETHOD(miibus_readreg, ed_miibus_readreg),
646 DEVMETHOD(miibus_writereg, ed_miibus_writereg),
647#endif
648
666 /* Card interface */
667 DEVMETHOD(card_compat_match, ed_pccard_match),
668 DEVMETHOD(card_compat_probe, ed_pccard_probe),
669 DEVMETHOD(card_compat_attach, ed_pccard_attach),
670 { 0, 0 }
671};
672
673static driver_t ed_pccard_driver = {
674 "ed",
675 ed_pccard_methods,
676 sizeof(struct ed_softc)
677};
678
679DRIVER_MODULE(ed, pccard, ed_pccard_driver, ed_devclass, 0, 0);
680#ifndef ED_NO_MIIBUS
681DRIVER_MODULE(miibus, ed, miibus_driver, miibus_devclass, 0, 0);
682#endif
649 { 0, 0 }
650};
651
652static driver_t ed_pccard_driver = {
653 "ed",
654 ed_pccard_methods,
655 sizeof(struct ed_softc)
656};
657
658DRIVER_MODULE(ed, pccard, ed_pccard_driver, ed_devclass, 0, 0);
659#ifndef ED_NO_MIIBUS
660DRIVER_MODULE(miibus, ed, miibus_driver, miibus_devclass, 0, 0);
661#endif