xref: /netbsd/sys/arch/pmax/tc/tcbus.c (revision c4a72b64)
1 /*	$NetBSD: tcbus.c,v 1.16 2002/10/02 04:15:11 thorpej 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.16 2002/10/02 04:15:11 thorpej 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 CFATTACH_DECL(tcbus, sizeof(struct tc_softc),
72     tcbus_match, tcbus_attach, NULL, NULL);
73 
74 static int tcbus_found;
75 
76 static int
77 tcbus_match(parent, cfdata, aux)
78 	struct device *parent;
79 	struct cfdata *cfdata;
80 	void *aux;
81 {
82 	struct mainbus_attach_args *ma = aux;
83 
84 	if (tcbus_found || strcmp(ma->ma_name, "tcbus"))
85 		return 0;
86 
87 	return 1;
88 }
89 
90 static void
91 tcbus_attach(parent, self, aux)
92 	struct device *parent, *self;
93 	void *aux;
94 {
95 	struct tcbus_attach_args *tba;
96 
97 	tcbus_found = 1;
98 
99 	switch (systype) {
100 #ifdef DEC_3MAX
101 	case DS_3MAX:
102 		tba = &kn02_tc_desc[0]; break;
103 #endif
104 #ifdef DEC_3MIN
105 	case DS_3MIN:
106 		tba = &kmin_tc_desc[0]; break;
107 #endif
108 #ifdef DEC_MAXINE
109 	case DS_MAXINE:
110 		tba = &xine_tc_desc[0]; break;
111 #endif
112 #ifdef DEC_3MAXPLUS
113 	case DS_3MAXPLUS:
114 		tba = &kn03_tc_desc[0]; break;
115 #endif
116 	default:
117 		panic("tcbus_attach: no TURBOchannel configured for systype = %d", systype);
118 	}
119 
120 	tba->tba_busname = "tc";
121 	tba->tba_memt = 0;
122 	tba->tba_intr_evcnt = tc_ds_intr_evcnt;
123 	tba->tba_intr_establish = tc_ds_intr_establish;
124 	tba->tba_intr_disestablish = tc_ds_intr_disestablish;
125 	tba->tba_get_dma_tag = tc_ds_get_dma_tag;
126 
127 	tcattach(parent, self, tba);
128 }
129 
130 /*
131  * Dispatch to model specific interrupt line evcnt fetch rontine
132  */
133 static const struct evcnt *
134 tc_ds_intr_evcnt(dev, cookie)
135 	struct device *dev;
136 	void *cookie;
137 {
138 
139 	/* XXX for now, no evcnt parent reported */
140 	return NULL;
141 }
142 
143 /*
144  * Dispatch to model specific interrupt establishing routine
145  */
146 static void
147 tc_ds_intr_establish(dev, cookie, level, handler, val)
148 	struct device *dev;
149 	void *cookie;
150 	int level;
151 	int (*handler) __P((void *));
152 	void *val;
153 {
154 
155 	(*platform.intr_establish)(dev, cookie, level, handler, val);
156 }
157 
158 static void
159 tc_ds_intr_disestablish(dev, arg)
160 	struct device *dev;
161 	void *arg;
162 {
163 
164 	printf("cannot disestablish TC interrupts\n");
165 }
166 
167 /*
168  * Return the DMA tag for use by the specified TURBOchannel slot.
169  */
170 static bus_dma_tag_t
171 tc_ds_get_dma_tag(slot)
172 	int slot;
173 {
174 	/*
175 	 * All DECstations use the default DMA tag.
176 	 */
177 	return (&pmax_default_bus_dma_tag);
178 }
179 
180 #include "rasterconsole.h"
181 
182 #if NRASTERCONSOLE > 0
183 
184 #include "mfb.h"
185 #include "cfb.h"
186 #include "sfb.h"
187 #include "px.h"
188 
189 #include <machine/pmioctl.h>	/* XXX */
190 #include <dev/sun/fbio.h>	/* XXX */
191 #include <machine/fbvar.h>	/* XXX */
192 #include <pmax/dev/fbreg.h>	/* XXX */
193 #include <pmax/dev/cfbvar.h>
194 #include <pmax/dev/mfbvar.h>
195 #include <pmax/dev/sfbvar.h>
196 #include <pmax/dev/pxreg.h>
197 #include <pmax/dev/pxvar.h>
198 
199 #include <machine/dec_prom.h>
200 
201 int
202 tcfb_cnattach(slotno)
203 	int slotno;
204 {
205 	paddr_t tcaddr;
206 	char tcname[TC_ROM_LLEN];
207 
208 	tcaddr = (*callv->_slot_address)(slotno);
209 	if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname) == 0)
210 		panic("TC console designated by PROM does not exist!?");
211 
212 #if NSFB > 0
213 	if (strncmp("PMAGB-BA", tcname, TC_ROM_LLEN) == 0) {
214 		return sfb_cnattach(tcaddr);
215 	}
216 #endif
217 #if NCFB > 0
218 	if (strncmp("PMAG-BA ", tcname, TC_ROM_LLEN) == 0) {
219 		return cfb_cnattach(tcaddr);
220 	}
221 #endif
222 #if NMFB > 0
223 	if (strncmp("PMAG-AA ", tcname, TC_ROM_LLEN) == 0) {
224 		return mfb_cnattach(tcaddr);
225 	}
226 #endif
227 #if NPX > 0
228 	if (strncmp("PMAG-CA ", tcname, TC_ROM_LLEN) == 0
229 	    || strncmp("PMAG-DA ", tcname, TC_ROM_LLEN) == 0
230 	    || strncmp("PMAG-FA ", tcname, TC_ROM_LLEN) == 0) {
231 		int px_cnattach __P((paddr_t)); /* XXX much simpler XXX */
232 
233 		return px_cnattach(tcaddr);
234 	}
235 #endif
236 	return 0;
237 }
238 
239 #endif
240