pioc.c revision 1.1.4.2 1 1.1.4.2 nathanw /* $NetBSD: pioc.c,v 1.1.4.2 2002/10/18 02:33:40 nathanw Exp $ */
2 1.1.4.2 nathanw
3 1.1.4.2 nathanw /*
4 1.1.4.2 nathanw * Copyright (c) 1997 Mark Brinicombe.
5 1.1.4.2 nathanw * Copyright (c) 1997 Causality Limited.
6 1.1.4.2 nathanw * All rights reserved.
7 1.1.4.2 nathanw *
8 1.1.4.2 nathanw * Redistribution and use in source and binary forms, with or without
9 1.1.4.2 nathanw * modification, are permitted provided that the following conditions
10 1.1.4.2 nathanw * are met:
11 1.1.4.2 nathanw * 1. Redistributions of source code must retain the above copyright
12 1.1.4.2 nathanw * notice, this list of conditions and the following disclaimer.
13 1.1.4.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
14 1.1.4.2 nathanw * notice, this list of conditions and the following disclaimer in the
15 1.1.4.2 nathanw * documentation and/or other materials provided with the distribution.
16 1.1.4.2 nathanw * 3. All advertising materials mentioning features or use of this software
17 1.1.4.2 nathanw * must display the following acknowledgement:
18 1.1.4.2 nathanw * This product includes software developed by Mark Brinicombe.
19 1.1.4.2 nathanw * 4. The name of the company nor the name of the author may be used to
20 1.1.4.2 nathanw * endorse or promote products derived from this software without specific
21 1.1.4.2 nathanw * prior written permission.
22 1.1.4.2 nathanw *
23 1.1.4.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 1.1.4.2 nathanw * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 1.1.4.2 nathanw * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1.4.2 nathanw * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 1.1.4.2 nathanw * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 1.1.4.2 nathanw * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 1.1.4.2 nathanw * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1.4.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1.4.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1.4.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1.4.2 nathanw * SUCH DAMAGE.
34 1.1.4.2 nathanw *
35 1.1.4.2 nathanw * Peripheral I/O controller - wd, fd, com, lpt Combo chip
36 1.1.4.2 nathanw *
37 1.1.4.2 nathanw * Parent device for combo chip I/O drivers
38 1.1.4.2 nathanw * Currently supports the SMC FDC37GT66[56] controllers.
39 1.1.4.2 nathanw */
40 1.1.4.2 nathanw
41 1.1.4.2 nathanw /*#define PIOC_DEBUG*/
42 1.1.4.2 nathanw
43 1.1.4.2 nathanw #include <sys/param.h>
44 1.1.4.2 nathanw #include <sys/systm.h>
45 1.1.4.2 nathanw #include <sys/kernel.h>
46 1.1.4.2 nathanw #include <sys/device.h>
47 1.1.4.2 nathanw
48 1.1.4.2 nathanw #include <machine/bus.h>
49 1.1.4.2 nathanw #include <arm/mainbus/mainbus.h>
50 1.1.4.2 nathanw #include <acorn32/mainbus/piocreg.h>
51 1.1.4.2 nathanw #include <acorn32/mainbus/piocvar.h>
52 1.1.4.2 nathanw
53 1.1.4.2 nathanw #include "locators.h"
54 1.1.4.2 nathanw
55 1.1.4.2 nathanw /*
56 1.1.4.2 nathanw * PIOC device.
57 1.1.4.2 nathanw *
58 1.1.4.2 nathanw * This probes and attaches the top level pioc device.
59 1.1.4.2 nathanw * It then configures any children of the pioc device.
60 1.1.4.2 nathanw */
61 1.1.4.2 nathanw
62 1.1.4.2 nathanw /*
63 1.1.4.2 nathanw * pioc softc structure.
64 1.1.4.2 nathanw *
65 1.1.4.2 nathanw * Contains the device node, bus space tag, handle and address along with
66 1.1.4.2 nathanw * other global information such as id and config registers.
67 1.1.4.2 nathanw */
68 1.1.4.2 nathanw
69 1.1.4.2 nathanw struct pioc_softc {
70 1.1.4.2 nathanw struct device sc_dev; /* device node */
71 1.1.4.2 nathanw bus_space_tag_t sc_iot; /* bus tag */
72 1.1.4.2 nathanw bus_space_handle_t sc_ioh; /* bus handle */
73 1.1.4.2 nathanw bus_addr_t sc_iobase; /* IO base address */
74 1.1.4.2 nathanw int sc_id; /* chip ID */
75 1.1.4.2 nathanw int sc_config[PIOC_CM_REGS];/* config regs */
76 1.1.4.2 nathanw };
77 1.1.4.2 nathanw
78 1.1.4.2 nathanw /*
79 1.1.4.2 nathanw * The pioc device is a parent to the com device.
80 1.1.4.2 nathanw * This means that it needs to provide a bus space tag for
81 1.1.4.2 nathanw * a serial console.
82 1.1.4.2 nathanw *
83 1.1.4.2 nathanw * XXX - This is not fully tested yet.
84 1.1.4.2 nathanw */
85 1.1.4.2 nathanw
86 1.1.4.2 nathanw extern struct bus_space mainbus_bs_tag;
87 1.1.4.2 nathanw bus_space_tag_t comconstag = &mainbus_bs_tag;
88 1.1.4.2 nathanw
89 1.1.4.2 nathanw /* Prototypes for functions */
90 1.1.4.2 nathanw
91 1.1.4.2 nathanw static int piocmatch __P((struct device *, struct cfdata *, void *));
92 1.1.4.2 nathanw static void piocattach __P((struct device *, struct device *, void *));
93 1.1.4.2 nathanw static int piocprint __P((void *aux, const char *name));
94 1.1.4.2 nathanw #if 0
95 1.1.4.2 nathanw static int piocsearch __P((struct device *, struct cfdata *, void *));
96 1.1.4.2 nathanw #endif
97 1.1.4.2 nathanw static int piocsubmatch __P((struct device *, struct cfdata *, void *));
98 1.1.4.2 nathanw static void piocgetid __P((bus_space_tag_t iot, bus_space_handle_t ioh,
99 1.1.4.2 nathanw int config_entry, int *id, int *revision));
100 1.1.4.2 nathanw
101 1.1.4.2 nathanw /* device attach and driver structure */
102 1.1.4.2 nathanw
103 1.1.4.2 nathanw CFATTACH_DECL(pioc, sizeof(struct pioc_softc),
104 1.1.4.2 nathanw piocmatch, piocattach, NULL, NULL);
105 1.1.4.2 nathanw
106 1.1.4.2 nathanw /*
107 1.1.4.2 nathanw * void piocgetid(bus_space_tag_t iot, bus_space_handle_t ioh,
108 1.1.4.2 nathanw * int config_entry, int *id, int *revision)
109 1.1.4.2 nathanw *
110 1.1.4.2 nathanw * Enter config mode and return the id and revision
111 1.1.4.2 nathanw */
112 1.1.4.2 nathanw
113 1.1.4.2 nathanw static void
114 1.1.4.2 nathanw piocgetid(iot, ioh, config_entry, id, revision)
115 1.1.4.2 nathanw bus_space_tag_t iot;
116 1.1.4.2 nathanw bus_space_handle_t ioh;
117 1.1.4.2 nathanw int config_entry;
118 1.1.4.2 nathanw int *id;
119 1.1.4.2 nathanw int *revision;
120 1.1.4.2 nathanw {
121 1.1.4.2 nathanw /*
122 1.1.4.2 nathanw * Put the chip info configuration mode and read the ID and revision
123 1.1.4.2 nathanw */
124 1.1.4.2 nathanw bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, config_entry);
125 1.1.4.2 nathanw bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, config_entry);
126 1.1.4.2 nathanw
127 1.1.4.2 nathanw bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_CRD);
128 1.1.4.2 nathanw *id = bus_space_read_1(iot, ioh, PIOC_CM_DATA_REG);
129 1.1.4.2 nathanw bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_CRE);
130 1.1.4.2 nathanw *revision = bus_space_read_1(iot, ioh, PIOC_CM_DATA_REG);
131 1.1.4.2 nathanw
132 1.1.4.2 nathanw bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_EXIT);
133 1.1.4.2 nathanw }
134 1.1.4.2 nathanw
135 1.1.4.2 nathanw /*
136 1.1.4.2 nathanw * int piocmatch(struct device *parent, struct cfdata *cf, void *aux)
137 1.1.4.2 nathanw *
138 1.1.4.2 nathanw * Put the controller into config mode and probe the ID to see if
139 1.1.4.2 nathanw * we recognise it.
140 1.1.4.2 nathanw *
141 1.1.4.2 nathanw * XXX - INTRUSIVE PROBE
142 1.1.4.2 nathanw */
143 1.1.4.2 nathanw
144 1.1.4.2 nathanw static int
145 1.1.4.2 nathanw piocmatch(parent, cf, aux)
146 1.1.4.2 nathanw struct device *parent;
147 1.1.4.2 nathanw struct cfdata *cf;
148 1.1.4.2 nathanw void *aux;
149 1.1.4.2 nathanw {
150 1.1.4.2 nathanw struct mainbus_attach_args *mb = aux;
151 1.1.4.2 nathanw bus_space_tag_t iot;
152 1.1.4.2 nathanw bus_space_handle_t ioh;
153 1.1.4.2 nathanw int id, rev;
154 1.1.4.2 nathanw int rv = 1;
155 1.1.4.2 nathanw
156 1.1.4.2 nathanw /* We need a base address */
157 1.1.4.2 nathanw if (mb->mb_iobase == MAINBUSCF_BASE_DEFAULT)
158 1.1.4.2 nathanw return(0);
159 1.1.4.2 nathanw
160 1.1.4.2 nathanw iot = mb->mb_iot;
161 1.1.4.2 nathanw if (bus_space_map(iot, mb->mb_iobase, PIOC_SIZE, 0, &ioh))
162 1.1.4.2 nathanw return(0);
163 1.1.4.2 nathanw
164 1.1.4.2 nathanw mb->mb_iosize = PIOC_SIZE;
165 1.1.4.2 nathanw
166 1.1.4.2 nathanw piocgetid(iot, ioh, PIOC_CM_ENTER_665, &id, &rev);
167 1.1.4.2 nathanw if (id == PIOC_CM_ID_665)
168 1.1.4.2 nathanw goto out;
169 1.1.4.2 nathanw
170 1.1.4.2 nathanw piocgetid(iot, ioh, PIOC_CM_ENTER_666, &id, &rev);
171 1.1.4.2 nathanw if (id == PIOC_CM_ID_666)
172 1.1.4.2 nathanw goto out;
173 1.1.4.2 nathanw
174 1.1.4.2 nathanw rv = 0;
175 1.1.4.2 nathanw
176 1.1.4.2 nathanw out:
177 1.1.4.2 nathanw bus_space_unmap(iot, ioh, PIOC_SIZE);
178 1.1.4.2 nathanw return(rv);
179 1.1.4.2 nathanw }
180 1.1.4.2 nathanw
181 1.1.4.2 nathanw /*
182 1.1.4.2 nathanw * int piocprint(void *aux, const char *name)
183 1.1.4.2 nathanw *
184 1.1.4.2 nathanw * print routine used during child configuration
185 1.1.4.2 nathanw */
186 1.1.4.2 nathanw
187 1.1.4.2 nathanw static int
188 1.1.4.2 nathanw piocprint(aux, name)
189 1.1.4.2 nathanw void *aux;
190 1.1.4.2 nathanw const char *name;
191 1.1.4.2 nathanw {
192 1.1.4.2 nathanw struct pioc_attach_args *pa = aux;
193 1.1.4.2 nathanw
194 1.1.4.2 nathanw if (!name) {
195 1.1.4.2 nathanw if (pa->pa_offset)
196 1.1.4.2 nathanw printf(" offset 0x%x", pa->pa_offset >> 2);
197 1.1.4.2 nathanw if (pa->pa_iosize > 1)
198 1.1.4.2 nathanw printf("-0x%x", ((pa->pa_offset >> 2) + pa->pa_iosize) - 1);
199 1.1.4.2 nathanw if (pa->pa_irq != -1)
200 1.1.4.2 nathanw printf(" irq %d", pa->pa_irq);
201 1.1.4.2 nathanw if (pa->pa_drq != -1)
202 1.1.4.2 nathanw printf(" drq 0x%08x", pa->pa_drq);
203 1.1.4.2 nathanw }
204 1.1.4.2 nathanw
205 1.1.4.2 nathanw /* XXX print flags */
206 1.1.4.2 nathanw return (QUIET);
207 1.1.4.2 nathanw }
208 1.1.4.2 nathanw
209 1.1.4.2 nathanw #if 0
210 1.1.4.2 nathanw /*
211 1.1.4.2 nathanw * int piocsearch(struct device *parent, struct cfdata *cf, void *aux)
212 1.1.4.2 nathanw *
213 1.1.4.2 nathanw * search function used to probe and attach the child devices.
214 1.1.4.2 nathanw *
215 1.1.4.2 nathanw * Note: since the offsets of the devices need to be specified in the
216 1.1.4.2 nathanw * config file we ignore the FSTAT_STAR.
217 1.1.4.2 nathanw */
218 1.1.4.2 nathanw
219 1.1.4.2 nathanw static int
220 1.1.4.2 nathanw piocsearch(parent, cf, aux)
221 1.1.4.2 nathanw struct device *parent;
222 1.1.4.2 nathanw struct cfdata *cf;
223 1.1.4.2 nathanw void *aux;
224 1.1.4.2 nathanw {
225 1.1.4.2 nathanw struct pioc_softc *sc = (struct pioc_softc *)parent;
226 1.1.4.2 nathanw struct pioc_attach_args pa;
227 1.1.4.2 nathanw int tryagain;
228 1.1.4.2 nathanw
229 1.1.4.2 nathanw do {
230 1.1.4.2 nathanw pa.pa_name = NULL;
231 1.1.4.2 nathanw pa.pa_iobase = sc->sc_iobase;
232 1.1.4.2 nathanw pa.pa_iosize = 0;
233 1.1.4.2 nathanw pa.pa_iot = sc->sc_iot;
234 1.1.4.2 nathanw if (cf->cf_loc[PIOCCF_OFFSET] == PIOCCF_OFFSET_DEFAULT) {
235 1.1.4.2 nathanw pa.pa_offset = PIOCCF_OFFSET_DEFAULT;
236 1.1.4.2 nathanw pa.pa_drq = PIOCCF_DACK_DEFAULT;
237 1.1.4.2 nathanw pa.pa_irq = PIOCCF_IRQ_DEFAULT;
238 1.1.4.2 nathanw } else {
239 1.1.4.2 nathanw pa.pa_offset = (cf->cf_loc[PIOCCF_OFFSET] << 2);
240 1.1.4.2 nathanw pa.pa_drq = cf->cf_loc[PIOCCF_DACK];
241 1.1.4.2 nathanw pa.pa_irq = cf->cf_loc[PIOCCF_IRQ];
242 1.1.4.2 nathanw }
243 1.1.4.2 nathanw
244 1.1.4.2 nathanw tryagain = 0;
245 1.1.4.2 nathanw if (config_match(parent, cf, &pa) > 0) {
246 1.1.4.2 nathanw config_attach(parent, cf, &pa, piocprint);
247 1.1.4.2 nathanw /* tryagain = (cf->cf_fstate == FSTATE_STAR);*/
248 1.1.4.2 nathanw }
249 1.1.4.2 nathanw } while (tryagain);
250 1.1.4.2 nathanw
251 1.1.4.2 nathanw return (0);
252 1.1.4.2 nathanw }
253 1.1.4.2 nathanw #endif
254 1.1.4.2 nathanw
255 1.1.4.2 nathanw /*
256 1.1.4.2 nathanw * int piocsubmatch(struct device *parent, struct cfdata *cf, void *aux)
257 1.1.4.2 nathanw *
258 1.1.4.2 nathanw * search function used to probe and attach the child devices.
259 1.1.4.2 nathanw *
260 1.1.4.2 nathanw * Note: since the offsets of the devices need to be specified in the
261 1.1.4.2 nathanw * config file we ignore the FSTAT_STAR.
262 1.1.4.2 nathanw */
263 1.1.4.2 nathanw
264 1.1.4.2 nathanw static int
265 1.1.4.2 nathanw piocsubmatch(parent, cf, aux)
266 1.1.4.2 nathanw struct device *parent;
267 1.1.4.2 nathanw struct cfdata *cf;
268 1.1.4.2 nathanw void *aux;
269 1.1.4.2 nathanw {
270 1.1.4.2 nathanw struct pioc_attach_args *pa = aux;
271 1.1.4.2 nathanw int tryagain;
272 1.1.4.2 nathanw
273 1.1.4.2 nathanw if ((pa->pa_offset >> 2) != cf->cf_loc[0])
274 1.1.4.2 nathanw return(0);
275 1.1.4.2 nathanw do {
276 1.1.4.2 nathanw if (pa->pa_drq == -1)
277 1.1.4.2 nathanw pa->pa_drq = cf->cf_loc[1];
278 1.1.4.2 nathanw if (pa->pa_irq == -1)
279 1.1.4.2 nathanw pa->pa_irq = cf->cf_loc[2];
280 1.1.4.2 nathanw tryagain = 0;
281 1.1.4.2 nathanw if (config_match(parent, cf, pa) > 0) {
282 1.1.4.2 nathanw config_attach(parent, cf, pa, piocprint);
283 1.1.4.2 nathanw /* tryagain = (cf->cf_fstate == FSTATE_STAR);*/
284 1.1.4.2 nathanw }
285 1.1.4.2 nathanw } while (tryagain);
286 1.1.4.2 nathanw
287 1.1.4.2 nathanw return (0);
288 1.1.4.2 nathanw }
289 1.1.4.2 nathanw
290 1.1.4.2 nathanw /*
291 1.1.4.2 nathanw * void piocattach(struct device *parent, struct device *dev, void *aux)
292 1.1.4.2 nathanw *
293 1.1.4.2 nathanw * Identify the PIOC and read the config registers into the softc.
294 1.1.4.2 nathanw * Search and configure all children
295 1.1.4.2 nathanw */
296 1.1.4.2 nathanw
297 1.1.4.2 nathanw static void
298 1.1.4.2 nathanw piocattach(parent, self, aux)
299 1.1.4.2 nathanw struct device *parent;
300 1.1.4.2 nathanw struct device *self;
301 1.1.4.2 nathanw void *aux;
302 1.1.4.2 nathanw {
303 1.1.4.2 nathanw struct mainbus_attach_args *mb = aux;
304 1.1.4.2 nathanw struct pioc_softc *sc = (struct pioc_softc *)self;
305 1.1.4.2 nathanw bus_space_tag_t iot;
306 1.1.4.2 nathanw bus_space_handle_t ioh;
307 1.1.4.2 nathanw int id, rev;
308 1.1.4.2 nathanw int loop;
309 1.1.4.2 nathanw struct pioc_attach_args pa;
310 1.1.4.2 nathanw
311 1.1.4.2 nathanw sc->sc_iobase = mb->mb_iobase;
312 1.1.4.2 nathanw iot = sc->sc_iot = mb->mb_iot;
313 1.1.4.2 nathanw
314 1.1.4.2 nathanw if (bus_space_map(iot, sc->sc_iobase, PIOC_SIZE, 0, &ioh))
315 1.1.4.2 nathanw panic("%s: couldn't map I/O space", self->dv_xname);
316 1.1.4.2 nathanw sc->sc_ioh = ioh;
317 1.1.4.2 nathanw
318 1.1.4.2 nathanw piocgetid(iot, ioh, PIOC_CM_ENTER_665, &id, &rev);
319 1.1.4.2 nathanw if (id != PIOC_CM_ID_665)
320 1.1.4.2 nathanw piocgetid(iot, ioh, PIOC_CM_ENTER_666, &id, &rev);
321 1.1.4.2 nathanw
322 1.1.4.2 nathanw printf("\n%s: ", self->dv_xname);
323 1.1.4.2 nathanw
324 1.1.4.2 nathanw /* Do we recognise it ? */
325 1.1.4.2 nathanw switch (id) {
326 1.1.4.2 nathanw case PIOC_CM_ID_665:
327 1.1.4.2 nathanw case PIOC_CM_ID_666:
328 1.1.4.2 nathanw printf("SMC FDC37C6%xGT peripheral controller rev %d\n", id, rev);
329 1.1.4.2 nathanw break;
330 1.1.4.2 nathanw default:
331 1.1.4.2 nathanw printf("Unrecognised peripheral controller id=%2x rev=%2x\n", id, rev);
332 1.1.4.2 nathanw return;
333 1.1.4.2 nathanw }
334 1.1.4.2 nathanw
335 1.1.4.2 nathanw sc->sc_id = id;
336 1.1.4.2 nathanw
337 1.1.4.2 nathanw /*
338 1.1.4.2 nathanw * Put the chip info configuration mode and save all the registers
339 1.1.4.2 nathanw */
340 1.1.4.2 nathanw
341 1.1.4.2 nathanw switch (id) {
342 1.1.4.2 nathanw case PIOC_CM_ID_665:
343 1.1.4.2 nathanw bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_ENTER_665);
344 1.1.4.2 nathanw bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_ENTER_665);
345 1.1.4.2 nathanw break;
346 1.1.4.2 nathanw
347 1.1.4.2 nathanw case PIOC_CM_ID_666:
348 1.1.4.2 nathanw bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_ENTER_666);
349 1.1.4.2 nathanw bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_ENTER_666);
350 1.1.4.2 nathanw break;
351 1.1.4.2 nathanw }
352 1.1.4.2 nathanw
353 1.1.4.2 nathanw for (loop = 0; loop < PIOC_CM_REGS; ++loop) {
354 1.1.4.2 nathanw bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, loop);
355 1.1.4.2 nathanw sc->sc_config[loop] = bus_space_read_1(iot, ioh, PIOC_CM_DATA_REG);
356 1.1.4.2 nathanw }
357 1.1.4.2 nathanw
358 1.1.4.2 nathanw bus_space_write_1(iot, ioh, PIOC_CM_SELECT_REG, PIOC_CM_EXIT);
359 1.1.4.2 nathanw
360 1.1.4.2 nathanw #ifdef PIOC_DEBUG
361 1.1.4.2 nathanw printf("%s: ", self->dv_xname);
362 1.1.4.2 nathanw
363 1.1.4.2 nathanw for (loop = 0; loop < PIOC_CM_REGS; ++loop)
364 1.1.4.2 nathanw printf("%02x ", sc->sc_config[loop]);
365 1.1.4.2 nathanw printf("\n");
366 1.1.4.2 nathanw #endif
367 1.1.4.2 nathanw
368 1.1.4.2 nathanw /*
369 1.1.4.2 nathanw * Ok as yet we cannot do specific config_found() calls
370 1.1.4.2 nathanw * for the children yet. This is because the pioc device does
371 1.1.4.2 nathanw * not know the interrupt numbers to use.
372 1.1.4.2 nathanw * Eventually this information will have to be provided by the
373 1.1.4.2 nathanw * riscpc specific code.
374 1.1.4.2 nathanw * Until then just do a config_search() and pick the info up
375 1.1.4.2 nathanw * from the cfdata.
376 1.1.4.2 nathanw * Note the child devices require some modifications as well.
377 1.1.4.2 nathanw */
378 1.1.4.2 nathanw
379 1.1.4.2 nathanw /*
380 1.1.4.2 nathanw * Ok Now configure the child devices of the pioc device
381 1.1.4.2 nathanw * Use the pioc config registers to determine the addressing
382 1.1.4.2 nathanw * of the children
383 1.1.4.2 nathanw */
384 1.1.4.2 nathanw
385 1.1.4.2 nathanw /*
386 1.1.4.2 nathanw * Start by configuring the IDE controller
387 1.1.4.2 nathanw */
388 1.1.4.2 nathanw
389 1.1.4.2 nathanw if (sc->sc_config[PIOC_CM_CR0] & PIOC_WDC_ENABLE) {
390 1.1.4.2 nathanw pa.pa_name = "wdc";
391 1.1.4.2 nathanw pa.pa_iobase = sc->sc_iobase;
392 1.1.4.2 nathanw pa.pa_iosize = 0;
393 1.1.4.2 nathanw pa.pa_iot = iot;
394 1.1.4.2 nathanw if (sc->sc_config[PIOC_CM_CR5] & PIOC_WDC_SECONDARY)
395 1.1.4.2 nathanw pa.pa_offset = (PIOC_WDC_SECONDARY_OFFSET << 2);
396 1.1.4.2 nathanw else
397 1.1.4.2 nathanw pa.pa_offset = (PIOC_WDC_PRIMARY_OFFSET << 2);
398 1.1.4.2 nathanw pa.pa_drq = -1;
399 1.1.4.2 nathanw pa.pa_irq = -1;
400 1.1.4.2 nathanw config_found_sm(self, &pa, piocprint, piocsubmatch);
401 1.1.4.2 nathanw }
402 1.1.4.2 nathanw
403 1.1.4.2 nathanw /*
404 1.1.4.2 nathanw * Next configure the floppy controller
405 1.1.4.2 nathanw */
406 1.1.4.2 nathanw
407 1.1.4.2 nathanw if (sc->sc_config[PIOC_CM_CR0] & PIOC_FDC_ENABLE) {
408 1.1.4.2 nathanw pa.pa_name = "fdc";
409 1.1.4.2 nathanw pa.pa_iobase = sc->sc_iobase;
410 1.1.4.2 nathanw pa.pa_iosize = 0;
411 1.1.4.2 nathanw pa.pa_iot = iot;
412 1.1.4.2 nathanw if (sc->sc_config[PIOC_CM_CR5] & PIOC_FDC_SECONDARY)
413 1.1.4.2 nathanw pa.pa_offset = (PIOC_FDC_SECONDARY_OFFSET << 2);
414 1.1.4.2 nathanw else
415 1.1.4.2 nathanw pa.pa_offset = (PIOC_FDC_PRIMARY_OFFSET << 2);
416 1.1.4.2 nathanw pa.pa_drq = -1;
417 1.1.4.2 nathanw pa.pa_irq = -1;
418 1.1.4.2 nathanw config_found_sm(self, &pa, piocprint, piocsubmatch);
419 1.1.4.2 nathanw }
420 1.1.4.2 nathanw
421 1.1.4.2 nathanw /*
422 1.1.4.2 nathanw * Next configure the serial ports
423 1.1.4.2 nathanw */
424 1.1.4.2 nathanw
425 1.1.4.2 nathanw /*
426 1.1.4.2 nathanw * XXX - There is a deficiency in the serial configuration
427 1.1.4.2 nathanw * If the PIOC has the serial ports configured for COM3 and COM4
428 1.1.4.2 nathanw * the standard COM3 and COM4 addresses are assumed rather than
429 1.1.4.2 nathanw * examining CR1 to determine the COM3 and COM4 addresses.
430 1.1.4.2 nathanw */
431 1.1.4.2 nathanw
432 1.1.4.2 nathanw if (sc->sc_config[PIOC_CM_CR2] & PIOC_UART1_ENABLE) {
433 1.1.4.2 nathanw pa.pa_name = "com";
434 1.1.4.2 nathanw pa.pa_iobase = sc->sc_iobase;
435 1.1.4.2 nathanw pa.pa_iosize = 0;
436 1.1.4.2 nathanw pa.pa_iot = iot;
437 1.1.4.2 nathanw switch (sc->sc_config[PIOC_CM_CR2] & PIOC_UART1_ADDR_MASK) {
438 1.1.4.2 nathanw case PIOC_UART1_ADDR_COM1:
439 1.1.4.2 nathanw pa.pa_offset = (PIOC_COM1_OFFSET << 2);
440 1.1.4.2 nathanw break;
441 1.1.4.2 nathanw case PIOC_UART1_ADDR_COM2:
442 1.1.4.2 nathanw pa.pa_offset = (PIOC_COM2_OFFSET << 2);
443 1.1.4.2 nathanw break;
444 1.1.4.2 nathanw case PIOC_UART1_ADDR_COM3:
445 1.1.4.2 nathanw pa.pa_offset = (PIOC_COM3_OFFSET << 2);
446 1.1.4.2 nathanw break;
447 1.1.4.2 nathanw case PIOC_UART1_ADDR_COM4:
448 1.1.4.2 nathanw pa.pa_offset = (PIOC_COM4_OFFSET << 2);
449 1.1.4.2 nathanw break;
450 1.1.4.2 nathanw }
451 1.1.4.2 nathanw pa.pa_drq = -1;
452 1.1.4.2 nathanw pa.pa_irq = -1;
453 1.1.4.2 nathanw config_found_sm(self, &pa, piocprint, piocsubmatch);
454 1.1.4.2 nathanw }
455 1.1.4.2 nathanw
456 1.1.4.2 nathanw if (sc->sc_config[PIOC_CM_CR2] & PIOC_UART2_ENABLE) {
457 1.1.4.2 nathanw pa.pa_name = "com";
458 1.1.4.2 nathanw pa.pa_iobase = sc->sc_iobase;
459 1.1.4.2 nathanw pa.pa_iosize = 0;
460 1.1.4.2 nathanw pa.pa_iot = iot;
461 1.1.4.2 nathanw switch (sc->sc_config[PIOC_CM_CR2] & PIOC_UART2_ADDR_MASK) {
462 1.1.4.2 nathanw case PIOC_UART2_ADDR_COM1:
463 1.1.4.2 nathanw pa.pa_offset = (PIOC_COM1_OFFSET << 2);
464 1.1.4.2 nathanw break;
465 1.1.4.2 nathanw case PIOC_UART2_ADDR_COM2:
466 1.1.4.2 nathanw pa.pa_offset = (PIOC_COM2_OFFSET << 2);
467 1.1.4.2 nathanw break;
468 1.1.4.2 nathanw case PIOC_UART2_ADDR_COM3:
469 1.1.4.2 nathanw pa.pa_offset = (PIOC_COM3_OFFSET << 2);
470 1.1.4.2 nathanw break;
471 1.1.4.2 nathanw case PIOC_UART2_ADDR_COM4:
472 1.1.4.2 nathanw pa.pa_offset = (PIOC_COM4_OFFSET << 2);
473 1.1.4.2 nathanw break;
474 1.1.4.2 nathanw }
475 1.1.4.2 nathanw pa.pa_drq = -1;
476 1.1.4.2 nathanw pa.pa_irq = -1;
477 1.1.4.2 nathanw config_found_sm(self, &pa, piocprint, piocsubmatch);
478 1.1.4.2 nathanw }
479 1.1.4.2 nathanw
480 1.1.4.2 nathanw /*
481 1.1.4.2 nathanw * Next configure the printer port
482 1.1.4.2 nathanw */
483 1.1.4.2 nathanw
484 1.1.4.2 nathanw if ((sc->sc_config[PIOC_CM_CR1] & PIOC_LPT_ADDR_MASK) != PIOC_LPT_ADDR_DISABLE) {
485 1.1.4.2 nathanw pa.pa_name = "lpt";
486 1.1.4.2 nathanw pa.pa_iobase = sc->sc_iobase;
487 1.1.4.2 nathanw pa.pa_iosize = 0;
488 1.1.4.2 nathanw pa.pa_iot = iot;
489 1.1.4.2 nathanw switch (sc->sc_config[PIOC_CM_CR1] & PIOC_LPT_ADDR_MASK) {
490 1.1.4.2 nathanw case PIOC_LPT_ADDR_1:
491 1.1.4.2 nathanw pa.pa_offset = (PIOC_LPT1_OFFSET << 2);
492 1.1.4.2 nathanw break;
493 1.1.4.2 nathanw case PIOC_LPT_ADDR_2:
494 1.1.4.2 nathanw pa.pa_offset = (PIOC_LPT2_OFFSET << 2);
495 1.1.4.2 nathanw break;
496 1.1.4.2 nathanw case PIOC_LPT_ADDR_3:
497 1.1.4.2 nathanw pa.pa_offset = (PIOC_LPT3_OFFSET << 2);
498 1.1.4.2 nathanw break;
499 1.1.4.2 nathanw }
500 1.1.4.2 nathanw pa.pa_drq = -1;
501 1.1.4.2 nathanw pa.pa_irq = -1;
502 1.1.4.2 nathanw config_found_sm(self, &pa, piocprint, piocsubmatch);
503 1.1.4.2 nathanw }
504 1.1.4.2 nathanw
505 1.1.4.2 nathanw #if 0
506 1.1.4.2 nathanw config_search(piocsearch, self, NULL);
507 1.1.4.2 nathanw #endif
508 1.1.4.2 nathanw }
509 1.1.4.2 nathanw
510 1.1.4.2 nathanw /* End of pioc.c */
511