2002-06-02 03:50:52 +04:00
|
|
|
/* $NetBSD: if_awi_pcmcia.c,v 1.23 2002/06/01 23:51:00 lukem Exp $ */
|
1999-11-05 08:13:36 +03:00
|
|
|
|
1999-11-04 20:12:43 +03:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Bill Sommerfeld
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCMCIA attachment for BayStack 650 802.11FH PCMCIA card,
|
|
|
|
* based on the AMD 79c930 802.11 controller chip.
|
|
|
|
*
|
|
|
|
* This attachment can probably be trivally adapted for other FH and
|
|
|
|
* DS cards based on the same chipset.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 10:24:43 +03:00
|
|
|
#include <sys/cdefs.h>
|
2002-06-02 03:50:52 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: if_awi_pcmcia.c,v 1.23 2002/06/01 23:51:00 lukem Exp $");
|
2001-11-13 10:24:43 +03:00
|
|
|
|
1999-11-04 20:12:43 +03:00
|
|
|
#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>
|
2000-03-22 14:22:20 +03:00
|
|
|
#include <net/if_ieee80211.h>
|
1999-11-04 20:12:43 +03:00
|
|
|
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/intr.h>
|
|
|
|
|
|
|
|
#include <dev/ic/am79c930reg.h>
|
|
|
|
#include <dev/ic/am79c930var.h>
|
|
|
|
#include <dev/ic/awireg.h>
|
|
|
|
#include <dev/ic/awivar.h>
|
|
|
|
|
|
|
|
#include <dev/pcmcia/pcmciareg.h>
|
|
|
|
#include <dev/pcmcia/pcmciavar.h>
|
|
|
|
#include <dev/pcmcia/pcmciadevs.h>
|
|
|
|
|
2001-09-18 13:09:57 +04:00
|
|
|
static int awi_pcmcia_match(struct device *, struct cfdata *, void *);
|
|
|
|
static void awi_pcmcia_attach(struct device *, struct device *, void *);
|
|
|
|
static int awi_pcmcia_detach(struct device *, int);
|
|
|
|
static int awi_pcmcia_enable(struct awi_softc *);
|
|
|
|
static void awi_pcmcia_disable(struct awi_softc *);
|
1999-11-04 20:12:43 +03:00
|
|
|
|
|
|
|
struct awi_pcmcia_softc {
|
2000-02-01 13:00:41 +03:00
|
|
|
struct awi_softc sc_awi; /* real "awi" softc */
|
1999-11-04 20:12:43 +03:00
|
|
|
|
|
|
|
/* PCMCIA-specific goo */
|
|
|
|
struct pcmcia_io_handle sc_pcioh; /* PCMCIA i/o space info */
|
2000-03-22 14:22:20 +03:00
|
|
|
struct pcmcia_mem_handle sc_memh; /* PCMCIA memory space info */
|
1999-11-04 20:12:43 +03:00
|
|
|
int sc_io_window; /* our i/o window */
|
2000-02-17 18:58:32 +03:00
|
|
|
int sc_mem_window; /* our memory window */
|
1999-11-04 20:12:43 +03:00
|
|
|
struct pcmcia_function *sc_pf; /* our PCMCIA function */
|
2001-09-18 13:09:57 +04:00
|
|
|
void *sc_ih; /* interrupt handler */
|
1999-11-04 20:12:43 +03:00
|
|
|
};
|
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
static int awi_pcmcia_find __P((struct awi_pcmcia_softc *,
|
1999-11-04 20:12:43 +03:00
|
|
|
struct pcmcia_attach_args *, struct pcmcia_config_entry *));
|
|
|
|
|
|
|
|
struct cfattach awi_pcmcia_ca = {
|
2000-03-22 14:22:20 +03:00
|
|
|
sizeof(struct awi_pcmcia_softc), awi_pcmcia_match, awi_pcmcia_attach,
|
2000-02-17 18:58:32 +03:00
|
|
|
awi_pcmcia_detach, awi_activate
|
1999-11-04 20:12:43 +03:00
|
|
|
};
|
|
|
|
|
2001-01-18 23:28:15 +03:00
|
|
|
static const struct awi_pcmcia_product {
|
2000-02-03 11:52:21 +03:00
|
|
|
u_int32_t app_vendor; /* vendor ID */
|
|
|
|
u_int32_t app_product; /* product ID */
|
|
|
|
const char *app_cisinfo[4]; /* CIS information */
|
|
|
|
const char *app_name; /* product name */
|
|
|
|
} awi_pcmcia_products[] = {
|
|
|
|
{ PCMCIA_VENDOR_BAY, PCMCIA_PRODUCT_BAY_STACK_650,
|
|
|
|
PCMCIA_CIS_BAY_STACK_650, PCMCIA_STR_BAY_STACK_650 },
|
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
{ PCMCIA_VENDOR_BAY, PCMCIA_PRODUCT_BAY_STACK_660,
|
|
|
|
PCMCIA_CIS_BAY_STACK_660, PCMCIA_STR_BAY_STACK_660 },
|
|
|
|
|
|
|
|
{ PCMCIA_VENDOR_BAY, PCMCIA_PRODUCT_BAY_SURFER_PRO,
|
|
|
|
PCMCIA_CIS_BAY_SURFER_PRO, PCMCIA_STR_BAY_SURFER_PRO },
|
|
|
|
|
|
|
|
{ PCMCIA_VENDOR_AMD, PCMCIA_PRODUCT_AMD_AM79C930,
|
|
|
|
PCMCIA_CIS_AMD_AM79C930, PCMCIA_STR_AMD_AM79C930 },
|
2000-02-03 11:52:21 +03:00
|
|
|
|
|
|
|
{ PCMCIA_VENDOR_ICOM, PCMCIA_PRODUCT_ICOM_SL200,
|
|
|
|
PCMCIA_CIS_ICOM_SL200, PCMCIA_STR_ICOM_SL200 },
|
|
|
|
|
2000-03-23 01:33:47 +03:00
|
|
|
{ PCMCIA_VENDOR_NOKIA, PCMCIA_PRODUCT_NOKIA_C020_WLAN,
|
|
|
|
PCMCIA_CIS_NOKIA_C020_WLAN, PCMCIA_STR_NOKIA_C020_WLAN },
|
|
|
|
|
2000-06-09 17:05:02 +04:00
|
|
|
{ PCMCIA_VENDOR_FARALLON, PCMCIA_PRODUCT_FARALLON_SKYLINE,
|
|
|
|
PCMCIA_CIS_FARALLON_SKYLINE, PCMCIA_STR_FARALLON_SKYLINE },
|
|
|
|
|
2000-02-03 11:52:21 +03:00
|
|
|
{ 0, 0,
|
|
|
|
{ NULL, NULL, NULL, NULL }, NULL },
|
|
|
|
};
|
|
|
|
|
2001-01-18 23:28:15 +03:00
|
|
|
static const struct awi_pcmcia_product *
|
2000-02-03 11:52:21 +03:00
|
|
|
awi_pcmcia_lookup __P((struct pcmcia_attach_args *));
|
|
|
|
|
2001-01-18 23:28:15 +03:00
|
|
|
static const struct awi_pcmcia_product *
|
2000-02-03 11:52:21 +03:00
|
|
|
awi_pcmcia_lookup(pa)
|
|
|
|
struct pcmcia_attach_args *pa;
|
|
|
|
{
|
2001-01-18 23:28:15 +03:00
|
|
|
const struct awi_pcmcia_product *app;
|
2000-02-03 11:52:21 +03:00
|
|
|
|
|
|
|
for (app = awi_pcmcia_products; app->app_name != NULL; app++) {
|
|
|
|
/* match by vendor/product id */
|
|
|
|
if (pa->manufacturer != PCMCIA_VENDOR_INVALID &&
|
|
|
|
pa->manufacturer == app->app_vendor &&
|
|
|
|
pa->product != PCMCIA_PRODUCT_INVALID &&
|
|
|
|
pa->product == app->app_product)
|
|
|
|
return (app);
|
|
|
|
|
|
|
|
/* match by CIS information */
|
|
|
|
if (pa->card->cis1_info[0] != NULL &&
|
|
|
|
app->app_cisinfo[0] != NULL &&
|
|
|
|
strcmp(pa->card->cis1_info[0], app->app_cisinfo[0]) == 0 &&
|
|
|
|
pa->card->cis1_info[1] != NULL &&
|
|
|
|
app->app_cisinfo[1] != NULL &&
|
|
|
|
strcmp(pa->card->cis1_info[1], app->app_cisinfo[1]) == 0)
|
|
|
|
return (app);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (NULL);
|
|
|
|
}
|
1999-11-06 19:43:53 +03:00
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
static int
|
1999-11-04 20:12:43 +03:00
|
|
|
awi_pcmcia_enable(sc)
|
|
|
|
struct awi_softc *sc;
|
|
|
|
{
|
2000-02-01 11:58:25 +03:00
|
|
|
struct awi_pcmcia_softc *psc = (struct awi_pcmcia_softc *)sc;
|
1999-11-04 20:12:43 +03:00
|
|
|
struct pcmcia_function *pf = psc->sc_pf;
|
|
|
|
|
|
|
|
/* establish the interrupt. */
|
2001-09-18 13:09:57 +04:00
|
|
|
psc->sc_ih = pcmcia_intr_establish(pf, IPL_NET, awi_intr, sc);
|
|
|
|
if (psc->sc_ih == NULL) {
|
1999-11-04 20:12:43 +03:00
|
|
|
printf("%s: couldn't establish interrupt\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
return (1);
|
|
|
|
}
|
2000-03-22 14:22:20 +03:00
|
|
|
|
|
|
|
if (pcmcia_function_enable(pf)) {
|
2001-09-18 13:09:57 +04:00
|
|
|
pcmcia_intr_disestablish(pf, psc->sc_ih);
|
2000-03-22 14:22:20 +03:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
DELAY(1000);
|
|
|
|
|
|
|
|
return (0);
|
1999-11-04 20:12:43 +03:00
|
|
|
}
|
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
static void
|
1999-11-04 20:12:43 +03:00
|
|
|
awi_pcmcia_disable(sc)
|
|
|
|
struct awi_softc *sc;
|
|
|
|
{
|
2000-02-01 11:58:25 +03:00
|
|
|
struct awi_pcmcia_softc *psc = (struct awi_pcmcia_softc *)sc;
|
1999-11-04 20:12:43 +03:00
|
|
|
struct pcmcia_function *pf = psc->sc_pf;
|
|
|
|
|
2000-02-01 11:58:25 +03:00
|
|
|
pcmcia_function_disable(pf);
|
2001-09-18 13:09:57 +04:00
|
|
|
pcmcia_intr_disestablish(pf, psc->sc_ih);
|
1999-11-04 20:12:43 +03:00
|
|
|
}
|
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
static int
|
1999-11-04 20:12:43 +03:00
|
|
|
awi_pcmcia_match(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct pcmcia_attach_args *pa = aux;
|
|
|
|
|
2000-02-03 11:52:21 +03:00
|
|
|
if (awi_pcmcia_lookup(pa) != NULL)
|
1999-11-04 20:12:43 +03:00
|
|
|
return (1);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
static int
|
2000-02-01 11:58:25 +03:00
|
|
|
awi_pcmcia_find(psc, pa, cfe)
|
1999-11-04 20:12:43 +03:00
|
|
|
struct awi_pcmcia_softc *psc;
|
|
|
|
struct pcmcia_attach_args *pa;
|
|
|
|
struct pcmcia_config_entry *cfe;
|
|
|
|
{
|
|
|
|
struct awi_softc *sc = &psc->sc_awi;
|
|
|
|
int fail = 0;
|
2000-02-01 11:58:25 +03:00
|
|
|
|
1999-11-04 20:12:43 +03:00
|
|
|
/*
|
|
|
|
* see if we can read the firmware version sanely
|
|
|
|
* through the i/o ports.
|
|
|
|
* if not, try a different CIS string..
|
|
|
|
*/
|
|
|
|
if (pcmcia_io_alloc(psc->sc_pf, cfe->iospace[0].start,
|
2000-03-22 14:22:20 +03:00
|
|
|
cfe->iospace[0].length, AM79C930_IO_ALIGN,
|
2000-02-01 13:12:04 +03:00
|
|
|
&psc->sc_pcioh) != 0)
|
1999-11-04 20:12:43 +03:00
|
|
|
goto fail;
|
2000-02-01 11:58:25 +03:00
|
|
|
|
1999-11-04 20:12:43 +03:00
|
|
|
if (pcmcia_io_map(psc->sc_pf, PCMCIA_WIDTH_AUTO, 0, psc->sc_pcioh.size,
|
1999-11-04 20:48:13 +03:00
|
|
|
&psc->sc_pcioh, &psc->sc_io_window))
|
1999-11-04 20:12:43 +03:00
|
|
|
goto fail_io_free;
|
|
|
|
|
|
|
|
/* Enable the card. */
|
|
|
|
pcmcia_function_init(psc->sc_pf, cfe);
|
2000-02-01 11:58:25 +03:00
|
|
|
if (pcmcia_function_enable(psc->sc_pf))
|
1999-11-04 20:12:43 +03:00
|
|
|
goto fail_io_unmap;
|
2000-02-01 11:58:25 +03:00
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
sc->sc_chip.sc_bustype = AM79C930_BUS_PCMCIA;
|
1999-11-04 20:12:43 +03:00
|
|
|
sc->sc_chip.sc_iot = psc->sc_pcioh.iot;
|
|
|
|
sc->sc_chip.sc_ioh = psc->sc_pcioh.ioh;
|
|
|
|
am79c930_chip_init(&sc->sc_chip, 0);
|
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
DELAY(1000);
|
1999-11-04 20:12:43 +03:00
|
|
|
|
2000-06-09 09:31:15 +04:00
|
|
|
awi_read_bytes(sc, AWI_BANNER, sc->sc_banner, AWI_BANNER_LEN);
|
1999-11-04 20:12:43 +03:00
|
|
|
|
2000-06-09 09:31:15 +04:00
|
|
|
if (memcmp(sc->sc_banner, "PCnetMobile:", 12) == 0)
|
2000-02-01 11:58:25 +03:00
|
|
|
return (0);
|
|
|
|
|
1999-11-04 20:12:43 +03:00
|
|
|
fail++;
|
2000-02-01 11:58:25 +03:00
|
|
|
pcmcia_function_disable(psc->sc_pf);
|
|
|
|
|
1999-11-04 20:12:43 +03:00
|
|
|
fail_io_unmap:
|
|
|
|
fail++;
|
2000-02-01 11:58:25 +03:00
|
|
|
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
|
|
|
|
1999-11-04 20:12:43 +03:00
|
|
|
fail_io_free:
|
|
|
|
fail++;
|
2000-02-01 11:58:25 +03:00
|
|
|
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
1999-11-04 20:12:43 +03:00
|
|
|
fail:
|
|
|
|
fail++;
|
2000-03-22 14:22:20 +03:00
|
|
|
psc->sc_io_window = -1;
|
2000-02-01 11:58:25 +03:00
|
|
|
return (fail);
|
1999-11-04 20:12:43 +03:00
|
|
|
}
|
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
static void
|
1999-11-04 20:12:43 +03:00
|
|
|
awi_pcmcia_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
2000-02-01 11:58:25 +03:00
|
|
|
struct awi_pcmcia_softc *psc = (void *)self;
|
1999-11-04 20:12:43 +03:00
|
|
|
struct awi_softc *sc = &psc->sc_awi;
|
2001-01-18 23:28:15 +03:00
|
|
|
const struct awi_pcmcia_product *app;
|
1999-11-04 20:12:43 +03:00
|
|
|
struct pcmcia_attach_args *pa = aux;
|
|
|
|
struct pcmcia_config_entry *cfe;
|
2001-12-15 16:23:20 +03:00
|
|
|
bus_size_t memoff;
|
1999-11-04 20:12:43 +03:00
|
|
|
|
2000-02-03 11:52:21 +03:00
|
|
|
app = awi_pcmcia_lookup(pa);
|
|
|
|
if (app == NULL)
|
|
|
|
panic("awi_pcmcia_attach: impossible");
|
|
|
|
|
1999-11-04 20:12:43 +03:00
|
|
|
psc->sc_pf = pa->pf;
|
|
|
|
|
2002-06-02 03:50:52 +04:00
|
|
|
SIMPLEQ_FOREACH(cfe, &pa->pf->cfe_head, cfe_list) {
|
1999-11-04 20:12:43 +03:00
|
|
|
if (cfe->iftype != PCMCIA_IFTYPE_IO)
|
|
|
|
continue;
|
|
|
|
if (cfe->num_iospace < 1)
|
|
|
|
continue;
|
|
|
|
if (cfe->iospace[0].length < AM79C930_IO_SIZE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (awi_pcmcia_find(psc, pa, cfe) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (cfe == NULL) {
|
|
|
|
printf(": no suitable CIS info found\n");
|
2000-03-22 14:22:20 +03:00
|
|
|
goto no_config_entry;
|
1999-11-04 20:12:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
sc->sc_enabled = 1;
|
2000-02-03 11:52:21 +03:00
|
|
|
printf(": %s\n", app->app_name);
|
2000-02-01 11:58:25 +03:00
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
psc->sc_mem_window = -1;
|
|
|
|
if (pcmcia_mem_alloc(psc->sc_pf, AM79C930_MEM_SIZE,
|
|
|
|
&psc->sc_memh) != 0) {
|
1999-11-04 20:48:13 +03:00
|
|
|
printf("%s: unable to allocate memory space; using i/o only\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
2000-02-12 22:58:35 +03:00
|
|
|
} else if (pcmcia_mem_map(psc->sc_pf,
|
|
|
|
PCMCIA_WIDTH_MEM8|PCMCIA_MEM_COMMON, AM79C930_MEM_BASE,
|
2000-02-17 18:58:32 +03:00
|
|
|
AM79C930_MEM_SIZE, &psc->sc_memh, &memoff, &psc->sc_mem_window)) {
|
1999-11-04 20:48:13 +03:00
|
|
|
printf("%s: unable to map memory space; using i/o only\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
2000-02-17 18:58:32 +03:00
|
|
|
pcmcia_mem_free(psc->sc_pf, &psc->sc_memh);
|
1999-11-04 20:48:13 +03:00
|
|
|
} else {
|
2000-02-17 18:58:32 +03:00
|
|
|
sc->sc_chip.sc_memt = psc->sc_memh.memt;
|
|
|
|
sc->sc_chip.sc_memh = psc->sc_memh.memh;
|
1999-11-04 20:48:13 +03:00
|
|
|
am79c930_chip_init(&sc->sc_chip, 1);
|
1999-11-04 20:12:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
sc->sc_enable = awi_pcmcia_enable;
|
|
|
|
sc->sc_disable = awi_pcmcia_disable;
|
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
/* establish the interrupt. */
|
2001-09-18 13:09:57 +04:00
|
|
|
psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, awi_intr, sc);
|
|
|
|
if (psc->sc_ih == NULL) {
|
2000-03-22 14:22:20 +03:00
|
|
|
printf("%s: couldn't establish interrupt\n",
|
1999-11-06 19:43:53 +03:00
|
|
|
sc->sc_dev.dv_xname);
|
2000-03-22 14:22:20 +03:00
|
|
|
goto no_interrupt;
|
2000-02-01 11:52:05 +03:00
|
|
|
}
|
2000-03-22 14:22:20 +03:00
|
|
|
sc->sc_cansleep = 1;
|
2000-02-01 11:52:05 +03:00
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
if (awi_attach(sc) != 0) {
|
|
|
|
printf("%s: failed to attach controller\n",
|
|
|
|
sc->sc_dev.dv_xname);
|
|
|
|
goto attach_failed;
|
2000-02-01 11:52:05 +03:00
|
|
|
}
|
1999-11-06 19:43:53 +03:00
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
sc->sc_enabled = 0;
|
|
|
|
/* disable device and disestablish the interrupt */
|
|
|
|
awi_pcmcia_disable(sc);
|
|
|
|
return;
|
1999-11-04 20:12:43 +03:00
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
attach_failed:
|
2001-09-18 13:09:57 +04:00
|
|
|
pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
|
1999-11-04 20:12:43 +03:00
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
no_interrupt:
|
|
|
|
/* Unmap our memory window and space */
|
|
|
|
if (psc->sc_mem_window != -1) {
|
|
|
|
pcmcia_mem_unmap(psc->sc_pf, psc->sc_mem_window);
|
|
|
|
pcmcia_mem_free(psc->sc_pf, &psc->sc_memh);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unmap our i/o window and space */
|
|
|
|
pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
|
|
|
|
pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
|
|
|
|
|
|
|
|
/* Disable the function */
|
1999-11-04 20:12:43 +03:00
|
|
|
pcmcia_function_disable(psc->sc_pf);
|
2000-03-22 14:22:20 +03:00
|
|
|
|
|
|
|
no_config_entry:
|
|
|
|
psc->sc_io_window = -1;
|
1999-11-04 20:12:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-22 14:22:20 +03:00
|
|
|
static int
|
1999-11-04 20:12:43 +03:00
|
|
|
awi_pcmcia_detach(self, flags)
|
|
|
|
struct device *self;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
struct awi_pcmcia_softc *psc = (struct awi_pcmcia_softc *)self;
|
2000-03-22 14:22:20 +03:00
|
|
|
int error;
|
|
|
|
|
|
|
|
if (psc->sc_io_window == -1)
|
|
|
|
/* Nothing to detach. */
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
error = awi_detach(&psc->sc_awi);
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
/* Unmap our memory window and free memory space */
|
|
|
|
if (psc->sc_mem_window != -1) {
|
|
|
|
pcmcia_mem_unmap(psc->sc_pf, psc->sc_mem_window);
|
|
|
|
pcmcia_mem_free(psc->sc_pf, &psc->sc_memh);
|
|
|
|
}
|
1999-11-04 20:12:43 +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);
|
2000-03-22 14:22:20 +03:00
|
|
|
return (0);
|
1999-11-04 20:12:43 +03:00
|
|
|
}
|