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