tcasic.c revision 1.19 1 /* $NetBSD: tcasic.c,v 1.19 1997/09/02 13:20:35 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 (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 <sys/cdefs.h> /* RCS ID & Copyright macro defns */
31
32 __KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.19 1997/09/02 13:20:35 thorpej Exp $");
33
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/device.h>
37
38 #include <machine/autoconf.h>
39 #include <machine/rpb.h>
40
41 #include <dev/tc/tcvar.h>
42 #include <alpha/tc/tc_conf.h>
43
44 /* Definition of the driver for autoconfig. */
45 int tcasicmatch(struct device *, struct cfdata *, void *);
46 void tcasicattach(struct device *, struct device *, void *);
47
48 struct cfattach tcasic_ca = {
49 sizeof (struct device), tcasicmatch, tcasicattach,
50 };
51
52 struct cfdriver tcasic_cd = {
53 NULL, "tcasic", DV_DULL,
54 };
55
56 int tcasicprint __P((void *, const char *));
57
58 extern int cputype;
59
60 /* There can be only one. */
61 int tcasicfound;
62
63 int
64 tcasicmatch(parent, cfdata, aux)
65 struct device *parent;
66 struct cfdata *cfdata;
67 void *aux;
68 {
69 struct confargs *ca = aux;
70
71 /* Make sure that we're looking for a TurboChannel ASIC. */
72 if (strcmp(ca->ca_name, tcasic_cd.cd_name))
73 return (0);
74
75 /* Make sure that the system supports a TurboChannel ASIC. */
76 if ((cputype != ST_DEC_3000_500) && (cputype != ST_DEC_3000_300))
77 return (0);
78
79 if (tcasicfound)
80 return (0);
81
82 return (1);
83 }
84
85 void
86 tcasicattach(parent, self, aux)
87 struct device *parent;
88 struct device *self;
89 void *aux;
90 {
91 struct tcbus_attach_args tba;
92 void (*intr_setup) __P((void));
93 void (*iointr) __P((void *, unsigned long));
94
95 printf("\n");
96 tcasicfound = 1;
97
98 switch (cputype) {
99 #ifdef DEC_3000_500
100 case ST_DEC_3000_500:
101
102 intr_setup = tc_3000_500_intr_setup;
103 iointr = tc_3000_500_iointr;
104
105 tc_dma_get_tag_func = tc_dma_get_tag_3000_500;
106
107 tba.tba_busname = "tc";
108 tba.tba_speed = TC_SPEED_25_MHZ;
109 tba.tba_nslots = tc_3000_500_nslots;
110 tba.tba_slots = tc_3000_500_slots;
111 if (hwrpb->rpb_variation & SV_GRAPHICS) {
112 tba.tba_nbuiltins = tc_3000_500_graphics_nbuiltins;
113 tba.tba_builtins = tc_3000_500_graphics_builtins;
114 } else {
115 tba.tba_nbuiltins = tc_3000_500_nographics_nbuiltins;
116 tba.tba_builtins = tc_3000_500_nographics_builtins;
117 }
118 tba.tba_intr_establish = tc_3000_500_intr_establish;
119 tba.tba_intr_disestablish = tc_3000_500_intr_disestablish;
120
121 /* Do 3000/500-specific DMA setup now. */
122 tc_dma_init_3000_500(tc_3000_500_nslots);
123 break;
124 #endif /* DEC_3000_500 */
125
126 #ifdef DEC_3000_300
127 case ST_DEC_3000_300:
128
129 intr_setup = tc_3000_300_intr_setup;
130 iointr = tc_3000_300_iointr;
131
132 tc_dma_get_tag_func = tc_dma_get_tag_3000_300;
133
134 tba.tba_busname = "tc";
135 tba.tba_speed = TC_SPEED_12_5_MHZ;
136 tba.tba_nslots = tc_3000_300_nslots;
137 tba.tba_slots = tc_3000_300_slots;
138 tba.tba_nbuiltins = tc_3000_300_nbuiltins;
139 tba.tba_builtins = tc_3000_300_builtins;
140 tba.tba_intr_establish = tc_3000_300_intr_establish;
141 tba.tba_intr_disestablish = tc_3000_300_intr_disestablish;
142 break;
143 #endif /* DEC_3000_300 */
144
145 default:
146 panic("tcasicattach: bad cputype");
147 }
148
149 tba.tba_memt = tc_bus_mem_init(NULL);
150
151 tc_dma_init();
152
153 (*intr_setup)();
154 set_iointr(iointr);
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