Deleted Added
sdiff udiff text old ( 148022 ) new ( 149558 )
full compact
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 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/*
83 * PC Card (PCMCIA) specific code.
84 */
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
200ed_pccard_probe(device_t dev)
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
228static int
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{
263 u_char sum;
264 u_char enaddr[ETHER_ADDR_LEN];
265 const struct ed_product *pp;
266 int error, i;
267 struct ed_softc *sc = device_get_softc(dev);
268
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;
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:
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) {
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 }
362#ifndef ED_NO_MIIBUS
363 if (sc->chip_type == ED_CHIP_TYPE_DL10019 ||
364 sc->chip_type == ED_CHIP_TYPE_DL10022) {
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);
375 return (0);
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 */
636 DEVMETHOD(device_probe, ed_pccard_probe),
637 DEVMETHOD(device_attach, ed_pccard_attach),
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
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