wdc_pcmcia.c revision 1.32 1 1.32 bouyer /* $NetBSD: wdc_pcmcia.c,v 1.32 2000/04/01 17:52:14 bouyer Exp $ */
2 1.1 matt
3 1.8 mycroft /*-
4 1.8 mycroft * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.8 mycroft * All rights reserved.
6 1.1 matt *
7 1.8 mycroft * This code is derived from software contributed to The NetBSD Foundation
8 1.8 mycroft * by Charles M. Hannum, by Onno van der Linden and by Manuel Bouyer.
9 1.1 matt *
10 1.1 matt * Redistribution and use in source and binary forms, with or without
11 1.1 matt * modification, are permitted provided that the following conditions
12 1.1 matt * are met:
13 1.1 matt * 1. Redistributions of source code must retain the above copyright
14 1.1 matt * notice, this list of conditions and the following disclaimer.
15 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 matt * notice, this list of conditions and the following disclaimer in the
17 1.1 matt * documentation and/or other materials provided with the distribution.
18 1.1 matt * 3. All advertising materials mentioning features or use of this software
19 1.1 matt * must display the following acknowledgement:
20 1.8 mycroft * This product includes software developed by the NetBSD
21 1.8 mycroft * Foundation, Inc. and its contributors.
22 1.8 mycroft * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.8 mycroft * contributors may be used to endorse or promote products derived
24 1.8 mycroft * from this software without specific prior written permission.
25 1.1 matt *
26 1.8 mycroft * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.8 mycroft * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.8 mycroft * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.8 mycroft * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.8 mycroft * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.8 mycroft * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.8 mycroft * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.8 mycroft * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.8 mycroft * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.8 mycroft * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.8 mycroft * POSSIBILITY OF SUCH DAMAGE.
37 1.1 matt */
38 1.1 matt
39 1.1 matt #include <sys/param.h>
40 1.30 enami #include <sys/device.h>
41 1.30 enami #include <sys/malloc.h>
42 1.1 matt #include <sys/systm.h>
43 1.1 matt
44 1.1 matt #include <vm/vm.h>
45 1.1 matt
46 1.30 enami #include <machine/bus.h>
47 1.1 matt #include <machine/intr.h>
48 1.1 matt
49 1.14 enami #include <dev/pcmcia/pcmciareg.h>
50 1.1 matt #include <dev/pcmcia/pcmciavar.h>
51 1.9 kenh #include <dev/pcmcia/pcmciadevs.h>
52 1.9 kenh
53 1.12 bouyer #include <dev/ata/atavar.h>
54 1.1 matt #include <dev/ic/wdcvar.h>
55 1.1 matt
56 1.1 matt #define WDC_PCMCIA_REG_NPORTS 8
57 1.9 kenh #define WDC_PCMCIA_AUXREG_OFFSET (WDC_PCMCIA_REG_NPORTS + 6)
58 1.2 mycroft #define WDC_PCMCIA_AUXREG_NPORTS 2
59 1.1 matt
60 1.1 matt struct wdc_pcmcia_softc {
61 1.1 matt struct wdc_softc sc_wdcdev;
62 1.16 drochner struct channel_softc *wdc_chanptr;
63 1.12 bouyer struct channel_softc wdc_channel;
64 1.1 matt struct pcmcia_io_handle sc_pioh;
65 1.1 matt struct pcmcia_io_handle sc_auxpioh;
66 1.1 matt int sc_iowindow;
67 1.1 matt int sc_auxiowindow;
68 1.1 matt void *sc_ih;
69 1.15 thorpej struct pcmcia_function *sc_pf;
70 1.22 enami int sc_flags;
71 1.22 enami #define WDC_PCMCIA_ATTACH 0x0001
72 1.1 matt };
73 1.1 matt
74 1.1 matt static int wdc_pcmcia_match __P((struct device *, struct cfdata *, void *));
75 1.1 matt static void wdc_pcmcia_attach __P((struct device *, struct device *, void *));
76 1.21 enami static int wdc_pcmcia_detach __P((struct device *, int));
77 1.1 matt
78 1.1 matt struct cfattach wdc_pcmcia_ca = {
79 1.21 enami sizeof(struct wdc_pcmcia_softc), wdc_pcmcia_match, wdc_pcmcia_attach,
80 1.21 enami wdc_pcmcia_detach, wdcactivate
81 1.1 matt };
82 1.1 matt
83 1.9 kenh struct wdc_pcmcia_product {
84 1.9 kenh u_int32_t wpp_vendor; /* vendor ID */
85 1.9 kenh u_int32_t wpp_product; /* product ID */
86 1.9 kenh int wpp_quirk_flag; /* Quirk flags */
87 1.9 kenh #define WDC_PCMCIA_NO_EXTRA_RESETS 0x02 /* Only reset ctrl once */
88 1.9 kenh const char *wpp_cis_info[4]; /* XXX necessary? */
89 1.9 kenh const char *wpp_name; /* product name */
90 1.9 kenh } wdc_pcmcia_products[] = {
91 1.9 kenh
92 1.9 kenh { /* PCMCIA_VENDOR_DIGITAL XXX */ 0x0100,
93 1.9 kenh PCMCIA_PRODUCT_DIGITAL_MOBILE_MEDIA_CDROM,
94 1.9 kenh 0, { NULL, "Digital Mobile Media CD-ROM", NULL, NULL },
95 1.9 kenh PCMCIA_STR_DIGITAL_MOBILE_MEDIA_CDROM },
96 1.19 abs
97 1.19 abs { PCMCIA_VENDOR_IBM,
98 1.24 soren PCMCIA_PRODUCT_IBM_PORTABLE_CDROM,
99 1.19 abs 0, { NULL, "PCMCIA Portable CD-ROM Drive", NULL, NULL },
100 1.24 soren PCMCIA_STR_IBM_PORTABLE_CDROM },
101 1.9 kenh
102 1.9 kenh /* The TEAC IDE/Card II is used on the Sony Vaio */
103 1.9 kenh { PCMCIA_VENDOR_TEAC,
104 1.9 kenh PCMCIA_PRODUCT_TEAC_IDECARDII,
105 1.9 kenh WDC_PCMCIA_NO_EXTRA_RESETS,
106 1.9 kenh PCMCIA_CIS_TEAC_IDECARDII,
107 1.9 kenh PCMCIA_STR_TEAC_IDECARDII },
108 1.26 augustss
109 1.27 enami /*
110 1.27 enami * EXP IDE/ATAPI DVD Card use with some DVD players.
111 1.27 enami * Does not have a vendor ID or product ID.
112 1.27 enami */
113 1.26 augustss { -1,
114 1.26 augustss -1,
115 1.26 augustss 0,
116 1.26 augustss PCMCIA_CIS_EXP_EXPMULTIMEDIA,
117 1.26 augustss PCMCIA_STR_EXP_EXPMULTIMEDIA },
118 1.23 takemura
119 1.23 takemura /* Mobile Dock 2, which doesn't have vendor ID nor product ID */
120 1.23 takemura { -1, -1, 0,
121 1.23 takemura { "SHUTTLE TECHNOLOGY LTD.", "PCCARD-IDE/ATAPI Adapter", NULL, NULL},
122 1.23 takemura "SHUTTLE TECHNOLOGY IDE/ATAPI Adapter"
123 1.23 takemura },
124 1.9 kenh
125 1.9 kenh { 0, 0, 0, { NULL, NULL, NULL, NULL}, NULL }
126 1.9 kenh };
127 1.9 kenh
128 1.14 enami struct wdc_pcmcia_disk_device_interface_args {
129 1.14 enami int ddi_type; /* interface type */
130 1.14 enami int ddi_reqfn; /* function we are requesting iftype */
131 1.14 enami int ddi_curfn; /* function we are currently parsing in CIS */
132 1.14 enami };
133 1.14 enami
134 1.14 enami int wdc_pcmcia_disk_device_interface_callback __P((struct pcmcia_tuple *,
135 1.14 enami void *));
136 1.14 enami int wdc_pcmcia_disk_device_interface __P((struct pcmcia_function *));
137 1.9 kenh struct wdc_pcmcia_product *
138 1.9 kenh wdc_pcmcia_lookup __P((struct pcmcia_attach_args *));
139 1.9 kenh
140 1.15 thorpej int wdc_pcmcia_enable __P((void *, int));
141 1.15 thorpej
142 1.14 enami int
143 1.14 enami wdc_pcmcia_disk_device_interface_callback(tuple, arg)
144 1.14 enami struct pcmcia_tuple *tuple;
145 1.14 enami void *arg;
146 1.14 enami {
147 1.14 enami struct wdc_pcmcia_disk_device_interface_args *ddi = arg;
148 1.14 enami
149 1.14 enami switch (tuple->code) {
150 1.14 enami case PCMCIA_CISTPL_FUNCID:
151 1.14 enami ddi->ddi_curfn++;
152 1.14 enami break;
153 1.14 enami
154 1.14 enami case PCMCIA_CISTPL_FUNCE:
155 1.14 enami if (ddi->ddi_reqfn != ddi->ddi_curfn)
156 1.14 enami break;
157 1.14 enami
158 1.14 enami /* subcode (disk device interface), data (interface type) */
159 1.14 enami if (tuple->length < 2)
160 1.14 enami break;
161 1.14 enami
162 1.14 enami /* check type */
163 1.14 enami if (pcmcia_tuple_read_1(tuple, 0) !=
164 1.14 enami PCMCIA_TPLFE_TYPE_DISK_DEVICE_INTERFACE)
165 1.14 enami break;
166 1.14 enami
167 1.14 enami ddi->ddi_type = pcmcia_tuple_read_1(tuple, 1);
168 1.14 enami return (1);
169 1.14 enami }
170 1.14 enami return (0);
171 1.14 enami }
172 1.14 enami
173 1.14 enami int
174 1.14 enami wdc_pcmcia_disk_device_interface(pf)
175 1.14 enami struct pcmcia_function *pf;
176 1.14 enami {
177 1.14 enami struct wdc_pcmcia_disk_device_interface_args ddi;
178 1.14 enami
179 1.14 enami ddi.ddi_reqfn = pf->number;
180 1.14 enami ddi.ddi_curfn = -1;
181 1.14 enami if (pcmcia_scan_cis((struct device *)pf->sc,
182 1.14 enami wdc_pcmcia_disk_device_interface_callback, &ddi) > 0)
183 1.14 enami return (ddi.ddi_type);
184 1.14 enami else
185 1.14 enami return (-1);
186 1.14 enami }
187 1.14 enami
188 1.9 kenh struct wdc_pcmcia_product *
189 1.9 kenh wdc_pcmcia_lookup(pa)
190 1.9 kenh struct pcmcia_attach_args *pa;
191 1.9 kenh {
192 1.9 kenh struct wdc_pcmcia_product *wpp;
193 1.9 kenh int i, cis_match;
194 1.9 kenh
195 1.9 kenh for (wpp = wdc_pcmcia_products; wpp->wpp_name != NULL; wpp++)
196 1.9 kenh if ((wpp->wpp_vendor == -1 ||
197 1.9 kenh pa->manufacturer == wpp->wpp_vendor) &&
198 1.9 kenh (wpp->wpp_product == -1 ||
199 1.9 kenh pa->product == wpp->wpp_product)) {
200 1.9 kenh cis_match = 1;
201 1.9 kenh for (i = 0; i < 4; i++) {
202 1.9 kenh if (!(wpp->wpp_cis_info[i] == NULL ||
203 1.9 kenh (pa->card->cis1_info[i] != NULL &&
204 1.9 kenh strcmp(pa->card->cis1_info[i],
205 1.9 kenh wpp->wpp_cis_info[i]) == 0)))
206 1.9 kenh cis_match = 0;
207 1.9 kenh }
208 1.9 kenh if (cis_match)
209 1.13 enami return (wpp);
210 1.9 kenh }
211 1.9 kenh
212 1.9 kenh return (NULL);
213 1.9 kenh }
214 1.9 kenh
215 1.1 matt static int
216 1.2 mycroft wdc_pcmcia_match(parent, match, aux)
217 1.2 mycroft struct device *parent;
218 1.2 mycroft struct cfdata *match;
219 1.2 mycroft void *aux;
220 1.1 matt {
221 1.1 matt struct pcmcia_attach_args *pa = aux;
222 1.14 enami struct pcmcia_softc *sc;
223 1.14 enami int iftype;
224 1.1 matt
225 1.9 kenh if (wdc_pcmcia_lookup(pa) != NULL)
226 1.9 kenh return (1);
227 1.3 matt
228 1.14 enami if (pa->pf->function == PCMCIA_FUNCTION_DISK) {
229 1.14 enami sc = pa->pf->sc;
230 1.14 enami
231 1.14 enami pcmcia_chip_socket_enable(sc->pct, sc->pch);
232 1.14 enami iftype = wdc_pcmcia_disk_device_interface(pa->pf);
233 1.14 enami pcmcia_chip_socket_disable(sc->pct, sc->pch);
234 1.14 enami
235 1.14 enami if (iftype == PCMCIA_TPLFE_DDI_PCCARD_ATA)
236 1.14 enami return (1);
237 1.14 enami }
238 1.14 enami
239 1.9 kenh return (0);
240 1.1 matt }
241 1.1 matt
242 1.1 matt static void
243 1.2 mycroft wdc_pcmcia_attach(parent, self, aux)
244 1.2 mycroft struct device *parent;
245 1.2 mycroft struct device *self;
246 1.2 mycroft void *aux;
247 1.1 matt {
248 1.1 matt struct wdc_pcmcia_softc *sc = (void *)self;
249 1.1 matt struct pcmcia_attach_args *pa = aux;
250 1.5 enami struct pcmcia_config_entry *cfe;
251 1.9 kenh struct wdc_pcmcia_product *wpp;
252 1.14 enami int quirks;
253 1.1 matt
254 1.15 thorpej sc->sc_pf = pa->pf;
255 1.15 thorpej
256 1.5 enami for (cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); cfe != NULL;
257 1.5 enami cfe = SIMPLEQ_NEXT(cfe, cfe_list)) {
258 1.9 kenh if (cfe->num_iospace != 1 && cfe->num_iospace != 2)
259 1.9 kenh continue;
260 1.9 kenh
261 1.1 matt if (pcmcia_io_alloc(pa->pf, cfe->iospace[0].start,
262 1.9 kenh cfe->iospace[0].length,
263 1.9 kenh cfe->iospace[0].start == 0 ? cfe->iospace[0].length : 0,
264 1.9 kenh &sc->sc_pioh))
265 1.1 matt continue;
266 1.9 kenh
267 1.9 kenh if (cfe->num_iospace == 2) {
268 1.1 matt if (!pcmcia_io_alloc(pa->pf, cfe->iospace[1].start,
269 1.9 kenh cfe->iospace[1].length, 0, &sc->sc_auxpioh))
270 1.1 matt break;
271 1.9 kenh } else /* num_iospace == 1 */ {
272 1.1 matt sc->sc_auxpioh.iot = sc->sc_pioh.iot;
273 1.9 kenh if (!bus_space_subregion(sc->sc_pioh.iot,
274 1.9 kenh sc->sc_pioh.ioh, WDC_PCMCIA_AUXREG_OFFSET,
275 1.9 kenh WDC_PCMCIA_AUXREG_NPORTS, &sc->sc_auxpioh.ioh))
276 1.1 matt break;
277 1.1 matt }
278 1.11 thorpej pcmcia_io_free(pa->pf, &sc->sc_pioh);
279 1.1 matt }
280 1.1 matt
281 1.1 matt if (cfe == NULL) {
282 1.6 enami printf(": can't handle card info\n");
283 1.29 enami goto no_config_entry;
284 1.1 matt }
285 1.1 matt
286 1.1 matt /* Enable the card. */
287 1.1 matt pcmcia_function_init(pa->pf, cfe);
288 1.1 matt if (pcmcia_function_enable(pa->pf)) {
289 1.5 enami printf(": function enable failed\n");
290 1.29 enami goto enable_failed;
291 1.1 matt }
292 1.1 matt
293 1.9 kenh wpp = wdc_pcmcia_lookup(pa);
294 1.14 enami if (wpp != NULL)
295 1.14 enami quirks = wpp->wpp_quirk_flag;
296 1.14 enami else
297 1.14 enami quirks = 0;
298 1.9 kenh
299 1.28 enami if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_AUTO, 0,
300 1.13 enami sc->sc_pioh.size, &sc->sc_pioh, &sc->sc_iowindow)) {
301 1.5 enami printf(": can't map first I/O space\n");
302 1.29 enami goto iomap_failed;
303 1.1 matt }
304 1.9 kenh
305 1.25 sommerfe if (cfe->num_iospace <= 1)
306 1.25 sommerfe sc->sc_auxiowindow = -1;
307 1.25 sommerfe else if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_AUTO, 0,
308 1.9 kenh sc->sc_auxpioh.size, &sc->sc_auxpioh, &sc->sc_auxiowindow)) {
309 1.27 enami printf(": can't map second I/O space\n");
310 1.29 enami goto iomapaux_failed;
311 1.25 sommerfe }
312 1.5 enami
313 1.25 sommerfe if ((wpp != NULL) && (wpp->wpp_name != NULL))
314 1.25 sommerfe printf(": %s", wpp->wpp_name);
315 1.25 sommerfe
316 1.5 enami printf("\n");
317 1.9 kenh
318 1.12 bouyer sc->wdc_channel.cmd_iot = sc->sc_pioh.iot;
319 1.12 bouyer sc->wdc_channel.cmd_ioh = sc->sc_pioh.ioh;
320 1.12 bouyer sc->wdc_channel.ctl_iot = sc->sc_auxpioh.iot;
321 1.12 bouyer sc->wdc_channel.ctl_ioh = sc->sc_auxpioh.ioh;
322 1.12 bouyer sc->wdc_channel.data32iot = sc->wdc_channel.cmd_iot;
323 1.12 bouyer sc->wdc_channel.data32ioh = sc->wdc_channel.cmd_ioh;
324 1.12 bouyer sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32;
325 1.18 bouyer sc->sc_wdcdev.PIO_cap = 0;
326 1.16 drochner sc->wdc_chanptr = &sc->wdc_channel;
327 1.16 drochner sc->sc_wdcdev.channels = &sc->wdc_chanptr;
328 1.12 bouyer sc->sc_wdcdev.nchannels = 1;
329 1.12 bouyer sc->wdc_channel.channel = 0;
330 1.12 bouyer sc->wdc_channel.wdc = &sc->sc_wdcdev;
331 1.12 bouyer sc->wdc_channel.ch_queue = malloc(sizeof(struct channel_queue),
332 1.12 bouyer M_DEVBUF, M_NOWAIT);
333 1.12 bouyer if (sc->wdc_channel.ch_queue == NULL) {
334 1.20 enami printf("%s: can't allocate memory for command queue\n",
335 1.13 enami sc->sc_wdcdev.sc_dev.dv_xname);
336 1.29 enami goto ch_queue_alloc_failed;
337 1.12 bouyer }
338 1.14 enami if (quirks & WDC_PCMCIA_NO_EXTRA_RESETS)
339 1.12 bouyer sc->sc_wdcdev.cap |= WDC_CAPABILITY_NO_EXTRA_RESETS;
340 1.15 thorpej
341 1.15 thorpej /* We can enable and disable the controller. */
342 1.32 bouyer sc->sc_wdcdev.sc_atapi_adapter._generic.scsipi_enable =
343 1.32 bouyer wdc_pcmcia_enable;
344 1.15 thorpej
345 1.22 enami sc->sc_flags |= WDC_PCMCIA_ATTACH;
346 1.30 enami wdcattach(&sc->wdc_channel); /* should return an error XXX */
347 1.22 enami sc->sc_flags &= ~WDC_PCMCIA_ATTACH;
348 1.29 enami return;
349 1.29 enami
350 1.29 enami ch_queue_alloc_failed:
351 1.29 enami /* Unmap our aux i/o window. */
352 1.29 enami if (sc->sc_auxiowindow != -1)
353 1.29 enami pcmcia_io_unmap(sc->sc_pf, sc->sc_auxiowindow);
354 1.29 enami
355 1.29 enami iomapaux_failed:
356 1.29 enami /* Unmap our i/o window. */
357 1.29 enami pcmcia_io_unmap(sc->sc_pf, sc->sc_iowindow);
358 1.29 enami
359 1.29 enami iomap_failed:
360 1.29 enami /* Disable the function */
361 1.29 enami pcmcia_function_disable(sc->sc_pf);
362 1.29 enami
363 1.29 enami enable_failed:
364 1.29 enami /* Unmap our i/o space. */
365 1.29 enami pcmcia_io_free(sc->sc_pf, &sc->sc_pioh);
366 1.29 enami if (cfe->num_iospace == 2)
367 1.29 enami pcmcia_io_free(sc->sc_pf, &sc->sc_auxpioh);
368 1.29 enami
369 1.29 enami no_config_entry:
370 1.29 enami sc->sc_iowindow = -1;
371 1.21 enami }
372 1.21 enami
373 1.21 enami int
374 1.21 enami wdc_pcmcia_detach(self, flags)
375 1.21 enami struct device *self;
376 1.21 enami int flags;
377 1.21 enami {
378 1.21 enami struct wdc_pcmcia_softc *sc = (struct wdc_pcmcia_softc *)self;
379 1.21 enami int error;
380 1.29 enami
381 1.29 enami if (sc->sc_iowindow == -1)
382 1.29 enami /* Nothing to detach */
383 1.29 enami return (0);
384 1.21 enami
385 1.21 enami if ((error = wdcdetach(self, flags)) != 0)
386 1.21 enami return (error);
387 1.21 enami
388 1.25 sommerfe if (sc->wdc_channel.ch_queue != NULL)
389 1.25 sommerfe free(sc->wdc_channel.ch_queue, M_DEVBUF);
390 1.21 enami
391 1.21 enami /* Unmap our i/o window and i/o space. */
392 1.21 enami pcmcia_io_unmap(sc->sc_pf, sc->sc_iowindow);
393 1.21 enami pcmcia_io_free(sc->sc_pf, &sc->sc_pioh);
394 1.21 enami if (sc->sc_auxiowindow != -1) {
395 1.21 enami pcmcia_io_unmap(sc->sc_pf, sc->sc_auxiowindow);
396 1.21 enami pcmcia_io_free(sc->sc_pf, &sc->sc_auxpioh);
397 1.21 enami }
398 1.21 enami
399 1.21 enami return (0);
400 1.15 thorpej }
401 1.15 thorpej
402 1.15 thorpej int
403 1.15 thorpej wdc_pcmcia_enable(arg, onoff)
404 1.15 thorpej void *arg;
405 1.15 thorpej int onoff;
406 1.15 thorpej {
407 1.15 thorpej struct wdc_pcmcia_softc *sc = arg;
408 1.15 thorpej
409 1.15 thorpej if (onoff) {
410 1.27 enami /* See the comment in aic_pcmcia_enable */
411 1.22 enami if ((sc->sc_flags & WDC_PCMCIA_ATTACH) == 0) {
412 1.31 enami /* Establish the interrupt handler. */
413 1.31 enami sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_BIO,
414 1.31 enami wdcintr, &sc->wdc_channel);
415 1.31 enami if (sc->sc_ih == NULL) {
416 1.31 enami printf("%s: "
417 1.31 enami "couldn't establish interrupt handler\n",
418 1.31 enami sc->sc_wdcdev.sc_dev.dv_xname);
419 1.31 enami return (EIO);
420 1.31 enami }
421 1.31 enami
422 1.22 enami if (pcmcia_function_enable(sc->sc_pf)) {
423 1.22 enami printf("%s: couldn't enable PCMCIA function\n",
424 1.22 enami sc->sc_wdcdev.sc_dev.dv_xname);
425 1.22 enami pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
426 1.22 enami return (EIO);
427 1.22 enami }
428 1.22 enami wdcreset(&sc->wdc_channel, VERBOSE);
429 1.15 thorpej }
430 1.15 thorpej } else {
431 1.15 thorpej pcmcia_function_disable(sc->sc_pf);
432 1.31 enami if ((sc->sc_flags & WDC_PCMCIA_ATTACH) == 0)
433 1.31 enami pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
434 1.15 thorpej }
435 1.15 thorpej
436 1.15 thorpej return (0);
437 1.1 matt }
438