1 1.30 thorpej /* $NetBSD: empsc.c,v 1.30 2021/08/07 16:18:41 thorpej Exp $ */ 2 1.25 agc 3 1.25 agc /* 4 1.25 agc * Copyright (c) 1982, 1990 The Regents of the University of California. 5 1.25 agc * All rights reserved. 6 1.25 agc * 7 1.25 agc * Redistribution and use in source and binary forms, with or without 8 1.25 agc * modification, are permitted provided that the following conditions 9 1.25 agc * are met: 10 1.25 agc * 1. Redistributions of source code must retain the above copyright 11 1.25 agc * notice, this list of conditions and the following disclaimer. 12 1.25 agc * 2. Redistributions in binary form must reproduce the above copyright 13 1.25 agc * notice, this list of conditions and the following disclaimer in the 14 1.25 agc * documentation and/or other materials provided with the distribution. 15 1.25 agc * 3. Neither the name of the University nor the names of its contributors 16 1.25 agc * may be used to endorse or promote products derived from this software 17 1.25 agc * without specific prior written permission. 18 1.25 agc * 19 1.25 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 1.25 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 1.25 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 1.25 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 1.25 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 1.25 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 1.25 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 1.25 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 1.25 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 1.25 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 1.25 agc * SUCH DAMAGE. 30 1.25 agc * 31 1.25 agc */ 32 1.1 is 33 1.1 is /* 34 1.1 is 35 1.1 is * Copyright (c) 1995 Sean Riddle, Bo Najdrovsky 36 1.1 is * Copyright (c) 1994 Michael L. Hitch 37 1.1 is * 38 1.1 is * Redistribution and use in source and binary forms, with or without 39 1.1 is * modification, are permitted provided that the following conditions 40 1.1 is * are met: 41 1.1 is * 1. Redistributions of source code must retain the above copyright 42 1.1 is * notice, this list of conditions and the following disclaimer. 43 1.1 is * 2. Redistributions in binary form must reproduce the above copyright 44 1.1 is * notice, this list of conditions and the following disclaimer in the 45 1.1 is * documentation and/or other materials provided with the distribution. 46 1.1 is * 3. All advertising materials mentioning features or use of this software 47 1.1 is * must display the following acknowledgement: 48 1.1 is * This product includes software developed by the University of 49 1.1 is * California, Berkeley and its contributors. 50 1.1 is * 4. Neither the name of the University nor the names of its contributors 51 1.1 is * may be used to endorse or promote products derived from this software 52 1.1 is * without specific prior written permission. 53 1.1 is * 54 1.1 is * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 55 1.1 is * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 56 1.1 is * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 57 1.1 is * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 58 1.1 is * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 59 1.1 is * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 60 1.1 is * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 61 1.1 is * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 62 1.1 is * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 63 1.1 is * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 64 1.1 is * SUCH DAMAGE. 65 1.1 is * 66 1.1 is */ 67 1.22 aymeric 68 1.22 aymeric #include <sys/cdefs.h> 69 1.30 thorpej __KERNEL_RCSID(0, "$NetBSD: empsc.c,v 1.30 2021/08/07 16:18:41 thorpej Exp $"); 70 1.22 aymeric 71 1.1 is #include <sys/param.h> 72 1.1 is #include <sys/systm.h> 73 1.1 is #include <sys/kernel.h> 74 1.1 is #include <sys/device.h> 75 1.14 bouyer #include <dev/scsipi/scsi_all.h> 76 1.14 bouyer #include <dev/scsipi/scsipi_all.h> 77 1.14 bouyer #include <dev/scsipi/scsiconf.h> 78 1.1 is #include <amiga/amiga/custom.h> 79 1.1 is #include <amiga/amiga/device.h> 80 1.1 is #include <amiga/amiga/isr.h> 81 1.1 is #include <amiga/dev/scireg.h> 82 1.1 is #include <amiga/dev/scivar.h> 83 1.1 is #include <amiga/dev/zbusvar.h> 84 1.1 is 85 1.27 chs void empscattach(device_t, device_t, void *); 86 1.27 chs int empscmatch(device_t, cfdata_t, void *); 87 1.21 aymeric int empsc_intr(void *); 88 1.1 is 89 1.1 is #ifdef DEBUG 90 1.1 is extern int sci_debug; 91 1.1 is #endif 92 1.1 is 93 1.1 is extern int sci_data_wait; 94 1.1 is 95 1.27 chs CFATTACH_DECL_NEW(empsc, sizeof(struct sci_softc), 96 1.24 thorpej empscmatch, empscattach, NULL, NULL); 97 1.1 is 98 1.1 is /* 99 1.1 is * if this is an EMPLANT board 100 1.1 is */ 101 1.1 is int 102 1.27 chs empscmatch(device_t parent, cfdata_t cf, void *aux) 103 1.1 is { 104 1.1 is struct zbus_args *zap; 105 1.1 is 106 1.27 chs zap = aux; 107 1.1 is 108 1.1 is /* 109 1.1 is * Check manufacturer and product id. 110 1.1 is */ 111 1.7 is if (zap->manid == 2171 && ((zap->prodid == 21)||(zap->prodid==32))) 112 1.1 is return(1); 113 1.1 is else 114 1.1 is return(0); 115 1.1 is } 116 1.1 is 117 1.1 is void 118 1.27 chs empscattach(device_t parent, device_t self, void *aux) 119 1.1 is { 120 1.1 is volatile u_char *rp; 121 1.27 chs struct sci_softc *sc = device_private(self); 122 1.1 is struct zbus_args *zap; 123 1.20 bouyer struct scsipi_adapter *adapt = &sc->sc_adapter; 124 1.20 bouyer struct scsipi_channel *chan = &sc->sc_channel; 125 1.1 is 126 1.11 christos printf("\n"); 127 1.1 is 128 1.27 chs zap = aux; 129 1.21 aymeric 130 1.19 tron rp = (u_char *)zap->va + 0x5000; 131 1.1 is 132 1.27 chs sc->sc_dev = self; 133 1.1 is sc->sci_data = rp; 134 1.1 is sc->sci_odata = rp; 135 1.1 is sc->sci_icmd = rp + 0x10; 136 1.1 is sc->sci_mode = rp + 0x20; 137 1.1 is sc->sci_tcmd = rp + 0x30; 138 1.1 is sc->sci_bus_csr = rp + 0x40; 139 1.1 is sc->sci_sel_enb = rp + 0x40; 140 1.1 is sc->sci_csr = rp + 0x50; 141 1.1 is sc->sci_dma_send = rp + 0x50; 142 1.1 is sc->sci_idata = rp + 0x60; 143 1.1 is sc->sci_trecv = rp + 0x60; 144 1.1 is sc->sci_iack = rp + 0x70; 145 1.1 is sc->sci_irecv = rp + 0x70; 146 1.7 is sc->sc_isr.isr_intr = empsc_intr; 147 1.1 is sc->sc_isr.isr_arg = sc; 148 1.1 is sc->sc_isr.isr_ipl = 2; 149 1.1 is add_isr(&sc->sc_isr); 150 1.1 is 151 1.1 is scireset(sc); 152 1.1 is 153 1.20 bouyer /* 154 1.20 bouyer * Fill in the scsipi_adapter. 155 1.20 bouyer */ 156 1.20 bouyer memset(adapt, 0, sizeof(*adapt)); 157 1.27 chs adapt->adapt_dev = self; 158 1.20 bouyer adapt->adapt_nchannels = 1; 159 1.20 bouyer adapt->adapt_openings = 7; 160 1.20 bouyer adapt->adapt_max_periph = 1; 161 1.20 bouyer adapt->adapt_request = sci_scsipi_request; 162 1.20 bouyer adapt->adapt_minphys = sci_minphys; 163 1.17 thorpej 164 1.20 bouyer /* 165 1.20 bouyer * Fill in the scsipi_channel. 166 1.20 bouyer */ 167 1.20 bouyer memset(chan, 0, sizeof(*chan)); 168 1.20 bouyer chan->chan_adapter = adapt; 169 1.20 bouyer chan->chan_bustype = &scsi_bustype; 170 1.20 bouyer chan->chan_channel = 0; 171 1.20 bouyer chan->chan_ntargets = 8; 172 1.20 bouyer chan->chan_nluns = 8; 173 1.20 bouyer chan->chan_id = 7; 174 1.1 is 175 1.1 is /* 176 1.1 is * attach all scsi units on us 177 1.1 is */ 178 1.30 thorpej config_found(self, chan, scsiprint, CFARGS_NONE); 179 1.1 is } 180 1.1 is 181 1.1 is int 182 1.21 aymeric empsc_intr(void *arg) 183 1.1 is { 184 1.7 is struct sci_softc *dev = arg; 185 1.1 is u_char stat; 186 1.1 is 187 1.1 is if ((*dev->sci_csr & SCI_CSR_INT) == 0) 188 1.1 is return(0); 189 1.1 is stat = *dev->sci_iack; 190 1.28 christos __USE(stat); 191 1.7 is /* XXXX is: something is missing here, at least a: */ 192 1.7 is return(1); 193 1.1 is } 194