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