1 /* $OpenBSD: aic_isa.c,v 1.9 2021/03/07 06:17:03 jsg 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/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/queue.h> 62 63 #include <machine/bus.h> 64 #include <machine/intr.h> 65 66 #include <scsi/scsi_all.h> 67 #include <scsi/scsi_message.h> 68 #include <scsi/scsiconf.h> 69 70 #include <dev/isa/isavar.h> 71 72 #include <dev/ic/aic6360reg.h> 73 #include <dev/ic/aic6360var.h> 74 75 int aic_isa_probe(struct device *, void *, void *); 76 void aic_isa_attach(struct device *, struct device *, void *); 77 78 struct cfattach aic_isa_ca = { 79 sizeof(struct aic_softc), aic_isa_probe, aic_isa_attach 80 }; 81 82 /* 83 * INITIALIZATION ROUTINES (probe, attach ++) 84 */ 85 86 /* 87 * aicprobe: probe for AIC6360 SCSI-controller 88 * returns non-zero value if a controller is found. 89 */ 90 int 91 aic_isa_probe(struct device *parent, void *match, void *aux) 92 { 93 struct isa_attach_args *ia = aux; 94 bus_space_tag_t iot = ia->ia_iot; 95 bus_space_handle_t ioh; 96 int rv; 97 98 if (bus_space_map(iot, ia->ia_iobase, AIC_NPORTS, 0, &ioh)) 99 return (0); 100 101 AIC_TRACE(("aic: probing for aic-chip at port 0x%x\n", ia->ia_iobase)); 102 rv = aic_find(iot, ioh); 103 104 bus_space_unmap(iot, ioh, AIC_NPORTS); 105 106 if (rv) { 107 ia->ia_msize = 0; 108 ia->ia_iosize = AIC_NPORTS; 109 } 110 return (rv); 111 } 112 113 /* 114 * Attach the AIC6360, fill out some high and low level data structures 115 */ 116 void 117 aic_isa_attach(struct device *parent, struct device *self, void *aux) 118 { 119 struct isa_attach_args *ia = aux; 120 bus_space_tag_t iot = ia->ia_iot; 121 bus_space_handle_t ioh; 122 struct aic_softc *sc = (void *)self; 123 124 if (bus_space_map(iot, ia->ia_iobase, AIC_NPORTS, 0, &ioh)) 125 panic("%s: can't map i/o-ports", sc->sc_dev.dv_xname); 126 127 sc->sc_iot = iot; 128 sc->sc_ioh = ioh; 129 130 printf("\n"); 131 132 sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, 133 IPL_BIO, aicintr, sc, sc->sc_dev.dv_xname); 134 135 aicattach(sc); 136 } 137