1 /* $OpenBSD: aic_isa.c,v 1.3 1999/01/07 06:14:47 niklas Exp $ */ 2 /* $NetBSD: aic6360.c,v 1.52 1996/12/10 21:27:51 thorpej Exp $ */ 3 4 /* 5 * Copyright (c) 1994, 1995, 1996 Charles Hannum. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Charles M. Hannum. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * Copyright (c) 1994 Jarle Greipsland 22 * All rights reserved. 23 * 24 * Redistribution and use in source and binary forms, with or without 25 * modification, are permitted provided that the following conditions 26 * are met: 27 * 1. Redistributions of source code must retain the above copyright 28 * notice, this list of conditions and the following disclaimer. 29 * 2. Redistributions in binary form must reproduce the above copyright 30 * notice, this list of conditions and the following disclaimer in the 31 * documentation and/or other materials provided with the distribution. 32 * 3. The name of the author may not be used to endorse or promote products 33 * derived from this software without specific prior written permission. 34 * 35 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 36 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 37 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 38 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 39 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 40 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 41 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 42 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 43 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 44 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 45 * POSSIBILITY OF SUCH DAMAGE. 46 */ 47 48 /* 49 * Acknowledgements: Many of the algorithms used in this driver are 50 * inspired by the work of Julian Elischer (julian@tfs.com) and 51 * Charles Hannum (mycroft@duality.gnu.ai.mit.edu). Thanks a million! 52 */ 53 54 #include <sys/types.h> 55 #include <sys/param.h> 56 #include <sys/systm.h> 57 #include <sys/kernel.h> 58 #include <sys/errno.h> 59 #include <sys/ioctl.h> 60 #include <sys/device.h> 61 #include <sys/buf.h> 62 #include <sys/proc.h> 63 #include <sys/user.h> 64 #include <sys/queue.h> 65 66 #include <machine/bus.h> 67 #include <machine/intr.h> 68 69 #include <scsi/scsi_all.h> 70 #include <scsi/scsi_message.h> 71 #include <scsi/scsiconf.h> 72 73 #include <dev/isa/isavar.h> 74 75 #include <dev/ic/aic6360reg.h> 76 #include <dev/ic/aic6360var.h> 77 78 int aic_isa_probe __P((struct device *, void *, void *)); 79 void aic_isa_attach __P((struct device *, struct device *, void *)); 80 81 struct cfattach aic_isa_ca = { 82 sizeof(struct aic_softc), aic_isa_probe, aic_isa_attach 83 }; 84 85 /* 86 * INITIALIZATION ROUTINES (probe, attach ++) 87 */ 88 89 /* 90 * aicprobe: probe for AIC6360 SCSI-controller 91 * returns non-zero value if a controller is found. 92 */ 93 int 94 aic_isa_probe(parent, match, aux) 95 struct device *parent; 96 void *match, *aux; 97 { 98 struct isa_attach_args *ia = aux; 99 bus_space_tag_t iot = ia->ia_iot; 100 bus_space_handle_t ioh; 101 int rv; 102 103 if (bus_space_map(iot, ia->ia_iobase, AIC_NPORTS, 0, &ioh)) 104 return (0); 105 106 AIC_TRACE(("aic: probing for aic-chip at port 0x%x\n", ia->ia_iobase)); 107 rv = aic_find(iot, ioh); 108 109 bus_space_unmap(iot, ioh, AIC_NPORTS); 110 111 if (rv) { 112 ia->ia_msize = 0; 113 ia->ia_iosize = AIC_NPORTS; 114 } 115 return (rv); 116 } 117 118 /* 119 * Attach the AIC6360, fill out some high and low level data structures 120 */ 121 void 122 aic_isa_attach(parent, self, aux) 123 struct device *parent, *self; 124 void *aux; 125 { 126 struct isa_attach_args *ia = aux; 127 bus_space_tag_t iot = ia->ia_iot; 128 bus_space_handle_t ioh; 129 struct aic_softc *sc = (void *)self; 130 131 if (bus_space_map(iot, ia->ia_iobase, AIC_NPORTS, 0, &ioh)) 132 panic("%s: could not map I/O-ports", sc->sc_dev.dv_xname); 133 134 sc->sc_iot = iot; 135 sc->sc_ioh = ioh; 136 137 printf("\n"); 138 139 sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, 140 IPL_BIO, aicintr, sc, sc->sc_dev.dv_xname); 141 142 aicattach(sc); 143 } 144 145