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