hcsc.c revision 1.8 1 1.8 lukem /* $NetBSD: hcsc.c,v 1.8 2001/11/13 07:23:15 lukem Exp $ */
2 1.1 bjh21
3 1.1 bjh21 /*
4 1.2 bjh21 * Copyright (c) 2001 Ben Harris
5 1.1 bjh21 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 1.1 bjh21 * All rights reserved.
7 1.1 bjh21 *
8 1.1 bjh21 * This code is derived from software contributed to The NetBSD Foundation
9 1.1 bjh21 * by Mark Brinicombe of Causality Limited.
10 1.1 bjh21 *
11 1.1 bjh21 * Redistribution and use in source and binary forms, with or without
12 1.1 bjh21 * modification, are permitted provided that the following conditions
13 1.1 bjh21 * are met:
14 1.1 bjh21 * 1. Redistributions of source code must retain the above copyright
15 1.1 bjh21 * notice, this list of conditions and the following disclaimer.
16 1.1 bjh21 * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 bjh21 * notice, this list of conditions and the following disclaimer in the
18 1.1 bjh21 * documentation and/or other materials provided with the distribution.
19 1.1 bjh21 * 3. All advertising materials mentioning features or use of this software
20 1.1 bjh21 * must display the following acknowledgement:
21 1.1 bjh21 * This product includes software developed by the NetBSD
22 1.1 bjh21 * Foundation, Inc. and its contributors.
23 1.1 bjh21 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.1 bjh21 * contributors may be used to endorse or promote products derived
25 1.1 bjh21 * from this software without specific prior written permission.
26 1.1 bjh21 *
27 1.1 bjh21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.1 bjh21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.1 bjh21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.1 bjh21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.1 bjh21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.1 bjh21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.1 bjh21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.1 bjh21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.1 bjh21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.1 bjh21 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.1 bjh21 * POSSIBILITY OF SUCH DAMAGE.
38 1.1 bjh21 */
39 1.2 bjh21 /*
40 1.2 bjh21 * Copyright (c) 1996, 1997 Matthias Pfaller.
41 1.2 bjh21 * All rights reserved.
42 1.2 bjh21 *
43 1.2 bjh21 * Redistribution and use in source and binary forms, with or without
44 1.2 bjh21 * modification, are permitted provided that the following conditions
45 1.2 bjh21 * are met:
46 1.2 bjh21 * 1. Redistributions of source code must retain the above copyright
47 1.2 bjh21 * notice, this list of conditions and the following disclaimer.
48 1.2 bjh21 * 2. Redistributions in binary form must reproduce the above copyright
49 1.2 bjh21 * notice, this list of conditions and the following disclaimer in the
50 1.2 bjh21 * documentation and/or other materials provided with the distribution.
51 1.2 bjh21 * 3. All advertising materials mentioning features or use of this software
52 1.2 bjh21 * must display the following acknowledgement:
53 1.2 bjh21 * This product includes software developed by Matthias Pfaller.
54 1.2 bjh21 * 4. The name of the author may not be used to endorse or promote products
55 1.2 bjh21 * derived from this software without specific prior written permission
56 1.2 bjh21 *
57 1.2 bjh21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
58 1.2 bjh21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 1.2 bjh21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 1.2 bjh21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
61 1.2 bjh21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62 1.2 bjh21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63 1.2 bjh21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64 1.2 bjh21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65 1.2 bjh21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
66 1.2 bjh21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 1.2 bjh21 */
68 1.1 bjh21
69 1.1 bjh21 /*
70 1.1 bjh21 * HCCS 8-bit SCSI driver using the generic NCR5380 driver
71 1.6 bjh21 *
72 1.6 bjh21 * Andy Armstrong gives some details of the HCCS SCSI cards at
73 1.6 bjh21 * <URL:http://www.armlinux.org/~webmail/linux-arm/1997-08/msg00042.html>.
74 1.1 bjh21 */
75 1.1 bjh21
76 1.8 lukem #include <sys/cdefs.h>
77 1.8 lukem __KERNEL_RCSID(0, "$NetBSD: hcsc.c,v 1.8 2001/11/13 07:23:15 lukem Exp $");
78 1.8 lukem
79 1.1 bjh21 #include <sys/param.h>
80 1.1 bjh21
81 1.1 bjh21 #include <sys/systm.h>
82 1.1 bjh21 #include <sys/kernel.h>
83 1.1 bjh21 #include <sys/device.h>
84 1.1 bjh21 #include <sys/buf.h>
85 1.1 bjh21 #include <dev/scsipi/scsi_all.h>
86 1.1 bjh21 #include <dev/scsipi/scsipi_all.h>
87 1.1 bjh21 #include <dev/scsipi/scsiconf.h>
88 1.1 bjh21
89 1.1 bjh21 #include <dev/ic/ncr5380reg.h>
90 1.1 bjh21 #include <dev/ic/ncr5380var.h>
91 1.1 bjh21
92 1.1 bjh21 #include <machine/bootconfig.h>
93 1.1 bjh21
94 1.1 bjh21 #include <dev/podulebus/podulebus.h>
95 1.1 bjh21 #include <dev/podulebus/podules.h>
96 1.7 bjh21 #include <dev/podulebus/powerromreg.h>
97 1.1 bjh21
98 1.5 bjh21 #include <dev/podulebus/hcscreg.h>
99 1.5 bjh21
100 1.1 bjh21 void hcsc_attach (struct device *, struct device *, void *);
101 1.1 bjh21 int hcsc_match (struct device *, struct cfdata *, void *);
102 1.1 bjh21
103 1.2 bjh21 static int hcsc_pdma_in(struct ncr5380_softc *, int, int, u_char *);
104 1.2 bjh21 static int hcsc_pdma_out(struct ncr5380_softc *, int, int, u_char *);
105 1.2 bjh21
106 1.2 bjh21
107 1.1 bjh21 /*
108 1.1 bjh21 * HCCS 8-bit SCSI softc structure.
109 1.1 bjh21 *
110 1.1 bjh21 * Contains the generic ncr5380 device node, podule information and
111 1.1 bjh21 * global information required by the driver.
112 1.1 bjh21 */
113 1.1 bjh21
114 1.1 bjh21 struct hcsc_softc {
115 1.1 bjh21 struct ncr5380_softc sc_ncr5380;
116 1.2 bjh21 bus_space_tag_t sc_pdmat;
117 1.2 bjh21 bus_space_handle_t sc_pdmah;
118 1.1 bjh21 void *sc_ih;
119 1.1 bjh21 struct evcnt sc_intrcnt;
120 1.1 bjh21 };
121 1.1 bjh21
122 1.1 bjh21 struct cfattach hcsc_ca = {
123 1.1 bjh21 sizeof(struct hcsc_softc), hcsc_match, hcsc_attach
124 1.1 bjh21 };
125 1.1 bjh21
126 1.1 bjh21 /*
127 1.1 bjh21 * Card probe function
128 1.1 bjh21 *
129 1.1 bjh21 * Just match the manufacturer and podule ID's
130 1.1 bjh21 */
131 1.1 bjh21
132 1.1 bjh21 int
133 1.1 bjh21 hcsc_match(struct device *parent, struct cfdata *cf, void *aux)
134 1.1 bjh21 {
135 1.1 bjh21 struct podulebus_attach_args *pa = aux;
136 1.1 bjh21
137 1.7 bjh21 /* Normal ROM */
138 1.4 bjh21 if (pa->pa_product == PODULE_HCCS_IDESCSI &&
139 1.4 bjh21 strncmp(pa->pa_descr, "SCSI", 4) == 0)
140 1.7 bjh21 return 1;
141 1.7 bjh21 /* PowerROM */
142 1.7 bjh21 if (pa->pa_product == PODULE_ALSYSTEMS_SCSI &&
143 1.7 bjh21 podulebus_initloader(pa) == 0 &&
144 1.7 bjh21 podloader_callloader(pa, 0, 0) == PRID_HCCS_SCSI1)
145 1.4 bjh21 return 1;
146 1.4 bjh21 return 0;
147 1.1 bjh21 }
148 1.1 bjh21
149 1.1 bjh21 /*
150 1.1 bjh21 * Card attach function
151 1.1 bjh21 *
152 1.1 bjh21 */
153 1.1 bjh21
154 1.1 bjh21 void
155 1.1 bjh21 hcsc_attach(struct device *parent, struct device *self, void *aux)
156 1.1 bjh21 {
157 1.1 bjh21 struct hcsc_softc *sc = (struct hcsc_softc *)self;
158 1.1 bjh21 struct podulebus_attach_args *pa = aux;
159 1.1 bjh21 u_char *iobase;
160 1.1 bjh21 char hi_option[sizeof(sc->sc_ncr5380.sc_dev.dv_xname) + 8];
161 1.1 bjh21
162 1.1 bjh21 sc->sc_ncr5380.sc_min_dma_len = 0;
163 1.3 bjh21 sc->sc_ncr5380.sc_no_disconnect = 0;
164 1.3 bjh21 sc->sc_ncr5380.sc_parity_disable = 0;
165 1.1 bjh21
166 1.1 bjh21 sc->sc_ncr5380.sc_dma_alloc = NULL;
167 1.1 bjh21 sc->sc_ncr5380.sc_dma_free = NULL;
168 1.1 bjh21 sc->sc_ncr5380.sc_dma_poll = NULL;
169 1.1 bjh21 sc->sc_ncr5380.sc_dma_setup = NULL;
170 1.1 bjh21 sc->sc_ncr5380.sc_dma_start = NULL;
171 1.1 bjh21 sc->sc_ncr5380.sc_dma_eop = NULL;
172 1.1 bjh21 sc->sc_ncr5380.sc_dma_stop = NULL;
173 1.1 bjh21 sc->sc_ncr5380.sc_intr_on = NULL;
174 1.1 bjh21 sc->sc_ncr5380.sc_intr_off = NULL;
175 1.1 bjh21
176 1.1 bjh21 #ifdef NCR5380_USE_BUS_SPACE
177 1.1 bjh21 sc->sc_ncr5380.sc_regt = pa->pa_fast_t;
178 1.5 bjh21 bus_space_map(sc->sc_ncr5380.sc_regt,
179 1.5 bjh21 pa->pa_fast_base + HCSC_DP8490_OFFSET, 8, 0,
180 1.1 bjh21 &sc->sc_ncr5380.sc_regh);
181 1.1 bjh21 sc->sc_ncr5380.sci_r0 = 0;
182 1.1 bjh21 sc->sc_ncr5380.sci_r1 = 1;
183 1.1 bjh21 sc->sc_ncr5380.sci_r2 = 2;
184 1.1 bjh21 sc->sc_ncr5380.sci_r3 = 3;
185 1.1 bjh21 sc->sc_ncr5380.sci_r4 = 4;
186 1.1 bjh21 sc->sc_ncr5380.sci_r5 = 5;
187 1.1 bjh21 sc->sc_ncr5380.sci_r6 = 6;
188 1.1 bjh21 sc->sc_ncr5380.sci_r7 = 7;
189 1.1 bjh21 #else
190 1.5 bjh21 iobase = (u_char *)pa->pa_fast_base + HCSC_DP8490_OFFSET;
191 1.1 bjh21 sc->sc_ncr5380.sci_r0 = iobase + 0;
192 1.1 bjh21 sc->sc_ncr5380.sci_r1 = iobase + 4;
193 1.1 bjh21 sc->sc_ncr5380.sci_r2 = iobase + 8;
194 1.1 bjh21 sc->sc_ncr5380.sci_r3 = iobase + 12;
195 1.1 bjh21 sc->sc_ncr5380.sci_r4 = iobase + 16;
196 1.1 bjh21 sc->sc_ncr5380.sci_r5 = iobase + 20;
197 1.1 bjh21 sc->sc_ncr5380.sci_r6 = iobase + 24;
198 1.1 bjh21 sc->sc_ncr5380.sci_r7 = iobase + 28;
199 1.1 bjh21 #endif
200 1.2 bjh21 sc->sc_pdmat = pa->pa_mod_t;
201 1.5 bjh21 bus_space_map(sc->sc_pdmat, pa->pa_mod_base + HCSC_PDMA_OFFSET, 1, 0,
202 1.5 bjh21 &sc->sc_pdmah);
203 1.1 bjh21
204 1.1 bjh21 sc->sc_ncr5380.sc_rev = NCR_VARIANT_DP8490;
205 1.1 bjh21
206 1.2 bjh21 sc->sc_ncr5380.sc_pio_in = hcsc_pdma_in;
207 1.2 bjh21 sc->sc_ncr5380.sc_pio_out = hcsc_pdma_out;
208 1.1 bjh21
209 1.1 bjh21 /* Provide an override for the host id */
210 1.1 bjh21 sc->sc_ncr5380.sc_channel.chan_id = 7;
211 1.1 bjh21 sprintf(hi_option, "%s.hostid", sc->sc_ncr5380.sc_dev.dv_xname);
212 1.1 bjh21 (void)get_bootconf_option(boot_args, hi_option,
213 1.1 bjh21 BOOTOPT_TYPE_INT, &sc->sc_ncr5380.sc_channel.chan_id);
214 1.1 bjh21 sc->sc_ncr5380.sc_adapter.adapt_minphys = minphys;
215 1.1 bjh21
216 1.2 bjh21 printf(": host ID %d\n", sc->sc_ncr5380.sc_channel.chan_id);
217 1.1 bjh21
218 1.1 bjh21 evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
219 1.1 bjh21 self->dv_xname, "intr");
220 1.1 bjh21 sc->sc_ih = podulebus_irq_establish(pa->pa_ih, IPL_BIO, ncr5380_intr,
221 1.1 bjh21 sc, &sc->sc_intrcnt);
222 1.1 bjh21
223 1.1 bjh21 ncr5380_attach(&sc->sc_ncr5380);
224 1.2 bjh21 }
225 1.2 bjh21
226 1.2 bjh21 #ifndef HCSC_TSIZE_OUT
227 1.2 bjh21 #define HCSC_TSIZE_OUT 512
228 1.2 bjh21 #endif
229 1.2 bjh21
230 1.2 bjh21 #ifndef HCSC_TSIZE_IN
231 1.2 bjh21 #define HCSC_TSIZE_IN 512
232 1.2 bjh21 #endif
233 1.2 bjh21
234 1.2 bjh21 #define TIMEOUT 1000000
235 1.2 bjh21
236 1.2 bjh21 static __inline int
237 1.2 bjh21 hcsc_ready(struct ncr5380_softc *sc)
238 1.2 bjh21 {
239 1.2 bjh21 int i;
240 1.2 bjh21
241 1.2 bjh21 for (i = TIMEOUT; i > 0; i--) {
242 1.2 bjh21 if ((NCR5380_READ(sc,sci_csr) &
243 1.2 bjh21 (SCI_CSR_DREQ | SCI_CSR_PHASE_MATCH)) ==
244 1.2 bjh21 (SCI_CSR_DREQ | SCI_CSR_PHASE_MATCH))
245 1.2 bjh21 return(1);
246 1.2 bjh21
247 1.2 bjh21 if ((NCR5380_READ(sc, sci_csr) & SCI_CSR_PHASE_MATCH) == 0 ||
248 1.2 bjh21 SCI_BUSY(sc) == 0)
249 1.2 bjh21 return(0);
250 1.2 bjh21 }
251 1.2 bjh21 printf("%s: ready timeout\n", sc->sc_dev.dv_xname);
252 1.2 bjh21 return(0);
253 1.2 bjh21 }
254 1.2 bjh21
255 1.2 bjh21
256 1.2 bjh21
257 1.2 bjh21 /* Return zero on success. */
258 1.2 bjh21 static __inline void hcsc_wait_not_req(struct ncr5380_softc *sc)
259 1.2 bjh21 {
260 1.2 bjh21 int timo;
261 1.2 bjh21 for (timo = TIMEOUT; timo; timo--) {
262 1.2 bjh21 if ((NCR5380_READ(sc, sci_bus_csr) & SCI_BUS_REQ) == 0 ||
263 1.2 bjh21 (NCR5380_READ(sc, sci_csr) & SCI_CSR_PHASE_MATCH) == 0 ||
264 1.2 bjh21 SCI_BUSY(sc) == 0) {
265 1.2 bjh21 return;
266 1.2 bjh21 }
267 1.2 bjh21 }
268 1.2 bjh21 printf("%s: pdma not_req timeout\n", sc->sc_dev.dv_xname);
269 1.2 bjh21 }
270 1.2 bjh21
271 1.2 bjh21 static int
272 1.2 bjh21 hcsc_pdma_in(struct ncr5380_softc *ncr_sc, int phase, int datalen,
273 1.2 bjh21 u_char *data)
274 1.2 bjh21 {
275 1.2 bjh21 struct hcsc_softc *sc = (void *)ncr_sc;
276 1.2 bjh21 bus_space_tag_t pdmat = sc->sc_pdmat;
277 1.2 bjh21 bus_space_handle_t pdmah = sc->sc_pdmah;
278 1.2 bjh21 int s, resid, len;
279 1.2 bjh21
280 1.2 bjh21 s = splbio();
281 1.2 bjh21
282 1.2 bjh21 NCR5380_WRITE(ncr_sc, sci_mode,
283 1.2 bjh21 NCR5380_READ(ncr_sc, sci_mode) | SCI_MODE_DMA);
284 1.2 bjh21 NCR5380_WRITE(ncr_sc, sci_irecv, 0);
285 1.2 bjh21
286 1.2 bjh21 resid = datalen;
287 1.2 bjh21 while (resid > 0) {
288 1.2 bjh21 len = min(resid, HCSC_TSIZE_IN);
289 1.2 bjh21 if (hcsc_ready(ncr_sc) == 0)
290 1.2 bjh21 goto interrupt;
291 1.2 bjh21 bus_space_read_multi_1(pdmat, pdmah, 0, data, len);
292 1.2 bjh21 data += len;
293 1.2 bjh21 resid -= len;
294 1.2 bjh21 }
295 1.2 bjh21
296 1.2 bjh21 hcsc_wait_not_req(ncr_sc);
297 1.2 bjh21
298 1.2 bjh21 interrupt:
299 1.2 bjh21 SCI_CLR_INTR(ncr_sc);
300 1.2 bjh21 NCR5380_WRITE(ncr_sc, sci_mode,
301 1.2 bjh21 NCR5380_READ(ncr_sc, sci_mode) & ~SCI_MODE_DMA);
302 1.2 bjh21 splx(s);
303 1.2 bjh21 return datalen - resid;
304 1.2 bjh21 }
305 1.2 bjh21
306 1.2 bjh21 static int
307 1.2 bjh21 hcsc_pdma_out(struct ncr5380_softc *ncr_sc, int phase, int datalen,
308 1.2 bjh21 u_char *data)
309 1.2 bjh21 {
310 1.2 bjh21 struct hcsc_softc *sc = (void *)ncr_sc;
311 1.2 bjh21 bus_space_tag_t pdmat = sc->sc_pdmat;
312 1.2 bjh21 bus_space_handle_t pdmah = sc->sc_pdmah;
313 1.2 bjh21 int i, s, icmd, resid;
314 1.2 bjh21
315 1.2 bjh21 s = splbio();
316 1.2 bjh21 icmd = NCR5380_READ(ncr_sc, sci_icmd) & SCI_ICMD_RMASK;
317 1.2 bjh21 NCR5380_WRITE(ncr_sc, sci_icmd, icmd | SCI_ICMD_DATA);
318 1.2 bjh21 NCR5380_WRITE(ncr_sc, sci_mode,
319 1.2 bjh21 NCR5380_READ(ncr_sc, sci_mode) | SCI_MODE_DMA);
320 1.2 bjh21 NCR5380_WRITE(ncr_sc, sci_dma_send, 0);
321 1.2 bjh21
322 1.2 bjh21 resid = datalen;
323 1.2 bjh21 if (hcsc_ready(ncr_sc) == 0)
324 1.2 bjh21 goto interrupt;
325 1.2 bjh21
326 1.2 bjh21 if (resid > HCSC_TSIZE_OUT) {
327 1.2 bjh21 /*
328 1.2 bjh21 * Because of the chips DMA prefetch, phase changes
329 1.2 bjh21 * etc, won't be detected until we have written at
330 1.2 bjh21 * least one byte more. We pre-write 4 bytes so
331 1.2 bjh21 * subsequent transfers will be aligned to a 4 byte
332 1.2 bjh21 * boundary. Assuming disconects will only occur on
333 1.2 bjh21 * block boundaries, we then correct for the pre-write
334 1.2 bjh21 * when and if we get a phase change. If the chip had
335 1.2 bjh21 * DMA byte counting hardware, the assumption would not
336 1.2 bjh21 * be necessary.
337 1.2 bjh21 */
338 1.2 bjh21 bus_space_write_multi_1(pdmat, pdmah, 0, data, 4);
339 1.2 bjh21 data += 4;
340 1.2 bjh21 resid -= 4;
341 1.2 bjh21
342 1.2 bjh21 for (; resid >= HCSC_TSIZE_OUT; resid -= HCSC_TSIZE_OUT) {
343 1.2 bjh21 if (hcsc_ready(ncr_sc) == 0) {
344 1.2 bjh21 resid += 4; /* Overshot */
345 1.2 bjh21 goto interrupt;
346 1.2 bjh21 }
347 1.2 bjh21 bus_space_write_multi_1(pdmat, pdmah, 0, data,
348 1.2 bjh21 HCSC_TSIZE_OUT);
349 1.2 bjh21 data += HCSC_TSIZE_OUT;
350 1.2 bjh21 }
351 1.2 bjh21 if (hcsc_ready(ncr_sc) == 0) {
352 1.2 bjh21 resid += 4; /* Overshot */
353 1.2 bjh21 goto interrupt;
354 1.2 bjh21 }
355 1.2 bjh21 }
356 1.2 bjh21
357 1.2 bjh21 if (resid) {
358 1.2 bjh21 bus_space_write_multi_1(pdmat, pdmah, 0, data, resid);
359 1.2 bjh21 resid = 0;
360 1.2 bjh21 }
361 1.2 bjh21 for (i = TIMEOUT; i > 0; i--) {
362 1.2 bjh21 if ((NCR5380_READ(ncr_sc, sci_csr)
363 1.2 bjh21 & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH))
364 1.2 bjh21 != SCI_CSR_DREQ)
365 1.2 bjh21 break;
366 1.2 bjh21 }
367 1.2 bjh21 if (i != 0)
368 1.2 bjh21 bus_space_write_1(pdmat, pdmah, 0, 0);
369 1.2 bjh21 else
370 1.2 bjh21 printf("%s: timeout waiting for final SCI_DSR_DREQ.\n",
371 1.2 bjh21 ncr_sc->sc_dev.dv_xname);
372 1.2 bjh21
373 1.2 bjh21 hcsc_wait_not_req(ncr_sc);
374 1.2 bjh21 interrupt:
375 1.2 bjh21 SCI_CLR_INTR(ncr_sc);
376 1.2 bjh21 NCR5380_WRITE(ncr_sc, sci_mode,
377 1.2 bjh21 NCR5380_READ(ncr_sc, sci_mode) & ~SCI_MODE_DMA);
378 1.2 bjh21 NCR5380_WRITE(ncr_sc, sci_icmd, icmd);
379 1.2 bjh21 splx(s);
380 1.2 bjh21 return(datalen - resid);
381 1.1 bjh21 }
382