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