tcasic.c revision 1.24 1 /* $NetBSD: tcasic.c,v 1.24 1998/10/22 01:03:09 briggs 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 (at) 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.24 1998/10/22 01:03:09 briggs 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
44 #include <dev/tc/tcvar.h>
45 #include <alpha/tc/tc_conf.h>
46
47 /* Definition of the driver for autoconfig. */
48 int tcasicmatch(struct device *, struct cfdata *, void *);
49 void tcasicattach(struct device *, struct device *, void *);
50
51 struct cfattach tcasic_ca = {
52 sizeof (struct device), tcasicmatch, tcasicattach,
53 };
54
55 extern struct cfdriver tcasic_cd;
56
57 int tcasicprint __P((void *, const char *));
58
59 extern int cputype;
60
61 /* There can be only one. */
62 int tcasicfound;
63
64 int
65 tcasicmatch(parent, cfdata, aux)
66 struct device *parent;
67 struct cfdata *cfdata;
68 void *aux;
69 {
70 struct mainbus_attach_args *ma = aux;
71
72 /* Make sure that we're looking for a TurboChannel ASIC. */
73 if (strcmp(ma->ma_name, tcasic_cd.cd_name))
74 return (0);
75
76 /* Make sure that the system supports a TurboChannel ASIC. */
77 if ((cputype != ST_DEC_3000_500) && (cputype != ST_DEC_3000_300))
78 return (0);
79
80 if (tcasicfound)
81 return (0);
82
83 return (1);
84 }
85
86 void
87 tcasicattach(parent, self, aux)
88 struct device *parent;
89 struct device *self;
90 void *aux;
91 {
92 struct tcbus_attach_args tba;
93 void (*intr_setup) __P((void));
94 void (*iointr) __P((void *, unsigned long));
95
96 printf("\n");
97 tcasicfound = 1;
98
99 switch (cputype) {
100 #ifdef DEC_3000_500
101 case ST_DEC_3000_500:
102
103 intr_setup = tc_3000_500_intr_setup;
104 iointr = tc_3000_500_iointr;
105
106 tba.tba_speed = TC_SPEED_25_MHZ;
107 tba.tba_nslots = tc_3000_500_nslots;
108 tba.tba_slots = tc_3000_500_slots;
109 if (hwrpb->rpb_variation & SV_GRAPHICS) {
110 tba.tba_nbuiltins = tc_3000_500_graphics_nbuiltins;
111 tba.tba_builtins = tc_3000_500_graphics_builtins;
112 } else {
113 tba.tba_nbuiltins = tc_3000_500_nographics_nbuiltins;
114 tba.tba_builtins = tc_3000_500_nographics_builtins;
115 }
116 tba.tba_intr_establish = tc_3000_500_intr_establish;
117 tba.tba_intr_disestablish = tc_3000_500_intr_disestablish;
118 tba.tba_get_dma_tag = tc_dma_get_tag_3000_500;
119
120 /* Do 3000/500-specific DMA setup now. */
121 tc_dma_init_3000_500(tc_3000_500_nslots);
122 break;
123 #endif /* DEC_3000_500 */
124
125 #ifdef DEC_3000_300
126 case ST_DEC_3000_300:
127
128 intr_setup = tc_3000_300_intr_setup;
129 iointr = tc_3000_300_iointr;
130
131 tba.tba_speed = TC_SPEED_12_5_MHZ;
132 tba.tba_nslots = tc_3000_300_nslots;
133 tba.tba_slots = tc_3000_300_slots;
134 tba.tba_nbuiltins = tc_3000_300_nbuiltins;
135 tba.tba_builtins = tc_3000_300_builtins;
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 set_iointr(iointr);
153
154 config_found(self, &tba, tcasicprint);
155 }
156
157 int
158 tcasicprint(aux, pnp)
159 void *aux;
160 const char *pnp;
161 {
162
163 /* only TCs can attach to tcasics; easy. */
164 if (pnp)
165 printf("tc at %s", pnp);
166 return (UNCONF);
167 }
168
169 #include "wsdisplay.h"
170
171 #if NWSDISPLAY > 0
172
173 #include "cfb.h"
174 #include "sfb.h"
175 #include <alpha/tc/sfbvar.h>
176 #include <alpha/tc/cfbvar.h>
177
178 extern int tc_checkslot __P((tc_addr_t, char *));
179
180 /*
181 * tc_fb_cnattach --
182 * Attempt to attach the appropriate display driver to the
183 * output console.
184 */
185 int
186 tc_fb_cnattach(tcaddr)
187 tc_addr_t tcaddr;
188 {
189 char tcname[TC_ROM_LLEN];
190
191 if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname) == 0)) {
192 return 0;
193 }
194
195 #if NSFB > 0
196 if (strncmp("PMAGB-BA", tcname, TC_ROM_LLEN) == 0) {
197 sfb_cnattach(tcaddr);
198 return 1;
199 }
200 #endif
201 #if NCFB > 0
202 if (strncmp("PMAG-BA ", tcname, TC_ROM_LLEN) == 0) {
203 cfb_cnattach(tcaddr);
204 return 1;
205 }
206 #endif
207 return 0;
208 }
209 #endif /* if NWSDISPLAY > 0 */
210