1 /* $NetBSD: aha_mca.c,v 1.4 2001/11/13 07:46:25 lukem Exp $ */ 2 3 /* 4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 5 * Copyright (c) 1996-1999 Scott D. Telford. 6 * Copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved. 7 * Portions: 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by Charles M. Hannum. 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 /* 36 * Originally written by Julian Elischer (julian@tfs.com) 37 * for TRW Financial Systems for use under the MACH(2.5) operating system. 38 * 39 * TRW Financial Systems, in accordance with their agreement with Carnegie 40 * Mellon University, makes this software available to CMU to distribute 41 * or use in any manner that they see fit as long as this message is kept with 42 * the software. For this reason TFS also grants any other persons or 43 * organisations permission to use or modify this software. 44 * 45 * TFS supplies this software to be publicly redistributed 46 * on the understanding that TFS is not responsible for the correct 47 * functioning of this software in any circumstances. 48 */ 49 50 /* 51 * AHA-1640 MCA bus code by Scott Telford 52 */ 53 54 #include <sys/cdefs.h> 55 __KERNEL_RCSID(0, "$NetBSD: aha_mca.c,v 1.4 2001/11/13 07:46:25 lukem Exp $"); 56 57 #include <sys/param.h> 58 #include <sys/types.h> 59 #include <sys/systm.h> 60 #include <sys/device.h> 61 62 #include <machine/bus.h> 63 #include <machine/intr.h> 64 65 #include <dev/scsipi/scsi_all.h> 66 #include <dev/scsipi/scsipi_all.h> 67 #include <dev/scsipi/scsiconf.h> 68 69 #include <dev/isa/isavar.h> 70 #include <dev/isa/isadmavar.h> 71 72 #include <dev/ic/ahareg.h> 73 #include <dev/ic/ahavar.h> 74 75 #include <dev/mca/mcareg.h> 76 #include <dev/mca/mcavar.h> 77 #include <dev/mca/mcadevs.h> 78 79 #define AHA_ISA_IOSIZE 4 80 81 int aha_mca_probe __P((struct device *, struct cfdata *, void *)); 82 void aha_mca_attach __P((struct device *, struct device *, void *)); 83 84 struct cfattach aha_mca_ca = { 85 sizeof(struct aha_softc), aha_mca_probe, aha_mca_attach 86 }; 87 88 89 int 90 aha_mca_probe(parent, match, aux) 91 struct device *parent; 92 struct cfdata *match; 93 void *aux; 94 { 95 register struct mca_attach_args *ma = aux; 96 97 switch(ma->ma_id) { 98 case MCA_PRODUCT_AHA1640: 99 return 1; 100 } 101 102 return 0; 103 } 104 105 106 /* 107 * Attach all the sub-devices we can find 108 */ 109 void 110 aha_mca_attach(parent, self, aux) 111 struct device *parent, *self; 112 void *aux; 113 { 114 struct mca_attach_args *ma = aux; 115 struct aha_softc *sc = (void *)self; 116 bus_space_tag_t iot = ma->ma_iot; 117 bus_space_handle_t ioh; 118 struct aha_probe_data apd; 119 mca_chipset_tag_t mc = ma->ma_mc; 120 bus_addr_t iobase; 121 122 apd.sc_irq=(ma->ma_pos[4] & 0x7) + 8; 123 apd.sc_drq=ma->ma_pos[5] & 0xf; 124 apd.sc_scsi_dev=(ma->ma_pos[4] & 0xe0) >> 5; 125 126 printf(" slot %d irq %d: Adaptec AHA-1640 SCSI Adapter\n", 127 ma->ma_slot + 1, 128 apd.sc_irq); 129 130 iobase=((ma->ma_pos[3] & 0x03) << 8) + 0x30 + 131 ((ma->ma_pos[3] & 0x40) >> 4); 132 133 if (bus_space_map(iot, iobase, AHA_ISA_IOSIZE, 0, &ioh)) { 134 printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname); 135 return; 136 } 137 138 sc->sc_iot = iot; 139 sc->sc_ioh = ioh; 140 sc->sc_dmat = ma->ma_dmat; 141 142 #ifdef notyet 143 if (apd.sc_drq != -1) 144 isa_dmacascade(mc, apd.sc_drq); 145 #endif 146 147 sc->sc_ih = mca_intr_establish(mc, apd.sc_irq, IPL_BIO, aha_intr, sc); 148 if (sc->sc_ih == NULL) { 149 printf("%s: couldn't establish interrupt\n", 150 sc->sc_dev.dv_xname); 151 return; 152 } 153 154 aha_attach(sc, &apd); 155 } 156