xref: /netbsd/sys/arch/alpha/tc/tcasic.c (revision c4a72b64)
1 /* $NetBSD: tcasic.c,v 1.38 2002/10/02 04:06:40 thorpej Exp $ */
2 
3 /*
4  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
29 
30 #include "opt_dec_3000_300.h"
31 #include "opt_dec_3000_500.h"
32 
33 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
34 
35 __KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.38 2002/10/02 04:06:40 thorpej Exp $");
36 
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/device.h>
40 
41 #include <machine/autoconf.h>
42 #include <machine/rpb.h>
43 #include <machine/alpha.h>
44 
45 #include <dev/tc/tcvar.h>
46 #include <alpha/tc/tc_conf.h>
47 
48 /* Definition of the driver for autoconfig. */
49 int	tcasicmatch(struct device *, struct cfdata *, void *);
50 void	tcasicattach(struct device *, struct device *, void *);
51 
52 CFATTACH_DECL(tcasic, sizeof (struct device),
53     tcasicmatch, tcasicattach, NULL, NULL);
54 
55 extern struct cfdriver tcasic_cd;
56 
57 int	tcasicprint __P((void *, const char *));
58 
59 /* There can be only one. */
60 int	tcasicfound;
61 
62 int
63 tcasicmatch(parent, cfdata, aux)
64 	struct device *parent;
65 	struct cfdata *cfdata;
66 	void *aux;
67 {
68 	struct mainbus_attach_args *ma = aux;
69 
70         /* Make sure that we're looking for a TurboChannel ASIC. */
71         if (strcmp(ma->ma_name, tcasic_cd.cd_name))
72                 return (0);
73 
74         /* Make sure that the system supports a TurboChannel ASIC. */
75 	if ((cputype != ST_DEC_3000_500) && (cputype != ST_DEC_3000_300))
76 		return (0);
77 
78 	if (tcasicfound)
79 		return (0);
80 
81 	return (1);
82 }
83 
84 void
85 tcasicattach(parent, self, aux)
86 	struct device *parent;
87 	struct device *self;
88 	void *aux;
89 {
90 	struct tcbus_attach_args tba;
91 	void (*intr_setup) __P((void));
92 	void (*iointr) __P((void *, unsigned long));
93 
94 	printf("\n");
95 	tcasicfound = 1;
96 
97 	switch (cputype) {
98 #ifdef DEC_3000_500
99 	case ST_DEC_3000_500:
100 
101 		intr_setup = tc_3000_500_intr_setup;
102 		iointr = tc_3000_500_iointr;
103 
104 		tba.tba_speed = TC_SPEED_25_MHZ;
105 		tba.tba_nslots = tc_3000_500_nslots;
106 		tba.tba_slots = tc_3000_500_slots;
107 		if (hwrpb->rpb_variation & SV_GRAPHICS) {
108 			tba.tba_nbuiltins = tc_3000_500_graphics_nbuiltins;
109 			tba.tba_builtins = tc_3000_500_graphics_builtins;
110 		} else {
111 			tba.tba_nbuiltins = tc_3000_500_nographics_nbuiltins;
112 			tba.tba_builtins = tc_3000_500_nographics_builtins;
113 		}
114 		tba.tba_intr_evcnt = tc_3000_500_intr_evcnt;
115 		tba.tba_intr_establish = tc_3000_500_intr_establish;
116 		tba.tba_intr_disestablish = tc_3000_500_intr_disestablish;
117 		tba.tba_get_dma_tag = tc_dma_get_tag_3000_500;
118 
119 		/* Do 3000/500-specific DMA setup now. */
120 		tc_dma_init_3000_500(tc_3000_500_nslots);
121 		break;
122 #endif /* DEC_3000_500 */
123 
124 #ifdef DEC_3000_300
125 	case ST_DEC_3000_300:
126 
127 		intr_setup = tc_3000_300_intr_setup;
128 		iointr = tc_3000_300_iointr;
129 
130 		tba.tba_speed = TC_SPEED_12_5_MHZ;
131 		tba.tba_nslots = tc_3000_300_nslots;
132 		tba.tba_slots = tc_3000_300_slots;
133 		tba.tba_nbuiltins = tc_3000_300_nbuiltins;
134 		tba.tba_builtins = tc_3000_300_builtins;
135 		tba.tba_intr_evcnt = tc_3000_300_intr_evcnt;
136 		tba.tba_intr_establish = tc_3000_300_intr_establish;
137 		tba.tba_intr_disestablish = tc_3000_300_intr_disestablish;
138 		tba.tba_get_dma_tag = tc_dma_get_tag_3000_300;
139 		break;
140 #endif /* DEC_3000_300 */
141 
142 	default:
143 		panic("tcasicattach: bad cputype");
144 	}
145 
146 	tba.tba_busname = "tc";
147 	tba.tba_memt = tc_bus_mem_init(NULL);
148 
149 	tc_dma_init();
150 
151 	(*intr_setup)();
152 
153 	/* They all come in at 0x800. */
154 	scb_set(0x800, iointr, NULL);
155 
156 	config_found(self, &tba, tcasicprint);
157 }
158 
159 int
160 tcasicprint(aux, pnp)
161 	void *aux;
162 	const char *pnp;
163 {
164 
165 	/* only TCs can attach to tcasics; easy. */
166 	if (pnp)
167 		printf("tc at %s", pnp);
168 	return (UNCONF);
169 }
170 
171 #include "wsdisplay.h"
172 
173 #if NWSDISPLAY > 0
174 
175 #include "sfb.h"
176 #include "sfbp.h"
177 #include "cfb.h"
178 #include "mfb.h"
179 #include "tfb.h"
180 #include "px.h"
181 #include "pxg.h"
182 
183 extern void	sfb_cnattach __P((tc_addr_t));
184 extern void	sfbp_cnattach __P((tc_addr_t));
185 extern void	cfb_cnattach __P((tc_addr_t));
186 extern void	mfb_cnattach __P((tc_addr_t));
187 extern void	tfb_cnattach __P((tc_addr_t));
188 extern void	px_cnattach __P((tc_addr_t));
189 extern void	pxg_cnattach __P((tc_addr_t));
190 extern int	tc_checkslot __P((tc_addr_t, char *));
191 
192 struct cnboards {
193 	const char	*cb_tcname;
194 	void	(*cb_cnattach)(tc_addr_t);
195 } static const cnboards[] = {
196 #if NSFB > 0
197 	{ "PMAGB-BA", sfb_cnattach },
198 #endif
199 #if NSFBP > 0
200 	{ "PMAGD   ", sfbp_cnattach },
201 #endif
202 #if NCFB > 0
203 	{ "PMAG-BA ", cfb_cnattach },
204 #endif
205 #if NMFB > 0
206 	{ "PMAG-AA ", mfb_cnattach },
207 #endif
208 #if NTFB > 0
209 	{ "PMAG-JA ", tfb_cnattach },
210 #endif
211 #if NPX > 0
212 	{ "PMAG-CA ", px_cnattach },
213 #endif
214 #if NPXG > 0
215 	{ "PMAG-DA ", pxg_cnattach },
216 	{ "PMAG-FA ", pxg_cnattach },
217 	{ "PMAG-FB ", pxg_cnattach },
218 	{ "PMAGB-FA", pxg_cnattach },
219 	{ "PMAGB-FB", pxg_cnattach },
220 #endif
221 };
222 
223 /*
224  * tc_fb_cnattach --
225  *	Attempt to attach the appropriate display driver to the
226  * output console.
227  */
228 int
229 tc_fb_cnattach(tcaddr)
230 	tc_addr_t tcaddr;
231 {
232 	char tcname[TC_ROM_LLEN];
233 	int i;
234 
235 	if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname) == 0))
236 		return (EINVAL);
237 
238 	for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++)
239 		if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0)
240 			break;
241 
242 	if (i == sizeof(cnboards) / sizeof(cnboards[0]))
243 		return (ENXIO);
244 
245 	(cnboards[i].cb_cnattach)(tcaddr);
246 	return (0);
247 }
248 #endif /* if NWSDISPLAY > 0 */
249