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