Home | History | Annotate | Line # | Download | only in dev
wstsc.c revision 1.2
      1 /*
      2  * Copyright (c) 1994 Michael L. Hitch
      3  * Copyright (c) 1982, 1990 The Regents of the University of California.
      4  * All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *	This product includes software developed by the University of
     17  *	California, Berkeley and its contributors.
     18  * 4. Neither the name of the University nor the names of its contributors
     19  *    may be used to endorse or promote products derived from this software
     20  *    without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  * SUCH DAMAGE.
     33  *
     34  *	@(#)supradma.c
     35  *	$Id: wstsc.c,v 1.2 1994/05/29 04:50:25 chopps Exp $
     36  */
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 #include <sys/kernel.h>
     40 #include <sys/device.h>
     41 #include <scsi/scsi_all.h>
     42 #include <scsi/scsiconf.h>
     43 #include <amiga/amiga/device.h>
     44 #include <amiga/dev/scireg.h>
     45 #include <amiga/dev/scivar.h>
     46 #include <amiga/dev/ztwobusvar.h>
     47 
     48 int wstscprint __P((void *auxp, char *));
     49 void wstscattach __P((struct device *, struct device *, void *));
     50 int wstscmatch __P((struct device *, struct cfdata *, void *));
     51 
     52 int wstsc_dma_xfer_in __P((struct sci_softc *dev, int len,
     53     register u_char *buf, int phase));
     54 int wstsc_dma_xfer_out __P((struct sci_softc *dev, int len,
     55     register u_char *buf, int phase));
     56 int wstsc_dma_xfer_in2 __P((struct sci_softc *dev, int len,
     57     register u_short *buf, int phase));
     58 int wstsc_dma_xfer_out2 __P((struct sci_softc *dev, int len,
     59     register u_short *buf, int phase));
     60 
     61 struct scsi_adapter wstsc_scsiswitch = {
     62 	sci_scsicmd,
     63 	sci_minphys,
     64 	0,			/* no lun support */
     65 	0,			/* no lun support */
     66 	sci_adinfo,
     67 	"wstsc",
     68 };
     69 
     70 struct scsi_device wstsc_scsidev = {
     71 	NULL,		/* use default error handler */
     72 	NULL,		/* do not have a start functio */
     73 	NULL,		/* have no async handler */
     74 	NULL,		/* Use default done routine */
     75 	"wstsc",
     76 	0,
     77 };
     78 
     79 #define QPRINTF
     80 
     81 #ifdef DEBUG
     82 extern int sci_debug;
     83 #endif
     84 
     85 extern int sci_data_wait;
     86 
     87 int supradma_pseudo = 0;	/* 0=none, 1=byte, 2=word */
     88 
     89 struct cfdriver wstsccd = {
     90 	NULL, "wstsc", wstscmatch, wstscattach,
     91 	DV_DULL, sizeof(struct sci_softc), NULL, 0 };
     92 
     93 /*
     94  * if this a Supra WordSync board
     95  */
     96 int
     97 wstscmatch(pdp, cdp, auxp)
     98 	struct device *pdp;
     99 	struct cfdata *cdp;
    100 	void *auxp;
    101 {
    102 	struct ztwobus_args *zap;
    103 
    104 	zap = auxp;
    105 
    106 	/*
    107 	 * Check manufacturer and product id.
    108 	 */
    109 	if (zap->manid == 1056 && zap->prodid == 12)	/* add other boards? */
    110 		return(1);
    111 	else
    112 		return(0);
    113 }
    114 
    115 void
    116 wstscattach(pdp, dp, auxp)
    117 	struct device *pdp, *dp;
    118 	void *auxp;
    119 {
    120 	volatile u_char *rp;
    121 	struct sci_softc *sc;
    122 	struct ztwobus_args *zap;
    123 
    124 	zap = auxp;
    125 
    126 	sc = (struct sci_softc *)dp;
    127 	rp = zap->va;
    128 	/*
    129 	 * set up 5380 register pointers
    130 	 * (Needs check on which Supra board this is - for now,
    131 	 *  just do the WordSync)
    132 	 */
    133 	sc->sci_data = rp + 0;
    134 	sc->sci_odata = rp + 0;
    135 	sc->sci_icmd = rp + 2;
    136 	sc->sci_mode = rp + 4;
    137 	sc->sci_tcmd = rp + 6;
    138 	sc->sci_bus_csr = rp + 8;
    139 	sc->sci_sel_enb = rp + 8;
    140 	sc->sci_csr = rp + 10;
    141 	sc->sci_dma_send = rp + 10;
    142 	sc->sci_idata = rp + 12;
    143 	sc->sci_trecv = rp + 12;
    144 	sc->sci_iack = rp + 14;
    145 	sc->sci_irecv = rp + 14;
    146 
    147 	if (supradma_pseudo == 2) {
    148 		sc->dma_xfer_in = wstsc_dma_xfer_in2;
    149 		sc->dma_xfer_out = wstsc_dma_xfer_out2;
    150 	}
    151 	else if (supradma_pseudo == 1) {
    152 		sc->dma_xfer_in = wstsc_dma_xfer_in;
    153 		sc->dma_xfer_out = wstsc_dma_xfer_out;
    154 	}
    155 
    156 	scireset(sc);
    157 
    158 	sc->sc_link.adapter_softc = sc;
    159 	sc->sc_link.adapter_targ = 7;
    160 	sc->sc_link.adapter = &wstsc_scsiswitch;
    161 	sc->sc_link.device = &wstsc_scsidev;
    162 	TAILQ_INIT(&sc->sc_xslist);
    163 
    164 	/*
    165 	 * attach all scsi units on us
    166 	 */
    167 	config_found(dp, &sc->sc_link, wstscprint);
    168 }
    169 
    170 /*
    171  * print diag if pnp is NULL else just extra
    172  */
    173 int
    174 wstscprint(auxp, pnp)
    175 	void *auxp;
    176 	char *pnp;
    177 {
    178 	if (pnp == NULL)
    179 		return(UNCONF);
    180 	return(QUIET);
    181 }
    182 
    183 int
    184 wstsc_dma_xfer_in (dev, len, buf, phase)
    185 	struct sci_softc *dev;
    186 	int len;
    187 	register u_char *buf;
    188 	int phase;
    189 {
    190 	int wait = sci_data_wait;
    191 	u_char csr;
    192 	u_char *obp = (u_char *) buf;
    193 	volatile register u_char *sci_dma = dev->sci_idata;
    194 	volatile register u_char *sci_csr = dev->sci_csr;
    195 
    196 	QPRINTF(("supradma_in %d, csr=%02x\n", len, *dev->sci_bus_csr));
    197 
    198 	*dev->sci_tcmd = phase;
    199 	*dev->sci_icmd = 0;
    200 	*dev->sci_mode = SCI_MODE_DMA;
    201 	*dev->sci_irecv = 0;
    202 
    203 	while (len >= 128) {
    204 		wait = sci_data_wait;
    205 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    206 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    207 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    208 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    209 			  || --wait < 0) {
    210 #ifdef DEBUG
    211 				if (sci_debug | 1)
    212 					printf("supradma2_in fail: l%d i%x w%d\n",
    213 					len, *dev->sci_bus_csr, wait);
    214 #endif
    215 				*dev->sci_mode = 0;
    216 				return 0;
    217 			}
    218 		}
    219 
    220 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    221 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    222 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    223 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    224 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    225 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    226 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    227 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    228 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    229 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    230 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    231 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    232 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    233 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    234 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    235 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    236 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    237 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    238 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    239 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    240 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    241 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    242 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    243 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    244 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    245 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    246 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    247 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    248 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    249 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    250 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    251 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    252 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    253 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    254 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    255 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    256 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    257 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    258 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    259 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    260 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    261 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    262 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    263 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    264 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    265 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    266 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    267 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    268 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    269 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    270 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    271 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    272 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    273 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    274 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    275 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    276 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    277 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    278 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    279 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    280 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    281 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    282 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    283 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    284 		len -= 128;
    285 	}
    286 
    287 	while (len > 0) {
    288 		wait = sci_data_wait;
    289 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    290 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    291 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    292 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    293 			  || --wait < 0) {
    294 #ifdef DEBUG
    295 				if (sci_debug | 1)
    296 					printf("supradma1_in fail: l%d i%x w%d\n",
    297 					len, *dev->sci_bus_csr, wait);
    298 #endif
    299 				*dev->sci_mode = 0;
    300 				return 0;
    301 			}
    302 		}
    303 
    304 		*buf++ = *sci_dma;
    305 		len--;
    306 	}
    307 
    308 	QPRINTF(("supradma_in {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
    309 	  len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5],
    310 	  obp[6], obp[7], obp[8], obp[9]));
    311 
    312 	*dev->sci_mode = 0;
    313 	return 0;
    314 }
    315 
    316 int
    317 wstsc_dma_xfer_out (dev, len, buf, phase)
    318 	struct sci_softc *dev;
    319 	int len;
    320 	register u_char *buf;
    321 	int phase;
    322 {
    323 	int wait = sci_data_wait;
    324 	u_char csr;
    325 	u_char *obp = buf;
    326 	volatile register u_char *sci_dma = dev->sci_data;
    327 	volatile register u_char *sci_csr = dev->sci_csr;
    328 
    329 	QPRINTF(("supradma_out %d, csr=%02x\n", len, *dev->sci_bus_csr));
    330 
    331 	QPRINTF(("supradma_out {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
    332   	 len, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
    333 	 buf[6], buf[7], buf[8], buf[9]));
    334 
    335 	*dev->sci_tcmd = phase;
    336 	*dev->sci_mode = SCI_MODE_DMA;
    337 	*dev->sci_icmd = SCI_ICMD_DATA;
    338 	*dev->sci_dma_send = 0;
    339 	while (len > 0) {
    340 		wait = sci_data_wait;
    341 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    342 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    343 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    344 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    345 			  || --wait < 0) {
    346 #ifdef DEBUG
    347 				if (sci_debug)
    348 					printf("supradma_out fail: l%d i%x w%d\n",
    349 					len, csr, wait);
    350 #endif
    351 				*dev->sci_mode = 0;
    352 				return 0;
    353 			}
    354 		}
    355 
    356 		*sci_dma = *buf++;
    357 		len--;
    358 	}
    359 
    360 	wait = sci_data_wait;
    361 	while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) ==
    362 	  SCI_CSR_PHASE_MATCH && --wait);
    363 
    364 
    365 	*dev->sci_mode = 0;
    366 	*dev->sci_icmd = 0;
    367 	return 0;
    368 }
    369 
    370 
    371 int
    372 wstsc_dma_xfer_in2 (dev, len, buf, phase)
    373 	struct sci_softc *dev;
    374 	int len;
    375 	register u_short *buf;
    376 	int phase;
    377 {
    378 	int wait = sci_data_wait;
    379 	u_char csr;
    380 	u_char *obp = (u_char *) buf;
    381 	volatile register u_short *sci_dma = (u_short *)(dev->sci_idata + 0x10);
    382 	volatile register u_char *sci_csr = dev->sci_csr + 0x10;
    383 
    384 	QPRINTF(("supradma_in2 %d, csr=%02x\n", len, *dev->sci_bus_csr));
    385 
    386 	*dev->sci_tcmd = phase;
    387 	*dev->sci_mode = SCI_MODE_DMA;
    388 	*dev->sci_icmd = 0;
    389 	*(dev->sci_irecv + 16) = 0;
    390 	while (len >= 128) {
    391 #if 0
    392 		wait = sci_data_wait;
    393 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    394 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    395 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    396 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    397 			  || --wait < 0) {
    398 #ifdef DEBUG
    399 				if (sci_debug | 1)
    400 					printf("supradma2_in2 fail: l%d i%x w%d\n",
    401 					len, *dev->sci_bus_csr, wait);
    402 #endif
    403 				*dev->sci_mode &= ~SCI_MODE_DMA;
    404 				return 0;
    405 			}
    406 		}
    407 #else
    408 		while (!(*sci_csr & SCI_CSR_DREQ))
    409 			;
    410 #endif
    411 
    412 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    413 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    414 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    415 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    416 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    417 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    418 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    419 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    420 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    421 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    422 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    423 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    424 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    425 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    426 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    427 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    428 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    429 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    430 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    431 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    432 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    433 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    434 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    435 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    436 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    437 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    438 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    439 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    440 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    441 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    442 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    443 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    444 		len -= 128;
    445 	}
    446 	while (len > 0) {
    447 #if 0
    448 		wait = sci_data_wait;
    449 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    450 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    451 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    452 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    453 			  || --wait < 0) {
    454 #ifdef DEBUG
    455 				if (sci_debug | 1)
    456 					printf("supradma1_in2 fail: l%d i%x w%d\n",
    457 					len, *dev->sci_bus_csr, wait);
    458 #endif
    459 				*dev->sci_mode &= ~SCI_MODE_DMA;
    460 				return 0;
    461 			}
    462 		}
    463 #else
    464 		while (!(*sci_csr * SCI_CSR_DREQ))
    465 			;
    466 #endif
    467 
    468 		*buf++ = *sci_dma;
    469 		len -= 2;
    470 	}
    471 
    472 	QPRINTF(("supradma_in2 {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
    473 	  len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5],
    474 	  obp[6], obp[7], obp[8], obp[9]));
    475 
    476 	*dev->sci_irecv = 0;
    477 	*dev->sci_mode = 0;
    478 	return 0;
    479 }
    480 
    481 int
    482 wstsc_dma_xfer_out2 (dev, len, buf, phase)
    483 	struct sci_softc *dev;
    484 	int len;
    485 	register u_short *buf;
    486 	int phase;
    487 {
    488 	int wait = sci_data_wait;
    489 	u_char csr;
    490 	u_char *obp = (u_char *) buf;
    491 	volatile register u_short *sci_dma = (ushort *)(dev->sci_data + 0x10);
    492 	volatile register u_char *sci_bus_csr = dev->sci_bus_csr;
    493 
    494 	QPRINTF(("supradma_out2 %d, csr=%02x\n", len, *dev->sci_bus_csr));
    495 
    496 	QPRINTF(("supradma_out2 {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
    497   	 len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5],
    498 	 obp[6], obp[7], obp[8], obp[9]));
    499 
    500 	*dev->sci_tcmd = phase;
    501 	*dev->sci_mode = SCI_MODE_DMA;
    502 	*dev->sci_icmd = SCI_ICMD_DATA;
    503 	*dev->sci_dma_send = 0;
    504 	while (len > 0) {
    505 #if 0
    506 		wait = sci_data_wait;
    507 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    508 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    509 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    510 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    511 			  || --wait < 0) {
    512 #ifdef DEBUG
    513 				if (sci_debug)
    514 					printf("supradma_out2 fail: l%d i%x w%d\n",
    515 					len, csr, wait);
    516 #endif
    517 				*dev->sci_mode = 0;
    518 				return 0;
    519 			}
    520 		}
    521 #else
    522 		*dev->sci_mode = 0;
    523 		*dev->sci_icmd &= ~SCI_ICMD_ACK;
    524 		while (!(*sci_bus_csr & SCI_BUS_REQ))
    525 			;
    526 		*dev->sci_mode = SCI_MODE_DMA;
    527 		*dev->sci_dma_send = 0;
    528 #endif
    529 
    530 		*sci_dma = *buf++; *sci_dma = *buf++;
    531 		*sci_dma = *buf++; *sci_dma = *buf++;
    532 		*sci_dma = *buf++; *sci_dma = *buf++;
    533 		*sci_dma = *buf++; *sci_dma = *buf++;
    534 		*sci_dma = *buf++; *sci_dma = *buf++;
    535 		*sci_dma = *buf++; *sci_dma = *buf++;
    536 		*sci_dma = *buf++; *sci_dma = *buf++;
    537 		*sci_dma = *buf++; *sci_dma = *buf++;
    538 		*sci_dma = *buf++; *sci_dma = *buf++;
    539 		*sci_dma = *buf++; *sci_dma = *buf++;
    540 		*sci_dma = *buf++; *sci_dma = *buf++;
    541 		*sci_dma = *buf++; *sci_dma = *buf++;
    542 		*sci_dma = *buf++; *sci_dma = *buf++;
    543 		*sci_dma = *buf++; *sci_dma = *buf++;
    544 		*sci_dma = *buf++; *sci_dma = *buf++;
    545 		*sci_dma = *buf++; *sci_dma = *buf++;
    546 		if (*(sci_bus_csr + 0x10) & SCI_BUS_REQ)
    547 			;
    548 		len -= 64;
    549 	}
    550 
    551 #if 0
    552 	wait = sci_data_wait;
    553 	while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) ==
    554 	  SCI_CSR_PHASE_MATCH && --wait);
    555 #endif
    556 
    557 
    558 	*dev->sci_irecv = 0;
    559 	*dev->sci_icmd &= ~SCI_ICMD_ACK;
    560 	*dev->sci_mode = 0;
    561 	*dev->sci_icmd = 0;
    562 	return 0;
    563 }
    564 
    565 int
    566 wstsc_intr()
    567 {
    568 	struct sci_softc *dev;
    569 	int i, found;
    570 	u_char stat;
    571 
    572 	found = 0;
    573 	for (i = 0; i < wstsccd.cd_ndevs; i++) {
    574 		dev = wstsccd.cd_devs[i];
    575 		if (dev == NULL)
    576 			continue;
    577 		if ((*(dev->sci_csr + 0x10) & SCI_CSR_INT) == 0)
    578 			continue;
    579 		++found;
    580 		stat = *(dev->sci_iack + 0x10);
    581 	}
    582 	return (found);
    583 }
    584