2000-03-14 02:36:02 +03:00
|
|
|
/* $NetBSD: if_ep_pcmcia.c,v 1.32 2000/03/13 23:36:02 cgd Exp $ */
|
1998-08-15 11:25:15 +04:00
|
|
|
|
|
|
|
/*-
|
2000-02-04 04:27:12 +03:00
|
|
|
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
1998-08-15 11:25:15 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
|
|
|
* NASA Ames Research Center.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
1997-10-17 03:27:16 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1997 Marc Horowitz. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Marc Horowitz.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1998-07-05 04:51:04 +04:00
|
|
|
#include "opt_inet.h"
|
1998-07-05 10:49:00 +04:00
|
|
|
#include "opt_ns.h"
|
1997-10-17 03:27:16 +04:00
|
|
|
#include "bpfilter.h"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_ether.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
|
|
|
|
#ifdef INET
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/if_inarp.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NS
|
|
|
|
#include <netns/ns.h>
|
|
|
|
#include <netns/ns_if.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NBPFILTER > 0
|
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/bpfdesc.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/intr.h>
|
|
|
|
|
1998-08-12 22:51:52 +04:00
|
|
|
#include <dev/mii/miivar.h>
|
|
|
|
|
1997-10-17 03:27:16 +04:00
|
|
|
#include <dev/ic/elink3var.h>
|
|
|
|
#include <dev/ic/elink3reg.h>
|
|
|
|
|
|
|
|
#include <dev/pcmcia/pcmciareg.h>
|
|
|
|
#include <dev/pcmcia/pcmciavar.h>
|
1998-07-19 21:28:15 +04:00
|
|
|
#include <dev/pcmcia/pcmciadevs.h>
|
1997-10-17 03:27:16 +04:00
|
|
|
|
|
|
|
int ep_pcmcia_match __P((struct device *, struct cfdata *, void *));
|
|
|
|
void ep_pcmcia_attach __P((struct device *, struct device *, void *));
|
1998-11-17 23:44:02 +03:00
|
|
|
int ep_pcmcia_detach __P((struct device *, int));
|
1997-10-17 03:27:16 +04:00
|
|
|
|
|
|
|
int ep_pcmcia_get_enaddr __P((struct pcmcia_tuple *, void *));
|
|
|
|
int ep_pcmcia_enable __P((struct ep_softc *));
|
|
|
|
void ep_pcmcia_disable __P((struct ep_softc *));
|
|
|
|
|
1998-03-31 12:13:34 +04:00
|
|
|
int ep_pcmcia_enable1 __P((struct ep_softc *));
|
|
|
|
void ep_pcmcia_disable1 __P((struct ep_softc *));
|
|
|
|
|
1997-10-17 03:27:16 +04:00
|
|
|
struct ep_pcmcia_softc {
|
|
|
|
struct ep_softc sc_ep; /* real "ep" softc */
|
|
|
|
|
|
|
|
/* PCMCIA-specific goo */
|
|
|
|
struct pcmcia_io_handle sc_pcioh; /* PCMCIA i/o space info */
|
|
|
|
int sc_io_window; /* our i/o window */
|
|
|
|
struct pcmcia_function *sc_pf; /* our PCMCIA function */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfattach ep_pcmcia_ca = {
|
1998-11-17 23:44:02 +03:00
|
|
|
sizeof(struct ep_pcmcia_softc), ep_pcmcia_match, ep_pcmcia_attach,
|
2000-02-02 11:41:00 +03:00
|
|
|
ep_pcmcia_detach, ep_activate
|
1997-10-17 03:27:16 +04:00
|
|
|
};
|
|
|
|
|
2000-02-04 04:27:12 +03:00
|
|
|
const struct ep_pcmcia_product {
|
|
|
|
struct pcmcia_product epp_product;
|
1998-08-15 11:25:15 +04:00
|
|
|
u_short epp_chipset; /* 3Com chipset used */
|
|
|
|
int epp_flags; /* initial softc flags */
|
|
|
|
} ep_pcmcia_products[] = {
|
2000-02-04 04:27:12 +03:00
|
|
|
{ { PCMCIA_STR_3COM_3C562, PCMCIA_VENDOR_3COM,
|
|
|
|
PCMCIA_PRODUCT_3COM_3C562, 0 },
|
|
|
|
ELINK_CHIPSET_3C509, 0 },
|
1998-08-15 11:25:15 +04:00
|
|
|
|
2000-02-04 04:27:12 +03:00
|
|
|
{ { PCMCIA_STR_3COM_3C589, PCMCIA_VENDOR_3COM,
|
|
|
|
PCMCIA_PRODUCT_3COM_3C589, 0 },
|
|
|
|
ELINK_CHIPSET_3C509, 0 },
|
1998-08-15 11:25:15 +04:00
|
|
|
|
2000-02-04 04:27:12 +03:00
|
|
|
{ { PCMCIA_STR_3COM_3CXEM556, PCMCIA_VENDOR_3COM,
|
|
|
|
PCMCIA_PRODUCT_3COM_3CXEM556, 0 },
|
|
|
|
ELINK_CHIPSET_3C509, 0 },
|
1998-08-15 11:25:15 +04:00
|
|
|
|
2000-02-04 04:27:12 +03:00
|
|
|
{ { PCMCIA_STR_3COM_3CXEM556INT, PCMCIA_VENDOR_3COM,
|
|
|
|
PCMCIA_PRODUCT_3COM_3CXEM556INT, 0 },
|
|
|
|
ELINK_CHIPSET_3C509, 0 },
|
1998-08-15 11:25:15 +04:00
|
|
|
|
2000-02-04 04:27:12 +03:00
|
|
|
{ { PCMCIA_STR_3COM_3C574, PCMCIA_VENDOR_3COM,
|
|
|
|
PCMCIA_PRODUCT_3COM_3C574, 0 },
|
|
|
|
ELINK_CHIPSET_ROADRUNNER, ELINK_FLAGS_MII },
|
|
|
|
|
|
|
|
{ { PCMCIA_STR_3COM_3CCFEM556BI, PCMCIA_VENDOR_3COM,
|
|
|
|
PCMCIA_PRODUCT_3COM_3CCFEM556BI, 0 },
|
|
|
|
ELINK_CHIPSET_ROADRUNNER, ELINK_FLAGS_MII },
|
|
|
|
|
2000-03-14 02:36:02 +03:00
|
|
|
{ { PCMCIA_STR_3COM_3C1, PCMCIA_VENDOR_3COM,
|
|
|
|
PCMCIA_PRODUCT_3COM_3C1, 0 },
|
2000-03-13 23:32:28 +03:00
|
|
|
ELINK_CHIPSET_3C509, 0 },
|
|
|
|
|
2000-02-04 04:27:12 +03:00
|
|
|
{ { NULL } }
|
|
|
|
};
|
1998-08-15 11:25:15 +04:00
|
|
|
|
1997-10-17 03:27:16 +04:00
|
|
|
int
|
|
|
|
ep_pcmcia_match(parent, match, aux)
|
|
|
|
struct device *parent;
|
1997-11-30 18:16:55 +03:00
|
|
|
struct cfdata *match;
|
1997-10-17 03:27:16 +04:00
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct pcmcia_attach_args *pa = aux;
|
|
|
|
|
2000-02-04 04:27:12 +03:00
|
|
|
if (pcmcia_product_lookup(pa,
|
|
|
|
(const struct pcmcia_product *)ep_pcmcia_products,
|
|
|
|
sizeof ep_pcmcia_products[0], NULL) != NULL)
|
1998-08-15 11:25:15 +04:00
|
|
|
return (1);
|
1997-10-17 03:27:16 +04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ep_pcmcia_enable(sc)
|
|
|
|
struct ep_softc *sc;
|
|
|
|
{
|
|
|
|
struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *) sc;
|
1998-02-02 02:52:25 +03:00
|
|
|
struct pcmcia_function *pf = psc->sc_pf;
|
2000-02-08 15:49:12 +03:00
|
|
|
int error;
|
1997-10-17 03:27:16 +04:00
|
|
|
|
|
|
|
/* establish the interrupt. */
|
1998-02-02 02:52:25 +03:00
|
|
|
sc->sc_ih = pcmcia_intr_establish(pf, IPL_NET, epintr, sc);
|
1997-10-17 03:27:16 +04:00
|
|
|
if (sc->sc_ih == NULL) {
|
|
|
|
printf("%s: couldn't establish interrupt\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2000-02-08 15:49:12 +03:00
|
|
|
error = ep_pcmcia_enable1(sc);
|
|
|
|
if (error != 0)
|
|
|
|
pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
|
|
|
|
return (error);
|
1998-03-31 12:13:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ep_pcmcia_enable1(sc)
|
|
|
|
struct ep_softc *sc;
|
|
|
|
{
|
|
|
|
struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *) sc;
|
|
|
|
struct pcmcia_function *pf = psc->sc_pf;
|
|
|
|
int ret;
|
|
|
|
|
1998-02-02 02:52:25 +03:00
|
|
|
if ((ret = pcmcia_function_enable(pf)))
|
1998-03-31 12:13:34 +04:00
|
|
|
return (ret);
|
|
|
|
|
1998-12-24 06:57:45 +03:00
|
|
|
if ((psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3C562) ||
|
1999-08-14 17:43:02 +04:00
|
|
|
(psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3CXEM556) ||
|
|
|
|
(psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3CXEM556INT)) {
|
1998-02-02 02:52:25 +03:00
|
|
|
int reg;
|
|
|
|
|
|
|
|
/* turn off the serial-disable bit */
|
|
|
|
|
|
|
|
reg = pcmcia_ccr_read(pf, PCMCIA_CCR_OPTION);
|
|
|
|
if (reg & 0x08) {
|
1998-03-31 12:13:34 +04:00
|
|
|
reg &= ~0x08;
|
|
|
|
pcmcia_ccr_write(pf, PCMCIA_CCR_OPTION, reg);
|
1998-02-02 02:52:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ret);
|
1997-10-17 03:27:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ep_pcmcia_disable(sc)
|
|
|
|
struct ep_softc *sc;
|
|
|
|
{
|
|
|
|
struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *) sc;
|
|
|
|
|
1998-03-31 12:13:34 +04:00
|
|
|
ep_pcmcia_disable1(sc);
|
2000-02-08 15:49:12 +03:00
|
|
|
pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
|
1997-10-17 03:27:16 +04:00
|
|
|
}
|
|
|
|
|
1998-03-31 12:13:34 +04:00
|
|
|
void
|
|
|
|
ep_pcmcia_disable1(sc)
|
|
|
|
struct ep_softc *sc;
|
|
|
|
{
|
|
|
|
struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *) sc;
|
|
|
|
|
|
|
|
pcmcia_function_disable(psc->sc_pf);
|
|
|
|
}
|
|
|
|
|
1997-10-17 03:27:16 +04:00
|
|
|
void
|
|
|
|
ep_pcmcia_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct ep_pcmcia_softc *psc = (void *) self;
|
|
|
|
struct ep_softc *sc = &psc->sc_ep;
|
|
|
|
struct pcmcia_attach_args *pa = aux;
|
|
|
|
struct pcmcia_config_entry *cfe;
|
2000-02-04 04:27:12 +03:00
|
|
|
const struct ep_pcmcia_product *epp;
|
1997-10-17 03:27:16 +04:00
|
|
|
u_int8_t myla[ETHER_ADDR_LEN];
|
1998-08-18 03:20:39 +04:00
|
|
|
u_int8_t *enaddr = NULL;
|
1998-08-15 11:25:15 +04:00
|
|
|
int i;
|
1997-10-17 03:27:16 +04:00
|
|
|
|
|
|
|
psc->sc_pf = pa->pf;
|
|
|
|
cfe = pa->pf->cfe_head.sqh_first;
|
|
|
|
|
|
|
|
/* Enable the card. */
|
|
|
|
pcmcia_function_init(pa->pf, cfe);
|
2000-02-08 15:49:12 +03:00
|
|
|
if (ep_pcmcia_enable1(sc)) {
|
1997-10-17 03:27:16 +04:00
|
|
|
printf(": function enable failed\n");
|
2000-02-08 15:49:12 +03:00
|
|
|
goto enable_failed;
|
|
|
|
}
|
1997-10-17 03:27:16 +04:00
|
|
|
sc->enabled = 1;
|
|
|
|
|
2000-02-08 15:49:12 +03:00
|
|
|
if (cfe->num_memspace != 0) {
|
1997-10-17 03:27:16 +04:00
|
|
|
printf(": unexpected number of memory spaces %d should be 0\n",
|
|
|
|
cfe->num_memspace);
|
2000-02-08 15:49:12 +03:00
|
|
|
goto ioalloc_failed;
|
|
|
|
}
|
1997-10-17 03:27:16 +04:00
|
|
|
|
2000-02-08 15:49:12 +03:00
|
|
|
if (cfe->num_iospace != 1) {
|
1997-10-17 03:27:16 +04:00
|
|
|
printf(": unexpected number of I/O spaces %d should be 1\n",
|
|
|
|
cfe->num_iospace);
|
2000-02-08 15:49:12 +03:00
|
|
|
goto ioalloc_failed;
|
|
|
|
}
|
1997-10-17 03:27:16 +04:00
|
|
|
|
|
|
|
if (pa->product == PCMCIA_PRODUCT_3COM_3C562) {
|
|
|
|
bus_addr_t maxaddr = (pa->pf->sc->iobase + pa->pf->sc->iosize);
|
|
|
|
|
1998-03-10 00:52:31 +03:00
|
|
|
for (i = pa->pf->sc->iobase; i < maxaddr; i += 0x10) {
|
|
|
|
/*
|
|
|
|
* the 3c562 can only use 0x??00-0x??7f
|
|
|
|
* according to the Linux driver
|
|
|
|
*/
|
|
|
|
if (i & 0x80)
|
|
|
|
continue;
|
1997-10-17 03:27:16 +04:00
|
|
|
if (pcmcia_io_alloc(pa->pf, i, cfe->iospace[0].length,
|
|
|
|
0, &psc->sc_pcioh) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i >= maxaddr) {
|
|
|
|
printf(": can't allocate i/o space\n");
|
2000-02-08 15:49:12 +03:00
|
|
|
goto ioalloc_failed;
|
1997-10-17 03:27:16 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (pcmcia_io_alloc(pa->pf, 0, cfe->iospace[0].length,
|
2000-02-08 15:49:12 +03:00
|
|
|
cfe->iospace[0].length, &psc->sc_pcioh)) {
|
1997-10-17 03:27:16 +04:00
|
|
|
printf(": can't allocate i/o space\n");
|
2000-02-08 15:49:12 +03:00
|
|
|
goto ioalloc_failed;
|
|
|
|
}
|
1997-10-17 03:27:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
sc->sc_iot = psc->sc_pcioh.iot;
|
|
|
|
sc->sc_ioh = psc->sc_pcioh.ioh;
|
|
|
|
|
|
|
|
if (pcmcia_io_map(pa->pf, ((cfe->flags & PCMCIA_CFE_IO16) ?
|
|
|
|
PCMCIA_WIDTH_IO16 : PCMCIA_WIDTH_IO8), 0, cfe->iospace[0].length,
|
|
|
|
&psc->sc_pcioh, &psc->sc_io_window)) {
|
|
|
|
printf(": can't map i/o space\n");
|
2000-02-08 15:49:12 +03:00
|
|
|
goto iomap_failed;
|
1997-10-17 03:27:16 +04:00
|
|
|
}
|
1998-08-18 03:20:39 +04:00
|
|
|
|
|
|
|
switch (pa->product) {
|
|
|
|
case PCMCIA_PRODUCT_3COM_3C562:
|
1998-03-10 00:52:31 +03:00
|
|
|
/*
|
|
|
|
* 3c562a-c use this; 3c562d does it in the regular way.
|
|
|
|
* we might want to check the revision and produce a warning
|
|
|
|
* in the future.
|
|
|
|
*/
|
1998-08-18 03:20:39 +04:00
|
|
|
/* FALLTHROUGH */
|
|
|
|
case PCMCIA_PRODUCT_3COM_3C574:
|
1999-10-11 21:49:21 +04:00
|
|
|
case PCMCIA_PRODUCT_3COM_3CCFEM556BI:
|
1998-08-18 03:20:39 +04:00
|
|
|
/*
|
|
|
|
* Apparently, some 3c574s do it this way, as well.
|
|
|
|
*/
|
|
|
|
if (pcmcia_scan_cis(parent, ep_pcmcia_get_enaddr, myla))
|
1998-03-10 00:52:31 +03:00
|
|
|
enaddr = myla;
|
1998-08-18 03:20:39 +04:00
|
|
|
break;
|
1997-10-17 03:27:16 +04:00
|
|
|
}
|
|
|
|
|
2000-02-04 04:27:12 +03:00
|
|
|
epp = (const struct ep_pcmcia_product *)pcmcia_product_lookup(pa,
|
|
|
|
(const struct pcmcia_product *)ep_pcmcia_products,
|
|
|
|
sizeof ep_pcmcia_products[0], NULL);
|
1998-08-15 11:25:15 +04:00
|
|
|
if (epp == NULL)
|
|
|
|
panic("ep_pcmcia_attach: impossible");
|
1997-10-17 03:27:16 +04:00
|
|
|
|
2000-02-04 04:27:12 +03:00
|
|
|
printf(": %s\n", epp->epp_product.pp_name);
|
1999-05-09 22:48:52 +04:00
|
|
|
|
|
|
|
sc->bustype = ELINK_BUS_PCMCIA;
|
|
|
|
sc->ep_flags = epp->epp_flags;
|
|
|
|
|
1997-10-17 03:27:16 +04:00
|
|
|
sc->enable = ep_pcmcia_enable;
|
|
|
|
sc->disable = ep_pcmcia_disable;
|
|
|
|
|
2000-02-08 15:49:12 +03:00
|
|
|
if (epconfig(sc, epp->epp_chipset, enaddr)) {
|
|
|
|
printf("%s: couldn't configure controller\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
goto config_failed;
|
|
|
|
}
|
1997-10-17 03:27:16 +04:00
|
|
|
|
|
|
|
sc->enabled = 0;
|
2000-02-08 15:49:12 +03:00
|
|
|
ep_pcmcia_disable1(sc);
|
|
|
|
return;
|
1997-10-17 03:27:16 +04:00
|
|
|
|
2000-02-08 15:49:12 +03:00
|
|
|
config_failed:
|
|
|
|
/* Unmap our i/o window. */
|
|
|
|
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
|
|
|
|
|
|
|
iomap_failed:
|
|
|
|
/* Free our i/o space. */
|
|
|
|
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
|
|
|
|
|
|
|
ioalloc_failed:
|
|
|
|
sc->enabled = 0;
|
1998-03-31 12:13:34 +04:00
|
|
|
ep_pcmcia_disable1(sc);
|
2000-02-08 15:49:12 +03:00
|
|
|
|
|
|
|
enable_failed:
|
|
|
|
psc->sc_io_window = -1;
|
1997-10-17 03:27:16 +04:00
|
|
|
}
|
|
|
|
|
1998-11-17 23:44:02 +03:00
|
|
|
int
|
|
|
|
ep_pcmcia_detach(self, flags)
|
|
|
|
struct device *self;
|
|
|
|
int flags;
|
|
|
|
{
|
1998-11-18 21:15:56 +03:00
|
|
|
struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *)self;
|
2000-02-02 11:00:21 +03:00
|
|
|
int rv;
|
|
|
|
|
2000-02-08 15:49:12 +03:00
|
|
|
if (psc->sc_io_window == -1)
|
|
|
|
/* Nothing to detach. */
|
|
|
|
return (0);
|
|
|
|
|
2000-02-02 11:00:21 +03:00
|
|
|
rv = ep_detach(self, flags);
|
2000-02-08 15:49:12 +03:00
|
|
|
if (rv != 0)
|
2000-02-02 11:00:21 +03:00
|
|
|
return (rv);
|
1998-11-18 21:15:56 +03:00
|
|
|
|
|
|
|
/* Unmap our i/o window. */
|
|
|
|
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
|
|
|
|
|
|
|
/* Free our i/o space. */
|
|
|
|
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
1998-11-17 23:44:02 +03:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1997-10-17 03:27:16 +04:00
|
|
|
int
|
|
|
|
ep_pcmcia_get_enaddr(tuple, arg)
|
|
|
|
struct pcmcia_tuple *tuple;
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
u_int8_t *myla = arg;
|
|
|
|
int i;
|
|
|
|
|
1998-03-10 00:52:31 +03:00
|
|
|
/* this is 3c562a-c magic */
|
1997-10-17 03:27:16 +04:00
|
|
|
if (tuple->code == 0x88) {
|
|
|
|
if (tuple->length < ETHER_ADDR_LEN)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
for (i = 0; i < ETHER_ADDR_LEN; i += 2) {
|
|
|
|
myla[i] = pcmcia_tuple_read_1(tuple, i + 1);
|
|
|
|
myla[i + 1] = pcmcia_tuple_read_1(tuple, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|