tcbus.c revision 1.13 1 /* $NetBSD: tcbus.c,v 1.13 2001/02/17 18:02:40 tsutsui Exp $ */
2
3 /*
4 * Copyright (c) 1999, 2000 Tohru Nishimura. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Tohru Nishimura
17 * for the NetBSD Project.
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 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
34 __KERNEL_RCSID(0, "$NetBSD: tcbus.c,v 1.13 2001/02/17 18:02:40 tsutsui Exp $");
35
36 /*
37 * Which system models were configured?
38 */
39 #include "opt_dec_3max.h"
40 #include "opt_dec_3min.h"
41 #include "opt_dec_maxine.h"
42 #include "opt_dec_3maxplus.h"
43
44 #include <sys/param.h>
45 #include <sys/systm.h>
46 #include <sys/device.h>
47
48 #include <machine/autoconf.h>
49 #include <machine/sysconf.h>
50
51 #define _PMAX_BUS_DMA_PRIVATE
52 #include <machine/bus.h>
53
54 #include <dev/tc/tcvar.h>
55 #include <pmax/pmax/pmaxtype.h>
56
57 static const struct evcnt *tc_ds_intr_evcnt __P((struct device *, void *));
58 static void tc_ds_intr_establish __P((struct device *, void *,
59 int, int (*)(void *), void *));
60 static void tc_ds_intr_disestablish __P((struct device *, void *));
61 static bus_dma_tag_t tc_ds_get_dma_tag __P((int));
62
63 extern struct tcbus_attach_args kn02_tc_desc[]; /* XXX */
64 extern struct tcbus_attach_args kmin_tc_desc[]; /* XXX */
65 extern struct tcbus_attach_args xine_tc_desc[]; /* XXX */
66 extern struct tcbus_attach_args kn03_tc_desc[]; /* XXX */
67
68 static int tcbus_match __P((struct device *, struct cfdata *, void *));
69 static void tcbus_attach __P((struct device *, struct device *, void *));
70
71 struct cfattach tcbus_ca = {
72 sizeof(struct tc_softc), tcbus_match, tcbus_attach,
73 };
74
75 static int tcbus_found;
76
77 static int
78 tcbus_match(parent, cfdata, aux)
79 struct device *parent;
80 struct cfdata *cfdata;
81 void *aux;
82 {
83 struct mainbus_attach_args *ma = aux;
84
85 if (tcbus_found || strcmp(ma->ma_name, "tcbus"))
86 return 0;
87
88 return 1;
89 }
90
91 static void
92 tcbus_attach(parent, self, aux)
93 struct device *parent, *self;
94 void *aux;
95 {
96 struct tcbus_attach_args *tba;
97
98 tcbus_found = 1;
99
100 switch (systype) {
101 #ifdef DEC_3MAX
102 case DS_3MAX:
103 tba = &kn02_tc_desc[0]; break;
104 #endif
105 #ifdef DEC_3MIN
106 case DS_3MIN:
107 tba = &kmin_tc_desc[0]; break;
108 #endif
109 #ifdef DEC_MAXINE
110 case DS_MAXINE:
111 tba = &xine_tc_desc[0]; break;
112 #endif
113 #ifdef DEC_3MAXPLUS
114 case DS_3MAXPLUS:
115 tba = &kn03_tc_desc[0]; break;
116 #endif
117 default:
118 panic("tcbus_attach: no TURBOchannel configured for systype = %d", systype);
119 }
120
121 tba->tba_busname = "tc";
122 tba->tba_memt = 0;
123 tba->tba_intr_evcnt = tc_ds_intr_evcnt;
124 tba->tba_intr_establish = tc_ds_intr_establish;
125 tba->tba_intr_disestablish = tc_ds_intr_disestablish;
126 tba->tba_get_dma_tag = tc_ds_get_dma_tag;
127
128 tcattach(parent, self, tba);
129 }
130
131 /*
132 * Dispatch to model specific interrupt line evcnt fetch rontine
133 */
134 static const struct evcnt *
135 tc_ds_intr_evcnt(dev, cookie)
136 struct device *dev;
137 void *cookie;
138 {
139
140 /* XXX for now, no evcnt parent reported */
141 return NULL;
142 }
143
144 /*
145 * Dispatch to model specific interrupt establishing routine
146 */
147 static void
148 tc_ds_intr_establish(dev, cookie, level, handler, val)
149 struct device *dev;
150 void *cookie;
151 int level;
152 int (*handler) __P((void *));
153 void *val;
154 {
155
156 (*platform.intr_establish)(dev, cookie, level, handler, val);
157 }
158
159 static void
160 tc_ds_intr_disestablish(dev, arg)
161 struct device *dev;
162 void *arg;
163 {
164
165 printf("cannot disestablish TC interrupts\n");
166 }
167
168 /*
169 * Return the DMA tag for use by the specified TURBOchannel slot.
170 */
171 static bus_dma_tag_t
172 tc_ds_get_dma_tag(slot)
173 int slot;
174 {
175 /*
176 * All DECstations use the default DMA tag.
177 */
178 return (&pmax_default_bus_dma_tag);
179 }
180
181 #include "rasterconsole.h"
182
183 #if NRASTERCONSOLE > 0
184
185 #include "mfb.h"
186 #include "cfb.h"
187 #include "sfb.h"
188 #include "px.h"
189
190 #include <machine/pmioctl.h> /* XXX */
191 #include <machine/fbio.h> /* XXX */
192 #include <machine/fbvar.h> /* XXX */
193 #include <pmax/dev/fbreg.h> /* XXX */
194 #include <pmax/dev/cfbvar.h>
195 #include <pmax/dev/mfbvar.h>
196 #include <pmax/dev/sfbvar.h>
197 #include <pmax/dev/pxreg.h>
198 #include <pmax/dev/pxvar.h>
199
200 #include <machine/dec_prom.h>
201
202 int
203 tcfb_cnattach(slotno)
204 int slotno;
205 {
206 paddr_t tcaddr;
207 char tcname[TC_ROM_LLEN];
208
209 tcaddr = (*callv->_slot_address)(slotno);
210 if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname) == 0)
211 panic("TC console designated by PROM does not exist!?");
212
213 #if NSFB > 0
214 if (strncmp("PMAGB-BA", tcname, TC_ROM_LLEN) == 0) {
215 return sfb_cnattach(tcaddr);
216 }
217 #endif
218 #if NCFB > 0
219 if (strncmp("PMAG-BA ", tcname, TC_ROM_LLEN) == 0) {
220 return cfb_cnattach(tcaddr);
221 }
222 #endif
223 #if NMFB > 0
224 if (strncmp("PMAG-AA ", tcname, TC_ROM_LLEN) == 0) {
225 return mfb_cnattach(tcaddr);
226 }
227 #endif
228 #if NPX > 0
229 if (strncmp("PMAG-CA ", tcname, TC_ROM_LLEN) == 0
230 || strncmp("PMAG-DA ", tcname, TC_ROM_LLEN) == 0
231 || strncmp("PMAG-FA ", tcname, TC_ROM_LLEN) == 0) {
232 int px_cnattach __P((paddr_t)); /* XXX much simpler XXX */
233
234 return px_cnattach(tcaddr);
235 }
236 #endif
237 return 0;
238 }
239
240 #endif
241