wdc_pcmcia.c revision 1.104 1 1.104 christos /* $NetBSD: wdc_pcmcia.c,v 1.104 2006/01/22 00:08:38 christos Exp $ */
2 1.1 matt
3 1.8 mycroft /*-
4 1.78 mycroft * Copyright (c) 1998, 2003, 2004 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.44 lukem
39 1.44 lukem #include <sys/cdefs.h>
40 1.104 christos __KERNEL_RCSID(0, "$NetBSD: wdc_pcmcia.c,v 1.104 2006/01/22 00:08:38 christos Exp $");
41 1.1 matt
42 1.1 matt #include <sys/param.h>
43 1.30 enami #include <sys/device.h>
44 1.100 bouyer #include <sys/kernel.h>
45 1.30 enami #include <sys/malloc.h>
46 1.1 matt #include <sys/systm.h>
47 1.100 bouyer #include <sys/proc.h>
48 1.1 matt
49 1.30 enami #include <machine/bus.h>
50 1.1 matt #include <machine/intr.h>
51 1.1 matt
52 1.14 enami #include <dev/pcmcia/pcmciareg.h>
53 1.1 matt #include <dev/pcmcia/pcmciavar.h>
54 1.9 kenh #include <dev/pcmcia/pcmciadevs.h>
55 1.9 kenh
56 1.64 fvdl #include <dev/ic/wdcreg.h>
57 1.12 bouyer #include <dev/ata/atavar.h>
58 1.1 matt #include <dev/ic/wdcvar.h>
59 1.1 matt
60 1.99 matt #ifndef __BUS_SPACE_HAS_STREAM_METHODS
61 1.99 matt #define bus_space_write_multi_stream_2 bus_space_write_multi_2
62 1.99 matt #define bus_space_write_multi_stream_4 bus_space_write_multi_4
63 1.99 matt #define bus_space_read_multi_stream_2 bus_space_read_multi_2
64 1.99 matt #define bus_space_read_multi_stream_4 bus_space_read_multi_4
65 1.99 matt #endif /* __BUS_SPACE_HAS_STREAM_METHODS */
66 1.99 matt
67 1.1 matt #define WDC_PCMCIA_REG_NPORTS 8
68 1.9 kenh #define WDC_PCMCIA_AUXREG_OFFSET (WDC_PCMCIA_REG_NPORTS + 6)
69 1.2 mycroft #define WDC_PCMCIA_AUXREG_NPORTS 2
70 1.1 matt
71 1.1 matt struct wdc_pcmcia_softc {
72 1.1 matt struct wdc_softc sc_wdcdev;
73 1.91 thorpej struct ata_channel *wdc_chanlist[1];
74 1.91 thorpej struct ata_channel ata_channel;
75 1.65 thorpej struct ata_queue wdc_chqueue;
76 1.91 thorpej struct wdc_regs wdc_regs;
77 1.84 mycroft
78 1.84 mycroft struct pcmcia_function *sc_pf;
79 1.1 matt void *sc_ih;
80 1.75 mycroft
81 1.75 mycroft int sc_state;
82 1.75 mycroft #define WDC_PCMCIA_ATTACHED 3
83 1.1 matt };
84 1.1 matt
85 1.97 toshii #ifndef __BUS_SPACE_HAS_STREAM_METHODS
86 1.97 toshii #define bus_space_read_region_stream_2 bus_space_read_region_2
87 1.97 toshii #define bus_space_read_region_stream_4 bus_space_read_region_4
88 1.97 toshii #define bus_space_write_region_stream_2 bus_space_write_region_2
89 1.97 toshii #define bus_space_write_region_stream_4 bus_space_write_region_4
90 1.97 toshii #endif /* __BUS_SPACE_HAS_STREAM_METHODS */
91 1.97 toshii
92 1.94 thorpej static int wdc_pcmcia_match(struct device *, struct cfdata *, void *);
93 1.94 thorpej static int wdc_pcmcia_validate_config_io(struct pcmcia_config_entry *);
94 1.94 thorpej static int wdc_pcmcia_validate_config_memory(struct pcmcia_config_entry *);
95 1.94 thorpej static void wdc_pcmcia_attach(struct device *, struct device *, void *);
96 1.94 thorpej static int wdc_pcmcia_detach(struct device *, int);
97 1.1 matt
98 1.51 thorpej CFATTACH_DECL(wdc_pcmcia, sizeof(struct wdc_pcmcia_softc),
99 1.52 thorpej wdc_pcmcia_match, wdc_pcmcia_attach, wdc_pcmcia_detach, wdcactivate);
100 1.1 matt
101 1.103 bouyer static const struct wdc_pcmcia_product {
102 1.103 bouyer struct pcmcia_product wdc_product;
103 1.103 bouyer int wdc_ndrive;
104 1.103 bouyer } wdc_pcmcia_products[] = {
105 1.103 bouyer { { PCMCIA_VENDOR_DIGITAL,
106 1.9 kenh PCMCIA_PRODUCT_DIGITAL_MOBILE_MEDIA_CDROM,
107 1.103 bouyer {NULL, "Digital Mobile Media CD-ROM", NULL, NULL} }, 2 },
108 1.19 abs
109 1.103 bouyer { { PCMCIA_VENDOR_IBM,
110 1.24 soren PCMCIA_PRODUCT_IBM_PORTABLE_CDROM,
111 1.103 bouyer {NULL, "PCMCIA Portable CD-ROM Drive", NULL, NULL} }, 2 },
112 1.9 kenh
113 1.9 kenh /* The TEAC IDE/Card II is used on the Sony Vaio */
114 1.103 bouyer { { PCMCIA_VENDOR_TEAC,
115 1.9 kenh PCMCIA_PRODUCT_TEAC_IDECARDII,
116 1.103 bouyer PCMCIA_CIS_TEAC_IDECARDII }, 2 },
117 1.43 christos
118 1.43 christos /*
119 1.98 perry * A fujitsu rebranded panasonic drive that reports
120 1.43 christos * itself as function "scsi", disk interface 0
121 1.43 christos */
122 1.103 bouyer { { PCMCIA_VENDOR_PANASONIC,
123 1.43 christos PCMCIA_PRODUCT_PANASONIC_KXLC005,
124 1.103 bouyer PCMCIA_CIS_PANASONIC_KXLC005 }, 2 },
125 1.26 augustss
126 1.103 bouyer { { PCMCIA_VENDOR_SANDISK,
127 1.102 christos PCMCIA_PRODUCT_SANDISK_SDCFB,
128 1.103 bouyer PCMCIA_CIS_SANDISK_SDCFB }, 1 },
129 1.102 christos
130 1.27 enami /*
131 1.27 enami * EXP IDE/ATAPI DVD Card use with some DVD players.
132 1.27 enami * Does not have a vendor ID or product ID.
133 1.27 enami */
134 1.103 bouyer { { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
135 1.103 bouyer PCMCIA_CIS_EXP_EXPMULTIMEDIA }, 2 },
136 1.23 takemura
137 1.36 abs /* Mobile Dock 2, neither vendor ID nor product ID */
138 1.103 bouyer { { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
139 1.103 bouyer {"SHUTTLE TECHNOLOGY LTD.", "PCCARD-IDE/ATAPI Adapter", NULL, NULL} }, 2 },
140 1.34 abs
141 1.36 abs /* Toshiba Portege 3110 CD, neither vendor ID nor product ID */
142 1.103 bouyer { { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
143 1.103 bouyer {"FREECOM", "PCCARD-IDE", NULL, NULL} }, 2 },
144 1.36 abs
145 1.98 perry /* Random CD-ROM, (badged AMACOM), neither vendor ID nor product ID */
146 1.103 bouyer { { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
147 1.103 bouyer {"PCMCIA", "CD-ROM", NULL, NULL} }, 2 },
148 1.37 haya
149 1.37 haya /* IO DATA CBIDE2, with neither vendor ID nor product ID */
150 1.103 bouyer { { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
151 1.103 bouyer PCMCIA_CIS_IODATA_CBIDE2 }, 2 },
152 1.54 ichiro
153 1.54 ichiro /* TOSHIBA PA2673U(IODATA_CBIDE2 OEM), */
154 1.54 ichiro /* with neither vendor ID nor product ID */
155 1.103 bouyer { { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
156 1.103 bouyer PCMCIA_CIS_TOSHIBA_CBIDE2 }, 2 },
157 1.38 sato
158 1.98 perry /*
159 1.98 perry * Novac PCMCIA-IDE Card for HD530P IDE Box,
160 1.38 sato * with neither vendor ID nor product ID
161 1.38 sato */
162 1.103 bouyer { { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
163 1.103 bouyer {"PCMCIA", "PnPIDE", NULL, NULL} }, 2 },
164 1.9 kenh };
165 1.94 thorpej static const size_t wdc_pcmcia_nproducts =
166 1.81 mycroft sizeof(wdc_pcmcia_products) / sizeof(wdc_pcmcia_products[0]);
167 1.9 kenh
168 1.94 thorpej static int wdc_pcmcia_enable(struct device *, int);
169 1.94 thorpej static void wdc_pcmcia_datain_memory(struct ata_channel *, int, void *,
170 1.94 thorpej size_t);
171 1.94 thorpej static void wdc_pcmcia_dataout_memory(struct ata_channel *, int, void *,
172 1.94 thorpej size_t);
173 1.14 enami
174 1.1 matt static int
175 1.94 thorpej wdc_pcmcia_match(struct device *parent, struct cfdata *match, void *aux)
176 1.1 matt {
177 1.1 matt struct pcmcia_attach_args *pa = aux;
178 1.35 haya
179 1.98 perry if (pa->pf->function == PCMCIA_FUNCTION_DISK &&
180 1.81 mycroft pa->pf->pf_funce_disk_interface == PCMCIA_TPLFE_DDI_PCCARD_ATA)
181 1.9 kenh return (1);
182 1.81 mycroft if (pcmcia_product_lookup(pa, wdc_pcmcia_products, wdc_pcmcia_nproducts,
183 1.81 mycroft sizeof(wdc_pcmcia_products[0]), NULL))
184 1.81 mycroft return (2);
185 1.9 kenh return (0);
186 1.1 matt }
187 1.1 matt
188 1.72 mycroft static int
189 1.94 thorpej wdc_pcmcia_validate_config_io(struct pcmcia_config_entry *cfe)
190 1.72 mycroft {
191 1.87 mycroft if (cfe->iftype != PCMCIA_IFTYPE_IO ||
192 1.87 mycroft cfe->num_iospace < 1 || cfe->num_iospace > 2)
193 1.87 mycroft return (EINVAL);
194 1.87 mycroft cfe->num_memspace = 0;
195 1.87 mycroft return (0);
196 1.87 mycroft }
197 1.87 mycroft
198 1.87 mycroft static int
199 1.94 thorpej wdc_pcmcia_validate_config_memory(struct pcmcia_config_entry *cfe)
200 1.87 mycroft {
201 1.87 mycroft if (cfe->iftype != PCMCIA_IFTYPE_MEMORY ||
202 1.87 mycroft cfe->num_memspace > 1 ||
203 1.87 mycroft cfe->memspace[0].length < 2048)
204 1.72 mycroft return (EINVAL);
205 1.87 mycroft cfe->num_iospace = 0;
206 1.72 mycroft return (0);
207 1.72 mycroft }
208 1.72 mycroft
209 1.1 matt static void
210 1.94 thorpej wdc_pcmcia_attach(struct device *parent, struct device *self, void *aux)
211 1.1 matt {
212 1.1 matt struct wdc_pcmcia_softc *sc = (void *)self;
213 1.1 matt struct pcmcia_attach_args *pa = aux;
214 1.5 enami struct pcmcia_config_entry *cfe;
215 1.91 thorpej struct wdc_regs *wdr;
216 1.103 bouyer const struct wdc_pcmcia_product *wdcp;
217 1.72 mycroft bus_size_t offset;
218 1.73 mycroft int i;
219 1.72 mycroft int error;
220 1.1 matt
221 1.15 thorpej sc->sc_pf = pa->pf;
222 1.15 thorpej
223 1.87 mycroft error = pcmcia_function_configure(pa->pf,
224 1.87 mycroft wdc_pcmcia_validate_config_io);
225 1.87 mycroft if (error)
226 1.87 mycroft /*XXXmem16|common*/
227 1.87 mycroft error = pcmcia_function_configure(pa->pf,
228 1.87 mycroft wdc_pcmcia_validate_config_memory);
229 1.72 mycroft if (error) {
230 1.72 mycroft aprint_error("%s: configure failed, error=%d\n", self->dv_xname,
231 1.72 mycroft error);
232 1.72 mycroft return;
233 1.1 matt }
234 1.1 matt
235 1.72 mycroft cfe = pa->pf->cfe;
236 1.95 thorpej sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA16;
237 1.41 uch
238 1.91 thorpej sc->sc_wdcdev.regs = wdr = &sc->wdc_regs;
239 1.91 thorpej
240 1.87 mycroft if (cfe->iftype == PCMCIA_IFTYPE_MEMORY) {
241 1.91 thorpej wdr->cmd_iot = cfe->memspace[0].handle.memt;
242 1.91 thorpej wdr->cmd_baseioh = cfe->memspace[0].handle.memh;
243 1.87 mycroft offset = cfe->memspace[0].offset;
244 1.91 thorpej wdr->ctl_iot = cfe->memspace[0].handle.memt;
245 1.87 mycroft if (bus_space_subregion(cfe->memspace[0].handle.memt,
246 1.87 mycroft cfe->memspace[0].handle.memh,
247 1.87 mycroft offset + WDC_PCMCIA_AUXREG_OFFSET, WDC_PCMCIA_AUXREG_NPORTS,
248 1.91 thorpej &wdr->ctl_ioh))
249 1.72 mycroft goto fail;
250 1.41 uch } else {
251 1.91 thorpej wdr->cmd_iot = cfe->iospace[0].handle.iot;
252 1.91 thorpej wdr->cmd_baseioh = cfe->iospace[0].handle.ioh;
253 1.87 mycroft offset = 0;
254 1.87 mycroft if (cfe->num_iospace == 1) {
255 1.91 thorpej wdr->ctl_iot = cfe->iospace[0].handle.iot;
256 1.87 mycroft if (bus_space_subregion(cfe->iospace[0].handle.iot,
257 1.87 mycroft cfe->iospace[0].handle.ioh,
258 1.87 mycroft WDC_PCMCIA_AUXREG_OFFSET, WDC_PCMCIA_AUXREG_NPORTS,
259 1.91 thorpej &wdr->ctl_ioh))
260 1.87 mycroft goto fail;
261 1.87 mycroft } else {
262 1.91 thorpej wdr->ctl_iot = cfe->iospace[1].handle.iot;
263 1.91 thorpej wdr->ctl_ioh = cfe->iospace[1].handle.ioh;
264 1.87 mycroft }
265 1.25 sommerfe }
266 1.5 enami
267 1.64 fvdl for (i = 0; i < WDC_PCMCIA_REG_NPORTS; i++) {
268 1.91 thorpej if (bus_space_subregion(wdr->cmd_iot,
269 1.91 thorpej wdr->cmd_baseioh,
270 1.64 fvdl offset + i, i == 0 ? 4 : 1,
271 1.91 thorpej &wdr->cmd_iohs[i]) != 0) {
272 1.69 mycroft aprint_error("%s: can't subregion I/O space\n",
273 1.69 mycroft self->dv_xname);
274 1.96 enami goto fail;
275 1.64 fvdl }
276 1.64 fvdl }
277 1.85 mycroft
278 1.87 mycroft if (cfe->iftype == PCMCIA_IFTYPE_MEMORY) {
279 1.87 mycroft aprint_normal("%s: memory mapped mode\n", self->dv_xname);
280 1.91 thorpej wdr->data32iot = cfe->memspace[0].handle.memt;
281 1.85 mycroft if (bus_space_subregion(cfe->memspace[0].handle.memt,
282 1.87 mycroft cfe->memspace[0].handle.memh, offset + 1024, 1024,
283 1.91 thorpej &wdr->data32ioh))
284 1.85 mycroft goto fail;
285 1.87 mycroft sc->sc_wdcdev.datain_pio = wdc_pcmcia_datain_memory;
286 1.87 mycroft sc->sc_wdcdev.dataout_pio = wdc_pcmcia_dataout_memory;
287 1.95 thorpej sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_NOIRQ;
288 1.85 mycroft } else {
289 1.87 mycroft aprint_normal("%s: i/o mapped mode\n", self->dv_xname);
290 1.91 thorpej wdr->data32iot = wdr->cmd_iot;
291 1.91 thorpej wdr->data32ioh = wdr->cmd_iohs[wd_data];
292 1.95 thorpej sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA32;
293 1.85 mycroft }
294 1.85 mycroft
295 1.95 thorpej sc->sc_wdcdev.sc_atac.atac_pio_cap = 0;
296 1.91 thorpej sc->wdc_chanlist[0] = &sc->ata_channel;
297 1.95 thorpej sc->sc_wdcdev.sc_atac.atac_channels = sc->wdc_chanlist;
298 1.95 thorpej sc->sc_wdcdev.sc_atac.atac_nchannels = 1;
299 1.91 thorpej sc->ata_channel.ch_channel = 0;
300 1.95 thorpej sc->ata_channel.ch_atac = &sc->sc_wdcdev.sc_atac;
301 1.91 thorpej sc->ata_channel.ch_queue = &sc->wdc_chqueue;
302 1.103 bouyer wdcp = pcmcia_product_lookup(pa, wdc_pcmcia_products,
303 1.103 bouyer wdc_pcmcia_nproducts, sizeof(wdc_pcmcia_products[0]), NULL);
304 1.104 christos sc->ata_channel.ch_ndrive = wdcp ? wdcp->wdc_ndrive : 2;
305 1.92 mycroft wdc_init_shadow_regs(&sc->ata_channel);
306 1.15 thorpej
307 1.90 mycroft error = wdc_pcmcia_enable(self, 1);
308 1.90 mycroft if (error)
309 1.90 mycroft goto fail;
310 1.90 mycroft
311 1.15 thorpej /* We can enable and disable the controller. */
312 1.95 thorpej sc->sc_wdcdev.sc_atac.atac_atapi_adapter._generic.adapt_enable =
313 1.32 bouyer wdc_pcmcia_enable;
314 1.95 thorpej sc->sc_wdcdev.sc_atac.atac_atapi_adapter._generic.adapt_refcnt = 1;
315 1.15 thorpej
316 1.100 bouyer /*
317 1.100 bouyer * Some devices needs some more delay after power up to stabilize
318 1.100 bouyer * and probe properly, so give them half a second.
319 1.100 bouyer * See PR 25659 for details.
320 1.100 bouyer */
321 1.100 bouyer tsleep(wdc_pcmcia_attach, PWAIT, "wdcattach", hz / 2);
322 1.100 bouyer
323 1.91 thorpej wdcattach(&sc->ata_channel);
324 1.91 thorpej ata_delref(&sc->ata_channel);
325 1.75 mycroft sc->sc_state = WDC_PCMCIA_ATTACHED;
326 1.29 enami return;
327 1.29 enami
328 1.72 mycroft fail:
329 1.72 mycroft pcmcia_function_unconfigure(pa->pf);
330 1.21 enami }
331 1.21 enami
332 1.94 thorpej static int
333 1.94 thorpej wdc_pcmcia_detach(struct device *self, int flags)
334 1.21 enami {
335 1.21 enami struct wdc_pcmcia_softc *sc = (struct wdc_pcmcia_softc *)self;
336 1.21 enami int error;
337 1.29 enami
338 1.75 mycroft if (sc->sc_state != WDC_PCMCIA_ATTACHED)
339 1.29 enami return (0);
340 1.21 enami
341 1.21 enami if ((error = wdcdetach(self, flags)) != 0)
342 1.21 enami return (error);
343 1.21 enami
344 1.72 mycroft pcmcia_function_unconfigure(sc->sc_pf);
345 1.61 briggs
346 1.21 enami return (0);
347 1.15 thorpej }
348 1.15 thorpej
349 1.94 thorpej static int
350 1.94 thorpej wdc_pcmcia_enable(struct device *self, int onoff)
351 1.15 thorpej {
352 1.42 bouyer struct wdc_pcmcia_softc *sc = (void *)self;
353 1.79 mycroft int error;
354 1.15 thorpej
355 1.15 thorpej if (onoff) {
356 1.83 mycroft /* Establish the interrupt handler. */
357 1.83 mycroft sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_BIO,
358 1.91 thorpej wdcintr, &sc->ata_channel);
359 1.83 mycroft if (!sc->sc_ih)
360 1.83 mycroft return (EIO);
361 1.83 mycroft
362 1.83 mycroft error = pcmcia_function_enable(sc->sc_pf);
363 1.83 mycroft if (error) {
364 1.83 mycroft pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
365 1.83 mycroft sc->sc_ih = 0;
366 1.83 mycroft return (error);
367 1.15 thorpej }
368 1.15 thorpej } else {
369 1.15 thorpej pcmcia_function_disable(sc->sc_pf);
370 1.56 mycroft pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
371 1.72 mycroft sc->sc_ih = 0;
372 1.15 thorpej }
373 1.15 thorpej
374 1.15 thorpej return (0);
375 1.1 matt }
376 1.86 mycroft
377 1.94 thorpej static void
378 1.94 thorpej wdc_pcmcia_datain_memory(struct ata_channel *chp, int flags, void *buf,
379 1.94 thorpej size_t len)
380 1.86 mycroft {
381 1.93 thorpej struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
382 1.86 mycroft
383 1.86 mycroft while (len > 0) {
384 1.86 mycroft size_t n;
385 1.86 mycroft
386 1.86 mycroft n = min(len, 1024);
387 1.88 mycroft if ((flags & DRIVE_CAP32) && (n & 3) == 0)
388 1.91 thorpej bus_space_read_region_stream_4(wdr->data32iot,
389 1.91 thorpej wdr->data32ioh, 0, buf, n >> 2);
390 1.88 mycroft else
391 1.91 thorpej bus_space_read_region_stream_2(wdr->data32iot,
392 1.91 thorpej wdr->data32ioh, 0, buf, n >> 1);
393 1.86 mycroft buf = (char *)buf + n;
394 1.86 mycroft len -= n;
395 1.86 mycroft }
396 1.86 mycroft }
397 1.86 mycroft
398 1.94 thorpej static void
399 1.94 thorpej wdc_pcmcia_dataout_memory(struct ata_channel *chp, int flags, void *buf,
400 1.94 thorpej size_t len)
401 1.86 mycroft {
402 1.93 thorpej struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
403 1.86 mycroft
404 1.86 mycroft while (len > 0) {
405 1.86 mycroft size_t n;
406 1.86 mycroft
407 1.86 mycroft n = min(len, 1024);
408 1.88 mycroft if ((flags & DRIVE_CAP32) && (n & 3) == 0)
409 1.91 thorpej bus_space_write_region_stream_4(wdr->data32iot,
410 1.91 thorpej wdr->data32ioh, 0, buf, n >> 2);
411 1.88 mycroft else
412 1.91 thorpej bus_space_write_region_stream_2(wdr->data32iot,
413 1.91 thorpej wdr->data32ioh, 0, buf, n >> 1);
414 1.86 mycroft buf = (char *)buf + n;
415 1.86 mycroft len -= n;
416 1.86 mycroft }
417 1.86 mycroft }
418