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 148022 2005-07-15 01:54:59Z 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_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
201ed_pccard_match(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
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
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{
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;
308
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;
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);
322 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);
379#ifndef ED_NO_MIIBUS
380 if (error == 0 && (sc->chip_type == ED_CHIP_TYPE_DL10019 ||
381 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);
392 return (error);
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 */
653 DEVMETHOD(device_probe, pccard_compat_probe),
654 DEVMETHOD(device_attach, pccard_compat_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
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