aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/kernel/ebus.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc64/kernel/ebus.c')
-rw-r--r--arch/sparc64/kernel/ebus.c65
1 files changed, 17 insertions, 48 deletions
diff --git a/arch/sparc64/kernel/ebus.c b/arch/sparc64/kernel/ebus.c
index 919a91d9e5de..33d79e10c653 100644
--- a/arch/sparc64/kernel/ebus.c
+++ b/arch/sparc64/kernel/ebus.c
@@ -283,60 +283,32 @@ static inline void *ebus_alloc(size_t size)
283 return mem; 283 return mem;
284} 284}
285 285
286static void __init ebus_ranges_init(struct linux_ebus *ebus) 286int __init ebus_intmap_match(struct linux_ebus *ebus,
287{ 287 struct linux_prom_registers *reg,
288 struct linux_prom_ebus_ranges *rngs; 288 int *interrupt)
289 int len;
290
291 ebus->num_ebus_ranges = 0;
292 rngs = of_get_property(ebus->prom_node, "ranges", &len);
293 if (rngs) {
294 memcpy(ebus->ebus_ranges, rngs, len);
295 ebus->num_ebus_ranges =
296 (len / sizeof(struct linux_prom_ebus_ranges));
297 }
298}
299
300static void __init ebus_intmap_init(struct linux_ebus *ebus)
301{ 289{
302 struct linux_prom_ebus_intmap *imap; 290 struct linux_prom_ebus_intmap *imap;
303 struct linux_prom_ebus_intmask *imask; 291 struct linux_prom_ebus_intmask *imask;
304 int len; 292 unsigned int hi, lo, irq;
293 int i, len, n_imap;
305 294
306 ebus->num_ebus_intmap = 0;
307 imap = of_get_property(ebus->prom_node, "interrupt-map", &len); 295 imap = of_get_property(ebus->prom_node, "interrupt-map", &len);
308 if (!imap) 296 if (!imap)
309 return; 297 return 0;
310 298 n_imap = len / sizeof(imap[0]);
311 memcpy(ebus->ebus_intmap, imap, len);
312 ebus->num_ebus_intmap = (len / sizeof(struct linux_prom_ebus_intmap));
313
314 imask = of_get_property(ebus->prom_node, "interrupt-map-mask", &len);
315 if (!imask) {
316 prom_printf("EBUS: can't get interrupt-map-mask\n");
317 prom_halt();
318 }
319 memcpy(&ebus->ebus_intmask, imask, sizeof(ebus->ebus_intmask));
320}
321
322int __init ebus_intmap_match(struct linux_ebus *ebus,
323 struct linux_prom_registers *reg,
324 int *interrupt)
325{
326 unsigned int hi, lo, irq;
327 int i;
328 299
329 if (!ebus->num_ebus_intmap) 300 imask = of_get_property(ebus->prom_node, "interrupt-map-mask", NULL);
301 if (!imask)
330 return 0; 302 return 0;
331 303
332 hi = reg->which_io & ebus->ebus_intmask.phys_hi; 304 hi = reg->which_io & imask->phys_hi;
333 lo = reg->phys_addr & ebus->ebus_intmask.phys_lo; 305 lo = reg->phys_addr & imask->phys_lo;
334 irq = *interrupt & ebus->ebus_intmask.interrupt; 306 irq = *interrupt & imask->interrupt;
335 for (i = 0; i < ebus->num_ebus_intmap; i++) { 307 for (i = 0; i < n_imap; i++) {
336 if ((ebus->ebus_intmap[i].phys_hi == hi) && 308 if ((imap[i].phys_hi == hi) &&
337 (ebus->ebus_intmap[i].phys_lo == lo) && 309 (imap[i].phys_lo == lo) &&
338 (ebus->ebus_intmap[i].interrupt == irq)) { 310 (imap[i].interrupt == irq)) {
339 *interrupt = ebus->ebus_intmap[i].cinterrupt; 311 *interrupt = imap[i].cinterrupt;
340 return 0; 312 return 0;
341 } 313 }
342 } 314 }
@@ -598,9 +570,6 @@ void __init ebus_init(void)
598 ebus->self = pdev; 570 ebus->self = pdev;
599 ebus->parent = pbm = cookie->pbm; 571 ebus->parent = pbm = cookie->pbm;
600 572
601 ebus_ranges_init(ebus);
602 ebus_intmap_init(ebus);
603
604 child = dp->child; 573 child = dp->child;
605 if (!child) 574 if (!child)
606 goto next_ebus; 575 goto next_ebus;