Home | History | Annotate | Line # | Download | only in dev
sbc.c revision 1.46.2.3
      1  1.46.2.3      yamt /*	$NetBSD: sbc.c,v 1.46.2.3 2007/09/03 14:27:21 yamt Exp $	*/
      2       1.1    scottr 
      3       1.1    scottr /*
      4      1.19    scottr  * Copyright (C) 1996 Scott Reynolds.  All rights reserved.
      5       1.1    scottr  *
      6       1.1    scottr  * Redistribution and use in source and binary forms, with or without
      7       1.1    scottr  * modification, are permitted provided that the following conditions
      8       1.1    scottr  * are met:
      9       1.1    scottr  * 1. Redistributions of source code must retain the above copyright
     10       1.1    scottr  *    notice, this list of conditions and the following disclaimer.
     11       1.1    scottr  * 2. Redistributions in binary form must reproduce the above copyright
     12       1.1    scottr  *    notice, this list of conditions and the following disclaimer in the
     13       1.1    scottr  *    documentation and/or other materials provided with the distribution.
     14      1.32    scottr  * 3. The name of the author may not be used to endorse or promote products
     15      1.19    scottr  *    derived from this software without specific prior written permission
     16       1.1    scottr  *
     17      1.19    scottr  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18       1.1    scottr  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19       1.1    scottr  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20      1.19    scottr  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21       1.1    scottr  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22       1.1    scottr  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23       1.1    scottr  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24       1.1    scottr  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25       1.1    scottr  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26       1.1    scottr  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27       1.1    scottr  */
     28       1.1    scottr 
     29       1.1    scottr /*
     30       1.1    scottr  * This file contains only the machine-dependent parts of the mac68k
     31       1.1    scottr  * NCR 5380 SCSI driver.  (Autoconfig stuff and PDMA functions.)
     32       1.1    scottr  * The machine-independent parts are in ncr5380sbc.c
     33       1.1    scottr  *
     34       1.1    scottr  * Supported hardware includes:
     35       1.1    scottr  * Macintosh II family 5380-based controller
     36       1.1    scottr  *
     37       1.1    scottr  * Credits, history:
     38       1.1    scottr  *
     39       1.1    scottr  * Scott Reynolds wrote this module, based on work by Allen Briggs
     40       1.9    scottr  * (mac68k), Gordon W. Ross and David Jones (sun3), and Leo Weppelman
     41       1.9    scottr  * (atari).  Thanks to Allen for supplying crucial interpretation of the
     42       1.9    scottr  * NetBSD/mac68k 1.1 'ncrscsi' driver.  Also, Allen, Gordon, and Jason
     43       1.9    scottr  * Thorpe all helped to refine this code, and were considerable sources
     44       1.9    scottr  * of moral support.
     45       1.1    scottr  */
     46      1.44     lukem 
     47      1.44     lukem #include <sys/cdefs.h>
     48  1.46.2.3      yamt __KERNEL_RCSID(0, "$NetBSD: sbc.c,v 1.46.2.3 2007/09/03 14:27:21 yamt Exp $");
     49      1.44     lukem 
     50      1.36  jonathan #include "opt_ddb.h"
     51       1.1    scottr 
     52       1.1    scottr #include <sys/types.h>
     53       1.1    scottr #include <sys/param.h>
     54       1.1    scottr #include <sys/systm.h>
     55       1.1    scottr #include <sys/kernel.h>
     56       1.1    scottr #include <sys/errno.h>
     57       1.1    scottr #include <sys/device.h>
     58       1.1    scottr #include <sys/buf.h>
     59       1.1    scottr #include <sys/proc.h>
     60       1.1    scottr #include <sys/user.h>
     61       1.1    scottr 
     62      1.30    bouyer #include <dev/scsipi/scsi_all.h>
     63      1.30    bouyer #include <dev/scsipi/scsipi_all.h>
     64      1.30    bouyer #include <dev/scsipi/scsipi_debug.h>
     65      1.30    bouyer #include <dev/scsipi/scsiconf.h>
     66       1.1    scottr 
     67       1.1    scottr #include <dev/ic/ncr5380reg.h>
     68       1.1    scottr #include <dev/ic/ncr5380var.h>
     69       1.1    scottr 
     70       1.8    scottr #include <machine/cpu.h>
     71       1.1    scottr #include <machine/viareg.h>
     72       1.1    scottr 
     73      1.29    scottr #include <mac68k/dev/sbcreg.h>
     74      1.29    scottr #include <mac68k/dev/sbcvar.h>
     75      1.36  jonathan 
     76      1.36  jonathan /* SBC_DEBUG --  relies on DDB */
     77      1.36  jonathan #ifdef SBC_DEBUG
     78      1.36  jonathan # define	SBC_DB_INTR	0x01
     79      1.36  jonathan # define	SBC_DB_DMA	0x02
     80      1.36  jonathan # define	SBC_DB_REG	0x04
     81      1.36  jonathan # define	SBC_DB_BREAK	0x08
     82      1.36  jonathan # ifndef DDB
     83      1.36  jonathan #  define	Debugger()	printf("Debug: sbc.c:%d\n", __LINE__)
     84      1.36  jonathan # endif
     85      1.36  jonathan # define	SBC_BREAK \
     86      1.36  jonathan 		do { if (sbc_debug & SBC_DB_BREAK) Debugger(); } while (0)
     87      1.36  jonathan #else
     88      1.36  jonathan # define	SBC_BREAK
     89      1.36  jonathan #endif
     90      1.36  jonathan 
     91       1.1    scottr 
     92      1.22    scottr int	sbc_debug = 0 /* | SBC_DB_INTR | SBC_DB_DMA */;
     93      1.22    scottr int	sbc_link_flags = 0 /* | SDEV_DB2 */;
     94      1.24    scottr int	sbc_options = 0 /* | SBC_PDMA */;
     95       1.1    scottr 
     96      1.31    scottr extern label_t	*nofault;
     97  1.46.2.3      yamt extern void *	m68k_fault_addr;
     98      1.31    scottr 
     99      1.45       chs static	int	sbc_wait_busy(struct ncr5380_softc *);
    100      1.45       chs static	int	sbc_ready(struct ncr5380_softc *);
    101      1.45       chs static	int	sbc_wait_dreq(struct ncr5380_softc *);
    102       1.1    scottr 
    103       1.1    scottr 
    104       1.1    scottr /***
    105       1.1    scottr  * General support for Mac-specific SCSI logic.
    106       1.1    scottr  ***/
    107       1.1    scottr 
    108      1.28    scottr /* These are used in the following inline functions. */
    109      1.28    scottr int sbc_wait_busy_timo = 1000 * 5000;	/* X2 = 10 S. */
    110      1.28    scottr int sbc_ready_timo = 1000 * 5000;	/* X2 = 10 S. */
    111      1.28    scottr int sbc_wait_dreq_timo = 1000 * 5000;	/* X2 = 10 S. */
    112      1.28    scottr 
    113      1.28    scottr /* Return zero on success. */
    114  1.46.2.1      yamt static inline int
    115      1.45       chs sbc_wait_busy(struct ncr5380_softc *sc)
    116      1.28    scottr {
    117      1.28    scottr 	int timo = sbc_wait_busy_timo;
    118      1.28    scottr 	for (;;) {
    119      1.28    scottr 		if (SCI_BUSY(sc)) {
    120      1.28    scottr 			timo = 0;	/* return 0 */
    121      1.28    scottr 			break;
    122      1.28    scottr 		}
    123      1.28    scottr 		if (--timo < 0)
    124      1.28    scottr 			break;	/* return -1 */
    125      1.28    scottr 		delay(2);
    126      1.28    scottr 	}
    127      1.28    scottr 	return (timo);
    128      1.28    scottr }
    129      1.28    scottr 
    130  1.46.2.1      yamt static inline int
    131      1.45       chs sbc_ready(struct ncr5380_softc *sc)
    132      1.28    scottr {
    133      1.28    scottr 	int timo = sbc_ready_timo;
    134      1.28    scottr 
    135      1.28    scottr 	for (;;) {
    136      1.28    scottr 		if ((*sc->sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH))
    137      1.28    scottr 		    == (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    138      1.28    scottr 			timo = 0;
    139      1.28    scottr 			break;
    140      1.28    scottr 		}
    141      1.28    scottr 		if (((*sc->sci_csr & SCI_CSR_PHASE_MATCH) == 0)
    142      1.28    scottr 		    || (SCI_BUSY(sc) == 0)) {
    143      1.28    scottr 			timo = -1;
    144      1.28    scottr 			break;
    145      1.28    scottr 		}
    146      1.28    scottr 		if (--timo < 0)
    147      1.28    scottr 			break;	/* return -1 */
    148      1.28    scottr 		delay(2);
    149      1.28    scottr 	}
    150      1.28    scottr 	return (timo);
    151      1.28    scottr }
    152      1.28    scottr 
    153  1.46.2.1      yamt static inline int
    154      1.45       chs sbc_wait_dreq(struct ncr5380_softc *sc)
    155      1.28    scottr {
    156      1.28    scottr 	int timo = sbc_wait_dreq_timo;
    157      1.28    scottr 
    158      1.28    scottr 	for (;;) {
    159      1.28    scottr 		if ((*sc->sci_csr & (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH))
    160      1.28    scottr 		    == (SCI_CSR_DREQ|SCI_CSR_PHASE_MATCH)) {
    161      1.28    scottr 			timo = 0;
    162      1.28    scottr 			break;
    163      1.28    scottr 		}
    164      1.28    scottr 		if (--timo < 0)
    165      1.28    scottr 			break;	/* return -1 */
    166      1.28    scottr 		delay(2);
    167      1.28    scottr 	}
    168      1.28    scottr 	return (timo);
    169      1.28    scottr }
    170      1.28    scottr 
    171       1.1    scottr void
    172      1.45       chs sbc_irq_intr(void *p)
    173       1.1    scottr {
    174      1.23    scottr 	struct ncr5380_softc *ncr_sc = p;
    175      1.33    scottr 	struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
    176      1.23    scottr 	int claimed = 0;
    177       1.1    scottr 
    178       1.1    scottr 	/* How we ever arrive here without IRQ set is a mystery... */
    179       1.1    scottr 	if (*ncr_sc->sci_csr & SCI_CSR_INT) {
    180       1.3    scottr #ifdef SBC_DEBUG
    181       1.3    scottr 		if (sbc_debug & SBC_DB_INTR)
    182       1.3    scottr 			decode_5380_intr(ncr_sc);
    183       1.3    scottr #endif
    184      1.33    scottr 		if (!cold)
    185      1.33    scottr 			claimed = ncr5380_intr(ncr_sc);
    186       1.1    scottr 		if (!claimed) {
    187       1.1    scottr 			if (((*ncr_sc->sci_csr & ~SCI_CSR_PHASE_MATCH) == SCI_CSR_INT)
    188      1.33    scottr 			    && ((*ncr_sc->sci_bus_csr & ~SCI_BUS_RST) == 0)) {
    189       1.1    scottr 				SCI_CLR_INTR(ncr_sc);	/* RST interrupt */
    190      1.33    scottr 				if (sc->sc_clrintr)
    191      1.33    scottr 					(*sc->sc_clrintr)(ncr_sc);
    192      1.33    scottr 			}
    193       1.1    scottr #ifdef SBC_DEBUG
    194       1.1    scottr 			else {
    195      1.13  christos 				printf("%s: spurious intr\n",
    196       1.1    scottr 				    ncr_sc->sc_dev.dv_xname);
    197       1.3    scottr 				SBC_BREAK;
    198       1.1    scottr 			}
    199       1.1    scottr #endif
    200       1.1    scottr 		}
    201       1.1    scottr 	}
    202       1.1    scottr }
    203       1.1    scottr 
    204       1.3    scottr #ifdef SBC_DEBUG
    205       1.3    scottr void
    206      1.45       chs decode_5380_intr(struct ncr5380_softc *ncr_sc)
    207       1.3    scottr {
    208      1.28    scottr 	u_int8_t csr = *ncr_sc->sci_csr;
    209      1.28    scottr 	u_int8_t bus_csr = *ncr_sc->sci_bus_csr;
    210       1.3    scottr 
    211       1.3    scottr 	if (((csr & ~(SCI_CSR_PHASE_MATCH | SCI_CSR_ATN)) == SCI_CSR_INT) &&
    212       1.3    scottr 	    ((bus_csr & ~(SCI_BUS_MSG | SCI_BUS_CD | SCI_BUS_IO | SCI_BUS_DBP)) == SCI_BUS_SEL)) {
    213       1.3    scottr 		if (csr & SCI_BUS_IO)
    214      1.13  christos 			printf("%s: reselect\n", ncr_sc->sc_dev.dv_xname);
    215       1.3    scottr 		else
    216      1.13  christos 			printf("%s: select\n", ncr_sc->sc_dev.dv_xname);
    217       1.3    scottr 	} else if (((csr & ~SCI_CSR_ACK) == (SCI_CSR_DONE | SCI_CSR_INT)) &&
    218       1.3    scottr 	    ((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_SEL)) == SCI_BUS_BSY))
    219      1.43       wiz 		printf("%s: DMA eop\n", ncr_sc->sc_dev.dv_xname);
    220       1.3    scottr 	else if (((csr & ~SCI_CSR_PHASE_MATCH) == SCI_CSR_INT) &&
    221       1.3    scottr 	    ((bus_csr & ~SCI_BUS_RST) == 0))
    222      1.13  christos 		printf("%s: bus reset\n", ncr_sc->sc_dev.dv_xname);
    223       1.3    scottr 	else if (((csr & ~(SCI_CSR_DREQ | SCI_CSR_ATN | SCI_CSR_ACK)) == (SCI_CSR_PERR | SCI_CSR_INT | SCI_CSR_PHASE_MATCH)) &&
    224       1.3    scottr 	    ((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_SEL)) == SCI_BUS_BSY))
    225      1.13  christos 		printf("%s: parity error\n", ncr_sc->sc_dev.dv_xname);
    226       1.3    scottr 	else if (((csr & ~SCI_CSR_ATN) == SCI_CSR_INT) &&
    227       1.3    scottr 	    ((bus_csr & (SCI_BUS_RST | SCI_BUS_BSY | SCI_BUS_REQ | SCI_BUS_SEL)) == (SCI_BUS_BSY | SCI_BUS_REQ)))
    228      1.13  christos 		printf("%s: phase mismatch\n", ncr_sc->sc_dev.dv_xname);
    229       1.3    scottr 	else if (((csr & ~SCI_CSR_PHASE_MATCH) == (SCI_CSR_INT | SCI_CSR_DISC)) &&
    230       1.3    scottr 	    (bus_csr == 0))
    231      1.13  christos 		printf("%s: disconnect\n", ncr_sc->sc_dev.dv_xname);
    232       1.3    scottr 	else
    233      1.13  christos 		printf("%s: unknown intr: csr=%x, bus_csr=%x\n",
    234       1.3    scottr 		    ncr_sc->sc_dev.dv_xname, csr, bus_csr);
    235       1.3    scottr }
    236       1.3    scottr #endif
    237       1.1    scottr 
    238       1.8    scottr 
    239       1.1    scottr /***
    240       1.1    scottr  * The following code implements polled PDMA.
    241       1.1    scottr  ***/
    242       1.1    scottr 
    243      1.23    scottr int
    244      1.45       chs sbc_pdma_in(struct ncr5380_softc *ncr_sc, int phase, int datalen, u_char *data)
    245      1.23    scottr {
    246      1.23    scottr 	struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
    247      1.24    scottr 	volatile u_int32_t *long_data = (u_int32_t *)sc->sc_drq_addr;
    248      1.24    scottr 	volatile u_int8_t *byte_data = (u_int8_t *)sc->sc_nodrq_addr;
    249  1.46.2.1      yamt 	label_t faultbuf;
    250      1.23    scottr 	int resid, s;
    251      1.23    scottr 
    252      1.28    scottr 	if (datalen < ncr_sc->sc_min_dma_len ||
    253      1.28    scottr 	    (sc->sc_options & SBC_PDMA) == 0)
    254      1.28    scottr 		return ncr5380_pio_in(ncr_sc, phase, datalen, data);
    255      1.28    scottr 
    256      1.23    scottr 	s = splbio();
    257      1.28    scottr 	if (sbc_wait_busy(ncr_sc)) {
    258      1.28    scottr 		splx(s);
    259      1.28    scottr 		return 0;
    260      1.28    scottr 	}
    261      1.28    scottr 
    262      1.23    scottr 	*ncr_sc->sci_mode |= SCI_MODE_DMA;
    263      1.23    scottr 	*ncr_sc->sci_irecv = 0;
    264       1.1    scottr 
    265  1.46.2.1      yamt 	resid = datalen;
    266  1.46.2.1      yamt 
    267  1.46.2.1      yamt 	/*
    268  1.46.2.1      yamt 	 * Setup for a possible bus error caused by SCSI controller
    269  1.46.2.1      yamt 	 * switching out of DATA OUT before we're done with the
    270  1.46.2.1      yamt 	 * current transfer.  (See comment before sbc_drq_intr().)
    271  1.46.2.1      yamt 	 */
    272  1.46.2.1      yamt 	nofault = &faultbuf;
    273  1.46.2.1      yamt 	if (setjmp(nofault)) {
    274  1.46.2.1      yamt 		goto interrupt;
    275  1.46.2.1      yamt 	}
    276  1.46.2.1      yamt 
    277  1.46.2.1      yamt #define R4	*(u_int32_t *)data = *long_data, data += 4;
    278  1.46.2.1      yamt #define R1	*(u_int8_t *)data = *byte_data, data += 1;
    279  1.46.2.1      yamt 	for (; resid >= 128; resid -= 128) {
    280      1.28    scottr 		if (sbc_ready(ncr_sc))
    281      1.23    scottr 			goto interrupt;
    282      1.23    scottr 		R4; R4; R4; R4; R4; R4; R4; R4;
    283      1.23    scottr 		R4; R4; R4; R4; R4; R4; R4; R4;
    284      1.23    scottr 		R4; R4; R4; R4; R4; R4; R4; R4;
    285      1.28    scottr 		R4; R4; R4; R4; R4; R4; R4; R4;		/* 128 */
    286      1.23    scottr 	}
    287      1.23    scottr 	while (resid) {
    288      1.28    scottr 		if (sbc_ready(ncr_sc))
    289      1.23    scottr 			goto interrupt;
    290      1.23    scottr 		R1;
    291      1.23    scottr 		resid--;
    292       1.1    scottr 	}
    293      1.23    scottr #undef R4
    294      1.23    scottr #undef R1
    295       1.1    scottr 
    296      1.23    scottr interrupt:
    297  1.46.2.1      yamt 	nofault = NULL;
    298       1.1    scottr 	SCI_CLR_INTR(ncr_sc);
    299       1.1    scottr 	*ncr_sc->sci_mode &= ~SCI_MODE_DMA;
    300      1.28    scottr 	*ncr_sc->sci_icmd = 0;
    301      1.23    scottr 	splx(s);
    302      1.28    scottr 	return (datalen - resid);
    303       1.1    scottr }
    304       1.1    scottr 
    305      1.22    scottr int
    306      1.45       chs sbc_pdma_out(struct ncr5380_softc *ncr_sc, int phase, int datalen, u_char *data)
    307       1.1    scottr {
    308       1.1    scottr 	struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
    309      1.24    scottr 	volatile u_int32_t *long_data = (u_int32_t *)sc->sc_drq_addr;
    310      1.24    scottr 	volatile u_int8_t *byte_data = (u_int8_t *)sc->sc_nodrq_addr;
    311      1.31    scottr 	label_t faultbuf;
    312      1.28    scottr 	int resid, s;
    313      1.28    scottr 	u_int8_t icmd;
    314      1.23    scottr 
    315      1.31    scottr #if 1
    316      1.31    scottr 	/* Work around lame gcc initialization bug */
    317      1.31    scottr 	(void)&data;
    318      1.31    scottr #endif
    319      1.31    scottr 
    320      1.28    scottr 	if (datalen < ncr_sc->sc_min_dma_len ||
    321      1.28    scottr 	    (sc->sc_options & SBC_PDMA) == 0)
    322      1.24    scottr 		return ncr5380_pio_out(ncr_sc, phase, datalen, data);
    323      1.24    scottr 
    324      1.23    scottr 	s = splbio();
    325      1.28    scottr 	if (sbc_wait_busy(ncr_sc)) {
    326      1.28    scottr 		splx(s);
    327      1.28    scottr 		return 0;
    328      1.28    scottr 	}
    329      1.28    scottr 
    330      1.23    scottr 	icmd = *(ncr_sc->sci_icmd) & SCI_ICMD_RMASK;
    331      1.23    scottr 	*ncr_sc->sci_icmd = icmd | SCI_ICMD_DATA;
    332      1.23    scottr 	*ncr_sc->sci_mode |= SCI_MODE_DMA;
    333      1.23    scottr 	*ncr_sc->sci_dma_send = 0;
    334      1.23    scottr 
    335      1.31    scottr 	/*
    336      1.31    scottr 	 * Setup for a possible bus error caused by SCSI controller
    337      1.31    scottr 	 * switching out of DATA OUT before we're done with the
    338      1.31    scottr 	 * current transfer.  (See comment before sbc_drq_intr().)
    339      1.31    scottr 	 */
    340      1.31    scottr 	nofault = &faultbuf;
    341      1.31    scottr 
    342      1.31    scottr 	if (setjmp(nofault)) {
    343      1.31    scottr 		printf("buf = 0x%lx, fault = 0x%lx\n",
    344      1.31    scottr 		    (u_long)sc->sc_drq_addr, (u_long)m68k_fault_addr);
    345      1.31    scottr 		panic("Unexpected bus error in sbc_pdma_out()");
    346      1.31    scottr 	}
    347      1.31    scottr 
    348  1.46.2.1      yamt #define W1	*byte_data = *(u_int8_t *)data, data += 1
    349  1.46.2.1      yamt #define W4	*long_data = *(u_int32_t *)data, data += 4
    350      1.28    scottr 	for (resid = datalen; resid >= 64; resid -= 64) {
    351      1.28    scottr 		if (sbc_ready(ncr_sc))
    352      1.23    scottr 			goto interrupt;
    353      1.23    scottr 		W1;
    354      1.28    scottr 		if (sbc_ready(ncr_sc))
    355      1.23    scottr 			goto interrupt;
    356      1.23    scottr 		W1;
    357      1.28    scottr 		if (sbc_ready(ncr_sc))
    358      1.23    scottr 			goto interrupt;
    359      1.23    scottr 		W1;
    360      1.28    scottr 		if (sbc_ready(ncr_sc))
    361      1.23    scottr 			goto interrupt;
    362      1.23    scottr 		W1;
    363      1.28    scottr 		if (sbc_ready(ncr_sc))
    364      1.23    scottr 			goto interrupt;
    365      1.23    scottr 		W4; W4; W4; W4;
    366      1.23    scottr 		W4; W4; W4; W4;
    367      1.23    scottr 		W4; W4; W4; W4;
    368      1.23    scottr 		W4; W4; W4;
    369      1.23    scottr 	}
    370      1.28    scottr 	while (resid) {
    371      1.28    scottr 		if (sbc_ready(ncr_sc))
    372      1.23    scottr 			goto interrupt;
    373      1.23    scottr 		W1;
    374      1.28    scottr 		resid--;
    375      1.23    scottr 	}
    376      1.23    scottr #undef  W1
    377      1.23    scottr #undef  W4
    378      1.28    scottr 	if (sbc_wait_dreq(ncr_sc))
    379      1.28    scottr 		printf("%s: timeout waiting for DREQ.\n",
    380      1.28    scottr 		    ncr_sc->sc_dev.dv_xname);
    381      1.28    scottr 
    382      1.28    scottr 	*byte_data = 0;
    383      1.28    scottr 	goto done;
    384       1.1    scottr 
    385      1.28    scottr interrupt:
    386      1.28    scottr 	if ((*ncr_sc->sci_csr & SCI_CSR_PHASE_MATCH) == 0) {
    387      1.28    scottr 		*ncr_sc->sci_icmd = icmd & ~SCI_ICMD_DATA;
    388      1.28    scottr 		--resid;
    389       1.1    scottr 	}
    390       1.1    scottr 
    391      1.28    scottr done:
    392       1.1    scottr 	SCI_CLR_INTR(ncr_sc);
    393       1.1    scottr 	*ncr_sc->sci_mode &= ~SCI_MODE_DMA;
    394      1.23    scottr 	*ncr_sc->sci_icmd = icmd;
    395      1.23    scottr 	splx(s);
    396      1.23    scottr 	return (datalen - resid);
    397       1.1    scottr }
    398       1.1    scottr 
    399       1.1    scottr 
    400       1.1    scottr /***
    401       1.1    scottr  * The following code implements interrupt-driven PDMA.
    402       1.1    scottr  ***/
    403       1.1    scottr 
    404       1.1    scottr /*
    405       1.1    scottr  * This is the meat of the PDMA transfer.
    406       1.1    scottr  * When we get here, we shove data as fast as the mac can take it.
    407       1.1    scottr  * We depend on several things:
    408       1.1    scottr  *   * All macs after the Mac Plus that have a 5380 chip should have a general
    409       1.1    scottr  *     logic IC that handshakes data for blind transfers.
    410       1.1    scottr  *   * If the SCSI controller finishes sending/receiving data before we do,
    411       1.1    scottr  *     the same general logic IC will generate a /BERR for us in short order.
    412       1.1    scottr  *   * The fault address for said /BERR minus the base address for the
    413       1.1    scottr  *     transfer will be the amount of data that was actually written.
    414       1.1    scottr  *
    415       1.1    scottr  * We use the nofault flag and the setjmp/longjmp in locore.s so we can
    416       1.1    scottr  * detect and handle the bus error for early termination of a command.
    417       1.1    scottr  * This is usually caused by a disconnecting target.
    418       1.1    scottr  */
    419       1.1    scottr void
    420      1.45       chs sbc_drq_intr(void *p)
    421       1.1    scottr {
    422      1.24    scottr 	struct sbc_softc *sc = (struct sbc_softc *)p;
    423      1.24    scottr 	struct ncr5380_softc *ncr_sc = (struct ncr5380_softc *)p;
    424      1.23    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    425      1.23    scottr 	struct sbc_pdma_handle *dh = sr->sr_dma_hand;
    426      1.23    scottr 	label_t faultbuf;
    427      1.23    scottr 	volatile u_int32_t *long_drq;
    428      1.23    scottr 	u_int32_t *long_data;
    429  1.46.2.2      yamt 	volatile u_int8_t *drq = 0;	/* XXX gcc4 -Wuninitialized */
    430      1.23    scottr 	u_int8_t *data;
    431      1.23    scottr 	int count, dcount, resid;
    432      1.23    scottr 	u_int8_t tmp;
    433      1.26    scottr 
    434       1.1    scottr 	/*
    435       1.1    scottr 	 * If we're not ready to xfer data, or have no more, just return.
    436       1.1    scottr 	 */
    437       1.3    scottr 	if ((*ncr_sc->sci_csr & SCI_CSR_DREQ) == 0 || dh->dh_len == 0)
    438       1.1    scottr 		return;
    439       1.1    scottr 
    440       1.1    scottr #ifdef SBC_DEBUG
    441       1.1    scottr 	if (sbc_debug & SBC_DB_INTR)
    442      1.13  christos 		printf("%s: drq intr, dh_len=0x%x, dh_flags=0x%x\n",
    443       1.1    scottr 		    ncr_sc->sc_dev.dv_xname, dh->dh_len, dh->dh_flags);
    444       1.1    scottr #endif
    445       1.1    scottr 
    446       1.1    scottr 	/*
    447       1.1    scottr 	 * Setup for a possible bus error caused by SCSI controller
    448       1.1    scottr 	 * switching out of DATA-IN/OUT before we're done with the
    449       1.1    scottr 	 * current transfer.
    450       1.1    scottr 	 */
    451      1.31    scottr 	nofault = &faultbuf;
    452       1.1    scottr 
    453      1.33    scottr 	if (setjmp(nofault)) {
    454      1.31    scottr 		nofault = (label_t *)0;
    455       1.8    scottr 		if ((dh->dh_flags & SBC_DH_DONE) == 0) {
    456      1.27    scottr 			count = ((  (u_long)m68k_fault_addr
    457      1.24    scottr 				  - (u_long)sc->sc_drq_addr));
    458       1.8    scottr 
    459       1.8    scottr 			if ((count < 0) || (count > dh->dh_len)) {
    460      1.13  christos 				printf("%s: complete=0x%x (pending 0x%x)\n",
    461       1.8    scottr 				    ncr_sc->sc_dev.dv_xname, count, dh->dh_len);
    462       1.8    scottr 				panic("something is wrong");
    463       1.8    scottr 			}
    464       1.1    scottr 
    465       1.8    scottr 			dh->dh_addr += count;
    466       1.8    scottr 			dh->dh_len -= count;
    467      1.18    scottr 		} else
    468      1.18    scottr 			count = 0;
    469       1.8    scottr 
    470       1.1    scottr #ifdef SBC_DEBUG
    471       1.1    scottr 		if (sbc_debug & SBC_DB_INTR)
    472      1.13  christos 			printf("%s: drq /berr, complete=0x%x (pending 0x%x)\n",
    473       1.8    scottr 			   ncr_sc->sc_dev.dv_xname, count, dh->dh_len);
    474       1.1    scottr #endif
    475      1.27    scottr 		m68k_fault_addr = 0;
    476       1.3    scottr 
    477       1.1    scottr 		return;
    478       1.1    scottr 	}
    479       1.1    scottr 
    480       1.1    scottr 	if (dh->dh_flags & SBC_DH_OUT) { /* Data Out */
    481      1.26    scottr 		dcount = 0;
    482      1.26    scottr 
    483       1.1    scottr 		/*
    484       1.1    scottr 		 * Get the source address aligned.
    485       1.1    scottr 		 */
    486       1.6    scottr 		resid =
    487      1.24    scottr 		    count = min(dh->dh_len, 4 - (((int)dh->dh_addr) & 0x3));
    488       1.1    scottr 		if (count && count < 4) {
    489      1.24    scottr 			drq = (volatile u_int8_t *)sc->sc_drq_addr;
    490      1.24    scottr 			data = (u_int8_t *)dh->dh_addr;
    491       1.8    scottr 
    492       1.1    scottr #define W1		*drq++ = *data++
    493       1.1    scottr 			while (count) {
    494       1.1    scottr 				W1; count--;
    495       1.1    scottr 			}
    496       1.1    scottr #undef W1
    497       1.1    scottr 			dh->dh_addr += resid;
    498       1.1    scottr 			dh->dh_len -= resid;
    499       1.1    scottr 		}
    500       1.1    scottr 
    501       1.1    scottr 		/*
    502       1.8    scottr 		 * Start the transfer.
    503       1.1    scottr 		 */
    504       1.1    scottr 		while (dh->dh_len) {
    505       1.1    scottr 			dcount = count = min(dh->dh_len, MAX_DMA_LEN);
    506      1.24    scottr 			long_drq = (volatile u_int32_t *)sc->sc_drq_addr;
    507      1.24    scottr 			long_data = (u_int32_t *)dh->dh_addr;
    508       1.1    scottr 
    509       1.1    scottr #define W4		*long_drq++ = *long_data++
    510       1.1    scottr 			while (count >= 64) {
    511       1.1    scottr 				W4; W4; W4; W4; W4; W4; W4; W4;
    512       1.1    scottr 				W4; W4; W4; W4; W4; W4; W4; W4; /*  64 */
    513       1.1    scottr 				count -= 64;
    514       1.1    scottr 			}
    515       1.1    scottr 			while (count >= 4) {
    516       1.1    scottr 				W4; count -= 4;
    517       1.1    scottr 			}
    518       1.1    scottr #undef W4
    519      1.24    scottr 			data = (u_int8_t *)long_data;
    520      1.46       jmc 			drq = (volatile u_int8_t *)long_drq;
    521       1.8    scottr 
    522       1.7    scottr #define W1		*drq++ = *data++
    523       1.7    scottr 			while (count) {
    524       1.7    scottr 				W1; count--;
    525       1.7    scottr 			}
    526       1.7    scottr #undef W1
    527       1.7    scottr 			dh->dh_len -= dcount;
    528       1.7    scottr 			dh->dh_addr += dcount;
    529       1.7    scottr 		}
    530       1.8    scottr 		dh->dh_flags |= SBC_DH_DONE;
    531       1.7    scottr 
    532       1.7    scottr 		/*
    533       1.8    scottr 		 * XXX -- Read a byte from the SBC to trigger a /BERR.
    534       1.8    scottr 		 * This seems to be necessary for us to notice that
    535       1.8    scottr 		 * the target has disconnected.  Ick.  06 jun 1996 (sr)
    536       1.7    scottr 		 */
    537      1.26    scottr 		if (dcount >= MAX_DMA_LEN)
    538      1.24    scottr 			drq = (volatile u_int8_t *)sc->sc_drq_addr;
    539       1.8    scottr 		tmp = *drq;
    540       1.1    scottr 	} else {	/* Data In */
    541       1.1    scottr 		/*
    542       1.1    scottr 		 * Get the dest address aligned.
    543       1.1    scottr 		 */
    544       1.6    scottr 		resid =
    545      1.24    scottr 		    count = min(dh->dh_len, 4 - (((int)dh->dh_addr) & 0x3));
    546       1.1    scottr 		if (count && count < 4) {
    547      1.24    scottr 			data = (u_int8_t *)dh->dh_addr;
    548      1.24    scottr 			drq = (volatile u_int8_t *)sc->sc_drq_addr;
    549       1.8    scottr 
    550       1.1    scottr #define R1		*data++ = *drq++
    551       1.1    scottr 			while (count) {
    552       1.1    scottr 				R1; count--;
    553       1.1    scottr 			}
    554       1.1    scottr #undef R1
    555       1.1    scottr 			dh->dh_addr += resid;
    556       1.1    scottr 			dh->dh_len -= resid;
    557       1.1    scottr 		}
    558       1.1    scottr 
    559       1.1    scottr 		/*
    560       1.8    scottr 		 * Start the transfer.
    561       1.1    scottr 		 */
    562       1.1    scottr 		while (dh->dh_len) {
    563       1.1    scottr 			dcount = count = min(dh->dh_len, MAX_DMA_LEN);
    564      1.24    scottr 			long_data = (u_int32_t *)dh->dh_addr;
    565      1.24    scottr 			long_drq = (volatile u_int32_t *)sc->sc_drq_addr;
    566       1.1    scottr 
    567       1.1    scottr #define R4		*long_data++ = *long_drq++
    568       1.8    scottr 			while (count >= 64) {
    569       1.1    scottr 				R4; R4; R4; R4; R4; R4; R4; R4;
    570       1.1    scottr 				R4; R4; R4; R4; R4; R4; R4; R4;	/* 64 */
    571       1.8    scottr 				count -= 64;
    572       1.1    scottr 			}
    573       1.1    scottr 			while (count >= 4) {
    574       1.1    scottr 				R4; count -= 4;
    575       1.1    scottr 			}
    576       1.1    scottr #undef R4
    577      1.24    scottr 			data = (u_int8_t *)long_data;
    578      1.24    scottr 			drq = (volatile u_int8_t *)long_drq;
    579       1.8    scottr 
    580       1.1    scottr #define R1		*data++ = *drq++
    581       1.1    scottr 			while (count) {
    582       1.1    scottr 				R1; count--;
    583       1.1    scottr 			}
    584       1.1    scottr #undef R1
    585       1.1    scottr 			dh->dh_len -= dcount;
    586       1.1    scottr 			dh->dh_addr += dcount;
    587       1.1    scottr 		}
    588       1.8    scottr 		dh->dh_flags |= SBC_DH_DONE;
    589       1.1    scottr 	}
    590       1.1    scottr 
    591       1.1    scottr 	/*
    592       1.1    scottr 	 * OK.  No bus error occurred above.  Clear the nofault flag
    593       1.1    scottr 	 * so we no longer short-circuit bus errors.
    594       1.1    scottr 	 */
    595      1.31    scottr 	nofault = (label_t *)0;
    596       1.7    scottr 
    597       1.7    scottr #ifdef SBC_DEBUG
    598       1.7    scottr 	if (sbc_debug & (SBC_DB_REG | SBC_DB_INTR))
    599      1.13  christos 		printf("%s: drq intr complete: csr=0x%x, bus_csr=0x%x\n",
    600       1.7    scottr 		    ncr_sc->sc_dev.dv_xname, *ncr_sc->sci_csr,
    601       1.7    scottr 		    *ncr_sc->sci_bus_csr);
    602       1.7    scottr #endif
    603       1.1    scottr }
    604       1.1    scottr 
    605       1.1    scottr void
    606      1.45       chs sbc_dma_alloc(struct ncr5380_softc *ncr_sc)
    607       1.1    scottr {
    608      1.24    scottr 	struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
    609       1.1    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    610      1.30    bouyer 	struct scsipi_xfer *xs = sr->sr_xs;
    611       1.1    scottr 	struct sbc_pdma_handle *dh;
    612       1.1    scottr 	int		i, xlen;
    613       1.1    scottr 
    614       1.6    scottr #ifdef DIAGNOSTIC
    615       1.1    scottr 	if (sr->sr_dma_hand != NULL)
    616       1.1    scottr 		panic("sbc_dma_alloc: already have PDMA handle");
    617       1.1    scottr #endif
    618       1.1    scottr 
    619       1.1    scottr 	/* Polled transfers shouldn't allocate a PDMA handle. */
    620       1.1    scottr 	if (sr->sr_flags & SR_IMMED)
    621       1.1    scottr 		return;
    622       1.1    scottr 
    623       1.1    scottr 	xlen = ncr_sc->sc_datalen;
    624       1.1    scottr 
    625       1.1    scottr 	/* Make sure our caller checked sc_min_dma_len. */
    626       1.1    scottr 	if (xlen < MIN_DMA_LEN)
    627      1.42    provos 		panic("sbc_dma_alloc: len=0x%x", xlen);
    628       1.1    scottr 
    629       1.1    scottr 	/*
    630       1.1    scottr 	 * Find free PDMA handle.  Guaranteed to find one since we
    631       1.1    scottr 	 * have as many PDMA handles as the driver has processes.
    632       1.1    scottr 	 * (instances?)
    633       1.1    scottr 	 */
    634       1.1    scottr 	 for (i = 0; i < SCI_OPENINGS; i++) {
    635       1.1    scottr 		if ((sc->sc_pdma[i].dh_flags & SBC_DH_BUSY) == 0)
    636       1.1    scottr 			goto found;
    637       1.1    scottr 	}
    638       1.1    scottr 	panic("sbc: no free PDMA handles");
    639       1.1    scottr found:
    640       1.1    scottr 	dh = &sc->sc_pdma[i];
    641       1.1    scottr 	dh->dh_flags = SBC_DH_BUSY;
    642       1.1    scottr 	dh->dh_addr = ncr_sc->sc_dataptr;
    643       1.1    scottr 	dh->dh_len = xlen;
    644       1.1    scottr 
    645       1.1    scottr 	/* Copy the 'write' flag for convenience. */
    646      1.40    scottr 	if (xs->xs_control & XS_CTL_DATA_OUT)
    647       1.1    scottr 		dh->dh_flags |= SBC_DH_OUT;
    648       1.1    scottr 
    649       1.1    scottr 	sr->sr_dma_hand = dh;
    650       1.1    scottr }
    651       1.1    scottr 
    652       1.1    scottr void
    653      1.45       chs sbc_dma_free(struct ncr5380_softc *ncr_sc)
    654       1.1    scottr {
    655       1.1    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    656       1.1    scottr 	struct sbc_pdma_handle *dh = sr->sr_dma_hand;
    657       1.1    scottr 
    658       1.6    scottr #ifdef DIAGNOSTIC
    659       1.1    scottr 	if (sr->sr_dma_hand == NULL)
    660       1.1    scottr 		panic("sbc_dma_free: no DMA handle");
    661       1.1    scottr #endif
    662       1.1    scottr 
    663       1.1    scottr 	if (ncr_sc->sc_state & NCR_DOINGDMA)
    664       1.1    scottr 		panic("sbc_dma_free: free while in progress");
    665       1.1    scottr 
    666       1.1    scottr 	if (dh->dh_flags & SBC_DH_BUSY) {
    667       1.1    scottr 		dh->dh_flags = 0;
    668       1.1    scottr 		dh->dh_addr = NULL;
    669       1.1    scottr 		dh->dh_len = 0;
    670       1.1    scottr 	}
    671       1.1    scottr 	sr->sr_dma_hand = NULL;
    672       1.1    scottr }
    673       1.1    scottr 
    674       1.1    scottr void
    675      1.45       chs sbc_dma_poll(struct ncr5380_softc *ncr_sc)
    676       1.1    scottr {
    677       1.1    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    678       1.1    scottr 
    679       1.3    scottr 	/*
    680       1.3    scottr 	 * We shouldn't arrive here; if SR_IMMED is set, then
    681       1.3    scottr 	 * dma_alloc() should have refused to allocate a handle
    682       1.3    scottr 	 * for the transfer.  This forces the polled PDMA code
    683       1.3    scottr 	 * to handle the request...
    684       1.3    scottr 	 */
    685       1.6    scottr #ifdef SBC_DEBUG
    686       1.1    scottr 	if (sbc_debug & SBC_DB_DMA)
    687      1.13  christos 		printf("%s: lost DRQ interrupt?\n", ncr_sc->sc_dev.dv_xname);
    688       1.1    scottr #endif
    689       1.3    scottr 	sr->sr_flags |= SR_OVERDUE;
    690       1.1    scottr }
    691       1.1    scottr 
    692       1.1    scottr void
    693      1.45       chs sbc_dma_setup(struct ncr5380_softc *ncr_sc)
    694       1.1    scottr {
    695       1.1    scottr 	/* Not needed; we don't have real DMA */
    696       1.1    scottr }
    697       1.1    scottr 
    698       1.1    scottr void
    699      1.45       chs sbc_dma_start(struct ncr5380_softc *ncr_sc)
    700       1.1    scottr {
    701      1.24    scottr 	struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
    702       1.1    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    703       1.1    scottr 	struct sbc_pdma_handle *dh = sr->sr_dma_hand;
    704       1.1    scottr 
    705       1.1    scottr 	/*
    706       1.7    scottr 	 * Match bus phase, clear pending interrupts, set DMA mode, and
    707       1.7    scottr 	 * assert data bus (for writing only), then start the transfer.
    708       1.1    scottr 	 */
    709       1.1    scottr 	if (dh->dh_flags & SBC_DH_OUT) {
    710       1.1    scottr 		*ncr_sc->sci_tcmd = PHASE_DATA_OUT;
    711       1.1    scottr 		SCI_CLR_INTR(ncr_sc);
    712      1.22    scottr 		if (sc->sc_clrintr)
    713      1.22    scottr 			(*sc->sc_clrintr)(ncr_sc);
    714       1.1    scottr 		*ncr_sc->sci_mode |= SCI_MODE_DMA;
    715       1.1    scottr 		*ncr_sc->sci_icmd = SCI_ICMD_DATA;
    716       1.1    scottr 		*ncr_sc->sci_dma_send = 0;
    717       1.1    scottr 	} else {
    718       1.1    scottr 		*ncr_sc->sci_tcmd = PHASE_DATA_IN;
    719       1.1    scottr 		SCI_CLR_INTR(ncr_sc);
    720      1.22    scottr 		if (sc->sc_clrintr)
    721      1.22    scottr 			(*sc->sc_clrintr)(ncr_sc);
    722       1.1    scottr 		*ncr_sc->sci_mode |= SCI_MODE_DMA;
    723       1.1    scottr 		*ncr_sc->sci_icmd = 0;
    724       1.1    scottr 		*ncr_sc->sci_irecv = 0;
    725       1.1    scottr 	}
    726       1.3    scottr 	ncr_sc->sc_state |= NCR_DOINGDMA;
    727       1.1    scottr 
    728       1.6    scottr #ifdef SBC_DEBUG
    729       1.1    scottr 	if (sbc_debug & SBC_DB_DMA)
    730      1.13  christos 		printf("%s: PDMA started, va=%p, len=0x%x\n",
    731       1.1    scottr 		    ncr_sc->sc_dev.dv_xname, dh->dh_addr, dh->dh_len);
    732       1.1    scottr #endif
    733       1.1    scottr }
    734       1.1    scottr 
    735       1.1    scottr void
    736      1.45       chs sbc_dma_eop(struct ncr5380_softc *ncr_sc)
    737       1.1    scottr {
    738       1.1    scottr 	/* Not used; the EOP pin is wired high (GMFH, pp. 389-390) */
    739       1.1    scottr }
    740       1.1    scottr 
    741       1.1    scottr void
    742      1.45       chs sbc_dma_stop(struct ncr5380_softc *ncr_sc)
    743       1.1    scottr {
    744      1.24    scottr 	struct sbc_softc *sc = (struct sbc_softc *)ncr_sc;
    745       1.1    scottr 	struct sci_req *sr = ncr_sc->sc_current;
    746       1.1    scottr 	struct sbc_pdma_handle *dh = sr->sr_dma_hand;
    747      1.23    scottr 	int ntrans;
    748       1.1    scottr 
    749       1.1    scottr 	if ((ncr_sc->sc_state & NCR_DOINGDMA) == 0) {
    750       1.1    scottr #ifdef SBC_DEBUG
    751       1.1    scottr 		if (sbc_debug & SBC_DB_DMA)
    752      1.13  christos 			printf("%s: dma_stop: DMA not running\n",
    753       1.1    scottr 			    ncr_sc->sc_dev.dv_xname);
    754       1.1    scottr #endif
    755       1.1    scottr 		return;
    756       1.1    scottr 	}
    757       1.1    scottr 	ncr_sc->sc_state &= ~NCR_DOINGDMA;
    758       1.1    scottr 
    759       1.3    scottr 	if ((ncr_sc->sc_state & NCR_ABORTING) == 0) {
    760       1.1    scottr 		ntrans = ncr_sc->sc_datalen - dh->dh_len;
    761       1.1    scottr 
    762       1.1    scottr #ifdef SBC_DEBUG
    763       1.1    scottr 		if (sbc_debug & SBC_DB_DMA)
    764      1.13  christos 			printf("%s: dma_stop: ntrans=0x%x\n",
    765       1.1    scottr 			    ncr_sc->sc_dev.dv_xname, ntrans);
    766       1.1    scottr #endif
    767       1.1    scottr 
    768       1.1    scottr 		if (ntrans > ncr_sc->sc_datalen)
    769      1.42    provos 			panic("sbc_dma_stop: excess transfer");
    770       1.1    scottr 
    771       1.1    scottr 		/* Adjust data pointer */
    772       1.1    scottr 		ncr_sc->sc_dataptr += ntrans;
    773       1.1    scottr 		ncr_sc->sc_datalen -= ntrans;
    774       1.1    scottr 
    775       1.1    scottr 		/* Clear any pending interrupts. */
    776       1.1    scottr 		SCI_CLR_INTR(ncr_sc);
    777      1.22    scottr 		if (sc->sc_clrintr)
    778      1.22    scottr 			(*sc->sc_clrintr)(ncr_sc);
    779       1.1    scottr 	}
    780       1.1    scottr 
    781       1.1    scottr 	/* Put SBIC back into PIO mode. */
    782       1.1    scottr 	*ncr_sc->sci_mode &= ~SCI_MODE_DMA;
    783       1.1    scottr 	*ncr_sc->sci_icmd = 0;
    784       1.1    scottr 
    785       1.1    scottr #ifdef SBC_DEBUG
    786       1.3    scottr 	if (sbc_debug & SBC_DB_REG)
    787      1.13  christos 		printf("%s: dma_stop: csr=0x%x, bus_csr=0x%x\n",
    788       1.1    scottr 		    ncr_sc->sc_dev.dv_xname, *ncr_sc->sci_csr,
    789       1.1    scottr 		    *ncr_sc->sci_bus_csr);
    790       1.1    scottr #endif
    791       1.1    scottr }
    792