ata_wdc.c revision 1.16 1 1.16 bouyer /* $NetBSD: ata_wdc.c,v 1.16 1999/03/07 14:02:53 bouyer Exp $ */
2 1.2 bouyer
3 1.2 bouyer /*
4 1.2 bouyer * Copyright (c) 1998 Manuel Bouyer.
5 1.2 bouyer *
6 1.2 bouyer * Redistribution and use in source and binary forms, with or without
7 1.2 bouyer * modification, are permitted provided that the following conditions
8 1.2 bouyer * are met:
9 1.2 bouyer * 1. Redistributions of source code must retain the above copyright
10 1.2 bouyer * notice, this list of conditions and the following disclaimer.
11 1.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
12 1.2 bouyer * notice, this list of conditions and the following disclaimer in the
13 1.2 bouyer * documentation and/or other materials provided with the distribution.
14 1.2 bouyer * 3. All advertising materials mentioning features or use of this software
15 1.2 bouyer * must display the following acknowledgement:
16 1.2 bouyer * This product includes software developed by the University of
17 1.2 bouyer * California, Berkeley and its contributors.
18 1.2 bouyer * 4. Neither the name of the University nor the names of its contributors
19 1.2 bouyer * may be used to endorse or promote products derived from this software
20 1.2 bouyer * without specific prior written permission.
21 1.2 bouyer *
22 1.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 1.2 bouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.2 bouyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.2 bouyer * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 1.2 bouyer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.2 bouyer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.2 bouyer * SUCH DAMAGE.
33 1.2 bouyer *
34 1.2 bouyer */
35 1.2 bouyer
36 1.2 bouyer /*-
37 1.2 bouyer * Copyright (c) 1998 The NetBSD Foundation, Inc.
38 1.2 bouyer * All rights reserved.
39 1.2 bouyer *
40 1.2 bouyer * This code is derived from software contributed to The NetBSD Foundation
41 1.2 bouyer * by Charles M. Hannum, by Onno van der Linden and by Manuel Bouyer.
42 1.2 bouyer *
43 1.2 bouyer * Redistribution and use in source and binary forms, with or without
44 1.2 bouyer * modification, are permitted provided that the following conditions
45 1.2 bouyer * are met:
46 1.2 bouyer * 1. Redistributions of source code must retain the above copyright
47 1.2 bouyer * notice, this list of conditions and the following disclaimer.
48 1.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
49 1.2 bouyer * notice, this list of conditions and the following disclaimer in the
50 1.2 bouyer * documentation and/or other materials provided with the distribution.
51 1.2 bouyer * 3. All advertising materials mentioning features or use of this software
52 1.2 bouyer * must display the following acknowledgement:
53 1.2 bouyer * This product includes software developed by the NetBSD
54 1.2 bouyer * Foundation, Inc. and its contributors.
55 1.2 bouyer * 4. Neither the name of The NetBSD Foundation nor the names of its
56 1.2 bouyer * contributors may be used to endorse or promote products derived
57 1.2 bouyer * from this software without specific prior written permission.
58 1.2 bouyer *
59 1.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
60 1.2 bouyer * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
61 1.2 bouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
62 1.2 bouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
63 1.2 bouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
64 1.2 bouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
65 1.2 bouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
66 1.2 bouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
67 1.2 bouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
68 1.2 bouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
69 1.2 bouyer * POSSIBILITY OF SUCH DAMAGE.
70 1.2 bouyer */
71 1.2 bouyer
72 1.15 hubertf #ifndef WDCDEBUG
73 1.2 bouyer #define WDCDEBUG
74 1.15 hubertf #endif /* WDCDEBUG */
75 1.2 bouyer
76 1.2 bouyer #include <sys/param.h>
77 1.2 bouyer #include <sys/systm.h>
78 1.2 bouyer #include <sys/kernel.h>
79 1.2 bouyer #include <sys/file.h>
80 1.2 bouyer #include <sys/stat.h>
81 1.2 bouyer #include <sys/buf.h>
82 1.2 bouyer #include <sys/malloc.h>
83 1.2 bouyer #include <sys/device.h>
84 1.2 bouyer #include <sys/disklabel.h>
85 1.2 bouyer #include <sys/syslog.h>
86 1.2 bouyer #include <sys/proc.h>
87 1.2 bouyer
88 1.2 bouyer #include <machine/intr.h>
89 1.2 bouyer #include <machine/bus.h>
90 1.2 bouyer #ifndef __BUS_SPACE_HAS_STREAM_METHODS
91 1.2 bouyer #define bus_space_write_multi_stream_2 bus_space_write_multi_2
92 1.2 bouyer #define bus_space_write_multi_stream_4 bus_space_write_multi_4
93 1.2 bouyer #define bus_space_read_multi_stream_2 bus_space_read_multi_2
94 1.2 bouyer #define bus_space_read_multi_stream_4 bus_space_read_multi_4
95 1.2 bouyer #endif /* __BUS_SPACE_HAS_STREAM_METHODS */
96 1.2 bouyer
97 1.2 bouyer #include <dev/ata/atareg.h>
98 1.2 bouyer #include <dev/ata/atavar.h>
99 1.2 bouyer #include <dev/ic/wdcreg.h>
100 1.2 bouyer #include <dev/ic/wdcvar.h>
101 1.2 bouyer #include <dev/ata/wdvar.h>
102 1.2 bouyer
103 1.2 bouyer #define DEBUG_INTR 0x01
104 1.2 bouyer #define DEBUG_XFERS 0x02
105 1.2 bouyer #define DEBUG_STATUS 0x04
106 1.2 bouyer #define DEBUG_FUNCS 0x08
107 1.2 bouyer #define DEBUG_PROBE 0x10
108 1.2 bouyer #ifdef WDCDEBUG
109 1.3 thorpej int wdcdebug_wd_mask = 0;
110 1.2 bouyer #define WDCDEBUG_PRINT(args, level) \
111 1.2 bouyer if (wdcdebug_wd_mask & (level)) \
112 1.2 bouyer printf args
113 1.2 bouyer #else
114 1.2 bouyer #define WDCDEBUG_PRINT(args, level)
115 1.2 bouyer #endif
116 1.2 bouyer
117 1.16 bouyer #define ATA_DELAY_NORMAL 1000 /* 1s for a normal drive I/O */
118 1.16 bouyer #define ATA_DELAY_RECOVERY 10000 /* 10s for setup or recovery drive I/O */
119 1.2 bouyer
120 1.2 bouyer void wdc_ata_bio_start __P((struct channel_softc *,struct wdc_xfer *));
121 1.2 bouyer int wdc_ata_bio_intr __P((struct channel_softc *, struct wdc_xfer *));
122 1.2 bouyer void wdc_ata_bio_done __P((struct channel_softc *, struct wdc_xfer *));
123 1.2 bouyer int wdc_ata_ctrl_intr __P((struct channel_softc *, struct wdc_xfer *));
124 1.16 bouyer int wdc_ata_err __P((struct ata_drive_datas *, struct ata_bio *));
125 1.2 bouyer #define WDC_ATA_NOERR 0x00 /* Drive doesn't report an error */
126 1.2 bouyer #define WDC_ATA_RECOV 0x01 /* There was a recovered error */
127 1.2 bouyer #define WDC_ATA_ERR 0x02 /* Drive reports an error */
128 1.2 bouyer
129 1.2 bouyer /*
130 1.2 bouyer * Handle block I/O operation. Return WDC_COMPLETE, WDC_QUEUED, or
131 1.2 bouyer * WDC_TRY_AGAIN. Must be called at splio().
132 1.2 bouyer */
133 1.2 bouyer int
134 1.2 bouyer wdc_ata_bio(drvp, ata_bio)
135 1.2 bouyer struct ata_drive_datas *drvp;
136 1.2 bouyer struct ata_bio *ata_bio;
137 1.2 bouyer {
138 1.2 bouyer struct wdc_xfer *xfer;
139 1.2 bouyer struct channel_softc *chp = drvp->chnl_softc;
140 1.2 bouyer
141 1.2 bouyer xfer = wdc_get_xfer(WDC_NOSLEEP);
142 1.2 bouyer if (xfer == NULL)
143 1.2 bouyer return WDC_TRY_AGAIN;
144 1.2 bouyer if (ata_bio->flags & ATA_POLL)
145 1.2 bouyer xfer->c_flags |= C_POLL;
146 1.2 bouyer if ((drvp->drive_flags & (DRIVE_DMA | DRIVE_UDMA)) &&
147 1.2 bouyer (ata_bio->flags & ATA_SINGLE) == 0)
148 1.2 bouyer xfer->c_flags |= C_DMA;
149 1.2 bouyer xfer->drive = drvp->drive;
150 1.2 bouyer xfer->cmd = ata_bio;
151 1.2 bouyer xfer->databuf = ata_bio->databuf;
152 1.2 bouyer xfer->c_bcount = ata_bio->bcount;
153 1.2 bouyer xfer->c_start = wdc_ata_bio_start;
154 1.2 bouyer xfer->c_intr = wdc_ata_bio_intr;
155 1.2 bouyer wdc_exec_xfer(chp, xfer);
156 1.2 bouyer return (ata_bio->flags & ATA_ITSDONE) ? WDC_COMPLETE : WDC_QUEUED;
157 1.2 bouyer }
158 1.2 bouyer
159 1.2 bouyer void
160 1.2 bouyer wdc_ata_bio_start(chp, xfer)
161 1.2 bouyer struct channel_softc *chp;
162 1.2 bouyer struct wdc_xfer *xfer;
163 1.2 bouyer {
164 1.2 bouyer struct ata_bio *ata_bio = xfer->cmd;
165 1.2 bouyer struct ata_drive_datas *drvp = &chp->ch_drive[xfer->drive];
166 1.2 bouyer u_int16_t cyl;
167 1.2 bouyer u_int8_t head, sect, cmd = 0;
168 1.2 bouyer int nblks;
169 1.16 bouyer int ata_delay;
170 1.2 bouyer int dma_flags = 0;
171 1.2 bouyer
172 1.2 bouyer WDCDEBUG_PRINT(("wdc_ata_bio_start %s:%d:%d\n",
173 1.2 bouyer chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive),
174 1.4 bouyer DEBUG_XFERS);
175 1.2 bouyer
176 1.2 bouyer /* Do control operations specially. */
177 1.2 bouyer if (drvp->state < READY) {
178 1.2 bouyer /*
179 1.2 bouyer * Actually, we want to be careful not to mess with the control
180 1.2 bouyer * state if the device is currently busy, but we can assume
181 1.2 bouyer * that we never get to this point if that's the case.
182 1.2 bouyer */
183 1.2 bouyer /* at this point, we should only be in RECAL state */
184 1.2 bouyer if (drvp->state != RECAL) {
185 1.2 bouyer printf("%s:%d:%d: bad state %d in wdc_ata_bio_start\n",
186 1.2 bouyer chp->wdc->sc_dev.dv_xname, chp->channel,
187 1.2 bouyer xfer->drive, drvp->state);
188 1.2 bouyer panic("wdc_ata_bio_start: bad state");
189 1.2 bouyer }
190 1.2 bouyer xfer->c_intr = wdc_ata_ctrl_intr;
191 1.2 bouyer bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
192 1.2 bouyer WDSD_IBM | (xfer->drive << 4));
193 1.16 bouyer if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY_RECOVERY) != 0)
194 1.2 bouyer goto timeout;
195 1.2 bouyer wdccommandshort(chp, xfer->drive, WDCC_RECAL);
196 1.2 bouyer drvp->state = RECAL_WAIT;
197 1.2 bouyer if ((ata_bio->flags & ATA_POLL) == 0) {
198 1.2 bouyer chp->ch_flags |= WDCF_IRQ_WAIT;
199 1.16 bouyer timeout(wdctimeout, chp,
200 1.16 bouyer ATA_DELAY_RECOVERY / 1000 * hz);
201 1.2 bouyer } else {
202 1.2 bouyer /* Wait for at last 400ns for status bit to be valid */
203 1.2 bouyer delay(1);
204 1.2 bouyer wdc_ata_ctrl_intr(chp, xfer);
205 1.2 bouyer }
206 1.2 bouyer return;
207 1.2 bouyer }
208 1.2 bouyer
209 1.2 bouyer if (xfer->c_flags & C_DMA) {
210 1.2 bouyer dma_flags = (ata_bio->flags & ATA_READ) ? WDC_DMA_READ : 0;
211 1.2 bouyer dma_flags |= (ata_bio->flags & ATA_POLL) ? WDC_DMA_POLL : 0;
212 1.2 bouyer }
213 1.16 bouyer if (ata_bio->flags & ATA_SINGLE)
214 1.16 bouyer ata_delay = ATA_DELAY_RECOVERY;
215 1.16 bouyer else
216 1.16 bouyer ata_delay = ATA_DELAY_NORMAL;
217 1.2 bouyer again:
218 1.2 bouyer /*
219 1.2 bouyer *
220 1.2 bouyer * When starting a multi-sector transfer, or doing single-sector
221 1.2 bouyer * transfers...
222 1.2 bouyer */
223 1.2 bouyer if (xfer->c_skip == 0 || (ata_bio->flags & ATA_SINGLE) != 0) {
224 1.2 bouyer if (ata_bio->flags & ATA_SINGLE)
225 1.2 bouyer nblks = 1;
226 1.2 bouyer else
227 1.2 bouyer nblks = xfer->c_bcount / ata_bio->lp->d_secsize;
228 1.2 bouyer /* Check for bad sectors and adjust transfer, if necessary. */
229 1.2 bouyer if ((ata_bio->lp->d_flags & D_BADSECT) != 0) {
230 1.2 bouyer long blkdiff;
231 1.2 bouyer int i;
232 1.2 bouyer for (i = 0; (blkdiff = ata_bio->badsect[i]) != -1;
233 1.2 bouyer i++) {
234 1.2 bouyer blkdiff -= ata_bio->blkno;
235 1.2 bouyer if (blkdiff < 0)
236 1.2 bouyer continue;
237 1.2 bouyer if (blkdiff == 0) {
238 1.2 bouyer /* Replace current block of transfer. */
239 1.2 bouyer ata_bio->blkno =
240 1.2 bouyer ata_bio->lp->d_secperunit -
241 1.2 bouyer ata_bio->lp->d_nsectors - i - 1;
242 1.2 bouyer }
243 1.2 bouyer if (blkdiff < nblks) {
244 1.2 bouyer /* Bad block inside transfer. */
245 1.2 bouyer ata_bio->flags |= ATA_SINGLE;
246 1.2 bouyer nblks = 1;
247 1.2 bouyer }
248 1.2 bouyer break;
249 1.2 bouyer }
250 1.2 bouyer /* Transfer is okay now. */
251 1.2 bouyer }
252 1.2 bouyer if (ata_bio->flags & ATA_LBA) {
253 1.2 bouyer sect = (ata_bio->blkno >> 0) & 0xff;
254 1.2 bouyer cyl = (ata_bio->blkno >> 8) & 0xffff;
255 1.2 bouyer head = (ata_bio->blkno >> 24) & 0x0f;
256 1.2 bouyer head |= WDSD_LBA;
257 1.2 bouyer } else {
258 1.2 bouyer int blkno = ata_bio->blkno;
259 1.2 bouyer sect = blkno % ata_bio->lp->d_nsectors;
260 1.2 bouyer sect++; /* Sectors begin with 1, not 0. */
261 1.2 bouyer blkno /= ata_bio->lp->d_nsectors;
262 1.2 bouyer head = blkno % ata_bio->lp->d_ntracks;
263 1.2 bouyer blkno /= ata_bio->lp->d_ntracks;
264 1.2 bouyer cyl = blkno;
265 1.2 bouyer head |= WDSD_CHS;
266 1.2 bouyer }
267 1.2 bouyer if (xfer->c_flags & C_DMA) {
268 1.2 bouyer ata_bio->nblks = nblks;
269 1.2 bouyer ata_bio->nbytes = xfer->c_bcount;
270 1.2 bouyer cmd = (ata_bio->flags & ATA_READ) ?
271 1.2 bouyer WDCC_READDMA : WDCC_WRITEDMA;
272 1.2 bouyer nblks = ata_bio->nblks;
273 1.2 bouyer /* Init the DMA channel. */
274 1.2 bouyer if ((*chp->wdc->dma_init)(chp->wdc->dma_arg,
275 1.2 bouyer chp->channel, xfer->drive,
276 1.11 augustss (char *)xfer->databuf + xfer->c_skip,
277 1.11 augustss ata_bio->nbytes, dma_flags) != 0) {
278 1.2 bouyer ata_bio->error = ERR_DMA;
279 1.2 bouyer ata_bio->r_error = 0;
280 1.2 bouyer wdc_ata_bio_done(chp, xfer);
281 1.2 bouyer return;
282 1.2 bouyer }
283 1.2 bouyer /* Initiate command */
284 1.2 bouyer bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
285 1.2 bouyer WDSD_IBM | (xfer->drive << 4));
286 1.16 bouyer if (wait_for_ready(chp, ata_delay) < 0)
287 1.2 bouyer goto timeout;
288 1.2 bouyer wdccommand(chp, xfer->drive, cmd, cyl,
289 1.2 bouyer head, sect, nblks, 0);
290 1.2 bouyer /* start the DMA channel */
291 1.2 bouyer (*chp->wdc->dma_start)(chp->wdc->dma_arg,
292 1.2 bouyer chp->channel, xfer->drive, dma_flags);
293 1.2 bouyer /* wait for irq */
294 1.2 bouyer goto intr;
295 1.2 bouyer } /* else not DMA */
296 1.2 bouyer ata_bio->nblks = min(nblks, ata_bio->multi);
297 1.2 bouyer ata_bio->nbytes = ata_bio->nblks * ata_bio->lp->d_secsize;
298 1.2 bouyer if (ata_bio->nblks > 1 && (ata_bio->flags & ATA_SINGLE) == 0) {
299 1.2 bouyer cmd = (ata_bio->flags & ATA_READ) ?
300 1.2 bouyer WDCC_READMULTI : WDCC_WRITEMULTI;
301 1.2 bouyer } else {
302 1.2 bouyer cmd = (ata_bio->flags & ATA_READ) ?
303 1.2 bouyer WDCC_READ : WDCC_WRITE;
304 1.2 bouyer }
305 1.2 bouyer /* Initiate command! */
306 1.2 bouyer bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
307 1.2 bouyer WDSD_IBM | (xfer->drive << 4));
308 1.16 bouyer if (wait_for_ready(chp, ata_delay) < 0)
309 1.2 bouyer goto timeout;
310 1.2 bouyer wdccommand(chp, xfer->drive, cmd, cyl,
311 1.2 bouyer head, sect, nblks,
312 1.2 bouyer (ata_bio->lp->d_type == DTYPE_ST506) ?
313 1.2 bouyer ata_bio->lp->d_precompcyl / 4 : 0);
314 1.2 bouyer } else if (ata_bio->nblks > 1) {
315 1.2 bouyer /* The number of blocks in the last stretch may be smaller. */
316 1.2 bouyer nblks = xfer->c_bcount / ata_bio->lp->d_secsize;
317 1.2 bouyer if (ata_bio->nblks > nblks) {
318 1.2 bouyer ata_bio->nblks = nblks;
319 1.2 bouyer ata_bio->nbytes = xfer->c_bcount;
320 1.2 bouyer }
321 1.2 bouyer }
322 1.2 bouyer /* If this was a write and not using DMA, push the data. */
323 1.2 bouyer if ((ata_bio->flags & ATA_READ) == 0) {
324 1.16 bouyer if (wait_for_drq(chp, ata_delay) != 0) {
325 1.2 bouyer printf("%s:%d:%d: timeout waiting for DRQ, "
326 1.2 bouyer "st=0x%02x, err=0x%02x\n",
327 1.2 bouyer chp->wdc->sc_dev.dv_xname, chp->channel,
328 1.2 bouyer xfer->drive, chp->ch_status, chp->ch_error);
329 1.16 bouyer if (wdc_ata_err(drvp, ata_bio) != WDC_ATA_ERR)
330 1.2 bouyer ata_bio->error = TIMEOUT;
331 1.2 bouyer wdc_ata_bio_done(chp, xfer);
332 1.2 bouyer return;
333 1.2 bouyer }
334 1.16 bouyer if (wdc_ata_err(drvp, ata_bio) == WDC_ATA_ERR) {
335 1.2 bouyer wdc_ata_bio_done(chp, xfer);
336 1.2 bouyer return;
337 1.2 bouyer }
338 1.2 bouyer if ((chp->wdc->cap & WDC_CAPABILITY_ATA_NOSTREAM)) {
339 1.2 bouyer if (drvp->drive_flags & DRIVE_CAP32) {
340 1.2 bouyer bus_space_write_multi_4(chp->data32iot,
341 1.2 bouyer chp->data32ioh, 0,
342 1.12 thorpej (u_int32_t *)((char *)xfer->databuf +
343 1.12 thorpej xfer->c_skip),
344 1.2 bouyer ata_bio->nbytes >> 2);
345 1.2 bouyer } else {
346 1.2 bouyer bus_space_write_multi_2(chp->cmd_iot,
347 1.2 bouyer chp->cmd_ioh, wd_data,
348 1.12 thorpej (u_int16_t *)((char *)xfer->databuf +
349 1.12 thorpej xfer->c_skip),
350 1.2 bouyer ata_bio->nbytes >> 1);
351 1.2 bouyer }
352 1.2 bouyer } else {
353 1.2 bouyer if (drvp->drive_flags & DRIVE_CAP32) {
354 1.2 bouyer bus_space_write_multi_stream_4(chp->data32iot,
355 1.2 bouyer chp->data32ioh, 0,
356 1.12 thorpej (u_int32_t *)((char *)xfer->databuf +
357 1.12 thorpej xfer->c_skip),
358 1.2 bouyer ata_bio->nbytes >> 2);
359 1.2 bouyer } else {
360 1.2 bouyer bus_space_write_multi_stream_2(chp->cmd_iot,
361 1.2 bouyer chp->cmd_ioh, wd_data,
362 1.12 thorpej (u_int16_t *)((char *)xfer->databuf +
363 1.12 thorpej xfer->c_skip),
364 1.2 bouyer ata_bio->nbytes >> 1);
365 1.2 bouyer }
366 1.2 bouyer }
367 1.2 bouyer }
368 1.2 bouyer
369 1.2 bouyer intr: /* Wait for IRQ (either real or polled) */
370 1.2 bouyer if ((ata_bio->flags & ATA_POLL) == 0) {
371 1.2 bouyer chp->ch_flags |= WDCF_IRQ_WAIT;
372 1.16 bouyer timeout(wdctimeout, chp, ata_delay / 1000 * hz);
373 1.2 bouyer } else {
374 1.2 bouyer /* Wait for at last 400ns for status bit to be valid */
375 1.2 bouyer delay(1);
376 1.2 bouyer wdc_ata_bio_intr(chp, xfer);
377 1.2 bouyer if ((ata_bio->flags & ATA_ITSDONE) == 0)
378 1.2 bouyer goto again;
379 1.2 bouyer }
380 1.2 bouyer return;
381 1.2 bouyer timeout:
382 1.2 bouyer printf("%s:%d:%d: not ready, st=0x%02x, err=0x%02x\n",
383 1.2 bouyer chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive,
384 1.2 bouyer chp->ch_status, chp->ch_error);
385 1.16 bouyer if (wdc_ata_err(drvp, ata_bio) != WDC_ATA_ERR)
386 1.2 bouyer ata_bio->error = TIMEOUT;
387 1.2 bouyer wdc_ata_bio_done(chp, xfer);
388 1.2 bouyer return;
389 1.2 bouyer }
390 1.2 bouyer
391 1.2 bouyer int
392 1.2 bouyer wdc_ata_bio_intr(chp, xfer)
393 1.2 bouyer struct channel_softc *chp;
394 1.2 bouyer struct wdc_xfer *xfer;
395 1.2 bouyer {
396 1.2 bouyer struct ata_bio *ata_bio = xfer->cmd;
397 1.2 bouyer struct ata_drive_datas *drvp = &chp->ch_drive[xfer->drive];
398 1.2 bouyer int drv_err;
399 1.2 bouyer int dma_flags = 0;
400 1.2 bouyer
401 1.2 bouyer WDCDEBUG_PRINT(("wdc_ata_bio_intr %s:%d:%d\n",
402 1.2 bouyer chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive),
403 1.2 bouyer DEBUG_INTR | DEBUG_XFERS);
404 1.2 bouyer
405 1.2 bouyer
406 1.2 bouyer /* Is it not a transfer, but a control operation? */
407 1.2 bouyer if (drvp->state < READY) {
408 1.2 bouyer printf("%s:%d:%d: bad state %d in wdc_ata_bio_intr\n",
409 1.2 bouyer chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive,
410 1.2 bouyer drvp->state);
411 1.2 bouyer panic("wdc_ata_bio_intr: bad state\n");
412 1.2 bouyer }
413 1.2 bouyer
414 1.2 bouyer if (xfer->c_flags & C_DMA) {
415 1.2 bouyer dma_flags = (ata_bio->flags & ATA_READ) ? WDC_DMA_READ : 0;
416 1.2 bouyer dma_flags |= (ata_bio->flags & ATA_POLL) ? WDC_DMA_POLL : 0;
417 1.2 bouyer }
418 1.2 bouyer
419 1.2 bouyer /* Ack interrupt done by wait_for_unbusy */
420 1.16 bouyer if (wait_for_unbusy(chp, ATA_DELAY_NORMAL) < 0) {
421 1.2 bouyer printf("%s:%d:%d: device timeout, c_bcount=%d, c_skip%d\n",
422 1.2 bouyer chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive,
423 1.2 bouyer xfer->c_bcount, xfer->c_skip);
424 1.2 bouyer /* if we were using DMA, turn off DMA channel */
425 1.10 bouyer if (xfer->c_flags & C_DMA) {
426 1.2 bouyer (*chp->wdc->dma_finish)(chp->wdc->dma_arg,
427 1.2 bouyer chp->channel, xfer->drive, dma_flags);
428 1.10 bouyer drvp->n_dmaerrs++;
429 1.10 bouyer }
430 1.2 bouyer ata_bio->error = TIMEOUT;
431 1.2 bouyer wdc_ata_bio_done(chp, xfer);
432 1.2 bouyer return 1;
433 1.2 bouyer }
434 1.2 bouyer
435 1.16 bouyer drv_err = wdc_ata_err(drvp, ata_bio);
436 1.2 bouyer
437 1.2 bouyer /* If we were using DMA, Turn off the DMA channel and check for error */
438 1.2 bouyer if (xfer->c_flags & C_DMA) {
439 1.2 bouyer if (ata_bio->flags & ATA_POLL) {
440 1.2 bouyer /*
441 1.13 bouyer * IDE drives deassert WDCS_BSY before transfer is
442 1.2 bouyer * complete when using DMA. Polling for DRQ to deassert
443 1.2 bouyer * is not enouth DRQ is not required to be
444 1.7 bouyer * asserted for DMA transfers, so poll for DRDY.
445 1.2 bouyer */
446 1.2 bouyer if (wdcwait(chp, WDCS_DRDY | WDCS_DRQ, WDCS_DRDY,
447 1.16 bouyer ATA_DELAY_NORMAL) < 0) {
448 1.7 bouyer printf("%s:%d:%d: polled transfer timed out "
449 1.2 bouyer "(st=0x%x)\n", chp->wdc->sc_dev.dv_xname,
450 1.2 bouyer chp->channel, xfer->drive, chp->ch_status);
451 1.2 bouyer ata_bio->error = TIMEOUT;
452 1.10 bouyer drv_err = WDC_ATA_ERR;
453 1.10 bouyer }
454 1.10 bouyer }
455 1.10 bouyer if ((*chp->wdc->dma_finish)(chp->wdc->dma_arg,
456 1.10 bouyer chp->channel, xfer->drive, dma_flags) != 0) {
457 1.10 bouyer if (drv_err != WDC_ATA_ERR) {
458 1.10 bouyer ata_bio->error = ERR_DMA;
459 1.10 bouyer drv_err = WDC_ATA_ERR;
460 1.2 bouyer }
461 1.2 bouyer }
462 1.2 bouyer if (chp->ch_status & WDCS_DRQ) {
463 1.2 bouyer if (drv_err != WDC_ATA_ERR) {
464 1.2 bouyer printf("%s:%d:%d: intr with DRQ (st=0x%x)\n",
465 1.2 bouyer chp->wdc->sc_dev.dv_xname, chp->channel,
466 1.2 bouyer xfer->drive, chp->ch_status);
467 1.2 bouyer ata_bio->error = TIMEOUT;
468 1.2 bouyer drv_err = WDC_ATA_ERR;
469 1.2 bouyer }
470 1.2 bouyer }
471 1.2 bouyer if (drv_err != WDC_ATA_ERR)
472 1.2 bouyer goto end;
473 1.10 bouyer drvp->n_dmaerrs++;
474 1.2 bouyer }
475 1.2 bouyer
476 1.2 bouyer /* if we had an error, end */
477 1.2 bouyer if (drv_err == WDC_ATA_ERR) {
478 1.2 bouyer wdc_ata_bio_done(chp, xfer);
479 1.2 bouyer return 1;
480 1.2 bouyer }
481 1.2 bouyer
482 1.2 bouyer /* If this was a read and not using DMA, fetch the data. */
483 1.2 bouyer if ((ata_bio->flags & ATA_READ) != 0) {
484 1.14 bouyer if ((chp->ch_status & WDCS_DRQ) != WDCS_DRQ) {
485 1.2 bouyer printf("%s:%d:%d: read intr before drq\n",
486 1.2 bouyer chp->wdc->sc_dev.dv_xname, chp->channel,
487 1.2 bouyer xfer->drive);
488 1.2 bouyer ata_bio->error = TIMEOUT;
489 1.2 bouyer wdc_ata_bio_done(chp, xfer);
490 1.2 bouyer return 1;
491 1.2 bouyer }
492 1.2 bouyer if ((chp->wdc->cap & WDC_CAPABILITY_ATA_NOSTREAM)) {
493 1.2 bouyer if (drvp->drive_flags & DRIVE_CAP32) {
494 1.2 bouyer bus_space_read_multi_4(chp->data32iot,
495 1.2 bouyer chp->data32ioh, 0,
496 1.12 thorpej (u_int32_t *)((char *)xfer->databuf +
497 1.12 thorpej xfer->c_skip),
498 1.2 bouyer ata_bio->nbytes >> 2);
499 1.2 bouyer } else {
500 1.2 bouyer bus_space_read_multi_2(chp->cmd_iot,
501 1.2 bouyer chp->cmd_ioh, wd_data,
502 1.12 thorpej (u_int16_t *)((char *)xfer->databuf +
503 1.12 thorpej xfer->c_skip),
504 1.2 bouyer ata_bio->nbytes >> 1);
505 1.2 bouyer }
506 1.2 bouyer } else {
507 1.2 bouyer if (drvp->drive_flags & DRIVE_CAP32) {
508 1.2 bouyer bus_space_read_multi_stream_4(chp->data32iot,
509 1.2 bouyer chp->data32ioh, 0,
510 1.12 thorpej (u_int32_t *)((char *)xfer->databuf +
511 1.12 thorpej xfer->c_skip),
512 1.2 bouyer ata_bio->nbytes >> 2);
513 1.2 bouyer } else {
514 1.2 bouyer bus_space_read_multi_stream_2(chp->cmd_iot,
515 1.2 bouyer chp->cmd_ioh, wd_data,
516 1.12 thorpej (u_int16_t *)((char *)xfer->databuf +
517 1.12 thorpej xfer->c_skip),
518 1.2 bouyer ata_bio->nbytes >> 1);
519 1.2 bouyer }
520 1.2 bouyer }
521 1.2 bouyer }
522 1.2 bouyer
523 1.2 bouyer end:
524 1.2 bouyer ata_bio->blkno += ata_bio->nblks;
525 1.2 bouyer ata_bio->blkdone += ata_bio->nblks;
526 1.2 bouyer xfer->c_skip += ata_bio->nbytes;
527 1.2 bouyer xfer->c_bcount -= ata_bio->nbytes;
528 1.2 bouyer /* See if this transfer is complete. */
529 1.2 bouyer if (xfer->c_bcount > 0) {
530 1.2 bouyer if ((ata_bio->flags & ATA_POLL) == 0) {
531 1.2 bouyer /* Start the next operation */
532 1.2 bouyer wdc_ata_bio_start(chp, xfer);
533 1.2 bouyer } else {
534 1.2 bouyer /* Let wdc_ata_bio_start do the loop */
535 1.2 bouyer return 1;
536 1.2 bouyer }
537 1.2 bouyer } else { /* Done with this transfer */
538 1.2 bouyer ata_bio->error = NOERROR;
539 1.2 bouyer wdc_ata_bio_done(chp, xfer);
540 1.2 bouyer }
541 1.2 bouyer return 1;
542 1.2 bouyer }
543 1.2 bouyer
544 1.2 bouyer void
545 1.2 bouyer wdc_ata_bio_done(chp, xfer)
546 1.2 bouyer struct channel_softc *chp;
547 1.2 bouyer struct wdc_xfer *xfer;
548 1.2 bouyer {
549 1.2 bouyer struct ata_bio *ata_bio = xfer->cmd;
550 1.2 bouyer int need_done = xfer->c_flags & C_NEEDDONE;
551 1.2 bouyer int drive = xfer->drive;
552 1.10 bouyer struct ata_drive_datas *drvp = &chp->ch_drive[drive];
553 1.2 bouyer
554 1.5 bouyer WDCDEBUG_PRINT(("wdc_ata_bio_done %s:%d:%d: flags 0x%x\n",
555 1.5 bouyer chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive,
556 1.5 bouyer (u_int)xfer->c_flags),
557 1.4 bouyer DEBUG_XFERS);
558 1.10 bouyer
559 1.10 bouyer if (ata_bio->error == NOERROR)
560 1.10 bouyer drvp->n_dmaerrs = 0;
561 1.10 bouyer else if (drvp->n_dmaerrs >= NERRS_MAX) {
562 1.10 bouyer wdc_downgrade_mode(drvp);
563 1.10 bouyer }
564 1.2 bouyer
565 1.2 bouyer /* feed back residual bcount to our caller */
566 1.2 bouyer ata_bio->bcount = xfer->c_bcount;
567 1.2 bouyer
568 1.2 bouyer /* remove this command from xfer queue */
569 1.2 bouyer wdc_free_xfer(chp, xfer);
570 1.2 bouyer
571 1.2 bouyer ata_bio->flags |= ATA_ITSDONE;
572 1.2 bouyer if (need_done) {
573 1.4 bouyer WDCDEBUG_PRINT(("wdc_ata_done: wddone\n"), DEBUG_XFERS);
574 1.2 bouyer wddone(chp->ch_drive[drive].drv_softc);
575 1.2 bouyer }
576 1.2 bouyer WDCDEBUG_PRINT(("wdcstart from wdc_ata_done, flags 0x%x\n",
577 1.4 bouyer chp->ch_flags), DEBUG_XFERS);
578 1.9 drochner wdcstart(chp);
579 1.2 bouyer }
580 1.2 bouyer
581 1.2 bouyer /*
582 1.2 bouyer * Implement operations needed before read/write.
583 1.2 bouyer */
584 1.2 bouyer int
585 1.2 bouyer wdc_ata_ctrl_intr(chp, xfer)
586 1.2 bouyer struct channel_softc *chp;
587 1.2 bouyer struct wdc_xfer *xfer;
588 1.2 bouyer {
589 1.2 bouyer struct ata_bio *ata_bio = xfer->cmd;
590 1.2 bouyer struct ata_drive_datas *drvp = &chp->ch_drive[xfer->drive];
591 1.2 bouyer char *errstring = NULL;
592 1.2 bouyer WDCDEBUG_PRINT(("wdc_ata_ctrl_intr: state %d\n", drvp->state),
593 1.2 bouyer DEBUG_FUNCS);
594 1.2 bouyer
595 1.2 bouyer again:
596 1.2 bouyer switch (drvp->state) {
597 1.2 bouyer case RECAL: /* Should not be in this state here */
598 1.2 bouyer panic("wdc_ata_ctrl_intr: state==RECAL");
599 1.2 bouyer break;
600 1.2 bouyer
601 1.2 bouyer case RECAL_WAIT:
602 1.2 bouyer errstring = "recal";
603 1.16 bouyer if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY_RECOVERY))
604 1.2 bouyer goto timeout;
605 1.2 bouyer if (chp->ch_status & (WDCS_ERR | WDCS_DWF))
606 1.2 bouyer goto error;
607 1.2 bouyer /* fall through */
608 1.2 bouyer
609 1.2 bouyer case PIOMODE:
610 1.2 bouyer /* Don't try to set modes if controller can't be adjusted */
611 1.2 bouyer if ((chp->wdc->cap & WDC_CAPABILITY_MODE) == 0)
612 1.6 bouyer goto geometry;
613 1.6 bouyer /* Also don't try if the drive didn't report its mode */
614 1.6 bouyer if ((drvp->drive_flags & DRIVE_MODE) == 0)
615 1.2 bouyer goto geometry;
616 1.2 bouyer wdccommand(chp, drvp->drive, SET_FEATURES, 0, 0, 0,
617 1.2 bouyer 0x08 | drvp->PIO_mode, WDSF_SET_MODE);
618 1.2 bouyer drvp->state = PIOMODE_WAIT;
619 1.2 bouyer break;
620 1.2 bouyer
621 1.2 bouyer case PIOMODE_WAIT:
622 1.2 bouyer errstring = "piomode";
623 1.16 bouyer if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY_RECOVERY))
624 1.2 bouyer goto timeout;
625 1.2 bouyer if (chp->ch_status & (WDCS_ERR | WDCS_DWF))
626 1.2 bouyer goto error;
627 1.2 bouyer /* fall through */
628 1.2 bouyer
629 1.2 bouyer case DMAMODE:
630 1.2 bouyer if (drvp->drive_flags & DRIVE_UDMA) {
631 1.2 bouyer wdccommand(chp, drvp->drive, SET_FEATURES, 0, 0, 0,
632 1.2 bouyer 0x40 | drvp->UDMA_mode, WDSF_SET_MODE);
633 1.2 bouyer } else if (drvp->drive_flags & DRIVE_DMA) {
634 1.2 bouyer wdccommand(chp, drvp->drive, SET_FEATURES, 0, 0, 0,
635 1.2 bouyer 0x20 | drvp->DMA_mode, WDSF_SET_MODE);
636 1.2 bouyer } else {
637 1.2 bouyer goto geometry;
638 1.2 bouyer }
639 1.2 bouyer drvp->state = DMAMODE_WAIT;
640 1.2 bouyer break;
641 1.2 bouyer case DMAMODE_WAIT:
642 1.2 bouyer errstring = "dmamode";
643 1.16 bouyer if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY_RECOVERY))
644 1.2 bouyer goto timeout;
645 1.2 bouyer if (chp->ch_status & (WDCS_ERR | WDCS_DWF))
646 1.2 bouyer goto error;
647 1.2 bouyer /* fall through */
648 1.2 bouyer
649 1.2 bouyer case GEOMETRY:
650 1.2 bouyer geometry:
651 1.2 bouyer if (ata_bio->flags & ATA_LBA)
652 1.2 bouyer goto multimode;
653 1.2 bouyer wdccommand(chp, xfer->drive, WDCC_IDP,
654 1.2 bouyer ata_bio->lp->d_ncylinders,
655 1.2 bouyer ata_bio->lp->d_ntracks - 1, 0, ata_bio->lp->d_nsectors,
656 1.2 bouyer (ata_bio->lp->d_type == DTYPE_ST506) ?
657 1.2 bouyer ata_bio->lp->d_precompcyl / 4 : 0);
658 1.2 bouyer drvp->state = GEOMETRY_WAIT;
659 1.2 bouyer break;
660 1.2 bouyer
661 1.2 bouyer case GEOMETRY_WAIT:
662 1.2 bouyer errstring = "geometry";
663 1.16 bouyer if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY_RECOVERY))
664 1.2 bouyer goto timeout;
665 1.2 bouyer if (chp->ch_status & (WDCS_ERR | WDCS_DWF))
666 1.2 bouyer goto error;
667 1.2 bouyer /* fall through */
668 1.2 bouyer
669 1.2 bouyer case MULTIMODE:
670 1.2 bouyer multimode:
671 1.2 bouyer if (ata_bio->multi == 1)
672 1.2 bouyer goto ready;
673 1.2 bouyer wdccommand(chp, xfer->drive, WDCC_SETMULTI, 0, 0, 0,
674 1.2 bouyer ata_bio->multi, 0);
675 1.2 bouyer drvp->state = MULTIMODE_WAIT;
676 1.2 bouyer break;
677 1.2 bouyer
678 1.2 bouyer case MULTIMODE_WAIT:
679 1.2 bouyer errstring = "setmulti";
680 1.16 bouyer if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY_RECOVERY))
681 1.2 bouyer goto timeout;
682 1.2 bouyer if (chp->ch_status & (WDCS_ERR | WDCS_DWF))
683 1.2 bouyer goto error;
684 1.2 bouyer /* fall through */
685 1.2 bouyer
686 1.2 bouyer case READY:
687 1.2 bouyer ready:
688 1.2 bouyer drvp->state = READY;
689 1.2 bouyer /*
690 1.2 bouyer * The drive is usable now
691 1.2 bouyer */
692 1.2 bouyer xfer->c_intr = wdc_ata_bio_intr;
693 1.2 bouyer wdc_ata_bio_start(chp, xfer);
694 1.2 bouyer return 1;
695 1.2 bouyer }
696 1.2 bouyer
697 1.2 bouyer if ((ata_bio->flags & ATA_POLL) == 0) {
698 1.2 bouyer chp->ch_flags |= WDCF_IRQ_WAIT;
699 1.16 bouyer timeout(wdctimeout, chp, ATA_DELAY_RECOVERY / 1000 * hz);
700 1.2 bouyer } else {
701 1.2 bouyer goto again;
702 1.2 bouyer }
703 1.2 bouyer return 1;
704 1.2 bouyer
705 1.2 bouyer timeout:
706 1.2 bouyer if ((xfer->c_flags & C_TIMEOU) == 0 ) {
707 1.2 bouyer return 0; /* IRQ was not for us */
708 1.2 bouyer }
709 1.2 bouyer printf("%s:%d:%d: %s timed out\n",
710 1.2 bouyer chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive, errstring);
711 1.2 bouyer ata_bio->error = TIMEOUT;
712 1.2 bouyer drvp->state = 0;
713 1.2 bouyer wdc_ata_bio_done(chp, xfer);
714 1.2 bouyer return 0;
715 1.2 bouyer error:
716 1.2 bouyer printf("%s:%d:%d: %s ",
717 1.2 bouyer chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive,
718 1.2 bouyer errstring);
719 1.2 bouyer if (chp->ch_status & WDCS_DWF) {
720 1.2 bouyer printf("drive fault\n");
721 1.2 bouyer ata_bio->error = ERR_DF;
722 1.2 bouyer } else {
723 1.2 bouyer printf("error (%x)\n", chp->ch_error);
724 1.2 bouyer ata_bio->r_error = chp->ch_error;
725 1.2 bouyer ata_bio->error = ERROR;
726 1.2 bouyer }
727 1.2 bouyer drvp->state = 0;
728 1.2 bouyer wdc_ata_bio_done(chp, xfer);
729 1.2 bouyer return 1;
730 1.2 bouyer }
731 1.2 bouyer
732 1.2 bouyer int
733 1.16 bouyer wdc_ata_err(drvp, ata_bio)
734 1.16 bouyer struct ata_drive_datas *drvp;
735 1.2 bouyer struct ata_bio *ata_bio;
736 1.2 bouyer {
737 1.16 bouyer struct channel_softc *chp = drvp->chnl_softc;
738 1.2 bouyer ata_bio->error = 0;
739 1.2 bouyer if (chp->ch_status & WDCS_BSY) {
740 1.2 bouyer ata_bio->error = TIMEOUT;
741 1.2 bouyer return WDC_ATA_ERR;
742 1.2 bouyer }
743 1.2 bouyer
744 1.2 bouyer if (chp->ch_status & WDCS_DWF) {
745 1.2 bouyer ata_bio->error = ERR_DF;
746 1.2 bouyer return WDC_ATA_ERR;
747 1.2 bouyer }
748 1.2 bouyer
749 1.2 bouyer if (chp->ch_status & WDCS_ERR) {
750 1.2 bouyer ata_bio->error = ERROR;
751 1.2 bouyer ata_bio->r_error = chp->ch_error;
752 1.16 bouyer if (drvp->drive_flags & DRIVE_UDMA &&
753 1.16 bouyer (ata_bio->r_error & WDCE_CRC)) {
754 1.16 bouyer /*
755 1.16 bouyer * Record the CRC error, to avoid downgrading to
756 1.16 bouyer * multiword DMA
757 1.16 bouyer */
758 1.16 bouyer drvp->drive_flags |= DRIVE_DMAERR;
759 1.16 bouyer }
760 1.2 bouyer if (ata_bio->r_error & (WDCE_BBK | WDCE_UNC | WDCE_IDNF |
761 1.2 bouyer WDCE_ABRT | WDCE_TK0NF | WDCE_AMNF))
762 1.2 bouyer return WDC_ATA_ERR;
763 1.2 bouyer return WDC_ATA_NOERR;
764 1.2 bouyer }
765 1.2 bouyer
766 1.2 bouyer if (chp->ch_status & WDCS_CORR)
767 1.2 bouyer ata_bio->flags |= ATA_CORR;
768 1.2 bouyer return WDC_ATA_NOERR;
769 1.8 thorpej }
770 1.8 thorpej
771 1.8 thorpej int
772 1.8 thorpej wdc_ata_addref(drvp)
773 1.8 thorpej struct ata_drive_datas *drvp;
774 1.8 thorpej {
775 1.8 thorpej struct channel_softc *chp = drvp->chnl_softc;
776 1.8 thorpej
777 1.8 thorpej return (wdc_addref(chp));
778 1.8 thorpej }
779 1.8 thorpej
780 1.8 thorpej void
781 1.8 thorpej wdc_ata_delref(drvp)
782 1.8 thorpej struct ata_drive_datas *drvp;
783 1.8 thorpej {
784 1.8 thorpej struct channel_softc *chp = drvp->chnl_softc;
785 1.8 thorpej
786 1.8 thorpej wdc_delref(chp);
787 1.2 bouyer }
788