Home | History | Annotate | Line # | Download | only in dev
ivsc.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  *	@(#)ivsdma.c
     35  *	$Id: ivsc.c,v 1.2 1994/05/29 04:50:12 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 <vm/vm.h>		/* XXXX Kludge for IVS Vector - mlh */
     42 #include <scsi/scsi_all.h>
     43 #include <scsi/scsiconf.h>
     44 #include <amiga/amiga/custom.h>
     45 #include <amiga/amiga/device.h>
     46 #include <amiga/dev/scireg.h>
     47 #include <amiga/dev/scivar.h>
     48 #include <amiga/dev/ztwobusvar.h>
     49 
     50 int ivscprint __P((void *auxp, char *));
     51 void ivscattach __P((struct device *, struct device *, void *));
     52 int ivscmatch __P((struct device *, struct cfdata *, void *));
     53 
     54 int ivsc_intr __P((void));
     55 #ifdef notyet
     56 int ivsc_dma_xfer_in __P((struct sci_softc *dev, int len,
     57     register u_char *buf, int phase));
     58 int ivsc_dma_xfer_out __P((struct sci_softc *dev, int len,
     59     register u_char *buf, int phase));
     60 #endif
     61 
     62 struct scsi_adapter ivsc_scsiswitch = {
     63 	sci_scsicmd,
     64 	sci_minphys,
     65 	0,			/* no lun support */
     66 	0,			/* no lun support */
     67 	sci_adinfo,
     68 	"ivsc",
     69 };
     70 
     71 struct scsi_device ivsc_scsidev = {
     72 	NULL,		/* use default error handler */
     73 	NULL,		/* do not have a start functio */
     74 	NULL,		/* have no async handler */
     75 	NULL,		/* Use default done routine */
     76 	"ivsc",
     77 	0,
     78 };
     79 
     80 #define QPRINTF
     81 
     82 #ifdef DEBUG
     83 extern int sci_debug;
     84 #endif
     85 
     86 extern int sci_data_wait;
     87 
     88 struct cfdriver ivsccd = {
     89 	NULL, "ivsc", ivscmatch, ivscattach,
     90 	DV_DULL, sizeof(struct sci_softc), NULL, 0 };
     91 
     92 /*
     93  * if this is an IVS board
     94  */
     95 int
     96 ivscmatch(pdp, cdp, auxp)
     97 	struct device *pdp;
     98 	struct cfdata *cdp;
     99 	void *auxp;
    100 {
    101 	struct ztwobus_args *zap;
    102 
    103 	zap = auxp;
    104 
    105 	/*
    106 	 * Check manufacturer and product id.
    107 	 */
    108 	if (zap->manid != 2112 ||	/* If manufacturer is IVS */
    109 	    (zap->prodid != 52 &&	/*   product = Trumpcard */
    110 	    zap->prodid != 243))	/*   product = Vector SCSI */
    111 		return(0);		/* didn't match */
    112 	if (zap->prodid == 243) {
    113 		/*
    114 		 * XXXX Ouch! board addresss isn't Zorro II or Zorro III!
    115 		 * XXXX Kludge it up until I can do it better (MLH).
    116 		 *
    117 		 * XXXX pa 0x00f00000 shouldn't be used for anything
    118 		 */
    119 		if (pmap_extract(kernel_pmap, ztwomap(0x00f00000)) == 0x00f00000) {
    120 			physaccess(ztwomap(0x00f00000),zap->pa,
    121 			    NBPG, PG_W|PG_CI);
    122 			zap->va = ztwomap(0x00f00000) + ((int)zap->pa & PGOFSET);
    123 #ifdef DEBUG
    124 			printf("IVS Vector: mapped to %x kva %x\n",
    125 			    ztwomap(0x00f00000), zap->va);
    126 #endif
    127 		}
    128 		else {
    129 			printf("Unable to map IVS Vector SCSI\n");
    130 			return (0);
    131 		}
    132 	}
    133 	return(1);
    134 }
    135 
    136 void
    137 ivscattach(pdp, dp, auxp)
    138 	struct device *pdp, *dp;
    139 	void *auxp;
    140 {
    141 	volatile u_char *rp;
    142 	struct sci_softc *sc;
    143 	struct ztwobus_args *zap;
    144 
    145 	zap = auxp;
    146 
    147 	sc = (struct sci_softc *)dp;
    148 	rp = zap->va + 0x40;
    149 	sc->sci_data = rp;
    150 	sc->sci_odata = rp;
    151 	sc->sci_icmd = rp + 2;
    152 	sc->sci_mode = rp + 4;
    153 	sc->sci_tcmd = rp + 6;
    154 	sc->sci_bus_csr = rp + 8;
    155 	sc->sci_sel_enb = rp + 8;
    156 	sc->sci_csr = rp + 10;
    157 	sc->sci_dma_send = rp + 10;
    158 	sc->sci_idata = rp + 12;
    159 	sc->sci_trecv = rp + 12;
    160 	sc->sci_iack = rp + 14;
    161 	sc->sci_irecv = rp + 14;
    162 
    163 #ifdef notyet
    164 	sc->dma_xfer_in = ivsc_dma_xfer_in;
    165 	sc->dma_xfer_out = ivsc_dma_xfer_out;
    166 #endif
    167 
    168 	scireset(sc);
    169 
    170 	sc->sc_link.adapter_softc = sc;
    171 	sc->sc_link.adapter_targ = 7;
    172 	sc->sc_link.adapter = &ivsc_scsiswitch;
    173 	sc->sc_link.device = &ivsc_scsidev;
    174 	TAILQ_INIT(&sc->sc_xslist);
    175 
    176 	custom.intreq = INTF_PORTS;
    177 	custom.intena = INTF_SETCLR | INTF_PORTS;
    178 
    179 	/*
    180 	 * attach all scsi units on us
    181 	 */
    182 	config_found(dp, &sc->sc_link, ivscprint);
    183 }
    184 
    185 /*
    186  * print diag if pnp is NULL else just extra
    187  */
    188 int
    189 ivscprint(auxp, pnp)
    190 	void *auxp;
    191 	char *pnp;
    192 {
    193 	if (pnp == NULL)
    194 		return(UNCONF);
    195 	return(QUIET);
    196 }
    197 
    198 #ifdef notyet
    199 int
    200 ivsc_dma_xfer_in (dev, len, buf, phase)
    201 	struct sci_softc *dev;
    202 	int len;
    203 	register u_char *buf;
    204 	int phase;
    205 {
    206 }
    207 
    208 int
    209 ivsc_dma_xfer_out (dev, len, buf, phase)
    210 	struct sci_softc *dev;
    211 	int len;
    212 	register u_char *buf;
    213 	int phase;
    214 {
    215 }
    216 #endif
    217 
    218 int
    219 ivsc_intr()
    220 {
    221 	struct sci_softc *dev;
    222 	int i, found;
    223 	u_char stat;
    224 
    225 	found = 0;
    226 	for (i = 0; i < ivsccd.cd_ndevs; i++) {
    227 		dev = ivsccd.cd_devs[i];
    228 		if (dev == NULL)
    229 			continue;
    230 		if ((*dev->sci_csr & SCI_CSR_INT) == 0)
    231 			continue;
    232 		++found;
    233 		stat = *dev->sci_iack;
    234 	}
    235 	return (found);
    236 }
    237