Home | History | Annotate | Line # | Download | only in pcmcia
if_ep_pcmcia.c revision 1.25
      1  1.25  augustss /*	$NetBSD: if_ep_pcmcia.c,v 1.25 2000/02/02 07:23:28 augustss Exp $	*/
      2  1.14   thorpej 
      3  1.14   thorpej /*-
      4  1.14   thorpej  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  1.14   thorpej  * All rights reserved.
      6  1.14   thorpej  *
      7  1.14   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.14   thorpej  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.14   thorpej  * NASA Ames Research Center.
     10  1.14   thorpej  *
     11  1.14   thorpej  * Redistribution and use in source and binary forms, with or without
     12  1.14   thorpej  * modification, are permitted provided that the following conditions
     13  1.14   thorpej  * are met:
     14  1.14   thorpej  * 1. Redistributions of source code must retain the above copyright
     15  1.14   thorpej  *    notice, this list of conditions and the following disclaimer.
     16  1.14   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.14   thorpej  *    notice, this list of conditions and the following disclaimer in the
     18  1.14   thorpej  *    documentation and/or other materials provided with the distribution.
     19  1.14   thorpej  * 3. All advertising materials mentioning features or use of this software
     20  1.14   thorpej  *    must display the following acknowledgement:
     21  1.14   thorpej  *	This product includes software developed by the NetBSD
     22  1.14   thorpej  *	Foundation, Inc. and its contributors.
     23  1.14   thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.14   thorpej  *    contributors may be used to endorse or promote products derived
     25  1.14   thorpej  *    from this software without specific prior written permission.
     26  1.14   thorpej  *
     27  1.14   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.14   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.14   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.14   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  1.14   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.14   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.14   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.14   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.14   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.14   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.14   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     38  1.14   thorpej  */
     39   1.2   thorpej 
     40   1.2   thorpej /*
     41   1.2   thorpej  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
     42   1.2   thorpej  *
     43   1.2   thorpej  * Redistribution and use in source and binary forms, with or without
     44   1.2   thorpej  * modification, are permitted provided that the following conditions
     45   1.2   thorpej  * are met:
     46   1.2   thorpej  * 1. Redistributions of source code must retain the above copyright
     47   1.2   thorpej  *    notice, this list of conditions and the following disclaimer.
     48   1.2   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     49   1.2   thorpej  *    notice, this list of conditions and the following disclaimer in the
     50   1.2   thorpej  *    documentation and/or other materials provided with the distribution.
     51   1.2   thorpej  * 3. All advertising materials mentioning features or use of this software
     52   1.2   thorpej  *    must display the following acknowledgement:
     53   1.2   thorpej  *	This product includes software developed by Marc Horowitz.
     54   1.2   thorpej  * 4. The name of the author may not be used to endorse or promote products
     55   1.2   thorpej  *    derived from this software without specific prior written permission.
     56   1.2   thorpej  *
     57   1.2   thorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     58   1.2   thorpej  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     59   1.2   thorpej  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     60   1.2   thorpej  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     61   1.2   thorpej  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     62   1.2   thorpej  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     63   1.2   thorpej  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     64   1.2   thorpej  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     65   1.2   thorpej  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     66   1.2   thorpej  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     67   1.2   thorpej  */
     68   1.2   thorpej 
     69   1.9  jonathan #include "opt_inet.h"
     70  1.10  jonathan #include "opt_ns.h"
     71   1.2   thorpej #include "bpfilter.h"
     72   1.2   thorpej 
     73   1.2   thorpej #include <sys/param.h>
     74   1.2   thorpej #include <sys/systm.h>
     75   1.2   thorpej #include <sys/mbuf.h>
     76   1.2   thorpej #include <sys/socket.h>
     77   1.2   thorpej #include <sys/ioctl.h>
     78   1.2   thorpej #include <sys/errno.h>
     79   1.2   thorpej #include <sys/syslog.h>
     80   1.2   thorpej #include <sys/select.h>
     81   1.2   thorpej #include <sys/device.h>
     82   1.2   thorpej 
     83   1.2   thorpej #include <net/if.h>
     84   1.2   thorpej #include <net/if_dl.h>
     85   1.2   thorpej #include <net/if_ether.h>
     86   1.2   thorpej #include <net/if_media.h>
     87   1.2   thorpej 
     88   1.2   thorpej #ifdef INET
     89   1.2   thorpej #include <netinet/in.h>
     90   1.2   thorpej #include <netinet/in_systm.h>
     91   1.2   thorpej #include <netinet/in_var.h>
     92   1.2   thorpej #include <netinet/ip.h>
     93   1.2   thorpej #include <netinet/if_inarp.h>
     94   1.2   thorpej #endif
     95   1.2   thorpej 
     96   1.2   thorpej #ifdef NS
     97   1.2   thorpej #include <netns/ns.h>
     98   1.2   thorpej #include <netns/ns_if.h>
     99   1.2   thorpej #endif
    100   1.2   thorpej 
    101   1.2   thorpej #if NBPFILTER > 0
    102   1.2   thorpej #include <net/bpf.h>
    103   1.2   thorpej #include <net/bpfdesc.h>
    104   1.2   thorpej #endif
    105   1.2   thorpej 
    106   1.2   thorpej #include <machine/cpu.h>
    107   1.2   thorpej #include <machine/bus.h>
    108   1.2   thorpej #include <machine/intr.h>
    109  1.13   thorpej 
    110  1.13   thorpej #include <dev/mii/miivar.h>
    111   1.2   thorpej 
    112   1.2   thorpej #include <dev/ic/elink3var.h>
    113   1.2   thorpej #include <dev/ic/elink3reg.h>
    114   1.2   thorpej 
    115   1.2   thorpej #include <dev/pcmcia/pcmciareg.h>
    116   1.2   thorpej #include <dev/pcmcia/pcmciavar.h>
    117  1.11  christos #include <dev/pcmcia/pcmciadevs.h>
    118   1.2   thorpej 
    119   1.2   thorpej int	ep_pcmcia_match __P((struct device *, struct cfdata *, void *));
    120   1.2   thorpej void	ep_pcmcia_attach __P((struct device *, struct device *, void *));
    121  1.18   thorpej int	ep_pcmcia_detach __P((struct device *, int));
    122  1.25  augustss int	ep_pcmcia_activate __P((struct device *, enum devact));
    123   1.2   thorpej 
    124   1.2   thorpej int	ep_pcmcia_get_enaddr __P((struct pcmcia_tuple *, void *));
    125   1.2   thorpej int	ep_pcmcia_enable __P((struct ep_softc *));
    126   1.2   thorpej void	ep_pcmcia_disable __P((struct ep_softc *));
    127   1.2   thorpej 
    128   1.7   thorpej int	ep_pcmcia_enable1 __P((struct ep_softc *));
    129   1.7   thorpej void	ep_pcmcia_disable1 __P((struct ep_softc *));
    130   1.7   thorpej 
    131   1.2   thorpej struct ep_pcmcia_softc {
    132   1.2   thorpej 	struct ep_softc sc_ep;			/* real "ep" softc */
    133   1.2   thorpej 
    134   1.2   thorpej 	/* PCMCIA-specific goo */
    135   1.2   thorpej 	struct pcmcia_io_handle sc_pcioh;	/* PCMCIA i/o space info */
    136   1.2   thorpej 	int sc_io_window;			/* our i/o window */
    137   1.2   thorpej 	struct pcmcia_function *sc_pf;		/* our PCMCIA function */
    138   1.2   thorpej };
    139   1.2   thorpej 
    140   1.2   thorpej struct cfattach ep_pcmcia_ca = {
    141  1.18   thorpej 	sizeof(struct ep_pcmcia_softc), ep_pcmcia_match, ep_pcmcia_attach,
    142  1.25  augustss 	    ep_pcmcia_detach, ep_pcmcia_activate
    143   1.2   thorpej };
    144   1.2   thorpej 
    145  1.14   thorpej struct ep_pcmcia_product {
    146  1.14   thorpej 	u_int32_t	epp_product;	/* PCMCIA product ID */
    147  1.14   thorpej 	u_short		epp_chipset;	/* 3Com chipset used */
    148  1.14   thorpej 	int		epp_flags;	/* initial softc flags */
    149  1.14   thorpej 	int		epp_expfunc;	/* expected function */
    150  1.14   thorpej 	const char	*epp_name;	/* device name */
    151  1.14   thorpej } ep_pcmcia_products[] = {
    152  1.23      tron 	{ PCMCIA_PRODUCT_3COM_3C562,		ELINK_CHIPSET_3C509,
    153  1.23      tron 	  0,					0,
    154  1.14   thorpej 	  PCMCIA_STR_3COM_3C562 },
    155  1.23      tron 	{ PCMCIA_PRODUCT_3COM_3C589,		ELINK_CHIPSET_3C509,
    156  1.23      tron 	  0,					0,
    157  1.14   thorpej 	  PCMCIA_STR_3COM_3C589 },
    158  1.14   thorpej 
    159  1.23      tron 	{ PCMCIA_PRODUCT_3COM_3CXEM556,		ELINK_CHIPSET_3C509,
    160  1.23      tron 	  0,					0,
    161  1.21      marc 	  PCMCIA_STR_3COM_3CXEM556 },
    162  1.21      marc 
    163  1.23      tron 	{ PCMCIA_PRODUCT_3COM_3CXEM556INT,	ELINK_CHIPSET_3C509,
    164  1.23      tron 	  0,					0,
    165  1.23      tron 	  PCMCIA_STR_3COM_3CXEM556INT },
    166  1.23      tron 
    167  1.23      tron 	{ PCMCIA_PRODUCT_3COM_3C574,		ELINK_CHIPSET_ROADRUNNER,
    168  1.23      tron 	  ELINK_FLAGS_MII,			0,
    169  1.16   thorpej 	  PCMCIA_STR_3COM_3C574 },
    170  1.16   thorpej 
    171  1.24   thorpej 	{ PCMCIA_PRODUCT_3COM_3CCFEM556BI,	ELINK_CHIPSET_ROADRUNNER,
    172  1.24   thorpej 	  ELINK_FLAGS_MII,			0,
    173  1.24   thorpej 	  PCMCIA_STR_3COM_3CCFEM556BI },
    174  1.24   thorpej 
    175  1.23      tron 	{ 0,					0,
    176  1.23      tron 	  0,					0,
    177  1.14   thorpej 	  NULL },
    178  1.14   thorpej };
    179  1.14   thorpej 
    180  1.14   thorpej struct ep_pcmcia_product *ep_pcmcia_lookup __P((struct pcmcia_attach_args *));
    181  1.14   thorpej 
    182  1.14   thorpej struct ep_pcmcia_product *
    183  1.14   thorpej ep_pcmcia_lookup(pa)
    184  1.14   thorpej 	struct pcmcia_attach_args *pa;
    185  1.14   thorpej {
    186  1.14   thorpej 	struct ep_pcmcia_product *epp;
    187  1.14   thorpej 
    188  1.14   thorpej 	for (epp = ep_pcmcia_products; epp->epp_name != NULL; epp++)
    189  1.14   thorpej 		if (pa->product == epp->epp_product &&
    190  1.15   thorpej 		    pa->pf->number == epp->epp_expfunc)
    191  1.14   thorpej 			return (epp);
    192  1.14   thorpej 
    193  1.14   thorpej 	return (NULL);
    194  1.14   thorpej }
    195  1.14   thorpej 
    196   1.2   thorpej int
    197   1.2   thorpej ep_pcmcia_match(parent, match, aux)
    198   1.2   thorpej 	struct device *parent;
    199   1.3  drochner 	struct cfdata *match;
    200   1.2   thorpej 	void *aux;
    201   1.2   thorpej {
    202   1.2   thorpej 	struct pcmcia_attach_args *pa = aux;
    203   1.2   thorpej 
    204  1.14   thorpej 	if (pa->manufacturer != PCMCIA_VENDOR_3COM)
    205  1.14   thorpej 		return (0);
    206  1.14   thorpej 
    207  1.14   thorpej 	if (ep_pcmcia_lookup(pa) != NULL)
    208  1.14   thorpej 		return (1);
    209   1.2   thorpej 
    210   1.2   thorpej 	return (0);
    211   1.2   thorpej }
    212   1.2   thorpej 
    213   1.2   thorpej int
    214   1.2   thorpej ep_pcmcia_enable(sc)
    215   1.2   thorpej 	struct ep_softc *sc;
    216   1.2   thorpej {
    217   1.2   thorpej 	struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *) sc;
    218   1.5      marc 	struct pcmcia_function *pf = psc->sc_pf;
    219   1.2   thorpej 
    220   1.2   thorpej 	/* establish the interrupt. */
    221   1.5      marc 	sc->sc_ih = pcmcia_intr_establish(pf, IPL_NET, epintr, sc);
    222   1.2   thorpej 	if (sc->sc_ih == NULL) {
    223   1.2   thorpej 		printf("%s: couldn't establish interrupt\n",
    224   1.2   thorpej 		    sc->sc_dev.dv_xname);
    225   1.2   thorpej 		return (1);
    226   1.2   thorpej 	}
    227   1.2   thorpej 
    228   1.7   thorpej 	return (ep_pcmcia_enable1(sc));
    229   1.7   thorpej }
    230   1.7   thorpej 
    231   1.7   thorpej int
    232   1.7   thorpej ep_pcmcia_enable1(sc)
    233   1.7   thorpej 	struct ep_softc *sc;
    234   1.7   thorpej {
    235   1.7   thorpej 	struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *) sc;
    236   1.7   thorpej 	struct pcmcia_function *pf = psc->sc_pf;
    237   1.7   thorpej 	int ret;
    238   1.7   thorpej 
    239   1.5      marc 	if ((ret = pcmcia_function_enable(pf)))
    240   1.7   thorpej 		return (ret);
    241   1.7   thorpej 
    242  1.21      marc 	if ((psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3C562) ||
    243  1.23      tron 	    (psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3CXEM556) ||
    244  1.23      tron 	    (psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3CXEM556INT)) {
    245   1.5      marc 		int reg;
    246   1.5      marc 
    247   1.5      marc 		/* turn off the serial-disable bit */
    248   1.5      marc 
    249   1.5      marc 		reg = pcmcia_ccr_read(pf, PCMCIA_CCR_OPTION);
    250   1.5      marc 		if (reg & 0x08) {
    251   1.7   thorpej 			reg &= ~0x08;
    252   1.7   thorpej 			pcmcia_ccr_write(pf, PCMCIA_CCR_OPTION, reg);
    253   1.5      marc 		}
    254   1.5      marc 
    255   1.5      marc 	}
    256   1.5      marc 
    257   1.5      marc 	return (ret);
    258   1.2   thorpej }
    259   1.2   thorpej 
    260   1.2   thorpej void
    261   1.2   thorpej ep_pcmcia_disable(sc)
    262   1.2   thorpej 	struct ep_softc *sc;
    263   1.2   thorpej {
    264   1.2   thorpej 	struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *) sc;
    265   1.2   thorpej 
    266   1.7   thorpej 	ep_pcmcia_disable1(sc);
    267   1.7   thorpej 	pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih);
    268  1.25  augustss 	sc->sc_ih = 0;
    269   1.7   thorpej }
    270   1.7   thorpej 
    271   1.7   thorpej void
    272   1.7   thorpej ep_pcmcia_disable1(sc)
    273   1.7   thorpej 	struct ep_softc *sc;
    274   1.7   thorpej {
    275   1.7   thorpej 	struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *) sc;
    276   1.7   thorpej 
    277   1.2   thorpej 	pcmcia_function_disable(psc->sc_pf);
    278   1.2   thorpej }
    279   1.2   thorpej 
    280   1.2   thorpej void
    281   1.2   thorpej ep_pcmcia_attach(parent, self, aux)
    282   1.2   thorpej 	struct device  *parent, *self;
    283   1.2   thorpej 	void           *aux;
    284   1.2   thorpej {
    285   1.2   thorpej 	struct ep_pcmcia_softc *psc = (void *) self;
    286   1.2   thorpej 	struct ep_softc *sc = &psc->sc_ep;
    287   1.2   thorpej 	struct pcmcia_attach_args *pa = aux;
    288   1.2   thorpej 	struct pcmcia_config_entry *cfe;
    289  1.14   thorpej 	struct ep_pcmcia_product *epp;
    290   1.2   thorpej 	u_int8_t myla[ETHER_ADDR_LEN];
    291  1.16   thorpej 	u_int8_t *enaddr = NULL;
    292  1.14   thorpej 	int i;
    293   1.2   thorpej 
    294   1.2   thorpej 	psc->sc_pf = pa->pf;
    295   1.2   thorpej 	cfe = pa->pf->cfe_head.sqh_first;
    296   1.2   thorpej 
    297   1.2   thorpej 	/* Enable the card. */
    298   1.2   thorpej 	pcmcia_function_init(pa->pf, cfe);
    299   1.7   thorpej 	if (ep_pcmcia_enable1(sc))
    300   1.2   thorpej 		printf(": function enable failed\n");
    301   1.2   thorpej 
    302   1.2   thorpej 	sc->enabled = 1;
    303   1.2   thorpej 
    304   1.2   thorpej 	if (cfe->num_memspace != 0)
    305   1.2   thorpej 		printf(": unexpected number of memory spaces %d should be 0\n",
    306   1.2   thorpej 		    cfe->num_memspace);
    307   1.2   thorpej 
    308   1.2   thorpej 	if (cfe->num_iospace != 1)
    309   1.2   thorpej 		printf(": unexpected number of I/O spaces %d should be 1\n",
    310   1.2   thorpej 		    cfe->num_iospace);
    311   1.2   thorpej 
    312   1.2   thorpej 	if (pa->product == PCMCIA_PRODUCT_3COM_3C562) {
    313   1.2   thorpej 		bus_addr_t maxaddr = (pa->pf->sc->iobase + pa->pf->sc->iosize);
    314   1.2   thorpej 
    315   1.6  christos 		for (i = pa->pf->sc->iobase; i < maxaddr; i += 0x10) {
    316   1.6  christos 			/*
    317   1.6  christos 			 * the 3c562 can only use 0x??00-0x??7f
    318   1.6  christos 			 * according to the Linux driver
    319   1.6  christos 			 */
    320   1.6  christos 			if (i & 0x80)
    321   1.6  christos 				continue;
    322   1.2   thorpej 			if (pcmcia_io_alloc(pa->pf, i, cfe->iospace[0].length,
    323   1.2   thorpej 			    0, &psc->sc_pcioh) == 0)
    324   1.2   thorpej 				break;
    325   1.2   thorpej 		}
    326   1.2   thorpej 		if (i >= maxaddr) {
    327   1.2   thorpej 			printf(": can't allocate i/o space\n");
    328   1.2   thorpej 			return;
    329   1.2   thorpej 		}
    330   1.2   thorpej 	} else {
    331   1.2   thorpej 		if (pcmcia_io_alloc(pa->pf, 0, cfe->iospace[0].length,
    332   1.2   thorpej 		    cfe->iospace[0].length, &psc->sc_pcioh))
    333   1.2   thorpej 			printf(": can't allocate i/o space\n");
    334   1.2   thorpej 	}
    335   1.2   thorpej 
    336   1.2   thorpej 	sc->sc_iot = psc->sc_pcioh.iot;
    337   1.2   thorpej 	sc->sc_ioh = psc->sc_pcioh.ioh;
    338   1.2   thorpej 
    339   1.2   thorpej 	if (pcmcia_io_map(pa->pf, ((cfe->flags & PCMCIA_CFE_IO16) ?
    340   1.2   thorpej 	    PCMCIA_WIDTH_IO16 : PCMCIA_WIDTH_IO8), 0, cfe->iospace[0].length,
    341   1.2   thorpej 	    &psc->sc_pcioh, &psc->sc_io_window)) {
    342   1.2   thorpej 		printf(": can't map i/o space\n");
    343   1.2   thorpej 		return;
    344   1.2   thorpej 	}
    345  1.16   thorpej 
    346  1.16   thorpej 	switch (pa->product) {
    347  1.16   thorpej 	case PCMCIA_PRODUCT_3COM_3C562:
    348   1.6  christos 		/*
    349   1.6  christos 		 * 3c562a-c use this; 3c562d does it in the regular way.
    350   1.6  christos 		 * we might want to check the revision and produce a warning
    351   1.6  christos 		 * in the future.
    352   1.6  christos 		 */
    353  1.16   thorpej 		/* FALLTHROUGH */
    354  1.16   thorpej 	case PCMCIA_PRODUCT_3COM_3C574:
    355  1.24   thorpej 	case PCMCIA_PRODUCT_3COM_3CCFEM556BI:
    356  1.16   thorpej 		/*
    357  1.16   thorpej 		 * Apparently, some 3c574s do it this way, as well.
    358  1.16   thorpej 		 */
    359  1.16   thorpej 		if (pcmcia_scan_cis(parent, ep_pcmcia_get_enaddr, myla))
    360   1.6  christos 			enaddr = myla;
    361  1.16   thorpej 		break;
    362   1.2   thorpej 	}
    363   1.2   thorpej 
    364  1.14   thorpej 	epp = ep_pcmcia_lookup(pa);
    365  1.14   thorpej 	if (epp == NULL)
    366  1.14   thorpej 		panic("ep_pcmcia_attach: impossible");
    367   1.2   thorpej 
    368  1.14   thorpej 	printf(": %s\n", epp->epp_name);
    369  1.22   thorpej 
    370  1.22   thorpej 	sc->bustype = ELINK_BUS_PCMCIA;
    371  1.22   thorpej 	sc->ep_flags = epp->epp_flags;
    372  1.22   thorpej 
    373   1.2   thorpej 	sc->enable = ep_pcmcia_enable;
    374   1.2   thorpej 	sc->disable = ep_pcmcia_disable;
    375   1.2   thorpej 
    376  1.14   thorpej 	epconfig(sc, epp->epp_chipset, enaddr);
    377   1.2   thorpej 
    378   1.2   thorpej 	sc->enabled = 0;
    379   1.2   thorpej 
    380   1.7   thorpej 	ep_pcmcia_disable1(sc);
    381  1.18   thorpej }
    382  1.18   thorpej 
    383  1.18   thorpej int
    384  1.25  augustss ep_pcmcia_activate(dev, act)
    385  1.25  augustss 	struct device *dev;
    386  1.25  augustss 	enum devact act;
    387  1.25  augustss {
    388  1.25  augustss 	struct ep_pcmcia_softc *sc = (struct ep_pcmcia_softc *)dev;
    389  1.25  augustss 	int s;
    390  1.25  augustss 	int rv = 0;
    391  1.25  augustss 
    392  1.25  augustss 	s = splnet();
    393  1.25  augustss 	switch (act) {
    394  1.25  augustss 	case DVACT_ACTIVATE:
    395  1.25  augustss 		rv = EOPNOTSUPP;
    396  1.25  augustss 		break;
    397  1.25  augustss 
    398  1.25  augustss 	case DVACT_DEACTIVATE:
    399  1.25  augustss 		if (sc->sc_ep.sc_ih != NULL)
    400  1.25  augustss 			ep_pcmcia_disable((void *)sc);
    401  1.25  augustss 		break;
    402  1.25  augustss 	}
    403  1.25  augustss 	splx(s);
    404  1.25  augustss 	return (rv);
    405  1.25  augustss }
    406  1.25  augustss 
    407  1.25  augustss int
    408  1.18   thorpej ep_pcmcia_detach(self, flags)
    409  1.18   thorpej 	struct device *self;
    410  1.18   thorpej 	int flags;
    411  1.18   thorpej {
    412  1.19   thorpej 	struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *)self;
    413  1.25  augustss 	struct ep_softc *sc = &psc->sc_ep;
    414  1.25  augustss 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
    415  1.19   thorpej 
    416  1.19   thorpej 	/* Unmap our i/o window. */
    417  1.19   thorpej 	pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
    418  1.19   thorpej 
    419  1.19   thorpej 	/* Free our i/o space. */
    420  1.19   thorpej 	pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
    421  1.19   thorpej 
    422  1.25  augustss 	bpfdetach(ifp);
    423  1.25  augustss 	ether_ifdetach(ifp);
    424  1.25  augustss 	if_detach(ifp);
    425  1.25  augustss 
    426  1.18   thorpej 	return (0);
    427   1.2   thorpej }
    428   1.2   thorpej 
    429   1.2   thorpej int
    430   1.2   thorpej ep_pcmcia_get_enaddr(tuple, arg)
    431   1.2   thorpej 	struct pcmcia_tuple *tuple;
    432   1.2   thorpej 	void *arg;
    433   1.2   thorpej {
    434   1.2   thorpej 	u_int8_t *myla = arg;
    435   1.2   thorpej 	int i;
    436   1.2   thorpej 
    437   1.6  christos 	/* this is 3c562a-c magic */
    438   1.2   thorpej 	if (tuple->code == 0x88) {
    439   1.2   thorpej 		if (tuple->length < ETHER_ADDR_LEN)
    440   1.2   thorpej 			return (0);
    441   1.2   thorpej 
    442   1.2   thorpej 		for (i = 0; i < ETHER_ADDR_LEN; i += 2) {
    443   1.2   thorpej 			myla[i] = pcmcia_tuple_read_1(tuple, i + 1);
    444   1.2   thorpej 			myla[i + 1] = pcmcia_tuple_read_1(tuple, i);
    445   1.2   thorpej 		}
    446   1.2   thorpej 
    447   1.2   thorpej 		return (1);
    448   1.2   thorpej 	}
    449   1.2   thorpej 	return (0);
    450   1.2   thorpej }
    451