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