Home | History | Annotate | Line # | Download | only in dev
empsc.c revision 1.2
      1 /*	$NetBSD: empsc.c,v 1.2 1996/03/28 18:56:08 is Exp $	*/
      2 
      3 /*
      4 
      5  * Copyright (c) 1995 Sean Riddle, Bo Najdrovsky
      6  * Copyright (c) 1994 Michael L. Hitch
      7  * Copyright (c) 1982, 1990 The Regents of the University of California.
      8  * All rights reserved.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  */
     39 #include <sys/param.h>
     40 #include <sys/systm.h>
     41 #include <sys/kernel.h>
     42 #include <sys/device.h>
     43 #include <scsi/scsi_all.h>
     44 #include <scsi/scsiconf.h>
     45 #include <amiga/amiga/custom.h>
     46 #include <amiga/amiga/device.h>
     47 #include <amiga/amiga/isr.h>
     48 #include <amiga/dev/scireg.h>
     49 #include <amiga/dev/scivar.h>
     50 #include <amiga/dev/zbusvar.h>
     51 
     52 int empscprint __P((void *auxp, char *));
     53 void empscattach __P((struct device *, struct device *, void *));
     54 int empscmatch __P((struct device *, struct cfdata *, void *));
     55 int empsc_intr __P((struct sci_softc *));
     56 
     57 struct scsi_adapter empsc_scsiswitch = {
     58 	sci_scsicmd,
     59 	sci_minphys,
     60 	0,			/* no lun support */
     61 	0,			/* no lun support */
     62 };
     63 
     64 struct scsi_device empsc_scsidev = {
     65 	NULL,		/* use default error handler */
     66 	NULL,		/* do not have a start functio */
     67 	NULL,		/* have no async handler */
     68 	NULL,		/* Use default done routine */
     69 };
     70 
     71 #define QPRINTF
     72 
     73 #ifdef DEBUG
     74 extern int sci_debug;
     75 #endif
     76 
     77 extern int sci_data_wait;
     78 
     79 struct cfattach empsc_ca = {
     80 	sizeof(struct sci_softc), empscmatch, empscattach
     81 };
     82 
     83 struct cfdriver empsccd = {
     84 	NULL, "empsc", DV_DULL, NULL, 0
     85 };
     86 
     87 /*
     88  * if this is an EMPLANT board
     89  */
     90 int
     91 empscmatch(pdp, match, auxp)
     92 	struct device *pdp;
     93 	void *match, *auxp;
     94 {
     95 	struct zbus_args *zap;
     96 
     97 	zap = auxp;
     98 
     99 	/*
    100 	 * Check manufacturer and product id.
    101 	 */
    102 	if (zap->manid == 2171 && ((zap->prodid == 21)||(zap->prodid==32)))
    103 		return(1);
    104 	else
    105 		return(0);
    106 }
    107 
    108 void
    109 empscattach(pdp, dp, auxp)
    110 	struct device *pdp, *dp;
    111 	void *auxp;
    112 {
    113 	volatile u_char *rp;
    114 	struct sci_softc *sc;
    115 	struct zbus_args *zap;
    116 
    117 	printf("\n");
    118 
    119 	zap = auxp;
    120 
    121 	sc = (struct sci_softc *)dp;
    122 	rp = zap->va + 0x5000;
    123 
    124 	sc->sci_data = rp;
    125 	sc->sci_odata = rp;
    126 	sc->sci_icmd = rp + 0x10;
    127 	sc->sci_mode = rp + 0x20;
    128 	sc->sci_tcmd = rp + 0x30;
    129 	sc->sci_bus_csr = rp + 0x40;
    130 	sc->sci_sel_enb = rp + 0x40;
    131 	sc->sci_csr = rp + 0x50;
    132 	sc->sci_dma_send = rp + 0x50;
    133 	sc->sci_idata = rp + 0x60;
    134 	sc->sci_trecv = rp + 0x60;
    135 	sc->sci_iack = rp + 0x70;
    136 	sc->sci_irecv = rp + 0x70;
    137 	sc->sc_isr.isr_intr = empsc_intr;
    138 	sc->sc_isr.isr_arg = sc;
    139 	sc->sc_isr.isr_ipl = 2;
    140 	add_isr(&sc->sc_isr);
    141 
    142 	scireset(sc);
    143 
    144 	sc->sc_link.adapter_softc = sc;
    145 	sc->sc_link.adapter_target = 7;
    146 	sc->sc_link.adapter = &empsc_scsiswitch;
    147 	sc->sc_link.device = &empsc_scsidev;
    148 	sc->sc_link.openings = 1;
    149 	TAILQ_INIT(&sc->sc_xslist);
    150 
    151 	/*
    152 	 * attach all scsi units on us
    153 	 */
    154 	config_found(dp, &sc->sc_link, empscprint);
    155 }
    156 
    157 /*
    158  * print diag if pnp is NULL else just extra
    159  */
    160 int
    161 empscprint(auxp, pnp)
    162 	void *auxp;
    163 	char *pnp;
    164 {
    165 	if (pnp == NULL)
    166 		return(UNCONF);
    167 	return(QUIET);
    168 }
    169 
    170 int
    171 empsc_intr(dev)
    172 	struct sci_softc *dev;
    173 {
    174 	u_char stat;
    175 
    176 	if ((*dev->sci_csr & SCI_CSR_INT) == 0)
    177 		return(0);
    178 	stat = *dev->sci_iack;
    179 }
    180