Home | History | Annotate | Line # | Download | only in dev
wstsc.c revision 1.1
      1  1.1  chopps /*
      2  1.1  chopps  * Copyright (c) 1982, 1990 The Regents of the University of California.
      3  1.1  chopps  * All rights reserved.
      4  1.1  chopps  *
      5  1.1  chopps  * Redistribution and use in source and binary forms, with or without
      6  1.1  chopps  * modification, are permitted provided that the following conditions
      7  1.1  chopps  * are met:
      8  1.1  chopps  * 1. Redistributions of source code must retain the above copyright
      9  1.1  chopps  *    notice, this list of conditions and the following disclaimer.
     10  1.1  chopps  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.1  chopps  *    notice, this list of conditions and the following disclaimer in the
     12  1.1  chopps  *    documentation and/or other materials provided with the distribution.
     13  1.1  chopps  * 3. All advertising materials mentioning features or use of this software
     14  1.1  chopps  *    must display the following acknowledgement:
     15  1.1  chopps  *	This product includes software developed by the University of
     16  1.1  chopps  *	California, Berkeley and its contributors.
     17  1.1  chopps  * 4. Neither the name of the University nor the names of its contributors
     18  1.1  chopps  *    may be used to endorse or promote products derived from this software
     19  1.1  chopps  *    without specific prior written permission.
     20  1.1  chopps  *
     21  1.1  chopps  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22  1.1  chopps  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  1.1  chopps  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  1.1  chopps  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25  1.1  chopps  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  1.1  chopps  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27  1.1  chopps  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28  1.1  chopps  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29  1.1  chopps  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30  1.1  chopps  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31  1.1  chopps  * SUCH DAMAGE.
     32  1.1  chopps  *
     33  1.1  chopps  *	@(#)supradma.c
     34  1.1  chopps  *	$Id: wstsc.c,v 1.1 1994/05/08 05:53:50 chopps Exp $
     35  1.1  chopps  */
     36  1.1  chopps 
     37  1.1  chopps /*
     38  1.1  chopps  * dummy Supra 5380 DMA driver
     39  1.1  chopps  */
     40  1.1  chopps 
     41  1.1  chopps #include "suprascsi.h"
     42  1.1  chopps 
     43  1.1  chopps #if NSUPRASCSI > 0
     44  1.1  chopps 
     45  1.1  chopps #include <sys/param.h>
     46  1.1  chopps 
     47  1.1  chopps #include <amiga/dev/device.h>
     48  1.1  chopps #include <amiga/dev/scivar.h>
     49  1.1  chopps #include <amiga/dev/scireg.h>
     50  1.1  chopps 
     51  1.1  chopps int supradma_pseudo = 0;	/* 0=none, 1=byte, 2=word */
     52  1.1  chopps 
     53  1.1  chopps #ifdef DEBUG
     54  1.1  chopps extern int sci_debug;
     55  1.1  chopps #define QUASEL
     56  1.1  chopps #endif
     57  1.1  chopps #define	HIST(h,w)
     58  1.1  chopps 
     59  1.1  chopps #ifdef QUASEL
     60  1.1  chopps #define QPRINTF(a) if (sci_debug > 1) printf a
     61  1.1  chopps #else
     62  1.1  chopps #define QPRINTF
     63  1.1  chopps #endif
     64  1.1  chopps 
     65  1.1  chopps extern int sci_data_wait;
     66  1.1  chopps 
     67  1.1  chopps static int dma_xfer_in __P((struct sci_softc *dev, int len,
     68  1.1  chopps     register u_char *buf, int phase));
     69  1.1  chopps static int dma_xfer_out __P((struct sci_softc *dev, int len,
     70  1.1  chopps     register u_char *buf, int phase));
     71  1.1  chopps static int dma_xfer_in2 __P((struct sci_softc *dev, int len,
     72  1.1  chopps     register u_short *buf, int phase));
     73  1.1  chopps static int dma_xfer_out2 __P((struct sci_softc *dev, int len,
     74  1.1  chopps     register u_short *buf, int phase));
     75  1.1  chopps static int supra_intr __P((struct sci_softc *dev));
     76  1.1  chopps 
     77  1.1  chopps void
     78  1.1  chopps supradmainit (dev)
     79  1.1  chopps 	struct sci_softc *dev;
     80  1.1  chopps {
     81  1.1  chopps 	if (supradma_pseudo == 2) {
     82  1.1  chopps 		dev->dma_xfer_in = dma_xfer_in2;
     83  1.1  chopps 		dev->dma_xfer_out = dma_xfer_out2;
     84  1.1  chopps 	} else if (supradma_pseudo == 1) {
     85  1.1  chopps 		dev->dma_xfer_in = dma_xfer_in;
     86  1.1  chopps 		dev->dma_xfer_out = dma_xfer_out;
     87  1.1  chopps 	}
     88  1.1  chopps 	dev->dma_intr = supra_intr;
     89  1.1  chopps }
     90  1.1  chopps 
     91  1.1  chopps static int
     92  1.1  chopps dma_xfer_in (dev, len, buf, phase)
     93  1.1  chopps 	struct sci_softc *dev;
     94  1.1  chopps 	int len;
     95  1.1  chopps 	register u_char *buf;
     96  1.1  chopps 	int phase;
     97  1.1  chopps {
     98  1.1  chopps 	int wait = sci_data_wait;
     99  1.1  chopps 	u_char csr;
    100  1.1  chopps 	u_char *obp = (u_char *) buf;
    101  1.1  chopps 	volatile register u_char *sci_dma = dev->sci_idata;
    102  1.1  chopps 	volatile register u_char *sci_csr = dev->sci_csr;
    103  1.1  chopps 
    104  1.1  chopps 	QPRINTF(("supradma_in %d, csr=%02x\n", len, *dev->sci_bus_csr));
    105  1.1  chopps 
    106  1.1  chopps 	*dev->sci_tcmd = phase;
    107  1.1  chopps 	*dev->sci_icmd = 0;
    108  1.1  chopps 	*dev->sci_mode = SCI_MODE_DMA;
    109  1.1  chopps 	*dev->sci_irecv = 0;
    110  1.1  chopps 
    111  1.1  chopps 	while (len >= 128) {
    112  1.1  chopps 		wait = sci_data_wait;
    113  1.1  chopps 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    114  1.1  chopps 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    115  1.1  chopps 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    116  1.1  chopps 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    117  1.1  chopps 			  || --wait < 0) {
    118  1.1  chopps #ifdef DEBUG
    119  1.1  chopps 				if (sci_debug | 1)
    120  1.1  chopps 					printf("supradma2_in fail: l%d i%x w%d\n",
    121  1.1  chopps 					len, *dev->sci_bus_csr, wait);
    122  1.1  chopps #endif
    123  1.1  chopps 				HIST(ixin_wait, wait)
    124  1.1  chopps 				*dev->sci_mode = 0;
    125  1.1  chopps 				return 0;
    126  1.1  chopps 			}
    127  1.1  chopps 		}
    128  1.1  chopps 
    129  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    130  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    131  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    132  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    133  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    134  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    135  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    136  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    137  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    138  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    139  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    140  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    141  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    142  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    143  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    144  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    145  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    146  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    147  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    148  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    149  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    150  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    151  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    152  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    153  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    154  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    155  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    156  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    157  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    158  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    159  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    160  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    161  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    162  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    163  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    164  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    165  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    166  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    167  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    168  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    169  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    170  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    171  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    172  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    173  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    174  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    175  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    176  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    177  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    178  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    179  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    180  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    181  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    182  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    183  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    184  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    185  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    186  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    187  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    188  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    189  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    190  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    191  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    192  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    193  1.1  chopps 		len -= 128;
    194  1.1  chopps 	}
    195  1.1  chopps 
    196  1.1  chopps 	while (len > 0) {
    197  1.1  chopps 		wait = sci_data_wait;
    198  1.1  chopps 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    199  1.1  chopps 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    200  1.1  chopps 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    201  1.1  chopps 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    202  1.1  chopps 			  || --wait < 0) {
    203  1.1  chopps #ifdef DEBUG
    204  1.1  chopps 				if (sci_debug | 1)
    205  1.1  chopps 					printf("supradma1_in fail: l%d i%x w%d\n",
    206  1.1  chopps 					len, *dev->sci_bus_csr, wait);
    207  1.1  chopps #endif
    208  1.1  chopps 				HIST(ixin_wait, wait)
    209  1.1  chopps 				*dev->sci_mode = 0;
    210  1.1  chopps 				return 0;
    211  1.1  chopps 			}
    212  1.1  chopps 		}
    213  1.1  chopps 
    214  1.1  chopps 		*buf++ = *sci_dma;
    215  1.1  chopps 		len--;
    216  1.1  chopps 	}
    217  1.1  chopps 
    218  1.1  chopps 	QPRINTF(("supradma_in {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
    219  1.1  chopps 	  len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5],
    220  1.1  chopps 	  obp[6], obp[7], obp[8], obp[9]));
    221  1.1  chopps 
    222  1.1  chopps 	HIST(ixin_wait, wait)
    223  1.1  chopps 	*dev->sci_mode = 0;
    224  1.1  chopps 	return 0;
    225  1.1  chopps }
    226  1.1  chopps 
    227  1.1  chopps static int
    228  1.1  chopps dma_xfer_out (dev, len, buf, phase)
    229  1.1  chopps 	struct sci_softc *dev;
    230  1.1  chopps 	int len;
    231  1.1  chopps 	register u_char *buf;
    232  1.1  chopps 	int phase;
    233  1.1  chopps {
    234  1.1  chopps 	int wait = sci_data_wait;
    235  1.1  chopps 	u_char csr;
    236  1.1  chopps 	u_char *obp = buf;
    237  1.1  chopps 	volatile register u_char *sci_dma = dev->sci_data;
    238  1.1  chopps 	volatile register u_char *sci_csr = dev->sci_csr;
    239  1.1  chopps 
    240  1.1  chopps 	QPRINTF(("supradma_out %d, csr=%02x\n", len, *dev->sci_bus_csr));
    241  1.1  chopps 
    242  1.1  chopps 	QPRINTF(("supradma_out {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
    243  1.1  chopps   	 len, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
    244  1.1  chopps 	 buf[6], buf[7], buf[8], buf[9]));
    245  1.1  chopps 
    246  1.1  chopps 	*dev->sci_tcmd = phase;
    247  1.1  chopps 	*dev->sci_mode = SCI_MODE_DMA;
    248  1.1  chopps 	*dev->sci_icmd = SCI_ICMD_DATA;
    249  1.1  chopps 	*dev->sci_dma_send = 0;
    250  1.1  chopps 	while (len > 0) {
    251  1.1  chopps 		wait = sci_data_wait;
    252  1.1  chopps 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    253  1.1  chopps 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    254  1.1  chopps 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    255  1.1  chopps 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    256  1.1  chopps 			  || --wait < 0) {
    257  1.1  chopps #ifdef DEBUG
    258  1.1  chopps 				if (sci_debug)
    259  1.1  chopps 					printf("supradma_out fail: l%d i%x w%d\n",
    260  1.1  chopps 					len, csr, wait);
    261  1.1  chopps #endif
    262  1.1  chopps 				HIST(ixin_wait, wait)
    263  1.1  chopps 				*dev->sci_mode = 0;
    264  1.1  chopps 				return 0;
    265  1.1  chopps 			}
    266  1.1  chopps 		}
    267  1.1  chopps 
    268  1.1  chopps 		*sci_dma = *buf++;
    269  1.1  chopps 		len--;
    270  1.1  chopps 	}
    271  1.1  chopps 
    272  1.1  chopps 	wait = sci_data_wait;
    273  1.1  chopps 	while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) ==
    274  1.1  chopps 	  SCI_CSR_PHASE_MATCH && --wait);
    275  1.1  chopps 
    276  1.1  chopps 
    277  1.1  chopps 	HIST(ixin_wait, wait)
    278  1.1  chopps 	*dev->sci_mode = 0;
    279  1.1  chopps 	*dev->sci_icmd = 0;
    280  1.1  chopps 	return 0;
    281  1.1  chopps }
    282  1.1  chopps 
    283  1.1  chopps 
    284  1.1  chopps static int
    285  1.1  chopps dma_xfer_in2 (dev, len, buf, phase)
    286  1.1  chopps 	struct sci_softc *dev;
    287  1.1  chopps 	int len;
    288  1.1  chopps 	register u_short *buf;
    289  1.1  chopps 	int phase;
    290  1.1  chopps {
    291  1.1  chopps 	int wait = sci_data_wait;
    292  1.1  chopps 	u_char csr;
    293  1.1  chopps 	u_char *obp = (u_char *) buf;
    294  1.1  chopps 	volatile register u_short *sci_dma = (u_short *)(dev->sci_idata + 0x10);
    295  1.1  chopps 	volatile register u_char *sci_csr = dev->sci_csr + 0x10;
    296  1.1  chopps 
    297  1.1  chopps 	QPRINTF(("supradma_in2 %d, csr=%02x\n", len, *dev->sci_bus_csr));
    298  1.1  chopps 
    299  1.1  chopps 	*dev->sci_tcmd = phase;
    300  1.1  chopps 	*dev->sci_mode = SCI_MODE_DMA;
    301  1.1  chopps 	*dev->sci_icmd = 0;
    302  1.1  chopps 	*(dev->sci_irecv + 16) = 0;
    303  1.1  chopps 	while (len >= 128) {
    304  1.1  chopps #if 0
    305  1.1  chopps 		wait = sci_data_wait;
    306  1.1  chopps 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    307  1.1  chopps 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    308  1.1  chopps 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    309  1.1  chopps 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    310  1.1  chopps 			  || --wait < 0) {
    311  1.1  chopps #ifdef DEBUG
    312  1.1  chopps 				if (sci_debug | 1)
    313  1.1  chopps 					printf("supradma2_in2 fail: l%d i%x w%d\n",
    314  1.1  chopps 					len, *dev->sci_bus_csr, wait);
    315  1.1  chopps #endif
    316  1.1  chopps 				HIST(ixin_wait, wait)
    317  1.1  chopps 				*dev->sci_mode &= ~SCI_MODE_DMA;
    318  1.1  chopps 				return 0;
    319  1.1  chopps 			}
    320  1.1  chopps 		}
    321  1.1  chopps #else
    322  1.1  chopps 		while (!(*sci_csr & SCI_CSR_DREQ))
    323  1.1  chopps 			;
    324  1.1  chopps #endif
    325  1.1  chopps 
    326  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    327  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    328  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    329  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    330  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    331  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    332  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    333  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    334  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    335  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    336  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    337  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    338  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    339  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    340  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    341  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    342  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    343  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    344  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    345  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    346  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    347  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    348  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    349  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    350  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    351  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    352  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    353  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    354  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    355  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    356  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    357  1.1  chopps 		*buf++ = *sci_dma; *buf++ = *sci_dma;
    358  1.1  chopps 		len -= 128;
    359  1.1  chopps 	}
    360  1.1  chopps 	while (len > 0) {
    361  1.1  chopps #if 0
    362  1.1  chopps 		wait = sci_data_wait;
    363  1.1  chopps 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    364  1.1  chopps 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    365  1.1  chopps 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    366  1.1  chopps 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    367  1.1  chopps 			  || --wait < 0) {
    368  1.1  chopps #ifdef DEBUG
    369  1.1  chopps 				if (sci_debug | 1)
    370  1.1  chopps 					printf("supradma1_in2 fail: l%d i%x w%d\n",
    371  1.1  chopps 					len, *dev->sci_bus_csr, wait);
    372  1.1  chopps #endif
    373  1.1  chopps 				HIST(ixin_wait, wait)
    374  1.1  chopps 				*dev->sci_mode &= ~SCI_MODE_DMA;
    375  1.1  chopps 				return 0;
    376  1.1  chopps 			}
    377  1.1  chopps 		}
    378  1.1  chopps #else
    379  1.1  chopps 		while (!(*sci_csr * SCI_CSR_DREQ))
    380  1.1  chopps 			;
    381  1.1  chopps #endif
    382  1.1  chopps 
    383  1.1  chopps 		*buf++ = *sci_dma;
    384  1.1  chopps 		len -= 2;
    385  1.1  chopps 	}
    386  1.1  chopps 
    387  1.1  chopps 	QPRINTF(("supradma_in2 {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
    388  1.1  chopps 	  len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5],
    389  1.1  chopps 	  obp[6], obp[7], obp[8], obp[9]));
    390  1.1  chopps 
    391  1.1  chopps 	HIST(ixin_wait, wait)
    392  1.1  chopps 	*dev->sci_irecv = 0;
    393  1.1  chopps 	*dev->sci_mode = 0;
    394  1.1  chopps 	return 0;
    395  1.1  chopps }
    396  1.1  chopps 
    397  1.1  chopps static int
    398  1.1  chopps dma_xfer_out2 (dev, len, buf, phase)
    399  1.1  chopps 	struct sci_softc *dev;
    400  1.1  chopps 	int len;
    401  1.1  chopps 	register u_short *buf;
    402  1.1  chopps 	int phase;
    403  1.1  chopps {
    404  1.1  chopps 	int wait = sci_data_wait;
    405  1.1  chopps 	u_char csr;
    406  1.1  chopps 	u_char *obp = (u_char *) buf;
    407  1.1  chopps 	volatile register u_short *sci_dma = (ushort *)(dev->sci_data + 0x10);
    408  1.1  chopps 	volatile register u_char *sci_bus_csr = dev->sci_bus_csr;
    409  1.1  chopps 
    410  1.1  chopps 	QPRINTF(("supradma_out2 %d, csr=%02x\n", len, *dev->sci_bus_csr));
    411  1.1  chopps 
    412  1.1  chopps 	QPRINTF(("supradma_out2 {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
    413  1.1  chopps   	 len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5],
    414  1.1  chopps 	 obp[6], obp[7], obp[8], obp[9]));
    415  1.1  chopps 
    416  1.1  chopps 	*dev->sci_tcmd = phase;
    417  1.1  chopps 	*dev->sci_mode = SCI_MODE_DMA;
    418  1.1  chopps 	*dev->sci_icmd = SCI_ICMD_DATA;
    419  1.1  chopps 	*dev->sci_dma_send = 0;
    420  1.1  chopps 	while (len > 0) {
    421  1.1  chopps #if 0
    422  1.1  chopps 		wait = sci_data_wait;
    423  1.1  chopps 		while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) !=
    424  1.1  chopps 		  (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    425  1.1  chopps 			if (!(*sci_csr & SCI_CSR_PHASE_MATCH)
    426  1.1  chopps 			  || !(*dev->sci_bus_csr & SCI_BUS_BSY)
    427  1.1  chopps 			  || --wait < 0) {
    428  1.1  chopps #ifdef DEBUG
    429  1.1  chopps 				if (sci_debug)
    430  1.1  chopps 					printf("supradma_out2 fail: l%d i%x w%d\n",
    431  1.1  chopps 					len, csr, wait);
    432  1.1  chopps #endif
    433  1.1  chopps 				HIST(ixin_wait, wait)
    434  1.1  chopps 				*dev->sci_mode = 0;
    435  1.1  chopps 				return 0;
    436  1.1  chopps 			}
    437  1.1  chopps 		}
    438  1.1  chopps #else
    439  1.1  chopps 		*dev->sci_mode = 0;
    440  1.1  chopps 		*dev->sci_icmd &= ~SCI_ICMD_ACK;
    441  1.1  chopps 		while (!(*sci_bus_csr & SCI_BUS_REQ))
    442  1.1  chopps 			;
    443  1.1  chopps 		*dev->sci_mode = SCI_MODE_DMA;
    444  1.1  chopps 		*dev->sci_dma_send = 0;
    445  1.1  chopps #endif
    446  1.1  chopps 
    447  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    448  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    449  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    450  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    451  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    452  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    453  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    454  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    455  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    456  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    457  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    458  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    459  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    460  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    461  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    462  1.1  chopps 		*sci_dma = *buf++; *sci_dma = *buf++;
    463  1.1  chopps 		if (*(sci_bus_csr + 0x10) & SCI_BUS_REQ)
    464  1.1  chopps 			;
    465  1.1  chopps 		len -= 64;
    466  1.1  chopps 	}
    467  1.1  chopps 
    468  1.1  chopps #if 0
    469  1.1  chopps 	wait = sci_data_wait;
    470  1.1  chopps 	while ((*sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) ==
    471  1.1  chopps 	  SCI_CSR_PHASE_MATCH && --wait);
    472  1.1  chopps #endif
    473  1.1  chopps 
    474  1.1  chopps 
    475  1.1  chopps 	HIST(ixin_wait, wait)
    476  1.1  chopps 	*dev->sci_irecv = 0;
    477  1.1  chopps 	*dev->sci_icmd &= ~SCI_ICMD_ACK;
    478  1.1  chopps 	*dev->sci_mode = 0;
    479  1.1  chopps 	*dev->sci_icmd = 0;
    480  1.1  chopps 	return 0;
    481  1.1  chopps }
    482  1.1  chopps 
    483  1.1  chopps static int
    484  1.1  chopps supra_intr (dev)
    485  1.1  chopps 	struct sci_softc *dev;
    486  1.1  chopps {
    487  1.1  chopps 	if (*(dev->sci_csr + 0x10) & SCI_CSR_INT) {
    488  1.1  chopps 		char dummy;
    489  1.1  chopps #if 0
    490  1.1  chopps printf ("supra_intr\n");
    491  1.1  chopps #endif
    492  1.1  chopps 		dummy = *(dev->sci_iack + 0x10);
    493  1.1  chopps 		return (1);
    494  1.1  chopps 	}
    495  1.1  chopps 	return (0);
    496  1.1  chopps }
    497  1.1  chopps #endif
    498