2000-12-18 20:21:11 +03:00
|
|
|
/* $NetBSD: wdc_pcmcia.c,v 1.36 2000/12/18 17:21:11 abs Exp $ */
|
1998-01-19 22:49:03 +03:00
|
|
|
|
1998-08-15 14:10:47 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
1998-01-19 22:49:03 +03:00
|
|
|
*
|
1998-08-15 14:10:47 +04:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Charles M. Hannum, by Onno van der Linden and by Manuel Bouyer.
|
1998-01-19 22:49:03 +03:00
|
|
|
*
|
|
|
|
* 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:
|
1998-08-15 14:10:47 +04:00
|
|
|
* 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.
|
1998-01-19 22:49:03 +03:00
|
|
|
*
|
1998-08-15 14:10:47 +04:00
|
|
|
* 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.
|
1998-01-19 22:49:03 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/device.h>
|
2000-02-05 07:41:49 +03:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/systm.h>
|
1998-01-19 22:49:03 +03:00
|
|
|
|
|
|
|
#include <machine/bus.h>
|
2000-02-05 07:41:49 +03:00
|
|
|
#include <machine/intr.h>
|
1998-01-19 22:49:03 +03:00
|
|
|
|
1998-10-29 12:49:51 +03:00
|
|
|
#include <dev/pcmcia/pcmciareg.h>
|
1998-01-19 22:49:03 +03:00
|
|
|
#include <dev/pcmcia/pcmciavar.h>
|
1998-09-10 23:55:30 +04:00
|
|
|
#include <dev/pcmcia/pcmciadevs.h>
|
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
#include <dev/ata/atavar.h>
|
1998-01-19 22:49:03 +03:00
|
|
|
#include <dev/ic/wdcvar.h>
|
|
|
|
|
|
|
|
#define WDC_PCMCIA_REG_NPORTS 8
|
1998-09-10 23:55:30 +04:00
|
|
|
#define WDC_PCMCIA_AUXREG_OFFSET (WDC_PCMCIA_REG_NPORTS + 6)
|
1998-01-23 04:14:13 +03:00
|
|
|
#define WDC_PCMCIA_AUXREG_NPORTS 2
|
1998-01-19 22:49:03 +03:00
|
|
|
|
|
|
|
struct wdc_pcmcia_softc {
|
|
|
|
struct wdc_softc sc_wdcdev;
|
1998-11-21 18:41:41 +03:00
|
|
|
struct channel_softc *wdc_chanptr;
|
1998-10-12 20:09:10 +04:00
|
|
|
struct channel_softc wdc_channel;
|
1998-01-19 22:49:03 +03:00
|
|
|
struct pcmcia_io_handle sc_pioh;
|
|
|
|
struct pcmcia_io_handle sc_auxpioh;
|
|
|
|
int sc_iowindow;
|
|
|
|
int sc_auxiowindow;
|
|
|
|
void *sc_ih;
|
1998-11-20 04:52:22 +03:00
|
|
|
struct pcmcia_function *sc_pf;
|
1999-10-20 19:22:24 +04:00
|
|
|
int sc_flags;
|
|
|
|
#define WDC_PCMCIA_ATTACH 0x0001
|
1998-01-19 22:49:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static int wdc_pcmcia_match __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void wdc_pcmcia_attach __P((struct device *, struct device *, void *));
|
1999-09-23 15:04:29 +04:00
|
|
|
static int wdc_pcmcia_detach __P((struct device *, int));
|
1998-01-19 22:49:03 +03:00
|
|
|
|
|
|
|
struct cfattach wdc_pcmcia_ca = {
|
1999-09-23 15:04:29 +04:00
|
|
|
sizeof(struct wdc_pcmcia_softc), wdc_pcmcia_match, wdc_pcmcia_attach,
|
|
|
|
wdc_pcmcia_detach, wdcactivate
|
1998-01-19 22:49:03 +03:00
|
|
|
};
|
|
|
|
|
1998-09-10 23:55:30 +04:00
|
|
|
struct wdc_pcmcia_product {
|
|
|
|
u_int32_t wpp_vendor; /* vendor ID */
|
|
|
|
u_int32_t wpp_product; /* product ID */
|
|
|
|
int wpp_quirk_flag; /* Quirk flags */
|
|
|
|
#define WDC_PCMCIA_NO_EXTRA_RESETS 0x02 /* Only reset ctrl once */
|
|
|
|
const char *wpp_cis_info[4]; /* XXX necessary? */
|
|
|
|
const char *wpp_name; /* product name */
|
|
|
|
} wdc_pcmcia_products[] = {
|
|
|
|
|
|
|
|
{ /* PCMCIA_VENDOR_DIGITAL XXX */ 0x0100,
|
|
|
|
PCMCIA_PRODUCT_DIGITAL_MOBILE_MEDIA_CDROM,
|
|
|
|
0, { NULL, "Digital Mobile Media CD-ROM", NULL, NULL },
|
|
|
|
PCMCIA_STR_DIGITAL_MOBILE_MEDIA_CDROM },
|
|
|
|
|
1999-02-20 00:49:43 +03:00
|
|
|
{ PCMCIA_VENDOR_IBM,
|
1999-11-27 04:03:33 +03:00
|
|
|
PCMCIA_PRODUCT_IBM_PORTABLE_CDROM,
|
1999-02-20 00:49:43 +03:00
|
|
|
0, { NULL, "PCMCIA Portable CD-ROM Drive", NULL, NULL },
|
1999-11-27 04:03:33 +03:00
|
|
|
PCMCIA_STR_IBM_PORTABLE_CDROM },
|
1999-02-20 00:49:43 +03:00
|
|
|
|
1998-09-10 23:55:30 +04:00
|
|
|
/* The TEAC IDE/Card II is used on the Sony Vaio */
|
|
|
|
{ PCMCIA_VENDOR_TEAC,
|
|
|
|
PCMCIA_PRODUCT_TEAC_IDECARDII,
|
|
|
|
WDC_PCMCIA_NO_EXTRA_RESETS,
|
|
|
|
PCMCIA_CIS_TEAC_IDECARDII,
|
|
|
|
PCMCIA_STR_TEAC_IDECARDII },
|
|
|
|
|
2000-01-25 02:14:23 +03:00
|
|
|
/*
|
|
|
|
* EXP IDE/ATAPI DVD Card use with some DVD players.
|
|
|
|
* Does not have a vendor ID or product ID.
|
|
|
|
*/
|
2000-01-08 10:34:49 +03:00
|
|
|
{ -1,
|
|
|
|
-1,
|
|
|
|
0,
|
|
|
|
PCMCIA_CIS_EXP_EXPMULTIMEDIA,
|
|
|
|
PCMCIA_STR_EXP_EXPMULTIMEDIA },
|
|
|
|
|
2000-12-18 20:21:11 +03:00
|
|
|
/* Mobile Dock 2, neither vendor ID nor product ID */
|
1999-11-21 13:13:08 +03:00
|
|
|
{ -1, -1, 0,
|
|
|
|
{ "SHUTTLE TECHNOLOGY LTD.", "PCCARD-IDE/ATAPI Adapter", NULL, NULL},
|
|
|
|
"SHUTTLE TECHNOLOGY IDE/ATAPI Adapter"
|
|
|
|
},
|
|
|
|
|
2000-12-18 20:21:11 +03:00
|
|
|
/* Toshiba Portege 3110 CD, neither vendor ID nor product ID */
|
2000-07-21 03:20:01 +04:00
|
|
|
{ -1, -1, 0,
|
|
|
|
{ "FREECOM", "PCCARD-IDE", NULL, NULL},
|
|
|
|
"FREECOM PCCARD-IDE"
|
|
|
|
},
|
|
|
|
|
2000-12-18 20:21:11 +03:00
|
|
|
/* Random CD-ROM, (badged AMACOM), neither vendor ID nor product ID */
|
|
|
|
{ -1, -1, 0,
|
|
|
|
{ "PCMCIA", "CD-ROM", NULL, NULL},
|
|
|
|
"PCMCIA CD-ROM"
|
|
|
|
},
|
|
|
|
|
1998-09-10 23:55:30 +04:00
|
|
|
{ 0, 0, 0, { NULL, NULL, NULL, NULL}, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wdc_pcmcia_product *
|
|
|
|
wdc_pcmcia_lookup __P((struct pcmcia_attach_args *));
|
|
|
|
|
1998-11-20 04:52:22 +03:00
|
|
|
int wdc_pcmcia_enable __P((void *, int));
|
|
|
|
|
1998-10-29 12:49:51 +03:00
|
|
|
|
|
|
|
|
1998-09-10 23:55:30 +04:00
|
|
|
struct wdc_pcmcia_product *
|
|
|
|
wdc_pcmcia_lookup(pa)
|
|
|
|
struct pcmcia_attach_args *pa;
|
|
|
|
{
|
|
|
|
struct wdc_pcmcia_product *wpp;
|
|
|
|
int i, cis_match;
|
|
|
|
|
|
|
|
for (wpp = wdc_pcmcia_products; wpp->wpp_name != NULL; wpp++)
|
|
|
|
if ((wpp->wpp_vendor == -1 ||
|
|
|
|
pa->manufacturer == wpp->wpp_vendor) &&
|
|
|
|
(wpp->wpp_product == -1 ||
|
|
|
|
pa->product == wpp->wpp_product)) {
|
|
|
|
cis_match = 1;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
if (!(wpp->wpp_cis_info[i] == NULL ||
|
|
|
|
(pa->card->cis1_info[i] != NULL &&
|
|
|
|
strcmp(pa->card->cis1_info[i],
|
|
|
|
wpp->wpp_cis_info[i]) == 0)))
|
|
|
|
cis_match = 0;
|
|
|
|
}
|
|
|
|
if (cis_match)
|
1998-10-29 12:42:45 +03:00
|
|
|
return (wpp);
|
1998-09-10 23:55:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
1998-01-19 22:49:03 +03:00
|
|
|
static int
|
1998-01-23 04:14:13 +03:00
|
|
|
wdc_pcmcia_match(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
1998-01-19 22:49:03 +03:00
|
|
|
{
|
|
|
|
struct pcmcia_attach_args *pa = aux;
|
2000-10-25 13:32:11 +04:00
|
|
|
|
|
|
|
if (pa->pf->function == PCMCIA_FUNCTION_DISK &&
|
|
|
|
pa->pf->pf_funce_disk_interface == PCMCIA_TPLFE_DDI_PCCARD_ATA) {
|
|
|
|
return 10;
|
|
|
|
}
|
1998-01-19 22:49:03 +03:00
|
|
|
|
1998-09-10 23:55:30 +04:00
|
|
|
if (wdc_pcmcia_lookup(pa) != NULL)
|
|
|
|
return (1);
|
1998-01-19 22:49:03 +03:00
|
|
|
|
1998-09-10 23:55:30 +04:00
|
|
|
return (0);
|
1998-01-19 22:49:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-01-23 04:14:13 +03:00
|
|
|
wdc_pcmcia_attach(parent, self, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct device *self;
|
|
|
|
void *aux;
|
1998-01-19 22:49:03 +03:00
|
|
|
{
|
|
|
|
struct wdc_pcmcia_softc *sc = (void *)self;
|
|
|
|
struct pcmcia_attach_args *pa = aux;
|
1998-06-05 07:26:52 +04:00
|
|
|
struct pcmcia_config_entry *cfe;
|
1998-09-10 23:55:30 +04:00
|
|
|
struct wdc_pcmcia_product *wpp;
|
1998-10-29 12:49:51 +03:00
|
|
|
int quirks;
|
1998-01-19 22:49:03 +03:00
|
|
|
|
1998-11-20 04:52:22 +03:00
|
|
|
sc->sc_pf = pa->pf;
|
|
|
|
|
1998-06-05 07:26:52 +04:00
|
|
|
for (cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); cfe != NULL;
|
|
|
|
cfe = SIMPLEQ_NEXT(cfe, cfe_list)) {
|
1998-09-10 23:55:30 +04:00
|
|
|
if (cfe->num_iospace != 1 && cfe->num_iospace != 2)
|
|
|
|
continue;
|
|
|
|
|
1998-01-19 22:49:03 +03:00
|
|
|
if (pcmcia_io_alloc(pa->pf, cfe->iospace[0].start,
|
1998-09-10 23:55:30 +04:00
|
|
|
cfe->iospace[0].length,
|
|
|
|
cfe->iospace[0].start == 0 ? cfe->iospace[0].length : 0,
|
|
|
|
&sc->sc_pioh))
|
1998-01-19 22:49:03 +03:00
|
|
|
continue;
|
1998-09-10 23:55:30 +04:00
|
|
|
|
|
|
|
if (cfe->num_iospace == 2) {
|
1998-01-19 22:49:03 +03:00
|
|
|
if (!pcmcia_io_alloc(pa->pf, cfe->iospace[1].start,
|
1998-09-10 23:55:30 +04:00
|
|
|
cfe->iospace[1].length, 0, &sc->sc_auxpioh))
|
1998-01-19 22:49:03 +03:00
|
|
|
break;
|
1998-09-10 23:55:30 +04:00
|
|
|
} else /* num_iospace == 1 */ {
|
1998-01-19 22:49:03 +03:00
|
|
|
sc->sc_auxpioh.iot = sc->sc_pioh.iot;
|
1998-09-10 23:55:30 +04:00
|
|
|
if (!bus_space_subregion(sc->sc_pioh.iot,
|
|
|
|
sc->sc_pioh.ioh, WDC_PCMCIA_AUXREG_OFFSET,
|
|
|
|
WDC_PCMCIA_AUXREG_NPORTS, &sc->sc_auxpioh.ioh))
|
1998-01-19 22:49:03 +03:00
|
|
|
break;
|
|
|
|
}
|
1998-10-11 02:01:24 +04:00
|
|
|
pcmcia_io_free(pa->pf, &sc->sc_pioh);
|
1998-01-19 22:49:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cfe == NULL) {
|
1998-06-05 07:40:07 +04:00
|
|
|
printf(": can't handle card info\n");
|
2000-02-04 12:31:07 +03:00
|
|
|
goto no_config_entry;
|
1998-01-19 22:49:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable the card. */
|
|
|
|
pcmcia_function_init(pa->pf, cfe);
|
|
|
|
if (pcmcia_function_enable(pa->pf)) {
|
1998-06-05 07:26:52 +04:00
|
|
|
printf(": function enable failed\n");
|
2000-02-04 12:31:07 +03:00
|
|
|
goto enable_failed;
|
1998-01-19 22:49:03 +03:00
|
|
|
}
|
|
|
|
|
1998-09-10 23:55:30 +04:00
|
|
|
wpp = wdc_pcmcia_lookup(pa);
|
1998-10-29 12:49:51 +03:00
|
|
|
if (wpp != NULL)
|
|
|
|
quirks = wpp->wpp_quirk_flag;
|
|
|
|
else
|
|
|
|
quirks = 0;
|
1998-09-10 23:55:30 +04:00
|
|
|
|
2000-02-01 09:48:15 +03:00
|
|
|
if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_AUTO, 0,
|
1998-10-29 12:42:45 +03:00
|
|
|
sc->sc_pioh.size, &sc->sc_pioh, &sc->sc_iowindow)) {
|
1998-06-05 07:26:52 +04:00
|
|
|
printf(": can't map first I/O space\n");
|
2000-02-04 12:31:07 +03:00
|
|
|
goto iomap_failed;
|
1998-01-19 22:49:03 +03:00
|
|
|
}
|
1998-09-10 23:55:30 +04:00
|
|
|
|
1999-12-09 06:22:41 +03:00
|
|
|
if (cfe->num_iospace <= 1)
|
1999-09-23 15:04:29 +04:00
|
|
|
sc->sc_auxiowindow = -1;
|
1999-12-09 06:22:41 +03:00
|
|
|
else if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_AUTO, 0,
|
|
|
|
sc->sc_auxpioh.size, &sc->sc_auxpioh, &sc->sc_auxiowindow)) {
|
2000-01-25 02:14:23 +03:00
|
|
|
printf(": can't map second I/O space\n");
|
2000-02-04 12:31:07 +03:00
|
|
|
goto iomapaux_failed;
|
1999-12-09 06:22:41 +03:00
|
|
|
}
|
1998-01-19 22:49:03 +03:00
|
|
|
|
1999-12-09 06:22:41 +03:00
|
|
|
if ((wpp != NULL) && (wpp->wpp_name != NULL))
|
|
|
|
printf(": %s", wpp->wpp_name);
|
|
|
|
|
1998-06-05 07:26:52 +04:00
|
|
|
printf("\n");
|
1998-01-23 04:14:13 +03:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
sc->wdc_channel.cmd_iot = sc->sc_pioh.iot;
|
|
|
|
sc->wdc_channel.cmd_ioh = sc->sc_pioh.ioh;
|
|
|
|
sc->wdc_channel.ctl_iot = sc->sc_auxpioh.iot;
|
|
|
|
sc->wdc_channel.ctl_ioh = sc->sc_auxpioh.ioh;
|
|
|
|
sc->wdc_channel.data32iot = sc->wdc_channel.cmd_iot;
|
|
|
|
sc->wdc_channel.data32ioh = sc->wdc_channel.cmd_ioh;
|
|
|
|
sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32;
|
1998-12-03 21:24:30 +03:00
|
|
|
sc->sc_wdcdev.PIO_cap = 0;
|
1998-11-21 18:41:41 +03:00
|
|
|
sc->wdc_chanptr = &sc->wdc_channel;
|
|
|
|
sc->sc_wdcdev.channels = &sc->wdc_chanptr;
|
1998-10-12 20:09:10 +04:00
|
|
|
sc->sc_wdcdev.nchannels = 1;
|
|
|
|
sc->wdc_channel.channel = 0;
|
|
|
|
sc->wdc_channel.wdc = &sc->sc_wdcdev;
|
|
|
|
sc->wdc_channel.ch_queue = malloc(sizeof(struct channel_queue),
|
|
|
|
M_DEVBUF, M_NOWAIT);
|
|
|
|
if (sc->wdc_channel.ch_queue == NULL) {
|
1999-09-22 14:03:37 +04:00
|
|
|
printf("%s: can't allocate memory for command queue\n",
|
1998-10-29 12:42:45 +03:00
|
|
|
sc->sc_wdcdev.sc_dev.dv_xname);
|
2000-02-04 12:31:07 +03:00
|
|
|
goto ch_queue_alloc_failed;
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
1998-10-29 12:49:51 +03:00
|
|
|
if (quirks & WDC_PCMCIA_NO_EXTRA_RESETS)
|
1998-10-12 20:09:10 +04:00
|
|
|
sc->sc_wdcdev.cap |= WDC_CAPABILITY_NO_EXTRA_RESETS;
|
1998-11-20 04:52:22 +03:00
|
|
|
|
|
|
|
/* We can enable and disable the controller. */
|
2000-04-01 21:52:14 +04:00
|
|
|
sc->sc_wdcdev.sc_atapi_adapter._generic.scsipi_enable =
|
|
|
|
wdc_pcmcia_enable;
|
1998-11-20 04:52:22 +03:00
|
|
|
|
1999-10-20 19:22:24 +04:00
|
|
|
sc->sc_flags |= WDC_PCMCIA_ATTACH;
|
2000-02-05 07:41:49 +03:00
|
|
|
wdcattach(&sc->wdc_channel); /* should return an error XXX */
|
1999-10-20 19:22:24 +04:00
|
|
|
sc->sc_flags &= ~WDC_PCMCIA_ATTACH;
|
2000-02-04 12:31:07 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
ch_queue_alloc_failed:
|
|
|
|
/* Unmap our aux i/o window. */
|
|
|
|
if (sc->sc_auxiowindow != -1)
|
|
|
|
pcmcia_io_unmap(sc->sc_pf, sc->sc_auxiowindow);
|
|
|
|
|
|
|
|
iomapaux_failed:
|
|
|
|
/* Unmap our i/o window. */
|
|
|
|
pcmcia_io_unmap(sc->sc_pf, sc->sc_iowindow);
|
|
|
|
|
|
|
|
iomap_failed:
|
|
|
|
/* Disable the function */
|
|
|
|
pcmcia_function_disable(sc->sc_pf);
|
|
|
|
|
|
|
|
enable_failed:
|
|
|
|
/* Unmap our i/o space. */
|
|
|
|
pcmcia_io_free(sc->sc_pf, &sc->sc_pioh);
|
|
|
|
if (cfe->num_iospace == 2)
|
|
|
|
pcmcia_io_free(sc->sc_pf, &sc->sc_auxpioh);
|
|
|
|
|
|
|
|
no_config_entry:
|
|
|
|
sc->sc_iowindow = -1;
|
1998-01-19 22:49:03 +03:00
|
|
|
}
|
1998-11-20 04:52:22 +03:00
|
|
|
|
1999-09-23 15:04:29 +04:00
|
|
|
int
|
|
|
|
wdc_pcmcia_detach(self, flags)
|
|
|
|
struct device *self;
|
|
|
|
int flags;
|
|
|
|
{
|
|
|
|
struct wdc_pcmcia_softc *sc = (struct wdc_pcmcia_softc *)self;
|
|
|
|
int error;
|
|
|
|
|
2000-02-04 12:31:07 +03:00
|
|
|
if (sc->sc_iowindow == -1)
|
|
|
|
/* Nothing to detach */
|
|
|
|
return (0);
|
|
|
|
|
1999-09-23 15:04:29 +04:00
|
|
|
if ((error = wdcdetach(self, flags)) != 0)
|
|
|
|
return (error);
|
|
|
|
|
1999-12-09 06:22:41 +03:00
|
|
|
if (sc->wdc_channel.ch_queue != NULL)
|
|
|
|
free(sc->wdc_channel.ch_queue, M_DEVBUF);
|
1999-09-23 15:04:29 +04:00
|
|
|
|
|
|
|
/* Unmap our i/o window and i/o space. */
|
|
|
|
pcmcia_io_unmap(sc->sc_pf, sc->sc_iowindow);
|
|
|
|
pcmcia_io_free(sc->sc_pf, &sc->sc_pioh);
|
|
|
|
if (sc->sc_auxiowindow != -1) {
|
|
|
|
pcmcia_io_unmap(sc->sc_pf, sc->sc_auxiowindow);
|
|
|
|
pcmcia_io_free(sc->sc_pf, &sc->sc_auxpioh);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1998-11-20 04:52:22 +03:00
|
|
|
int
|
|
|
|
wdc_pcmcia_enable(arg, onoff)
|
|
|
|
void *arg;
|
|
|
|
int onoff;
|
|
|
|
{
|
|
|
|
struct wdc_pcmcia_softc *sc = arg;
|
|
|
|
|
|
|
|
if (onoff) {
|
2000-01-25 02:14:23 +03:00
|
|
|
/* See the comment in aic_pcmcia_enable */
|
1999-10-20 19:22:24 +04:00
|
|
|
if ((sc->sc_flags & WDC_PCMCIA_ATTACH) == 0) {
|
2000-02-21 06:55:22 +03:00
|
|
|
/* Establish the interrupt handler. */
|
|
|
|
sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_BIO,
|
|
|
|
wdcintr, &sc->wdc_channel);
|
|
|
|
if (sc->sc_ih == NULL) {
|
|
|
|
printf("%s: "
|
|
|
|
"couldn't establish interrupt handler\n",
|
|
|
|
sc->sc_wdcdev.sc_dev.dv_xname);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
|
1999-10-20 19:22:24 +04:00
|
|
|
if (pcmcia_function_enable(sc->sc_pf)) {
|
|
|
|
printf("%s: couldn't enable PCMCIA function\n",
|
|
|
|
sc->sc_wdcdev.sc_dev.dv_xname);
|
|
|
|
pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
wdcreset(&sc->wdc_channel, VERBOSE);
|
1998-11-20 04:52:22 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pcmcia_function_disable(sc->sc_pf);
|
2000-02-21 06:55:22 +03:00
|
|
|
if ((sc->sc_flags & WDC_PCMCIA_ATTACH) == 0)
|
|
|
|
pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
|
1998-11-20 04:52:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|