Home | History | Annotate | Line # | Download | only in pcmcia
if_an_pcmcia.c revision 1.4.4.2
      1  1.4.4.2  bouyer /* $NetBSD: if_an_pcmcia.c,v 1.4.4.2 2000/12/13 15:50:10 bouyer Exp $ */
      2  1.4.4.2  bouyer 
      3  1.4.4.2  bouyer /*-
      4  1.4.4.2  bouyer  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  1.4.4.2  bouyer  * All rights reserved.
      6  1.4.4.2  bouyer  *
      7  1.4.4.2  bouyer  * This code is derived from software contributed to The NetBSD Foundation
      8  1.4.4.2  bouyer  * by Atsushi Onoe
      9  1.4.4.2  bouyer  *
     10  1.4.4.2  bouyer  * Redistribution and use in source and binary forms, with or without
     11  1.4.4.2  bouyer  * modification, are permitted provided that the following conditions
     12  1.4.4.2  bouyer  * are met:
     13  1.4.4.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     14  1.4.4.2  bouyer  *    notice, this list of conditions and the following disclaimer.
     15  1.4.4.2  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.4.4.2  bouyer  *    notice, this list of conditions and the following disclaimer in the
     17  1.4.4.2  bouyer  *    documentation and/or other materials provided with the distribution.
     18  1.4.4.2  bouyer  * 3. All advertising materials mentioning features or use of this software
     19  1.4.4.2  bouyer  *    must display the following acknowledgement:
     20  1.4.4.2  bouyer  *        This product includes software developed by the NetBSD
     21  1.4.4.2  bouyer  *        Foundation, Inc. and its contributors.
     22  1.4.4.2  bouyer  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.4.4.2  bouyer  *    contributors may be used to endorse or promote products derived
     24  1.4.4.2  bouyer  *    from this software without specific prior written permission.
     25  1.4.4.2  bouyer  *
     26  1.4.4.2  bouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.4.4.2  bouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.4.4.2  bouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.4.4.2  bouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.4.4.2  bouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.4.4.2  bouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.4.4.2  bouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.4.4.2  bouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.4.4.2  bouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.4.4.2  bouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.4.4.2  bouyer  * POSSIBILITY OF SUCH DAMAGE.
     37  1.4.4.2  bouyer  */
     38  1.4.4.2  bouyer 
     39  1.4.4.2  bouyer #include "opt_inet.h"
     40  1.4.4.2  bouyer #include "opt_ns.h"
     41  1.4.4.2  bouyer #include "bpfilter.h"
     42  1.4.4.2  bouyer 
     43  1.4.4.2  bouyer #ifdef INET
     44  1.4.4.2  bouyer #define	ANCACHE		/* XXX: should be defined elsewhere */
     45  1.4.4.2  bouyer #endif
     46  1.4.4.2  bouyer 
     47  1.4.4.2  bouyer #include <sys/param.h>
     48  1.4.4.2  bouyer #include <sys/systm.h>
     49  1.4.4.2  bouyer #include <sys/callout.h>
     50  1.4.4.2  bouyer #include <sys/mbuf.h>
     51  1.4.4.2  bouyer #include <sys/socket.h>
     52  1.4.4.2  bouyer #include <sys/ioctl.h>
     53  1.4.4.2  bouyer #include <sys/errno.h>
     54  1.4.4.2  bouyer #include <sys/syslog.h>
     55  1.4.4.2  bouyer #include <sys/select.h>
     56  1.4.4.2  bouyer #include <sys/device.h>
     57  1.4.4.2  bouyer 
     58  1.4.4.2  bouyer #include <net/if.h>
     59  1.4.4.2  bouyer #include <net/if_dl.h>
     60  1.4.4.2  bouyer #include <net/if_ether.h>
     61  1.4.4.2  bouyer #include <net/if_media.h>
     62  1.4.4.2  bouyer #include <net/if_ieee80211.h>
     63  1.4.4.2  bouyer 
     64  1.4.4.2  bouyer #ifdef INET
     65  1.4.4.2  bouyer #include <netinet/in.h>
     66  1.4.4.2  bouyer #include <netinet/in_systm.h>
     67  1.4.4.2  bouyer #include <netinet/in_var.h>
     68  1.4.4.2  bouyer #include <netinet/ip.h>
     69  1.4.4.2  bouyer #include <netinet/if_inarp.h>
     70  1.4.4.2  bouyer #endif
     71  1.4.4.2  bouyer 
     72  1.4.4.2  bouyer #ifdef NS
     73  1.4.4.2  bouyer #include <netns/ns.h>
     74  1.4.4.2  bouyer #include <netns/ns_if.h>
     75  1.4.4.2  bouyer #endif
     76  1.4.4.2  bouyer 
     77  1.4.4.2  bouyer #if NBPFILTER > 0
     78  1.4.4.2  bouyer #include <net/bpf.h>
     79  1.4.4.2  bouyer #include <net/bpfdesc.h>
     80  1.4.4.2  bouyer #endif
     81  1.4.4.2  bouyer 
     82  1.4.4.2  bouyer #include <machine/cpu.h>
     83  1.4.4.2  bouyer #include <machine/bus.h>
     84  1.4.4.2  bouyer #include <machine/intr.h>
     85  1.4.4.2  bouyer 
     86  1.4.4.2  bouyer #include <dev/ic/anreg.h>
     87  1.4.4.2  bouyer #include <dev/ic/anvar.h>
     88  1.4.4.2  bouyer 
     89  1.4.4.2  bouyer #include <dev/pcmcia/pcmciareg.h>
     90  1.4.4.2  bouyer #include <dev/pcmcia/pcmciavar.h>
     91  1.4.4.2  bouyer #include <dev/pcmcia/pcmciadevs.h>
     92  1.4.4.2  bouyer 
     93  1.4.4.2  bouyer static int an_pcmcia_match __P((struct device *, struct cfdata *, void *));
     94  1.4.4.2  bouyer static void an_pcmcia_attach __P((struct device *, struct device *, void *));
     95  1.4.4.2  bouyer static int an_pcmcia_detach __P((struct device *, int));
     96  1.4.4.2  bouyer static int an_pcmcia_enable __P((struct an_softc *));
     97  1.4.4.2  bouyer static void an_pcmcia_disable __P((struct an_softc *));
     98  1.4.4.2  bouyer static void an_pcmcia_powerhook __P((int, void *));
     99  1.4.4.2  bouyer 
    100  1.4.4.2  bouyer struct an_pcmcia_softc {
    101  1.4.4.2  bouyer 	struct an_softc sc_an;		/* real "an" softc */
    102  1.4.4.2  bouyer 
    103  1.4.4.2  bouyer 	/* PCMCIA-specific goo */
    104  1.4.4.2  bouyer 	struct pcmcia_io_handle sc_pcioh;	/* PCMCIA i/o space info */
    105  1.4.4.2  bouyer 	int sc_io_window;			/* our i/o window */
    106  1.4.4.2  bouyer 	struct pcmcia_function *sc_pf;		/* our PCMCIA function */
    107  1.4.4.2  bouyer 	void *sc_powerhook;			/* power hook descriptor */
    108  1.4.4.2  bouyer };
    109  1.4.4.2  bouyer 
    110  1.4.4.2  bouyer static int	an_pcmcia_find __P((struct an_pcmcia_softc *,
    111  1.4.4.2  bouyer     struct pcmcia_attach_args *, struct pcmcia_config_entry *));
    112  1.4.4.2  bouyer 
    113  1.4.4.2  bouyer struct cfattach an_pcmcia_ca = {
    114  1.4.4.2  bouyer 	sizeof(struct an_pcmcia_softc), an_pcmcia_match, an_pcmcia_attach,
    115  1.4.4.2  bouyer 	an_pcmcia_detach, an_activate
    116  1.4.4.2  bouyer };
    117  1.4.4.2  bouyer 
    118  1.4.4.2  bouyer static struct an_pcmcia_product {
    119  1.4.4.2  bouyer 	u_int32_t	app_vendor;	/* vendor ID */
    120  1.4.4.2  bouyer 	u_int32_t	app_product;	/* product ID */
    121  1.4.4.2  bouyer 	const char	*app_cisinfo[4]; /* CIS information */
    122  1.4.4.2  bouyer 	const char	*app_name;	/* product name */
    123  1.4.4.2  bouyer } an_pcmcia_products[] = {
    124  1.4.4.2  bouyer 	{ PCMCIA_VENDOR_AIRONET,	PCMCIA_PRODUCT_AIRONET_PC4800,
    125  1.4.4.2  bouyer 	  PCMCIA_CIS_AIRONET_PC4800,	PCMCIA_STR_AIRONET_PC4800 },
    126  1.4.4.2  bouyer 	{ PCMCIA_VENDOR_AIRONET,	PCMCIA_PRODUCT_AIRONET_PC4500,
    127  1.4.4.2  bouyer 	  PCMCIA_CIS_AIRONET_PC4500,	PCMCIA_STR_AIRONET_PC4500 },
    128  1.4.4.2  bouyer 	{ 0,				0,
    129  1.4.4.2  bouyer 	  { NULL, NULL, NULL, NULL },	NULL }
    130  1.4.4.2  bouyer };
    131  1.4.4.2  bouyer 
    132  1.4.4.2  bouyer static struct an_pcmcia_product *
    133  1.4.4.2  bouyer 	an_pcmcia_lookup __P((struct pcmcia_attach_args *));
    134  1.4.4.2  bouyer 
    135  1.4.4.2  bouyer static struct an_pcmcia_product *
    136  1.4.4.2  bouyer an_pcmcia_lookup(pa)
    137  1.4.4.2  bouyer 	struct pcmcia_attach_args *pa;
    138  1.4.4.2  bouyer {
    139  1.4.4.2  bouyer 	struct an_pcmcia_product *app;
    140  1.4.4.2  bouyer 
    141  1.4.4.2  bouyer 	for (app = an_pcmcia_products; app->app_name != NULL; app++) {
    142  1.4.4.2  bouyer 		/* match by vendor/product id */
    143  1.4.4.2  bouyer 		if (pa->manufacturer != PCMCIA_VENDOR_INVALID &&
    144  1.4.4.2  bouyer 		    pa->manufacturer == app->app_vendor &&
    145  1.4.4.2  bouyer 		    pa->product != PCMCIA_PRODUCT_INVALID &&
    146  1.4.4.2  bouyer 		    pa->product == app->app_product)
    147  1.4.4.2  bouyer 			return (app);
    148  1.4.4.2  bouyer 
    149  1.4.4.2  bouyer 		/* match by CIS information */
    150  1.4.4.2  bouyer 		if (pa->card->cis1_info[0] != NULL &&
    151  1.4.4.2  bouyer 		    app->app_cisinfo[0] != NULL &&
    152  1.4.4.2  bouyer 		    strcmp(pa->card->cis1_info[0], app->app_cisinfo[0]) == 0 &&
    153  1.4.4.2  bouyer 		    pa->card->cis1_info[1] != NULL &&
    154  1.4.4.2  bouyer 		    app->app_cisinfo[1] != NULL &&
    155  1.4.4.2  bouyer 		    strcmp(pa->card->cis1_info[1], app->app_cisinfo[1]) == 0)
    156  1.4.4.2  bouyer 			return (app);
    157  1.4.4.2  bouyer 	}
    158  1.4.4.2  bouyer 
    159  1.4.4.2  bouyer 	return (NULL);
    160  1.4.4.2  bouyer }
    161  1.4.4.2  bouyer 
    162  1.4.4.2  bouyer static int
    163  1.4.4.2  bouyer an_pcmcia_enable(sc)
    164  1.4.4.2  bouyer 	struct an_softc *sc;
    165  1.4.4.2  bouyer {
    166  1.4.4.2  bouyer 	struct an_pcmcia_softc *psc = (struct an_pcmcia_softc *)sc;
    167  1.4.4.2  bouyer 	struct pcmcia_function *pf = psc->sc_pf;
    168  1.4.4.2  bouyer 
    169  1.4.4.2  bouyer 	/* establish the interrupt. */
    170  1.4.4.2  bouyer 	sc->irq_handle = pcmcia_intr_establish(pf, IPL_NET, an_intr, sc);
    171  1.4.4.2  bouyer 	if (sc->irq_handle == NULL) {
    172  1.4.4.2  bouyer 		printf("%s: couldn't establish interrupt\n",
    173  1.4.4.2  bouyer 		    sc->an_dev.dv_xname);
    174  1.4.4.2  bouyer 		return (1);
    175  1.4.4.2  bouyer 	}
    176  1.4.4.2  bouyer 
    177  1.4.4.2  bouyer 	if (pcmcia_function_enable(pf)) {
    178  1.4.4.2  bouyer 		pcmcia_intr_disestablish(pf, sc->irq_handle);
    179  1.4.4.2  bouyer 		return (1);
    180  1.4.4.2  bouyer 	}
    181  1.4.4.2  bouyer 	DELAY(1000);
    182  1.4.4.2  bouyer 
    183  1.4.4.2  bouyer 	return (0);
    184  1.4.4.2  bouyer }
    185  1.4.4.2  bouyer 
    186  1.4.4.2  bouyer static void
    187  1.4.4.2  bouyer an_pcmcia_disable(sc)
    188  1.4.4.2  bouyer 	struct an_softc *sc;
    189  1.4.4.2  bouyer {
    190  1.4.4.2  bouyer 	struct an_pcmcia_softc *psc = (struct an_pcmcia_softc *)sc;
    191  1.4.4.2  bouyer 	struct pcmcia_function *pf = psc->sc_pf;
    192  1.4.4.2  bouyer 
    193  1.4.4.2  bouyer 	pcmcia_function_disable(pf);
    194  1.4.4.2  bouyer 	pcmcia_intr_disestablish(pf, sc->irq_handle);
    195  1.4.4.2  bouyer }
    196  1.4.4.2  bouyer 
    197  1.4.4.2  bouyer static int
    198  1.4.4.2  bouyer an_pcmcia_match(parent, match, aux)
    199  1.4.4.2  bouyer 	struct device *parent;
    200  1.4.4.2  bouyer 	struct cfdata *match;
    201  1.4.4.2  bouyer 	void *aux;
    202  1.4.4.2  bouyer {
    203  1.4.4.2  bouyer 	struct pcmcia_attach_args *pa = aux;
    204  1.4.4.2  bouyer 
    205  1.4.4.2  bouyer 	if (an_pcmcia_lookup(pa) != NULL)
    206  1.4.4.2  bouyer 		return (1);
    207  1.4.4.2  bouyer 
    208  1.4.4.2  bouyer 	return (0);
    209  1.4.4.2  bouyer }
    210  1.4.4.2  bouyer 
    211  1.4.4.2  bouyer static int
    212  1.4.4.2  bouyer an_pcmcia_find(psc, pa, cfe)
    213  1.4.4.2  bouyer 	struct an_pcmcia_softc *psc;
    214  1.4.4.2  bouyer 	struct pcmcia_attach_args *pa;
    215  1.4.4.2  bouyer 	struct pcmcia_config_entry *cfe;
    216  1.4.4.2  bouyer {
    217  1.4.4.2  bouyer 	struct an_softc *sc = &psc->sc_an;
    218  1.4.4.2  bouyer 	int fail = 0;
    219  1.4.4.2  bouyer 
    220  1.4.4.2  bouyer 	/*
    221  1.4.4.2  bouyer 	 * see if we can read the firmware version sanely
    222  1.4.4.2  bouyer 	 * through the i/o ports.
    223  1.4.4.2  bouyer 	 * if not, try a different CIS string..
    224  1.4.4.2  bouyer 	 */
    225  1.4.4.2  bouyer 	if (pcmcia_io_alloc(psc->sc_pf, cfe->iospace[0].start,
    226  1.4.4.2  bouyer 	    cfe->iospace[0].length, AN_IOSIZ,
    227  1.4.4.2  bouyer 	    &psc->sc_pcioh) != 0)
    228  1.4.4.2  bouyer 		goto fail;
    229  1.4.4.2  bouyer 
    230  1.4.4.2  bouyer 	if (pcmcia_io_map(psc->sc_pf, PCMCIA_WIDTH_AUTO, 0, psc->sc_pcioh.size,
    231  1.4.4.2  bouyer 	    &psc->sc_pcioh, &psc->sc_io_window))
    232  1.4.4.2  bouyer 		goto fail_io_free;
    233  1.4.4.2  bouyer 
    234  1.4.4.2  bouyer 	/* Enable the card. */
    235  1.4.4.2  bouyer 	pcmcia_function_init(psc->sc_pf, cfe);
    236  1.4.4.2  bouyer 	if (pcmcia_function_enable(psc->sc_pf))
    237  1.4.4.2  bouyer 		goto fail_io_unmap;
    238  1.4.4.2  bouyer 
    239  1.4.4.2  bouyer 	sc->an_btag = psc->sc_pcioh.iot;
    240  1.4.4.2  bouyer 	sc->an_bhandle = psc->sc_pcioh.ioh;
    241  1.4.4.2  bouyer 
    242  1.4.4.2  bouyer 	if (an_probe(sc))
    243  1.4.4.2  bouyer 		return 0;
    244  1.4.4.2  bouyer 
    245  1.4.4.2  bouyer 	fail++;
    246  1.4.4.2  bouyer 	pcmcia_function_disable(psc->sc_pf);
    247  1.4.4.2  bouyer 
    248  1.4.4.2  bouyer  fail_io_unmap:
    249  1.4.4.2  bouyer 	fail++;
    250  1.4.4.2  bouyer 	pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
    251  1.4.4.2  bouyer 
    252  1.4.4.2  bouyer  fail_io_free:
    253  1.4.4.2  bouyer 	fail++;
    254  1.4.4.2  bouyer 	pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
    255  1.4.4.2  bouyer  fail:
    256  1.4.4.2  bouyer 	fail++;
    257  1.4.4.2  bouyer 	return (fail);
    258  1.4.4.2  bouyer }
    259  1.4.4.2  bouyer 
    260  1.4.4.2  bouyer static void
    261  1.4.4.2  bouyer an_pcmcia_attach(parent, self, aux)
    262  1.4.4.2  bouyer 	struct device  *parent, *self;
    263  1.4.4.2  bouyer 	void           *aux;
    264  1.4.4.2  bouyer {
    265  1.4.4.2  bouyer 	struct an_pcmcia_softc *psc = (void *)self;
    266  1.4.4.2  bouyer 	struct an_softc *sc = &psc->sc_an;
    267  1.4.4.2  bouyer 	struct an_pcmcia_product *app;
    268  1.4.4.2  bouyer 	struct pcmcia_attach_args *pa = aux;
    269  1.4.4.2  bouyer 	struct pcmcia_config_entry *cfe;
    270  1.4.4.2  bouyer 
    271  1.4.4.2  bouyer 	app = an_pcmcia_lookup(pa);
    272  1.4.4.2  bouyer 	if (app == NULL)
    273  1.4.4.2  bouyer 		panic("an_pcmcia_attach: impossible");
    274  1.4.4.2  bouyer 
    275  1.4.4.2  bouyer 	psc->sc_pf = pa->pf;
    276  1.4.4.2  bouyer 
    277  1.4.4.2  bouyer 	for (cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); cfe != NULL;
    278  1.4.4.2  bouyer 	     cfe = SIMPLEQ_NEXT(cfe, cfe_list)) {
    279  1.4.4.2  bouyer 		if (cfe->iftype != PCMCIA_IFTYPE_IO)
    280  1.4.4.2  bouyer 			continue;
    281  1.4.4.2  bouyer 		if (cfe->num_iospace < 1)
    282  1.4.4.2  bouyer 			continue;
    283  1.4.4.2  bouyer 		if (cfe->iospace[0].length < AN_IOSIZ)
    284  1.4.4.2  bouyer 			continue;
    285  1.4.4.2  bouyer 
    286  1.4.4.2  bouyer 		if (an_pcmcia_find(psc, pa, cfe) == 0)
    287  1.4.4.2  bouyer 			break;
    288  1.4.4.2  bouyer 	}
    289  1.4.4.2  bouyer 	if (cfe == NULL) {
    290  1.4.4.2  bouyer 		printf(": no suitable CIS info found\n");
    291  1.4.4.2  bouyer 		goto no_config_entry;
    292  1.4.4.2  bouyer 	}
    293  1.4.4.2  bouyer 
    294  1.4.4.2  bouyer 	sc->sc_enabled = 1;
    295  1.4.4.2  bouyer 	printf(": %s\n", app->app_name);
    296  1.4.4.2  bouyer 
    297  1.4.4.2  bouyer 	sc->sc_enable = an_pcmcia_enable;
    298  1.4.4.2  bouyer 	sc->sc_disable = an_pcmcia_disable;
    299  1.4.4.2  bouyer 
    300  1.4.4.2  bouyer 	/* establish the interrupt. */
    301  1.4.4.2  bouyer 	sc->irq_handle = pcmcia_intr_establish(psc->sc_pf, IPL_NET, an_intr, sc);
    302  1.4.4.2  bouyer 	if (sc->irq_handle == NULL) {
    303  1.4.4.2  bouyer 		printf("%s: couldn't establish interrupt\n",
    304  1.4.4.2  bouyer 		    sc->an_dev.dv_xname);
    305  1.4.4.2  bouyer 		goto no_interrupt;
    306  1.4.4.2  bouyer 	}
    307  1.4.4.2  bouyer 
    308  1.4.4.2  bouyer 	if (an_attach(sc) != 0) {
    309  1.4.4.2  bouyer 		printf("%s: failed to attach controller\n",
    310  1.4.4.2  bouyer 		    sc->an_dev.dv_xname);
    311  1.4.4.2  bouyer 		goto attach_failed;
    312  1.4.4.2  bouyer 	}
    313  1.4.4.2  bouyer 	psc->sc_powerhook = powerhook_establish(an_pcmcia_powerhook, psc);
    314  1.4.4.2  bouyer 	sc->sc_enabled = 0;
    315  1.4.4.2  bouyer 
    316  1.4.4.2  bouyer 	/* disable device and disestablish the interrupt */
    317  1.4.4.2  bouyer 	an_pcmcia_disable(sc);
    318  1.4.4.2  bouyer 	return;
    319  1.4.4.2  bouyer 
    320  1.4.4.2  bouyer  attach_failed:
    321  1.4.4.2  bouyer 	pcmcia_intr_disestablish(psc->sc_pf, sc->irq_handle);
    322  1.4.4.2  bouyer 
    323  1.4.4.2  bouyer  no_interrupt:
    324  1.4.4.2  bouyer 	/* Unmap our i/o window and space */
    325  1.4.4.2  bouyer 	pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
    326  1.4.4.2  bouyer 	pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
    327  1.4.4.2  bouyer 
    328  1.4.4.2  bouyer 	/* Disable the function */
    329  1.4.4.2  bouyer 	pcmcia_function_disable(psc->sc_pf);
    330  1.4.4.2  bouyer 
    331  1.4.4.2  bouyer  no_config_entry:
    332  1.4.4.2  bouyer 	psc->sc_io_window = -1;
    333  1.4.4.2  bouyer }
    334  1.4.4.2  bouyer 
    335  1.4.4.2  bouyer 
    336  1.4.4.2  bouyer static int
    337  1.4.4.2  bouyer an_pcmcia_detach(self, flags)
    338  1.4.4.2  bouyer 	struct device *self;
    339  1.4.4.2  bouyer 	int flags;
    340  1.4.4.2  bouyer {
    341  1.4.4.2  bouyer 	struct an_pcmcia_softc *psc = (struct an_pcmcia_softc *)self;
    342  1.4.4.2  bouyer 	int error;
    343  1.4.4.2  bouyer 
    344  1.4.4.2  bouyer 	if (psc->sc_io_window == -1)
    345  1.4.4.2  bouyer 		/* Nothing to detach. */
    346  1.4.4.2  bouyer 		return (0);
    347  1.4.4.2  bouyer 
    348  1.4.4.2  bouyer 	if (psc->sc_powerhook != NULL)
    349  1.4.4.2  bouyer 		powerhook_disestablish(psc->sc_powerhook);
    350  1.4.4.2  bouyer 
    351  1.4.4.2  bouyer 	error = an_detach(&psc->sc_an);
    352  1.4.4.2  bouyer 	if (error != 0)
    353  1.4.4.2  bouyer 		return (error);
    354  1.4.4.2  bouyer 
    355  1.4.4.2  bouyer 	/* Unmap our i/o window. */
    356  1.4.4.2  bouyer 	pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
    357  1.4.4.2  bouyer 
    358  1.4.4.2  bouyer 	/* Free our i/o space. */
    359  1.4.4.2  bouyer 	pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
    360  1.4.4.2  bouyer 	return (0);
    361  1.4.4.2  bouyer }
    362  1.4.4.2  bouyer 
    363  1.4.4.2  bouyer static void
    364  1.4.4.2  bouyer an_pcmcia_powerhook(why, arg)
    365  1.4.4.2  bouyer 	int why;
    366  1.4.4.2  bouyer 	void *arg;
    367  1.4.4.2  bouyer {
    368  1.4.4.2  bouyer #if 0
    369  1.4.4.2  bouyer 	struct an_pcmcia_softc *psc = arg;
    370  1.4.4.2  bouyer 	struct an_softc *sc = &psc->sc_an;
    371  1.4.4.2  bouyer 
    372  1.4.4.2  bouyer 	an_power(sc, why);
    373  1.4.4.2  bouyer #endif
    374  1.4.4.2  bouyer }
    375