jensenio.c revision 1.1 1 /* $NetBSD: jensenio.c,v 1.1 2000/07/12 20:36:08 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Driver for the Jensen I/O bus.
41 *
42 * The Jensen I/O `bus' is comprised of two things:
43 *
44 * - VLSI VL82C106 junk I/O chip
45 * - Intel EISA bus interface
46 *
47 * Access to the 82C106 is different than to the rest of EISA space, even
48 * though it is a single address space.
49 */
50
51 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
52
53 __KERNEL_RCSID(0, "$NetBSD: jensenio.c,v 1.1 2000/07/12 20:36:08 thorpej Exp $");
54
55 #include <sys/param.h>
56 #include <sys/systm.h>
57 #include <sys/device.h>
58
59 #include <machine/autoconf.h>
60
61 #include <dev/eisa/eisavar.h>
62
63 #include <dev/isa/isareg.h>
64 #include <dev/isa/isavar.h>
65
66 #include <alpha/jensenio/jensenioreg.h>
67 #include <alpha/jensenio/jenseniovar.h>
68
69 /*
70 * The devices built-in to the VLSI VL82C106 junk I/O chip.
71 */
72 const struct jensenio_dev {
73 const char *jd_name; /* device name */
74 bus_addr_t jd_ioaddr; /* I/O space address */
75 int jd_irq[2]; /* Jensen IRQs */
76 } jensenio_devs[] = {
77 { "pckbc", IO_KBD, { 18, 19 } }, /* 0x980, 0x990 */
78 { "com", IO_COM1, { 16, -1 } }, /* 0x900 */
79 { "com", IO_COM2, { 17, -1 } }, /* 0x920 */
80 { "lpt", IO_LPT3, { 1, -1 } },
81 { "mcclock", 0x170, { -1, -1 } },
82 { NULL, 0, { -1, -1 } },
83 };
84
85 int jensenio_match(struct device *, struct cfdata *, void *);
86 void jensenio_attach(struct device *, struct device *, void *);
87
88 struct cfattach jensenio_ca = {
89 sizeof(struct device), jensenio_match, jensenio_attach
90 };
91
92 int jensenio_print(void *, const char *);
93 int jensenio_submatch(struct device *, struct cfdata *, void *);
94
95 int jensenio_attached;
96
97 struct jensenio_config jensenio_configuration;
98
99 void jensenio_eisa_attach_hook(struct device *, struct device *,
100 struct eisabus_attach_args *);
101 int jensenio_eisa_maxslots(void *);
102
103 void jensenio_isa_attach_hook(struct device *, struct device *,
104 struct isabus_attach_args *);
105
106 /*
107 * Set up the Jensen's function pointers.
108 */
109 void
110 jensenio_init(struct jensenio_config *jcp, int mallocsafe)
111 {
112
113 /*
114 * Initialize the Host Address Extension register to 0
115 * (the firmware should have already done this). We will
116 * disallow mapping of any device who's address would
117 * require a non-0 HAE. This should be safe as the final
118 * draft of the Jensen system specification states that
119 * applications should follow this little rule.
120 *
121 * There's a good reason for this; actually using HAE would
122 * require a mutex around *every* EISA cycle! Gross!
123 */
124 REGVAL(JENSEN_HAE) = 0;
125 alpha_mb();
126
127 if (jcp->jc_initted == 0) {
128 /* don't do these twice since they set up extents */
129 jensenio_bus_io_init(&jcp->jc_eisa_iot, jcp);
130 jensenio_bus_intio_init(&jcp->jc_internal_iot, jcp);
131 jensenio_bus_mem_init(&jcp->jc_eisa_memt, jcp);
132 }
133 jcp->jc_mallocsafe = mallocsafe;
134 }
135
136 int
137 jensenio_match(struct device *parent, struct cfdata *cf, void *aux)
138 {
139 struct mainbus_attach_args *ma = aux;
140
141 if (strcmp(ma->ma_name, cf->cf_driver->cd_name) != 0)
142 return (0);
143
144 /* There can be only one. */
145 if (jensenio_attached)
146 return (0);
147
148 return (1);
149 }
150
151 void
152 jensenio_attach(struct device *parent, struct device *self, void *aux)
153 {
154 struct jensenio_attach_args ja;
155 struct jensenio_config *jcp = &jensenio_configuration;
156 int i;
157
158 printf("\n");
159
160 jensenio_attached = 1;
161
162 /*
163 * Done once at console init time, but we might need to do
164 * additional work this time.
165 */
166 jensenio_init(jcp, 1);
167
168 /*
169 * Initialize DMA.
170 */
171 jensenio_dma_init(jcp);
172
173 /*
174 * Initialize interrupts.
175 */
176 jensenio_intr_init(jcp);
177
178 /*
179 * First attach all of the built-in devices.
180 */
181 for (i = 0; jensenio_devs[i].jd_name != NULL; i++) {
182 ja.ja_name = jensenio_devs[i].jd_name;
183 ja.ja_ioaddr = jensenio_devs[i].jd_ioaddr;
184 ja.ja_irq[0] = jensenio_devs[i].jd_irq[0];
185 ja.ja_irq[1] = jensenio_devs[i].jd_irq[1];
186
187 ja.ja_iot = &jcp->jc_internal_iot;
188 ja.ja_ec = &jcp->jc_ec;
189
190 (void) config_found_sm(self, &ja, jensenio_print,
191 jensenio_submatch);
192 }
193
194 /*
195 * Attach the EISA bus.
196 */
197 jcp->jc_ec.ec_attach_hook = jensenio_eisa_attach_hook;
198 jcp->jc_ec.ec_maxslots = jensenio_eisa_maxslots;
199
200 ja.ja_eisa.eba_busname = "eisa";
201 ja.ja_eisa.eba_iot = &jcp->jc_eisa_iot;
202 ja.ja_eisa.eba_memt = &jcp->jc_eisa_memt;
203 ja.ja_eisa.eba_dmat = &jcp->jc_dmat_eisa;
204 ja.ja_eisa.eba_ec = &jcp->jc_ec;
205 (void) config_found(self, &ja.ja_eisa, jensenio_print);
206
207 /*
208 * Attach the ISA bus.
209 */
210 jcp->jc_ic.ic_attach_hook = jensenio_isa_attach_hook;
211
212 ja.ja_isa.iba_busname = "isa";
213 ja.ja_isa.iba_iot = &jcp->jc_eisa_iot;
214 ja.ja_isa.iba_memt = &jcp->jc_eisa_memt;
215 ja.ja_isa.iba_dmat = &jcp->jc_dmat_isa;
216 ja.ja_isa.iba_ic = &jcp->jc_ic;
217 (void) config_found(self, &ja.ja_isa, jensenio_print);
218 }
219
220 int
221 jensenio_submatch(struct device *parent, struct cfdata *cf, void *aux)
222 {
223 struct jensenio_attach_args *ja = aux;
224
225 /*
226 * Skip the locator song-and-dance if we're attaching the
227 * EISA or ISA layer.
228 */
229 if (strcmp(ja->ja_name, "eisa") == 0 ||
230 strcmp(ja->ja_name, "isa") == 0)
231 return ((*cf->cf_attach->ca_match)(parent, cf, aux));
232
233 if (cf->cf_loc[JENSENIOCF_PORT] != JENSENIOCF_PORT_DEFAULT &&
234 cf->cf_loc[JENSENIOCF_PORT] != ja->ja_ioaddr)
235 return (0);
236
237 return ((*cf->cf_attach->ca_match)(parent, cf, aux));
238 }
239
240 int
241 jensenio_print(void *aux, const char *pnp)
242 {
243 struct jensenio_attach_args *ja = aux;
244
245 if (pnp != NULL)
246 printf("%s at %s", ja->ja_name, pnp);
247
248 /*
249 * Skip the locator song-and-dance if we're attaching the
250 * EISA or ISA layer.
251 */
252 if (strcmp(ja->ja_name, "eisa") != 0 &&
253 strcmp(ja->ja_name, "isa") != 0)
254 printf(" port 0x%lx", ja->ja_ioaddr);
255
256 return (UNCONF);
257 }
258
259 void
260 jensenio_eisa_attach_hook(struct device *parent, struct device *self,
261 struct eisabus_attach_args *eba)
262 {
263
264 /* Nothing to do. */
265 }
266
267 int
268 jensenio_eisa_maxslots(void *v)
269 {
270
271 return (16); /* as good a number as any. only 8, maybe? */
272 }
273
274 void
275 jensenio_isa_attach_hook(struct device *parent, struct device *self,
276 struct isabus_attach_args *iba)
277 {
278
279 /* Nothing to do. */
280 }
281