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