Home | History | Annotate | Line # | Download | only in isa
aic_isa.c revision 1.5
      1 /*	$NetBSD: aic_isa.c,v 1.5 1997/11/30 15:31:23 drochner Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1994, 1995, 1996 Charles M. Hannum.  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 Charles M. Hannum.
     17  * 4. The name of the author may not be used to endorse or promote products
     18  *    derived from this software without specific prior written permission.
     19  *
     20  * Copyright (c) 1994 Jarle Greipsland
     21  * All rights reserved.
     22  *
     23  * Redistribution and use in source and binary forms, with or without
     24  * modification, are permitted provided that the following conditions
     25  * are met:
     26  * 1. Redistributions of source code must retain the above copyright
     27  *    notice, this list of conditions and the following disclaimer.
     28  * 2. Redistributions in binary form must reproduce the above copyright
     29  *    notice, this list of conditions and the following disclaimer in the
     30  *    documentation and/or other materials provided with the distribution.
     31  * 3. The name of the author may not be used to endorse or promote products
     32  *    derived from this software without specific prior written permission.
     33  *
     34  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     35  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     36  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     37  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     38  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     39  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     40  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     41  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     42  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     43  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     44  * POSSIBILITY OF SUCH DAMAGE.
     45  */
     46 
     47 /*
     48  * Acknowledgements: Many of the algorithms used in this driver are
     49  * inspired by the work of Julian Elischer (julian (at) tfs.com) and
     50  * Charles Hannum (mycroft (at) duality.gnu.ai.mit.edu).  Thanks a million!
     51  */
     52 
     53 #include <sys/types.h>
     54 #include <sys/param.h>
     55 #include <sys/systm.h>
     56 #include <sys/kernel.h>
     57 #include <sys/errno.h>
     58 #include <sys/ioctl.h>
     59 #include <sys/device.h>
     60 #include <sys/buf.h>
     61 #include <sys/proc.h>
     62 #include <sys/user.h>
     63 #include <sys/queue.h>
     64 
     65 #include <machine/intr.h>
     66 #include <machine/pio.h>
     67 
     68 #include <dev/scsipi/scsi_all.h>
     69 #include <dev/scsipi/scsipi_all.h>
     70 #include <dev/scsipi/scsiconf.h>
     71 
     72 #include <dev/isa/isavar.h>
     73 #include <dev/ic/aic6360reg.h>
     74 #include <dev/ic/aic6360var.h>
     75 
     76 #ifdef __BROKEN_INDIRECT_CONFIG
     77 int	aic_isa_probe __P((struct device *, void *, void *));
     78 #else
     79 int	aic_isa_probe __P((struct device *, struct cfdata *, void *));
     80 #endif
     81 
     82 struct aic_isa_softc {
     83 	struct	aic_softc sc_aic;	/* real "aic" softc */
     84 
     85 	/* ISA-specific goo. */
     86 	void	*sc_ih;			/* interrupt handler */
     87 };
     88 
     89 struct cfattach aic_isa_ca = {
     90 	sizeof(struct aic_isa_softc), aic_isa_probe, aic_isa_attach
     91 };
     92 
     93 
     94 /*
     96  * INITIALIZATION ROUTINES (probe, attach ++)
     97  */
     98 
     99 /*
    100  * aic_isa_probe: probe for AIC6360 SCSI-controller
    101  * returns non-zero value if a controller is found.
    102  */
    103 int
    104 aic_isa_probe(parent, match, aux)
    105 	struct device *parent;
    106 #ifdef __BROKEN_INDIRECT_CONFIG
    107 	void *match;
    108 #else
    109 	struct cfdata *match;
    110 #endif
    111 	void *aux;
    112 {
    113 	struct isa_attach_args *ia = aux;
    114 	bus_space_tag_t iot = ia->ia_iot;
    115 	bus_space_handle_t ioh;
    116 	int rv;
    117 
    118 	/* Disallow wildcarded i/o address. */
    119 	if (ia->ia_iobase == ISACF_PORT_DEFAULT)
    120 		return (0);
    121 
    122 	if (bus_space_map(iot, ia->ia_iobase, AIC_ISA_IOSIZE, 0, &ioh))
    123 		return (0);
    124 
    125 	AIC_TRACE(("aic_isa_probe: port 0x%x\n", ia->ia_iobase));
    126 	rv = aic_find(iot, ioh);
    127 
    128 	bus_space_unmap(iot, ioh, AIC_ISA_IOSIZE);
    129 
    130 	if (rv) {
    131 		ia->ia_msize = 0;
    132 		ia->ia_iosize = AIC_ISA_IOSIZE;
    133 	}
    134 	return rv;
    135 }
    136 
    137 void
    138 aic_isa_attach(parent, self, aux)
    139 	struct device *parent, *self;
    140 	void *aux;
    141 {
    142 	struct isa_attach_args *ia = aux;
    143 	struct aic_isa_softc *isc = (void *)self;
    144 	struct aic_softc *sc = &isc->sc_aic;
    145 	bus_space_tag_t iot = ia->ia_iot;
    146 	bus_space_handle_t ioh;
    147 	isa_chipset_tag_t ic = ia->ia_ic;
    148 
    149 	printf("\n");
    150 
    151 	if (bus_space_map(iot, ia->ia_iobase, AIC_ISA_IOSIZE, 0, &ioh)) {
    152 		printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
    153 		return;
    154 	}
    155 
    156 	sc->sc_iot = iot;
    157 	sc->sc_ioh = ioh;
    158 	AIC_TRACE(("aic_isa_attach: port 0x%x\n", ia->ia_iobase));
    159 	if (!aic_find(iot, ioh)) {
    160 		printf("%s: aic_find failed", sc->sc_dev.dv_xname);
    161 		return;
    162 	}
    163 
    164 	isc->sc_ih = isa_intr_establish(ic, ia->ia_irq, IST_EDGE, IPL_BIO,
    165 	    aicintr, sc);
    166 	if (isc->sc_ih == NULL) {
    167 		printf("%s: couldn't establish interrupt\n",
    168 		    sc->sc_dev.dv_xname);
    169 		return;
    170 	}
    171 
    172 	aicattach(sc);
    173 }
    174