xref: /openbsd/sys/arch/alpha/tc/tcasic.c (revision 76d0caae)
1 /* $OpenBSD: tcasic.c,v 1.18 2020/05/23 08:40:55 jsg Exp $ */
2 /* $NetBSD: tcasic.c,v 1.36 2001/08/23 01:16:52 nisimura Exp $ */
3 
4 /*
5  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
6  * All rights reserved.
7  *
8  * Author: Chris G. Demetriou
9  *
10  * Permission to use, copy, modify and distribute this software and
11  * its documentation is hereby granted, provided that both the copyright
12  * notice and this permission notice appear in all copies of the
13  * software, derivative works or modified versions, and any portions
14  * thereof, and that both notices appear in supporting documentation.
15  *
16  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19  *
20  * Carnegie Mellon requests users of this software to return to
21  *
22  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
23  *  School of Computer Science
24  *  Carnegie Mellon University
25  *  Pittsburgh PA 15213-3890
26  *
27  * any improvements or extensions that they make and grant Carnegie the
28  * rights to redistribute these changes.
29  */
30 
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/device.h>
34 
35 #include <machine/autoconf.h>
36 #include <machine/rpb.h>
37 #include <machine/cpu.h>
38 
39 #include <dev/tc/tcvar.h>
40 #include <alpha/tc/tc_conf.h>
41 
42 /* Definition of the driver for autoconfig. */
43 int	tcasicmatch(struct device *, void *, void *);
44 void	tcasicattach(struct device *, struct device *, void *);
45 int	tcasicactivate(struct device *, int);
46 
47 struct cfattach tcasic_ca = {
48 	.ca_devsize = sizeof (struct device),
49 	.ca_match = tcasicmatch,
50 	.ca_attach = tcasicattach,
51 	.ca_activate = tcasicactivate
52 };
53 
54 struct cfdriver tcasic_cd = {
55 	NULL, "tcasic", DV_DULL,
56 };
57 
58 
59 int	tcasicprint(void *, const char *);
60 
61 /* There can be only one. */
62 int	tcasicfound;
63 
64 int
65 tcasicmatch(parent, cfdata, aux)
66 	struct device *parent;
67 	void *cfdata, *aux;
68 {
69 	struct mainbus_attach_args *ma = aux;
70 
71         /* Make sure that we're looking for a TurboChannel ASIC. */
72         if (strcmp(ma->ma_name, tcasic_cd.cd_name))
73                 return (0);
74 
75 	if (tcasicfound)
76 		return (0);
77 
78 	return (1);
79 }
80 
81 void
82 tcasicattach(parent, self, aux)
83 	struct device *parent;
84 	struct device *self;
85 	void *aux;
86 {
87 	struct tcbus_attach_args tba;
88 	void (*intr_setup)(void);
89 	void (*iointr)(void *, unsigned long);
90 
91 	printf("\n");
92 	tcasicfound = 1;
93 
94 	switch (cputype) {
95 #ifdef DEC_3000_500
96 	case ST_DEC_3000_500:
97 
98 		intr_setup = tc_3000_500_intr_setup;
99 		iointr = tc_3000_500_iointr;
100 
101 		if ((hwrpb->rpb_type & SV_ST_MASK) == SV_ST_SANDPIPER)
102 			tba.tba_speed = TC_SPEED_22_5_MHZ;
103 		else
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_establish = tc_3000_500_intr_establish;
115 		tba.tba_intr_disestablish = tc_3000_500_intr_disestablish;
116 		tba.tba_get_dma_tag = tc_dma_get_tag_3000_500;
117 
118 		/* Do 3000/500-specific DMA setup now. */
119 		tc_dma_init_3000_500(tc_3000_500_nslots);
120 		break;
121 #endif /* DEC_3000_500 */
122 
123 #ifdef DEC_3000_300
124 	case ST_DEC_3000_300:
125 
126 		intr_setup = tc_3000_300_intr_setup;
127 		iointr = tc_3000_300_iointr;
128 
129 		tba.tba_speed = TC_SPEED_12_5_MHZ;
130 		tba.tba_nslots = tc_3000_300_nslots;
131 		tba.tba_slots = tc_3000_300_slots;
132 		tba.tba_nbuiltins = tc_3000_300_nbuiltins;
133 		tba.tba_builtins = tc_3000_300_builtins;
134 		tba.tba_intr_establish = tc_3000_300_intr_establish;
135 		tba.tba_intr_disestablish = tc_3000_300_intr_disestablish;
136 		tba.tba_get_dma_tag = tc_dma_get_tag_3000_300;
137 		break;
138 #endif /* DEC_3000_300 */
139 
140 	default:
141 		panic("tcasicattach: bad cputype");
142 	}
143 
144 	tba.tba_busname = "tc";
145 	tba.tba_memt = tc_bus_mem_init(NULL);
146 
147 	tc_dma_init();
148 
149 	(*intr_setup)();
150 
151 	/* They all come in at 0x800. */
152 	scb_set(0x800, iointr, NULL);
153 
154 	config_found(self, &tba, tcasicprint);
155 }
156 
157 int
158 tcasicactivate(struct device *self, int act)
159 {
160 	switch (cputype) {
161 #ifdef DEC_3000_500
162 	case ST_DEC_3000_500:
163 		return tc_3000_500_activate(self, act);
164 #endif
165 	default:
166 		return config_activate_children(self, act);
167 	}
168 }
169 
170 int
171 tcasicprint(aux, pnp)
172 	void *aux;
173 	const char *pnp;
174 {
175 
176 	/* only TCs can attach to tcasics; easy. */
177 	if (pnp)
178 		printf("tc at %s", pnp);
179 	return (UNCONF);
180 }
181 
182 int
183 tc_fb_cnattach(tcaddr)
184 	tc_addr_t tcaddr;
185 {
186 		return (ENXIO);
187 }
188