podulebus.c revision 1.22 1 1.22 dsl /* $NetBSD: podulebus.c,v 1.22 2009/03/14 15:35:59 dsl Exp $ */
2 1.1 reinoud
3 1.1 reinoud /*
4 1.1 reinoud * Copyright (c) 1994-1996 Mark Brinicombe.
5 1.1 reinoud * Copyright (c) 1994 Brini.
6 1.1 reinoud * All rights reserved.
7 1.1 reinoud *
8 1.1 reinoud * Redistribution and use in source and binary forms, with or without
9 1.1 reinoud * modification, are permitted provided that the following conditions
10 1.1 reinoud * are met:
11 1.1 reinoud * 1. Redistributions of source code must retain the above copyright
12 1.1 reinoud * notice, this list of conditions and the following disclaimer.
13 1.1 reinoud * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 reinoud * notice, this list of conditions and the following disclaimer in the
15 1.1 reinoud * documentation and/or other materials provided with the distribution.
16 1.1 reinoud * 3. All advertising materials mentioning features or use of this software
17 1.1 reinoud * must display the following acknowledgement:
18 1.1 reinoud * This product includes software developed by Brini.
19 1.1 reinoud * 4. The name of the company nor the name of the author may be used to
20 1.1 reinoud * endorse or promote products derived from this software without specific
21 1.1 reinoud * prior written permission.
22 1.1 reinoud *
23 1.1 reinoud * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 1.1 reinoud * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 1.1 reinoud * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1 reinoud * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 1.1 reinoud * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 1.1 reinoud * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 1.1 reinoud * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 reinoud * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 reinoud * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 reinoud * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 reinoud * SUCH DAMAGE.
34 1.1 reinoud *
35 1.1 reinoud * RiscBSD kernel project
36 1.1 reinoud *
37 1.1 reinoud * podulebus.c
38 1.1 reinoud *
39 1.1 reinoud * Podule probe and configuration routines
40 1.1 reinoud *
41 1.1 reinoud * Created : 07/11/94
42 1.1 reinoud */
43 1.1 reinoud
44 1.1 reinoud #include <sys/param.h>
45 1.5 bjh21
46 1.22 dsl __KERNEL_RCSID(0, "$NetBSD: podulebus.c,v 1.22 2009/03/14 15:35:59 dsl Exp $");
47 1.5 bjh21
48 1.1 reinoud #include <sys/systm.h>
49 1.1 reinoud #include <sys/kernel.h>
50 1.1 reinoud #include <sys/conf.h>
51 1.1 reinoud #include <sys/malloc.h>
52 1.1 reinoud #include <sys/device.h>
53 1.1 reinoud #include <uvm/uvm_extern.h>
54 1.1 reinoud #include <machine/io.h>
55 1.2 thorpej #include <arm/arm32/katelib.h>
56 1.4 thorpej #include <machine/intr.h>
57 1.1 reinoud #include <machine/bootconfig.h>
58 1.1 reinoud #include <machine/pmap.h>
59 1.1 reinoud #include <arm/iomd/iomdreg.h>
60 1.1 reinoud #include <arm/iomd/iomdvar.h>
61 1.1 reinoud #include <acorn32/podulebus/podulebus.h>
62 1.1 reinoud #include <dev/podulebus/podules.h>
63 1.1 reinoud #include <dev/podulebus/podule_data.h>
64 1.1 reinoud
65 1.1 reinoud #include "locators.h"
66 1.1 reinoud
67 1.1 reinoud /* Array of podule structures, one per possible podule */
68 1.1 reinoud
69 1.1 reinoud podule_t podules[MAX_PODULES + MAX_NETSLOTS];
70 1.1 reinoud
71 1.1 reinoud extern struct bus_space podulebus_bs_tag;
72 1.1 reinoud
73 1.1 reinoud /* Declare prototypes */
74 1.1 reinoud
75 1.21 dsl u_int poduleread(u_int, int);
76 1.5 bjh21 int podulebusmatch(struct device *, struct cfdata *, void *);
77 1.5 bjh21 void podulebusattach(struct device *, struct device *, void *);
78 1.5 bjh21 int podulebusprint(void *, const char *);
79 1.18 drochner int podulebussubmatch(struct device *, struct cfdata *,
80 1.19 drochner const int *, void *);
81 1.5 bjh21 void podulechunkdirectory(podule_t *);
82 1.5 bjh21 void podulescan(struct device *);
83 1.1 reinoud
84 1.1 reinoud /*
85 1.1 reinoud * int podulebusmatch(struct device *parent, void *match, void *aux)
86 1.1 reinoud *
87 1.1 reinoud * Probe for the podule bus. Currently all this does is return 1 to
88 1.1 reinoud * indicate that the podule bus was found.
89 1.1 reinoud */
90 1.1 reinoud
91 1.1 reinoud int
92 1.22 dsl podulebusmatch(struct device *parent, struct cfdata *cf, void *aux)
93 1.1 reinoud {
94 1.1 reinoud switch (IOMD_ID) {
95 1.1 reinoud case RPC600_IOMD_ID:
96 1.1 reinoud case ARM7500_IOC_ID:
97 1.1 reinoud case ARM7500FE_IOC_ID:
98 1.1 reinoud return(1);
99 1.1 reinoud }
100 1.1 reinoud return (0);
101 1.1 reinoud }
102 1.1 reinoud
103 1.1 reinoud
104 1.1 reinoud int
105 1.22 dsl podulebusprint(void *aux, const char *name)
106 1.1 reinoud {
107 1.1 reinoud struct podule_attach_args *pa = aux;
108 1.1 reinoud
109 1.1 reinoud if (name)
110 1.15 thorpej aprint_normal("podule at %s", name);
111 1.1 reinoud if (pa->pa_podule->slottype == SLOT_POD)
112 1.15 thorpej aprint_normal(" slot %d", pa->pa_podule_number);
113 1.1 reinoud else if (pa->pa_podule->slottype == SLOT_NET)
114 1.15 thorpej aprint_normal(" [ netslot %d ]",
115 1.15 thorpej pa->pa_podule_number - MAX_PODULES);
116 1.1 reinoud #ifdef DIAGNOSTIC
117 1.1 reinoud else
118 1.11 provos panic("Invalid slot type");
119 1.1 reinoud #endif
120 1.1 reinoud
121 1.1 reinoud return (UNCONF);
122 1.1 reinoud }
123 1.1 reinoud
124 1.1 reinoud
125 1.1 reinoud int
126 1.22 dsl podulebussubmatch(struct device *parent, struct cfdata *cf, const int *ldesc, void *aux)
127 1.1 reinoud {
128 1.1 reinoud struct podule_attach_args *pa = aux;
129 1.1 reinoud
130 1.1 reinoud /* Return priority 0 or 1 for wildcarded podule */
131 1.1 reinoud
132 1.1 reinoud if (cf->cf_loc[PODULEBUSCF_SLOT] == PODULEBUSCF_SLOT_DEFAULT)
133 1.10 thorpej return(config_match(parent, cf, aux));
134 1.1 reinoud
135 1.1 reinoud /* Return higher priority if we match the specific podule */
136 1.1 reinoud
137 1.1 reinoud else if (cf->cf_loc[PODULEBUSCF_SLOT] == pa->pa_podule_number)
138 1.10 thorpej return(config_match(parent, cf, aux) * 8);
139 1.1 reinoud
140 1.1 reinoud /* Fail */
141 1.1 reinoud return(0);
142 1.1 reinoud }
143 1.1 reinoud
144 1.1 reinoud
145 1.1 reinoud #if 0
146 1.1 reinoud void
147 1.22 dsl dump_podule(podule_t *podule)
148 1.1 reinoud {
149 1.1 reinoud printf("podule%d: ", podule->podulenum);
150 1.1 reinoud printf("flags0=%02x ", podule->flags0);
151 1.1 reinoud printf("flags1=%02x ", podule->flags1);
152 1.1 reinoud printf("reserved=%02x ", podule->reserved);
153 1.1 reinoud printf("product=%02x ", podule->product);
154 1.1 reinoud printf("manufacturer=%02x ", podule->manufacturer);
155 1.1 reinoud printf("country=%02x ", podule->country);
156 1.1 reinoud printf("irq_addr=%08x ", podule->irq_addr);
157 1.1 reinoud printf("irq_mask=%02x ", podule->irq_mask);
158 1.1 reinoud printf("fiq_addr=%08x ", podule->fiq_addr);
159 1.1 reinoud printf("fiq_mask=%02x ", podule->fiq_mask);
160 1.1 reinoud printf("fast_base=%08x ", podule->fast_base);
161 1.1 reinoud printf("medium_base=%08x ", podule->medium_base);
162 1.1 reinoud printf("slow_base=%08x ", podule->slow_base);
163 1.1 reinoud printf("sync_base=%08x ", podule->sync_base);
164 1.1 reinoud printf("mod_base=%08x ", podule->mod_base);
165 1.1 reinoud printf("easi_base=%08x ", podule->easi_base);
166 1.1 reinoud printf("attached=%d ", podule->attached);
167 1.1 reinoud printf("slottype=%d ", podule->slottype);
168 1.1 reinoud printf("podulenum=%d ", podule->podulenum);
169 1.1 reinoud printf("description=%s ", podule->description);
170 1.1 reinoud printf("\n");
171 1.1 reinoud }
172 1.1 reinoud #endif
173 1.1 reinoud
174 1.1 reinoud void
175 1.22 dsl podulechunkdirectory(podule_t *podule)
176 1.1 reinoud {
177 1.1 reinoud u_int address;
178 1.1 reinoud u_int id;
179 1.1 reinoud u_int size;
180 1.1 reinoud u_int addr;
181 1.1 reinoud int loop;
182 1.1 reinoud int done_f5;
183 1.1 reinoud
184 1.1 reinoud done_f5 = 0;
185 1.1 reinoud address = 0x40;
186 1.1 reinoud
187 1.1 reinoud do {
188 1.1 reinoud id = podule->read_rom(podule->sync_base, address);
189 1.1 reinoud size = podule->read_rom(podule->sync_base, address + 4);
190 1.1 reinoud size |= (podule->read_rom(podule->sync_base, address + 8) << 8);
191 1.1 reinoud size |= (podule->read_rom(podule->sync_base, address + 12) << 16);
192 1.1 reinoud if (id == 0xf5) {
193 1.1 reinoud addr = podule->read_rom(podule->sync_base, address + 16);
194 1.1 reinoud addr |= (podule->read_rom(podule->sync_base, address + 20) << 8);
195 1.1 reinoud addr |= (podule->read_rom(podule->sync_base, address + 24) << 16);
196 1.1 reinoud addr |= (podule->read_rom(podule->sync_base, address + 28) << 24);
197 1.1 reinoud if (addr < 0x800 && done_f5 == 0) {
198 1.1 reinoud done_f5 = 1;
199 1.1 reinoud for (loop = 0; loop < size; ++loop) {
200 1.1 reinoud if (loop < PODULE_DESCRIPTION_LENGTH) {
201 1.1 reinoud podule->description[loop] =
202 1.1 reinoud podule->read_rom(podule->sync_base, (addr + loop)*4);
203 1.1 reinoud podule->description[loop + 1] = 0;
204 1.1 reinoud }
205 1.1 reinoud }
206 1.1 reinoud }
207 1.1 reinoud }
208 1.1 reinoud #ifdef DEBUG_CHUNK_DIR
209 1.1 reinoud if (id == 0xf5 || id == 0xf1 || id == 0xf2 || id == 0xf3 || id == 0xf4 || id == 0xf6) {
210 1.1 reinoud addr = podule->read_rom(podule->sync_base, address + 16);
211 1.1 reinoud addr |= (podule->read_rom(podule->sync_base, address + 20) << 8);
212 1.1 reinoud addr |= (podule->read_rom(podule->sync_base, address + 24) << 16);
213 1.1 reinoud addr |= (podule->read_rom(podule->sync_base, address + 28) << 24);
214 1.1 reinoud printf("<%04x.%04x.%04x.%04x>", id, address, addr, size);
215 1.1 reinoud if (addr < 0x800) {
216 1.1 reinoud for (loop = 0; loop < size; ++loop) {
217 1.1 reinoud printf("%c", podule->read_rom(podule->sync_base, (addr + loop)*4));
218 1.1 reinoud }
219 1.1 reinoud printf("\\n\n");
220 1.1 reinoud }
221 1.1 reinoud }
222 1.1 reinoud #endif
223 1.1 reinoud address += 32;
224 1.1 reinoud } while (id != 0 && address < 0x800);
225 1.1 reinoud }
226 1.1 reinoud
227 1.1 reinoud
228 1.1 reinoud void
229 1.22 dsl poduleexamine(podule_t *podule, struct device *dev, int slottype)
230 1.1 reinoud {
231 1.9 bjh21 struct manufacturer_description *man_desc;
232 1.1 reinoud struct podule_description *pod_desc;
233 1.1 reinoud
234 1.1 reinoud /* Test to see if the podule is present */
235 1.1 reinoud
236 1.1 reinoud if ((podule->flags0 & 0x02) == 0x00) {
237 1.1 reinoud podule->slottype = slottype;
238 1.1 reinoud if (slottype == SLOT_NET)
239 1.1 reinoud printf("netslot%d at %s : ", podule->podulenum - MAX_PODULES,
240 1.1 reinoud dev->dv_xname);
241 1.1 reinoud else
242 1.1 reinoud printf("podule%d at %s : ", podule->podulenum,
243 1.1 reinoud dev->dv_xname);
244 1.1 reinoud
245 1.1 reinoud /* Is it Acorn conformant ? */
246 1.1 reinoud
247 1.1 reinoud if (podule->flags0 & 0x80)
248 1.1 reinoud printf("Non-Acorn conformant expansion card\n");
249 1.1 reinoud else {
250 1.1 reinoud int id;
251 1.1 reinoud
252 1.1 reinoud /* Is it a simple podule ? */
253 1.1 reinoud
254 1.1 reinoud id = (podule->flags0 >> 3) & 0x0f;
255 1.1 reinoud if (id != 0)
256 1.1 reinoud printf("Simple expansion card <%x>\n", id);
257 1.1 reinoud else {
258 1.1 reinoud /* Scan the chunk directory if present for tags we use */
259 1.1 reinoud if (podule->flags1 & PODULE_FLAGS_CD)
260 1.1 reinoud podulechunkdirectory(podule);
261 1.1 reinoud
262 1.1 reinoud /* Do we know this manufacturer ? */
263 1.9 bjh21 man_desc = known_manufacturers;
264 1.9 bjh21 while (man_desc->description) {
265 1.9 bjh21 if (man_desc->manufacturer_id ==
266 1.9 bjh21 podule->manufacturer)
267 1.1 reinoud break;
268 1.9 bjh21 ++man_desc;
269 1.1 reinoud }
270 1.9 bjh21 if (!man_desc->description)
271 1.1 reinoud printf("man=%04x : ", podule->manufacturer);
272 1.1 reinoud else
273 1.9 bjh21 printf("%s : ", man_desc->description);
274 1.1 reinoud
275 1.1 reinoud /* Do we know this product ? */
276 1.1 reinoud
277 1.9 bjh21 pod_desc = known_podules;
278 1.1 reinoud while (pod_desc->description) {
279 1.1 reinoud if (pod_desc->product_id == podule->product)
280 1.1 reinoud break;
281 1.1 reinoud ++pod_desc;
282 1.1 reinoud }
283 1.9 bjh21 if (!pod_desc->description)
284 1.9 bjh21 printf("prod=%04x : ",
285 1.9 bjh21 podule->product);
286 1.9 bjh21 else
287 1.9 bjh21 printf("%s : ", pod_desc->description);
288 1.9 bjh21 printf("%s\n", podule->description);
289 1.1 reinoud }
290 1.1 reinoud }
291 1.1 reinoud }
292 1.1 reinoud }
293 1.1 reinoud
294 1.1 reinoud
295 1.1 reinoud u_int
296 1.22 dsl poduleread(u_int address, int offset)
297 1.1 reinoud {
298 1.1 reinoud
299 1.1 reinoud return(ReadByte(address + offset));
300 1.1 reinoud }
301 1.1 reinoud
302 1.1 reinoud void
303 1.22 dsl podulescan(struct device *dev)
304 1.1 reinoud {
305 1.1 reinoud int loop;
306 1.1 reinoud podule_t *podule;
307 1.1 reinoud u_char *address;
308 1.1 reinoud u_int offset = 0;
309 1.1 reinoud
310 1.1 reinoud /* Loop round all the podules */
311 1.1 reinoud
312 1.1 reinoud for (loop = 0; loop < MAX_PODULES; ++loop, offset += SIMPLE_PODULE_SIZE) {
313 1.1 reinoud podule = &podules[loop];
314 1.1 reinoud podule->podulenum = loop;
315 1.1 reinoud podule->attached = 0;
316 1.1 reinoud podule->slottype = SLOT_NONE;
317 1.1 reinoud podule->interrupt = IRQ_PODULE;
318 1.1 reinoud podule->read_rom = poduleread;
319 1.1 reinoud podule->dma_channel = -1;
320 1.1 reinoud podule->dma_interrupt = -1;
321 1.1 reinoud podule->description[0] = 0;
322 1.1 reinoud
323 1.1 reinoud if (loop == 4) offset += PODULE_GAP;
324 1.1 reinoud address = ((u_char *)SYNC_PODULE_BASE) + offset;
325 1.1 reinoud
326 1.1 reinoud if ((address[0] & 0x02) == 0x00) {
327 1.1 reinoud podule->fast_base = FAST_PODULE_BASE + offset;
328 1.1 reinoud podule->medium_base = MEDIUM_PODULE_BASE + offset;
329 1.1 reinoud podule->slow_base = SLOW_PODULE_BASE + offset;
330 1.1 reinoud podule->sync_base = SYNC_PODULE_BASE + offset;
331 1.1 reinoud podule->mod_base = MOD_PODULE_BASE + offset;
332 1.1 reinoud podule->easi_base = EASI_BASE + loop * EASI_SIZE;
333 1.1 reinoud } else {
334 1.1 reinoud address = ((u_char *)EASI_BASE) + loop * EASI_SIZE;
335 1.1 reinoud if ((address[0] & 0x02) != 0x00)
336 1.1 reinoud continue;
337 1.1 reinoud
338 1.1 reinoud podule->fast_base = 0;
339 1.1 reinoud podule->medium_base = 0;
340 1.1 reinoud podule->slow_base = 0;
341 1.1 reinoud podule->sync_base = 0;
342 1.1 reinoud podule->mod_base = 0;
343 1.1 reinoud podule->easi_base = EASI_BASE + loop * EASI_SIZE;
344 1.1 reinoud }
345 1.1 reinoud
346 1.1 reinoud /* XXX - Really needs to be linked to a DMA manager */
347 1.1 reinoud if (IOMD_ID == RPC600_IOMD_ID) {
348 1.1 reinoud switch (loop) {
349 1.1 reinoud case 0:
350 1.1 reinoud podule->dma_channel = 2;
351 1.1 reinoud podule->dma_interrupt = IRQ_DMACH2;
352 1.1 reinoud break;
353 1.1 reinoud case 1:
354 1.1 reinoud podule->dma_channel = 3;
355 1.1 reinoud podule->dma_interrupt = IRQ_DMACH3;
356 1.1 reinoud break;
357 1.1 reinoud }
358 1.1 reinoud }
359 1.1 reinoud
360 1.1 reinoud /* Get information from the podule header */
361 1.1 reinoud
362 1.1 reinoud podule->flags0 = address[0];
363 1.1 reinoud if ((podule->flags0 & 0x78) == 0) {
364 1.1 reinoud podule->flags1 = address[4];
365 1.1 reinoud podule->reserved = address[8];
366 1.1 reinoud podule->product = address[12] + (address[16] << 8);
367 1.1 reinoud podule->manufacturer = address[20] + (address[24] << 8);
368 1.1 reinoud podule->country = address[28];
369 1.1 reinoud if (podule->flags1 & PODULE_FLAGS_IS) {
370 1.1 reinoud podule->irq_addr = address[52] + (address[56] << 8) + (address[60] << 16);
371 1.1 reinoud podule->irq_addr += podule->slow_base;
372 1.1 reinoud podule->irq_mask = address[48];
373 1.1 reinoud if (podule->irq_mask == 0)
374 1.1 reinoud podule->irq_mask = 0x01;
375 1.1 reinoud podule->fiq_addr = address[36] + (address[40] << 8) + (address[44] << 16);
376 1.1 reinoud podule->fiq_addr += podule->slow_base;
377 1.1 reinoud podule->fiq_mask = address[32];
378 1.1 reinoud if (podule->fiq_mask == 0)
379 1.1 reinoud podule->fiq_mask = 0x04;
380 1.1 reinoud } else {
381 1.1 reinoud podule->irq_addr = podule->slow_base;
382 1.1 reinoud podule->irq_mask = 0x01;
383 1.1 reinoud podule->fiq_addr = podule->slow_base;
384 1.1 reinoud podule->fiq_mask = 0x04;
385 1.1 reinoud }
386 1.1 reinoud }
387 1.1 reinoud
388 1.1 reinoud poduleexamine(podule, dev, SLOT_POD);
389 1.1 reinoud }
390 1.1 reinoud }
391 1.1 reinoud
392 1.1 reinoud
393 1.1 reinoud /*
394 1.1 reinoud * void podulebusattach(struct device *parent, struct device *dev, void *aux)
395 1.1 reinoud *
396 1.1 reinoud * Attach podulebus.
397 1.1 reinoud * This probes all the podules and sets up the podules array with
398 1.1 reinoud * information found in the podule headers.
399 1.1 reinoud * After identifing all the podules, all the children of the podulebus
400 1.1 reinoud * are probed and attached.
401 1.1 reinoud */
402 1.1 reinoud
403 1.1 reinoud void
404 1.22 dsl podulebusattach(struct device *parent, struct device *self, void *aux)
405 1.1 reinoud {
406 1.1 reinoud int loop;
407 1.1 reinoud struct podule_attach_args pa;
408 1.1 reinoud #if 0
409 1.1 reinoud int easi_time;
410 1.1 reinoud int bit;
411 1.1 reinoud #endif
412 1.1 reinoud unsigned int value;
413 1.1 reinoud char argstring[20];
414 1.1 reinoud
415 1.1 reinoud #if 0
416 1.1 reinoud easi_time = IOMD_READ_BYTE(IOMD_ECTCR);
417 1.1 reinoud printf(": easi timings=");
418 1.1 reinoud for (bit = 0x01; bit < 0x100; bit = bit << 1)
419 1.1 reinoud if (easi_time & bit)
420 1.1 reinoud printf("C");
421 1.1 reinoud else
422 1.1 reinoud printf("A");
423 1.1 reinoud #endif
424 1.1 reinoud printf("\n");
425 1.1 reinoud
426 1.16 chris
427 1.17 thorpej #if 0 /* XXXJRT */
428 1.1 reinoud /* Ok we need to map in the podulebus */
429 1.16 chris /* with the new pmap mappings have to be done when the L1 tables
430 1.16 chris * are built during initarm
431 1.16 chris */
432 1.1 reinoud /* Map the FAST and SYNC simple podules */
433 1.6 thorpej pmap_map_section((vm_offset_t)pmap_kernel()->pm_pdir,
434 1.6 thorpej SYNC_PODULE_BASE & 0xfff00000, SYNC_PODULE_HW_BASE & 0xfff00000,
435 1.6 thorpej VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
436 1.1 reinoud cpu_tlb_flushD();
437 1.1 reinoud /* Now map the EASI space */
438 1.1 reinoud
439 1.1 reinoud for (loop = 0; loop < MAX_PODULES; ++loop) {
440 1.1 reinoud int loop1;
441 1.1 reinoud
442 1.1 reinoud for (loop1 = loop * EASI_SIZE; loop1 < ((loop + 1) * EASI_SIZE);
443 1.8 thorpej loop1 += L1_S_SIZE)
444 1.6 thorpej pmap_map_section((vm_offset_t)pmap_kernel()->pm_pdir,
445 1.6 thorpej EASI_BASE + loop1, EASI_HW_BASE + loop1,
446 1.6 thorpej VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
447 1.1 reinoud }
448 1.1 reinoud cpu_tlb_flushD();
449 1.16 chris #endif
450 1.1 reinoud /*
451 1.1 reinoud * The MEDIUM and SLOW simple podules and the module space will have been
452 1.1 reinoud * mapped when the IOMD and COMBO we mapped in for the RPC
453 1.1 reinoud */
454 1.1 reinoud
455 1.1 reinoud /* Find out what hardware is bolted on */
456 1.1 reinoud
457 1.1 reinoud podulescan(self);
458 1.1 reinoud netslotscan(self);
459 1.1 reinoud
460 1.1 reinoud /* Look for drivers to attach */
461 1.1 reinoud
462 1.1 reinoud for (loop = 0; loop < MAX_PODULES+MAX_NETSLOTS; ++loop) {
463 1.1 reinoud #if 1
464 1.1 reinoud /* Provide backwards compat for a while */
465 1.1 reinoud sprintf(argstring, "podule%d.disable", loop);
466 1.1 reinoud if (get_bootconf_option(boot_args, argstring,
467 1.1 reinoud BOOTOPT_TYPE_BOOLEAN, &value)) {
468 1.1 reinoud if (value) {
469 1.1 reinoud if (podules[loop].slottype != SLOT_NONE)
470 1.1 reinoud printf("podule%d: Disabled\n", loop);
471 1.1 reinoud continue;
472 1.1 reinoud }
473 1.1 reinoud }
474 1.1 reinoud #endif
475 1.1 reinoud sprintf(argstring, "podule%d=", loop);
476 1.1 reinoud if (get_bootconf_option(boot_args, argstring,
477 1.1 reinoud BOOTOPT_TYPE_HEXINT, &value)) {
478 1.1 reinoud /* Override the ID */
479 1.1 reinoud podules[loop].manufacturer = value >> 16;
480 1.1 reinoud podules[loop].product = value & 0xffff;
481 1.1 reinoud /* Any old description is now wrong */
482 1.1 reinoud podules[loop].description[0] = 0;
483 1.1 reinoud if (value != 0xffff) {
484 1.1 reinoud printf("podule%d: ID overriden man=%04x prod=%04x\n",
485 1.1 reinoud loop, podules[loop].manufacturer,
486 1.1 reinoud podules[loop].product);
487 1.1 reinoud podules[loop].slottype = SLOT_POD;
488 1.1 reinoud pa.pa_podule_number = loop;
489 1.1 reinoud pa.pa_ih = pa.pa_podule_number;
490 1.1 reinoud pa.pa_podule = &podules[loop];
491 1.1 reinoud pa.pa_iot = &podulebus_bs_tag;
492 1.18 drochner config_found_sm_loc(self, "podulebus", NULL, &pa,
493 1.18 drochner podulebusprint, podulebussubmatch);
494 1.1 reinoud continue;
495 1.1 reinoud }
496 1.1 reinoud if (value == 0xffff) {
497 1.1 reinoud printf("podule%d: Disabled\n", loop);
498 1.1 reinoud continue;
499 1.1 reinoud }
500 1.1 reinoud }
501 1.1 reinoud
502 1.1 reinoud if (podules[loop].slottype != SLOT_NONE) {
503 1.1 reinoud pa.pa_podule_number = loop;
504 1.1 reinoud pa.pa_ih = pa.pa_podule_number;
505 1.1 reinoud pa.pa_podule = &podules[loop];
506 1.1 reinoud pa.pa_iot = &podulebus_bs_tag;
507 1.18 drochner config_found_sm_loc(self, "podulebus", NULL, &pa,
508 1.18 drochner podulebusprint, podulebussubmatch);
509 1.1 reinoud }
510 1.1 reinoud }
511 1.1 reinoud }
512 1.1 reinoud
513 1.1 reinoud
514 1.14 thorpej CFATTACH_DECL(podulebus, sizeof(struct device),
515 1.13 thorpej podulebusmatch, podulebusattach, NULL, NULL);
516 1.1 reinoud
517 1.1 reinoud /* Useful functions that drivers may share */
518 1.1 reinoud
519 1.1 reinoud /*
520 1.1 reinoud * Match a podule structure with the specified parameters
521 1.1 reinoud * Returns 0 if the match failed
522 1.1 reinoud * The required_slot is not used at the moment.
523 1.1 reinoud */
524 1.1 reinoud
525 1.1 reinoud int
526 1.22 dsl matchpodule(struct podule_attach_args *pa, int manufacturer, int product, int required_slot)
527 1.1 reinoud {
528 1.1 reinoud if (pa->pa_podule->attached)
529 1.11 provos panic("podulebus: Podule already attached");
530 1.1 reinoud
531 1.1 reinoud if (IS_PODULE(pa, manufacturer, product))
532 1.1 reinoud return(1);
533 1.1 reinoud
534 1.1 reinoud return(0);
535 1.1 reinoud }
536 1.1 reinoud
537 1.1 reinoud void *
538 1.1 reinoud podulebus_irq_establish(ih, ipl, func, arg, ev)
539 1.1 reinoud podulebus_intr_handle_t ih;
540 1.1 reinoud int ipl;
541 1.21 dsl int (*func)(void *);
542 1.1 reinoud void *arg;
543 1.1 reinoud struct evcnt *ev;
544 1.1 reinoud {
545 1.1 reinoud
546 1.1 reinoud /* XXX We don't actually use the evcnt supplied, just its name. */
547 1.1 reinoud return intr_claim(podules[ih].interrupt, ipl, ev->ev_group, func,
548 1.1 reinoud arg);
549 1.1 reinoud }
550 1.1 reinoud
551 1.1 reinoud /*
552 1.1 reinoud * Generate a bus_space_tag_t with the specified address-bus shift.
553 1.1 reinoud */
554 1.1 reinoud void
555 1.1 reinoud podulebus_shift_tag(tag, shift, tagp)
556 1.1 reinoud bus_space_tag_t tag, *tagp;
557 1.1 reinoud u_int shift;
558 1.1 reinoud {
559 1.1 reinoud
560 1.1 reinoud /*
561 1.1 reinoud * For the podulebus, the bus tag cookie is the shift to apply
562 1.1 reinoud * to registers, so duplicate the bus space tag and change the
563 1.1 reinoud * cookie.
564 1.1 reinoud */
565 1.1 reinoud
566 1.1 reinoud /* XXX never freed, but podules are never detached anyway. */
567 1.1 reinoud *tagp = malloc(sizeof(struct bus_space), M_DEVBUF, M_WAITOK);
568 1.1 reinoud **tagp = *tag;
569 1.1 reinoud (*tagp)->bs_cookie = (void *)shift;
570 1.1 reinoud }
571 1.1 reinoud
572 1.1 reinoud int
573 1.1 reinoud podulebus_initloader(struct podulebus_attach_args *pa)
574 1.1 reinoud {
575 1.1 reinoud
576 1.1 reinoud /* No loader support at present on arm32, so always fail. */
577 1.1 reinoud return -1;
578 1.1 reinoud }
579 1.1 reinoud
580 1.1 reinoud int
581 1.1 reinoud podloader_readbyte(struct podulebus_attach_args *pa, u_int addr)
582 1.1 reinoud {
583 1.1 reinoud
584 1.1 reinoud panic("podloader_readbyte");
585 1.1 reinoud }
586 1.1 reinoud
587 1.1 reinoud void
588 1.1 reinoud podloader_writebyte(struct podulebus_attach_args *pa, u_int addr, int val)
589 1.1 reinoud {
590 1.1 reinoud
591 1.1 reinoud panic("podloader_writebyte");
592 1.1 reinoud }
593 1.1 reinoud
594 1.1 reinoud void
595 1.1 reinoud podloader_reset(struct podulebus_attach_args *pa)
596 1.1 reinoud {
597 1.1 reinoud
598 1.1 reinoud panic("podloader_reset");
599 1.1 reinoud }
600 1.1 reinoud
601 1.1 reinoud int
602 1.1 reinoud podloader_callloader(struct podulebus_attach_args *pa, u_int r0, u_int r1)
603 1.1 reinoud {
604 1.1 reinoud
605 1.1 reinoud panic("podloader_callloader");
606 1.1 reinoud }
607 1.1 reinoud
608 1.1 reinoud /* End of podulebus.c */
609