2 * Procedures for creating, accessing and interpreting the device tree.
4 * Paul Mackerras August 1996.
5 * Copyright (C) 1996-2005 Paul Mackerras.
7 * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
8 * {engebret|bergner}@us.ibm.com
10 * Adapted for sparc64 by David S. Miller davem@davemloft.net
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
18 #include <linux/kernel.h>
19 #include <linux/types.h>
20 #include <linux/string.h>
22 #include <linux/bootmem.h>
23 #include <linux/module.h>
26 #include <asm/of_device.h>
27 #include <asm/oplib.h>
33 static struct device_node *allnodes;
35 extern rwlock_t devtree_lock; /* temporary while merging */
37 struct device_node *of_get_parent(const struct device_node *node)
39 struct device_node *np;
48 EXPORT_SYMBOL(of_get_parent);
50 struct device_node *of_get_next_child(const struct device_node *node,
51 struct device_node *prev)
53 struct device_node *next;
55 next = prev ? prev->sibling : node->child;
56 for (; next != 0; next = next->sibling) {
62 EXPORT_SYMBOL(of_get_next_child);
64 struct device_node *of_find_node_by_path(const char *path)
66 struct device_node *np = allnodes;
68 for (; np != 0; np = np->allnext) {
69 if (np->full_name != 0 && strcmp(np->full_name, path) == 0)
75 EXPORT_SYMBOL(of_find_node_by_path);
77 struct device_node *of_find_node_by_phandle(phandle handle)
79 struct device_node *np;
81 for (np = allnodes; np != 0; np = np->allnext)
82 if (np->node == handle)
87 EXPORT_SYMBOL(of_find_node_by_phandle);
89 struct device_node *of_find_node_by_name(struct device_node *from,
92 struct device_node *np;
94 np = from ? from->allnext : allnodes;
95 for (; np != NULL; np = np->allnext)
96 if (np->name != NULL && strcmp(np->name, name) == 0)
101 EXPORT_SYMBOL(of_find_node_by_name);
103 struct device_node *of_find_node_by_type(struct device_node *from,
106 struct device_node *np;
108 np = from ? from->allnext : allnodes;
109 for (; np != 0; np = np->allnext)
110 if (np->type != 0 && strcmp(np->type, type) == 0)
115 EXPORT_SYMBOL(of_find_node_by_type);
117 struct device_node *of_find_compatible_node(struct device_node *from,
118 const char *type, const char *compatible)
120 struct device_node *np;
122 np = from ? from->allnext : allnodes;
123 for (; np != 0; np = np->allnext) {
125 && !(np->type != 0 && strcmp(np->type, type) == 0))
127 if (of_device_is_compatible(np, compatible))
133 EXPORT_SYMBOL(of_find_compatible_node);
135 int of_getintprop_default(struct device_node *np, const char *name, int def)
137 struct property *prop;
140 prop = of_find_property(np, name, &len);
141 if (!prop || len != 4)
144 return *(int *) prop->value;
146 EXPORT_SYMBOL(of_getintprop_default);
148 int of_set_property(struct device_node *dp, const char *name, void *val, int len)
150 struct property **prevp;
154 new_val = kmalloc(len, GFP_KERNEL);
158 memcpy(new_val, val, len);
162 write_lock(&devtree_lock);
163 prevp = &dp->properties;
165 struct property *prop = *prevp;
167 if (!strcasecmp(prop->name, name)) {
168 void *old_val = prop->value;
171 ret = prom_setprop(dp->node, name, val, len);
174 prop->value = new_val;
177 if (OF_IS_DYNAMIC(prop))
180 OF_MARK_DYNAMIC(prop);
186 prevp = &(*prevp)->next;
188 write_unlock(&devtree_lock);
190 /* XXX Upate procfs if necessary... */
194 EXPORT_SYMBOL(of_set_property);
196 static unsigned int prom_early_allocated;
198 static void * __init prom_early_alloc(unsigned long size)
202 ret = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL);
204 memset(ret, 0, size);
206 prom_early_allocated += size;
212 /* PSYCHO interrupt mapping support. */
213 #define PSYCHO_IMAP_A_SLOT0 0x0c00UL
214 #define PSYCHO_IMAP_B_SLOT0 0x0c20UL
215 static unsigned long psycho_pcislot_imap_offset(unsigned long ino)
217 unsigned int bus = (ino & 0x10) >> 4;
218 unsigned int slot = (ino & 0x0c) >> 2;
221 return PSYCHO_IMAP_A_SLOT0 + (slot * 8);
223 return PSYCHO_IMAP_B_SLOT0 + (slot * 8);
226 #define PSYCHO_IMAP_SCSI 0x1000UL
227 #define PSYCHO_IMAP_ETH 0x1008UL
228 #define PSYCHO_IMAP_BPP 0x1010UL
229 #define PSYCHO_IMAP_AU_REC 0x1018UL
230 #define PSYCHO_IMAP_AU_PLAY 0x1020UL
231 #define PSYCHO_IMAP_PFAIL 0x1028UL
232 #define PSYCHO_IMAP_KMS 0x1030UL
233 #define PSYCHO_IMAP_FLPY 0x1038UL
234 #define PSYCHO_IMAP_SHW 0x1040UL
235 #define PSYCHO_IMAP_KBD 0x1048UL
236 #define PSYCHO_IMAP_MS 0x1050UL
237 #define PSYCHO_IMAP_SER 0x1058UL
238 #define PSYCHO_IMAP_TIM0 0x1060UL
239 #define PSYCHO_IMAP_TIM1 0x1068UL
240 #define PSYCHO_IMAP_UE 0x1070UL
241 #define PSYCHO_IMAP_CE 0x1078UL
242 #define PSYCHO_IMAP_A_ERR 0x1080UL
243 #define PSYCHO_IMAP_B_ERR 0x1088UL
244 #define PSYCHO_IMAP_PMGMT 0x1090UL
245 #define PSYCHO_IMAP_GFX 0x1098UL
246 #define PSYCHO_IMAP_EUPA 0x10a0UL
248 static unsigned long __psycho_onboard_imap_off[] = {
249 /*0x20*/ PSYCHO_IMAP_SCSI,
250 /*0x21*/ PSYCHO_IMAP_ETH,
251 /*0x22*/ PSYCHO_IMAP_BPP,
252 /*0x23*/ PSYCHO_IMAP_AU_REC,
253 /*0x24*/ PSYCHO_IMAP_AU_PLAY,
254 /*0x25*/ PSYCHO_IMAP_PFAIL,
255 /*0x26*/ PSYCHO_IMAP_KMS,
256 /*0x27*/ PSYCHO_IMAP_FLPY,
257 /*0x28*/ PSYCHO_IMAP_SHW,
258 /*0x29*/ PSYCHO_IMAP_KBD,
259 /*0x2a*/ PSYCHO_IMAP_MS,
260 /*0x2b*/ PSYCHO_IMAP_SER,
261 /*0x2c*/ PSYCHO_IMAP_TIM0,
262 /*0x2d*/ PSYCHO_IMAP_TIM1,
263 /*0x2e*/ PSYCHO_IMAP_UE,
264 /*0x2f*/ PSYCHO_IMAP_CE,
265 /*0x30*/ PSYCHO_IMAP_A_ERR,
266 /*0x31*/ PSYCHO_IMAP_B_ERR,
267 /*0x32*/ PSYCHO_IMAP_PMGMT,
268 /*0x33*/ PSYCHO_IMAP_GFX,
269 /*0x34*/ PSYCHO_IMAP_EUPA,
271 #define PSYCHO_ONBOARD_IRQ_BASE 0x20
272 #define PSYCHO_ONBOARD_IRQ_LAST 0x34
273 #define psycho_onboard_imap_offset(__ino) \
274 __psycho_onboard_imap_off[(__ino) - PSYCHO_ONBOARD_IRQ_BASE]
276 #define PSYCHO_ICLR_A_SLOT0 0x1400UL
277 #define PSYCHO_ICLR_SCSI 0x1800UL
279 #define psycho_iclr_offset(ino) \
280 ((ino & 0x20) ? (PSYCHO_ICLR_SCSI + (((ino) & 0x1f) << 3)) : \
281 (PSYCHO_ICLR_A_SLOT0 + (((ino) & 0x1f)<<3)))
283 static unsigned int psycho_irq_build(struct device_node *dp,
287 unsigned long controller_regs = (unsigned long) _data;
288 unsigned long imap, iclr;
289 unsigned long imap_off, iclr_off;
293 if (ino < PSYCHO_ONBOARD_IRQ_BASE) {
295 imap_off = psycho_pcislot_imap_offset(ino);
298 if (ino > PSYCHO_ONBOARD_IRQ_LAST) {
299 prom_printf("psycho_irq_build: Wacky INO [%x]\n", ino);
302 imap_off = psycho_onboard_imap_offset(ino);
305 /* Now build the IRQ bucket. */
306 imap = controller_regs + imap_off;
308 iclr_off = psycho_iclr_offset(ino);
309 iclr = controller_regs + iclr_off;
311 if ((ino & 0x20) == 0)
312 inofixup = ino & 0x03;
314 return build_irq(inofixup, iclr, imap);
317 static void __init psycho_irq_trans_init(struct device_node *dp)
319 const struct linux_prom64_registers *regs;
321 dp->irq_trans = prom_early_alloc(sizeof(struct of_irq_controller));
322 dp->irq_trans->irq_build = psycho_irq_build;
324 regs = of_get_property(dp, "reg", NULL);
325 dp->irq_trans->data = (void *) regs[2].phys_addr;
328 #define sabre_read(__reg) \
330 __asm__ __volatile__("ldxa [%1] %2, %0" \
332 : "r" (__reg), "i" (ASI_PHYS_BYPASS_EC_E) \
337 struct sabre_irq_data {
338 unsigned long controller_regs;
339 unsigned int pci_first_busno;
341 #define SABRE_CONFIGSPACE 0x001000000UL
342 #define SABRE_WRSYNC 0x1c20UL
344 #define SABRE_CONFIG_BASE(CONFIG_SPACE) \
345 (CONFIG_SPACE | (1UL << 24))
346 #define SABRE_CONFIG_ENCODE(BUS, DEVFN, REG) \
347 (((unsigned long)(BUS) << 16) | \
348 ((unsigned long)(DEVFN) << 8) | \
349 ((unsigned long)(REG)))
351 /* When a device lives behind a bridge deeper in the PCI bus topology
352 * than APB, a special sequence must run to make sure all pending DMA
353 * transfers at the time of IRQ delivery are visible in the coherency
354 * domain by the cpu. This sequence is to perform a read on the far
355 * side of the non-APB bridge, then perform a read of Sabre's DMA
356 * write-sync register.
358 static void sabre_wsync_handler(unsigned int ino, void *_arg1, void *_arg2)
360 unsigned int phys_hi = (unsigned int) (unsigned long) _arg1;
361 struct sabre_irq_data *irq_data = _arg2;
362 unsigned long controller_regs = irq_data->controller_regs;
363 unsigned long sync_reg = controller_regs + SABRE_WRSYNC;
364 unsigned long config_space = controller_regs + SABRE_CONFIGSPACE;
365 unsigned int bus, devfn;
368 config_space = SABRE_CONFIG_BASE(config_space);
370 bus = (phys_hi >> 16) & 0xff;
371 devfn = (phys_hi >> 8) & 0xff;
373 config_space |= SABRE_CONFIG_ENCODE(bus, devfn, 0x00);
375 __asm__ __volatile__("membar #Sync\n\t"
376 "lduha [%1] %2, %0\n\t"
379 : "r" ((u16 *) config_space),
380 "i" (ASI_PHYS_BYPASS_EC_E_L)
383 sabre_read(sync_reg);
386 #define SABRE_IMAP_A_SLOT0 0x0c00UL
387 #define SABRE_IMAP_B_SLOT0 0x0c20UL
388 #define SABRE_IMAP_SCSI 0x1000UL
389 #define SABRE_IMAP_ETH 0x1008UL
390 #define SABRE_IMAP_BPP 0x1010UL
391 #define SABRE_IMAP_AU_REC 0x1018UL
392 #define SABRE_IMAP_AU_PLAY 0x1020UL
393 #define SABRE_IMAP_PFAIL 0x1028UL
394 #define SABRE_IMAP_KMS 0x1030UL
395 #define SABRE_IMAP_FLPY 0x1038UL
396 #define SABRE_IMAP_SHW 0x1040UL
397 #define SABRE_IMAP_KBD 0x1048UL
398 #define SABRE_IMAP_MS 0x1050UL
399 #define SABRE_IMAP_SER 0x1058UL
400 #define SABRE_IMAP_UE 0x1070UL
401 #define SABRE_IMAP_CE 0x1078UL
402 #define SABRE_IMAP_PCIERR 0x1080UL
403 #define SABRE_IMAP_GFX 0x1098UL
404 #define SABRE_IMAP_EUPA 0x10a0UL
405 #define SABRE_ICLR_A_SLOT0 0x1400UL
406 #define SABRE_ICLR_B_SLOT0 0x1480UL
407 #define SABRE_ICLR_SCSI 0x1800UL
408 #define SABRE_ICLR_ETH 0x1808UL
409 #define SABRE_ICLR_BPP 0x1810UL
410 #define SABRE_ICLR_AU_REC 0x1818UL
411 #define SABRE_ICLR_AU_PLAY 0x1820UL
412 #define SABRE_ICLR_PFAIL 0x1828UL
413 #define SABRE_ICLR_KMS 0x1830UL
414 #define SABRE_ICLR_FLPY 0x1838UL
415 #define SABRE_ICLR_SHW 0x1840UL
416 #define SABRE_ICLR_KBD 0x1848UL
417 #define SABRE_ICLR_MS 0x1850UL
418 #define SABRE_ICLR_SER 0x1858UL
419 #define SABRE_ICLR_UE 0x1870UL
420 #define SABRE_ICLR_CE 0x1878UL
421 #define SABRE_ICLR_PCIERR 0x1880UL
423 static unsigned long sabre_pcislot_imap_offset(unsigned long ino)
425 unsigned int bus = (ino & 0x10) >> 4;
426 unsigned int slot = (ino & 0x0c) >> 2;
429 return SABRE_IMAP_A_SLOT0 + (slot * 8);
431 return SABRE_IMAP_B_SLOT0 + (slot * 8);
434 static unsigned long __sabre_onboard_imap_off[] = {
435 /*0x20*/ SABRE_IMAP_SCSI,
436 /*0x21*/ SABRE_IMAP_ETH,
437 /*0x22*/ SABRE_IMAP_BPP,
438 /*0x23*/ SABRE_IMAP_AU_REC,
439 /*0x24*/ SABRE_IMAP_AU_PLAY,
440 /*0x25*/ SABRE_IMAP_PFAIL,
441 /*0x26*/ SABRE_IMAP_KMS,
442 /*0x27*/ SABRE_IMAP_FLPY,
443 /*0x28*/ SABRE_IMAP_SHW,
444 /*0x29*/ SABRE_IMAP_KBD,
445 /*0x2a*/ SABRE_IMAP_MS,
446 /*0x2b*/ SABRE_IMAP_SER,
447 /*0x2c*/ 0 /* reserved */,
448 /*0x2d*/ 0 /* reserved */,
449 /*0x2e*/ SABRE_IMAP_UE,
450 /*0x2f*/ SABRE_IMAP_CE,
451 /*0x30*/ SABRE_IMAP_PCIERR,
452 /*0x31*/ 0 /* reserved */,
453 /*0x32*/ 0 /* reserved */,
454 /*0x33*/ SABRE_IMAP_GFX,
455 /*0x34*/ SABRE_IMAP_EUPA,
457 #define SABRE_ONBOARD_IRQ_BASE 0x20
458 #define SABRE_ONBOARD_IRQ_LAST 0x30
459 #define sabre_onboard_imap_offset(__ino) \
460 __sabre_onboard_imap_off[(__ino) - SABRE_ONBOARD_IRQ_BASE]
462 #define sabre_iclr_offset(ino) \
463 ((ino & 0x20) ? (SABRE_ICLR_SCSI + (((ino) & 0x1f) << 3)) : \
464 (SABRE_ICLR_A_SLOT0 + (((ino) & 0x1f)<<3)))
466 static int sabre_device_needs_wsync(struct device_node *dp)
468 struct device_node *parent = dp->parent;
469 const char *parent_model, *parent_compat;
471 /* This traversal up towards the root is meant to
474 * 1) non-PCI bus sitting under PCI, such as 'ebus'
475 * 2) the PCI controller interrupts themselves, which
476 * will use the sabre_irq_build but do not need
477 * the DMA synchronization handling
480 if (!strcmp(parent->type, "pci"))
482 parent = parent->parent;
488 parent_model = of_get_property(parent,
491 (!strcmp(parent_model, "SUNW,sabre") ||
492 !strcmp(parent_model, "SUNW,simba")))
495 parent_compat = of_get_property(parent,
498 (!strcmp(parent_compat, "pci108e,a000") ||
499 !strcmp(parent_compat, "pci108e,a001")))
505 static unsigned int sabre_irq_build(struct device_node *dp,
509 struct sabre_irq_data *irq_data = _data;
510 unsigned long controller_regs = irq_data->controller_regs;
511 const struct linux_prom_pci_registers *regs;
512 unsigned long imap, iclr;
513 unsigned long imap_off, iclr_off;
518 if (ino < SABRE_ONBOARD_IRQ_BASE) {
520 imap_off = sabre_pcislot_imap_offset(ino);
523 if (ino > SABRE_ONBOARD_IRQ_LAST) {
524 prom_printf("sabre_irq_build: Wacky INO [%x]\n", ino);
527 imap_off = sabre_onboard_imap_offset(ino);
530 /* Now build the IRQ bucket. */
531 imap = controller_regs + imap_off;
533 iclr_off = sabre_iclr_offset(ino);
534 iclr = controller_regs + iclr_off;
536 if ((ino & 0x20) == 0)
537 inofixup = ino & 0x03;
539 virt_irq = build_irq(inofixup, iclr, imap);
541 /* If the parent device is a PCI<->PCI bridge other than
542 * APB, we have to install a pre-handler to ensure that
543 * all pending DMA is drained before the interrupt handler
546 regs = of_get_property(dp, "reg", NULL);
547 if (regs && sabre_device_needs_wsync(dp)) {
548 irq_install_pre_handler(virt_irq,
550 (void *) (long) regs->phys_hi,
557 static void __init sabre_irq_trans_init(struct device_node *dp)
559 const struct linux_prom64_registers *regs;
560 struct sabre_irq_data *irq_data;
563 dp->irq_trans = prom_early_alloc(sizeof(struct of_irq_controller));
564 dp->irq_trans->irq_build = sabre_irq_build;
566 irq_data = prom_early_alloc(sizeof(struct sabre_irq_data));
568 regs = of_get_property(dp, "reg", NULL);
569 irq_data->controller_regs = regs[0].phys_addr;
571 busrange = of_get_property(dp, "bus-range", NULL);
572 irq_data->pci_first_busno = busrange[0];
574 dp->irq_trans->data = irq_data;
577 /* SCHIZO interrupt mapping support. Unlike Psycho, for this controller the
578 * imap/iclr registers are per-PBM.
580 #define SCHIZO_IMAP_BASE 0x1000UL
581 #define SCHIZO_ICLR_BASE 0x1400UL
583 static unsigned long schizo_imap_offset(unsigned long ino)
585 return SCHIZO_IMAP_BASE + (ino * 8UL);
588 static unsigned long schizo_iclr_offset(unsigned long ino)
590 return SCHIZO_ICLR_BASE + (ino * 8UL);
593 static unsigned long schizo_ino_to_iclr(unsigned long pbm_regs,
597 return pbm_regs + schizo_iclr_offset(ino);
600 static unsigned long schizo_ino_to_imap(unsigned long pbm_regs,
603 return pbm_regs + schizo_imap_offset(ino);
606 #define schizo_read(__reg) \
608 __asm__ __volatile__("ldxa [%1] %2, %0" \
610 : "r" (__reg), "i" (ASI_PHYS_BYPASS_EC_E) \
614 #define schizo_write(__reg, __val) \
615 __asm__ __volatile__("stxa %0, [%1] %2" \
617 : "r" (__val), "r" (__reg), \
618 "i" (ASI_PHYS_BYPASS_EC_E) \
621 static void tomatillo_wsync_handler(unsigned int ino, void *_arg1, void *_arg2)
623 unsigned long sync_reg = (unsigned long) _arg2;
624 u64 mask = 1UL << (ino & IMAP_INO);
628 schizo_write(sync_reg, mask);
633 val = schizo_read(sync_reg);
638 printk("tomatillo_wsync_handler: DMA won't sync [%lx:%lx]\n",
643 static unsigned char cacheline[64]
644 __attribute__ ((aligned (64)));
646 __asm__ __volatile__("rd %%fprs, %0\n\t"
648 "wr %1, 0x0, %%fprs\n\t"
649 "stda %%f0, [%5] %6\n\t"
650 "wr %0, 0x0, %%fprs\n\t"
652 : "=&r" (mask), "=&r" (val)
653 : "0" (mask), "1" (val),
654 "i" (FPRS_FEF), "r" (&cacheline[0]),
655 "i" (ASI_BLK_COMMIT_P));
659 struct schizo_irq_data {
660 unsigned long pbm_regs;
661 unsigned long sync_reg;
666 static unsigned int schizo_irq_build(struct device_node *dp,
670 struct schizo_irq_data *irq_data = _data;
671 unsigned long pbm_regs = irq_data->pbm_regs;
672 unsigned long imap, iclr;
679 /* Now build the IRQ bucket. */
680 imap = schizo_ino_to_imap(pbm_regs, ino);
681 iclr = schizo_ino_to_iclr(pbm_regs, ino);
683 /* On Schizo, no inofixup occurs. This is because each
684 * INO has it's own IMAP register. On Psycho and Sabre
685 * there is only one IMAP register for each PCI slot even
686 * though four different INOs can be generated by each
689 * But, for JBUS variants (essentially, Tomatillo), we have
690 * to fixup the lowest bit of the interrupt group number.
694 is_tomatillo = (irq_data->sync_reg != 0UL);
697 if (irq_data->portid & 1)
698 ign_fixup = (1 << 6);
701 virt_irq = build_irq(ign_fixup, iclr, imap);
704 irq_install_pre_handler(virt_irq,
705 tomatillo_wsync_handler,
706 ((irq_data->chip_version <= 4) ?
707 (void *) 1 : (void *) 0),
708 (void *) irq_data->sync_reg);
714 static void __init __schizo_irq_trans_init(struct device_node *dp,
717 const struct linux_prom64_registers *regs;
718 struct schizo_irq_data *irq_data;
720 dp->irq_trans = prom_early_alloc(sizeof(struct of_irq_controller));
721 dp->irq_trans->irq_build = schizo_irq_build;
723 irq_data = prom_early_alloc(sizeof(struct schizo_irq_data));
725 regs = of_get_property(dp, "reg", NULL);
726 dp->irq_trans->data = irq_data;
728 irq_data->pbm_regs = regs[0].phys_addr;
730 irq_data->sync_reg = regs[3].phys_addr + 0x1a18UL;
732 irq_data->sync_reg = 0UL;
733 irq_data->portid = of_getintprop_default(dp, "portid", 0);
734 irq_data->chip_version = of_getintprop_default(dp, "version#", 0);
737 static void __init schizo_irq_trans_init(struct device_node *dp)
739 __schizo_irq_trans_init(dp, 0);
742 static void __init tomatillo_irq_trans_init(struct device_node *dp)
744 __schizo_irq_trans_init(dp, 1);
747 static unsigned int pci_sun4v_irq_build(struct device_node *dp,
751 u32 devhandle = (u32) (unsigned long) _data;
753 return sun4v_build_irq(devhandle, devino);
756 static void __init pci_sun4v_irq_trans_init(struct device_node *dp)
758 const struct linux_prom64_registers *regs;
760 dp->irq_trans = prom_early_alloc(sizeof(struct of_irq_controller));
761 dp->irq_trans->irq_build = pci_sun4v_irq_build;
763 regs = of_get_property(dp, "reg", NULL);
764 dp->irq_trans->data = (void *) (unsigned long)
765 ((regs->phys_addr >> 32UL) & 0x0fffffff);
768 struct fire_irq_data {
769 unsigned long pbm_regs;
773 #define FIRE_IMAP_BASE 0x001000
774 #define FIRE_ICLR_BASE 0x001400
776 static unsigned long fire_imap_offset(unsigned long ino)
778 return FIRE_IMAP_BASE + (ino * 8UL);
781 static unsigned long fire_iclr_offset(unsigned long ino)
783 return FIRE_ICLR_BASE + (ino * 8UL);
786 static unsigned long fire_ino_to_iclr(unsigned long pbm_regs,
789 return pbm_regs + fire_iclr_offset(ino);
792 static unsigned long fire_ino_to_imap(unsigned long pbm_regs,
795 return pbm_regs + fire_imap_offset(ino);
798 static unsigned int fire_irq_build(struct device_node *dp,
802 struct fire_irq_data *irq_data = _data;
803 unsigned long pbm_regs = irq_data->pbm_regs;
804 unsigned long imap, iclr;
805 unsigned long int_ctrlr;
809 /* Now build the IRQ bucket. */
810 imap = fire_ino_to_imap(pbm_regs, ino);
811 iclr = fire_ino_to_iclr(pbm_regs, ino);
813 /* Set the interrupt controller number. */
815 upa_writeq(int_ctrlr, imap);
817 /* The interrupt map registers do not have an INO field
818 * like other chips do. They return zero in the INO
819 * field, and the interrupt controller number is controlled
820 * in bits 6 to 9. So in order for build_irq() to get
821 * the INO right we pass it in as part of the fixup
822 * which will get added to the map register zero value
823 * read by build_irq().
825 ino |= (irq_data->portid << 6);
827 return build_irq(ino, iclr, imap);
830 static void __init fire_irq_trans_init(struct device_node *dp)
832 const struct linux_prom64_registers *regs;
833 struct fire_irq_data *irq_data;
835 dp->irq_trans = prom_early_alloc(sizeof(struct of_irq_controller));
836 dp->irq_trans->irq_build = fire_irq_build;
838 irq_data = prom_early_alloc(sizeof(struct fire_irq_data));
840 regs = of_get_property(dp, "reg", NULL);
841 dp->irq_trans->data = irq_data;
843 irq_data->pbm_regs = regs[0].phys_addr;
844 irq_data->portid = of_getintprop_default(dp, "portid", 0);
846 #endif /* CONFIG_PCI */
849 /* INO number to IMAP register offset for SYSIO external IRQ's.
850 * This should conform to both Sunfire/Wildfire server and Fusion
853 #define SYSIO_IMAP_SLOT0 0x2c00UL
854 #define SYSIO_IMAP_SLOT1 0x2c08UL
855 #define SYSIO_IMAP_SLOT2 0x2c10UL
856 #define SYSIO_IMAP_SLOT3 0x2c18UL
857 #define SYSIO_IMAP_SCSI 0x3000UL
858 #define SYSIO_IMAP_ETH 0x3008UL
859 #define SYSIO_IMAP_BPP 0x3010UL
860 #define SYSIO_IMAP_AUDIO 0x3018UL
861 #define SYSIO_IMAP_PFAIL 0x3020UL
862 #define SYSIO_IMAP_KMS 0x3028UL
863 #define SYSIO_IMAP_FLPY 0x3030UL
864 #define SYSIO_IMAP_SHW 0x3038UL
865 #define SYSIO_IMAP_KBD 0x3040UL
866 #define SYSIO_IMAP_MS 0x3048UL
867 #define SYSIO_IMAP_SER 0x3050UL
868 #define SYSIO_IMAP_TIM0 0x3060UL
869 #define SYSIO_IMAP_TIM1 0x3068UL
870 #define SYSIO_IMAP_UE 0x3070UL
871 #define SYSIO_IMAP_CE 0x3078UL
872 #define SYSIO_IMAP_SBERR 0x3080UL
873 #define SYSIO_IMAP_PMGMT 0x3088UL
874 #define SYSIO_IMAP_GFX 0x3090UL
875 #define SYSIO_IMAP_EUPA 0x3098UL
877 #define bogon ((unsigned long) -1)
878 static unsigned long sysio_irq_offsets[] = {
879 /* SBUS Slot 0 --> 3, level 1 --> 7 */
880 SYSIO_IMAP_SLOT0, SYSIO_IMAP_SLOT0, SYSIO_IMAP_SLOT0, SYSIO_IMAP_SLOT0,
881 SYSIO_IMAP_SLOT0, SYSIO_IMAP_SLOT0, SYSIO_IMAP_SLOT0, SYSIO_IMAP_SLOT0,
882 SYSIO_IMAP_SLOT1, SYSIO_IMAP_SLOT1, SYSIO_IMAP_SLOT1, SYSIO_IMAP_SLOT1,
883 SYSIO_IMAP_SLOT1, SYSIO_IMAP_SLOT1, SYSIO_IMAP_SLOT1, SYSIO_IMAP_SLOT1,
884 SYSIO_IMAP_SLOT2, SYSIO_IMAP_SLOT2, SYSIO_IMAP_SLOT2, SYSIO_IMAP_SLOT2,
885 SYSIO_IMAP_SLOT2, SYSIO_IMAP_SLOT2, SYSIO_IMAP_SLOT2, SYSIO_IMAP_SLOT2,
886 SYSIO_IMAP_SLOT3, SYSIO_IMAP_SLOT3, SYSIO_IMAP_SLOT3, SYSIO_IMAP_SLOT3,
887 SYSIO_IMAP_SLOT3, SYSIO_IMAP_SLOT3, SYSIO_IMAP_SLOT3, SYSIO_IMAP_SLOT3,
889 /* Onboard devices (not relevant/used on SunFire). */
920 #define NUM_SYSIO_OFFSETS ARRAY_SIZE(sysio_irq_offsets)
922 /* Convert Interrupt Mapping register pointer to associated
923 * Interrupt Clear register pointer, SYSIO specific version.
925 #define SYSIO_ICLR_UNUSED0 0x3400UL
926 #define SYSIO_ICLR_SLOT0 0x3408UL
927 #define SYSIO_ICLR_SLOT1 0x3448UL
928 #define SYSIO_ICLR_SLOT2 0x3488UL
929 #define SYSIO_ICLR_SLOT3 0x34c8UL
930 static unsigned long sysio_imap_to_iclr(unsigned long imap)
932 unsigned long diff = SYSIO_ICLR_UNUSED0 - SYSIO_IMAP_SLOT0;
936 static unsigned int sbus_of_build_irq(struct device_node *dp,
940 unsigned long reg_base = (unsigned long) _data;
941 const struct linux_prom_registers *regs;
942 unsigned long imap, iclr;
948 regs = of_get_property(dp, "reg", NULL);
950 sbus_slot = regs->which_io;
953 ino += (sbus_slot * 8);
955 imap = sysio_irq_offsets[ino];
956 if (imap == ((unsigned long)-1)) {
957 prom_printf("get_irq_translations: Bad SYSIO INO[%x]\n",
963 /* SYSIO inconsistency. For external SLOTS, we have to select
964 * the right ICLR register based upon the lower SBUS irq level
968 iclr = sysio_imap_to_iclr(imap);
970 sbus_level = ino & 0x7;
974 iclr = reg_base + SYSIO_ICLR_SLOT0;
977 iclr = reg_base + SYSIO_ICLR_SLOT1;
980 iclr = reg_base + SYSIO_ICLR_SLOT2;
984 iclr = reg_base + SYSIO_ICLR_SLOT3;
988 iclr += ((unsigned long)sbus_level - 1UL) * 8UL;
990 return build_irq(sbus_level, iclr, imap);
993 static void __init sbus_irq_trans_init(struct device_node *dp)
995 const struct linux_prom64_registers *regs;
997 dp->irq_trans = prom_early_alloc(sizeof(struct of_irq_controller));
998 dp->irq_trans->irq_build = sbus_of_build_irq;
1000 regs = of_get_property(dp, "reg", NULL);
1001 dp->irq_trans->data = (void *) (unsigned long) regs->phys_addr;
1003 #endif /* CONFIG_SBUS */
1006 static unsigned int central_build_irq(struct device_node *dp,
1010 struct device_node *central_dp = _data;
1011 struct of_device *central_op = of_find_device_by_node(central_dp);
1012 struct resource *res;
1013 unsigned long imap, iclr;
1016 if (!strcmp(dp->name, "eeprom")) {
1017 res = ¢ral_op->resource[5];
1018 } else if (!strcmp(dp->name, "zs")) {
1019 res = ¢ral_op->resource[4];
1020 } else if (!strcmp(dp->name, "clock-board")) {
1021 res = ¢ral_op->resource[3];
1026 imap = res->start + 0x00UL;
1027 iclr = res->start + 0x10UL;
1029 /* Set the INO state to idle, and disable. */
1030 upa_writel(0, iclr);
1033 tmp = upa_readl(imap);
1035 upa_writel(tmp, imap);
1037 return build_irq(0, iclr, imap);
1040 static void __init central_irq_trans_init(struct device_node *dp)
1042 dp->irq_trans = prom_early_alloc(sizeof(struct of_irq_controller));
1043 dp->irq_trans->irq_build = central_build_irq;
1045 dp->irq_trans->data = dp;
1050 void (*init)(struct device_node *);
1054 static struct irq_trans __initdata pci_irq_trans_table[] = {
1055 { "SUNW,sabre", sabre_irq_trans_init },
1056 { "pci108e,a000", sabre_irq_trans_init },
1057 { "pci108e,a001", sabre_irq_trans_init },
1058 { "SUNW,psycho", psycho_irq_trans_init },
1059 { "pci108e,8000", psycho_irq_trans_init },
1060 { "SUNW,schizo", schizo_irq_trans_init },
1061 { "pci108e,8001", schizo_irq_trans_init },
1062 { "SUNW,schizo+", schizo_irq_trans_init },
1063 { "pci108e,8002", schizo_irq_trans_init },
1064 { "SUNW,tomatillo", tomatillo_irq_trans_init },
1065 { "pci108e,a801", tomatillo_irq_trans_init },
1066 { "SUNW,sun4v-pci", pci_sun4v_irq_trans_init },
1067 { "pciex108e,80f0", fire_irq_trans_init },
1071 static unsigned int sun4v_vdev_irq_build(struct device_node *dp,
1072 unsigned int devino,
1075 u32 devhandle = (u32) (unsigned long) _data;
1077 return sun4v_build_irq(devhandle, devino);
1080 static void __init sun4v_vdev_irq_trans_init(struct device_node *dp)
1082 const struct linux_prom64_registers *regs;
1084 dp->irq_trans = prom_early_alloc(sizeof(struct of_irq_controller));
1085 dp->irq_trans->irq_build = sun4v_vdev_irq_build;
1087 regs = of_get_property(dp, "reg", NULL);
1088 dp->irq_trans->data = (void *) (unsigned long)
1089 ((regs->phys_addr >> 32UL) & 0x0fffffff);
1092 static void __init irq_trans_init(struct device_node *dp)
1100 model = of_get_property(dp, "model", NULL);
1102 model = of_get_property(dp, "compatible", NULL);
1104 for (i = 0; i < ARRAY_SIZE(pci_irq_trans_table); i++) {
1105 struct irq_trans *t = &pci_irq_trans_table[i];
1107 if (!strcmp(model, t->name))
1113 if (!strcmp(dp->name, "sbus") ||
1114 !strcmp(dp->name, "sbi"))
1115 return sbus_irq_trans_init(dp);
1117 if (!strcmp(dp->name, "fhc") &&
1118 !strcmp(dp->parent->name, "central"))
1119 return central_irq_trans_init(dp);
1120 if (!strcmp(dp->name, "virtual-devices"))
1121 return sun4v_vdev_irq_trans_init(dp);
1124 static int is_root_node(const struct device_node *dp)
1129 return (dp->parent == NULL);
1132 /* The following routines deal with the black magic of fully naming a
1135 * Certain well known named nodes are just the simple name string.
1137 * Actual devices have an address specifier appended to the base name
1138 * string, like this "foo@addr". The "addr" can be in any number of
1139 * formats, and the platform plus the type of the node determine the
1140 * format and how it is constructed.
1142 * For children of the ROOT node, the naming convention is fixed and
1143 * determined by whether this is a sun4u or sun4v system.
1145 * For children of other nodes, it is bus type specific. So
1146 * we walk up the tree until we discover a "device_type" property
1147 * we recognize and we go from there.
1149 * As an example, the boot device on my workstation has a full path:
1151 * /pci@1e,600000/ide@d/disk@0,0:c
1153 static void __init sun4v_path_component(struct device_node *dp, char *tmp_buf)
1155 struct linux_prom64_registers *regs;
1156 struct property *rprop;
1157 u32 high_bits, low_bits, type;
1159 rprop = of_find_property(dp, "reg", NULL);
1163 regs = rprop->value;
1164 if (!is_root_node(dp->parent)) {
1165 sprintf(tmp_buf, "%s@%x,%x",
1167 (unsigned int) (regs->phys_addr >> 32UL),
1168 (unsigned int) (regs->phys_addr & 0xffffffffUL));
1172 type = regs->phys_addr >> 60UL;
1173 high_bits = (regs->phys_addr >> 32UL) & 0x0fffffffUL;
1174 low_bits = (regs->phys_addr & 0xffffffffUL);
1176 if (type == 0 || type == 8) {
1177 const char *prefix = (type == 0) ? "m" : "i";
1180 sprintf(tmp_buf, "%s@%s%x,%x",
1182 high_bits, low_bits);
1184 sprintf(tmp_buf, "%s@%s%x",
1188 } else if (type == 12) {
1189 sprintf(tmp_buf, "%s@%x",
1190 dp->name, high_bits);
1194 static void __init sun4u_path_component(struct device_node *dp, char *tmp_buf)
1196 struct linux_prom64_registers *regs;
1197 struct property *prop;
1199 prop = of_find_property(dp, "reg", NULL);
1204 if (!is_root_node(dp->parent)) {
1205 sprintf(tmp_buf, "%s@%x,%x",
1207 (unsigned int) (regs->phys_addr >> 32UL),
1208 (unsigned int) (regs->phys_addr & 0xffffffffUL));
1212 prop = of_find_property(dp, "upa-portid", NULL);
1214 prop = of_find_property(dp, "portid", NULL);
1216 unsigned long mask = 0xffffffffUL;
1218 if (tlb_type >= cheetah)
1221 sprintf(tmp_buf, "%s@%x,%x",
1223 *(u32 *)prop->value,
1224 (unsigned int) (regs->phys_addr & mask));
1228 /* "name@slot,offset" */
1229 static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)
1231 struct linux_prom_registers *regs;
1232 struct property *prop;
1234 prop = of_find_property(dp, "reg", NULL);
1239 sprintf(tmp_buf, "%s@%x,%x",
1245 /* "name@devnum[,func]" */
1246 static void __init pci_path_component(struct device_node *dp, char *tmp_buf)
1248 struct linux_prom_pci_registers *regs;
1249 struct property *prop;
1252 prop = of_find_property(dp, "reg", NULL);
1257 devfn = (regs->phys_hi >> 8) & 0xff;
1259 sprintf(tmp_buf, "%s@%x,%x",
1264 sprintf(tmp_buf, "%s@%x",
1270 /* "name@UPA_PORTID,offset" */
1271 static void __init upa_path_component(struct device_node *dp, char *tmp_buf)
1273 struct linux_prom64_registers *regs;
1274 struct property *prop;
1276 prop = of_find_property(dp, "reg", NULL);
1282 prop = of_find_property(dp, "upa-portid", NULL);
1286 sprintf(tmp_buf, "%s@%x,%x",
1288 *(u32 *) prop->value,
1289 (unsigned int) (regs->phys_addr & 0xffffffffUL));
1293 static void __init vdev_path_component(struct device_node *dp, char *tmp_buf)
1295 struct property *prop;
1298 prop = of_find_property(dp, "reg", NULL);
1304 sprintf(tmp_buf, "%s@%x", dp->name, *regs);
1307 /* "name@addrhi,addrlo" */
1308 static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)
1310 struct linux_prom64_registers *regs;
1311 struct property *prop;
1313 prop = of_find_property(dp, "reg", NULL);
1319 sprintf(tmp_buf, "%s@%x,%x",
1321 (unsigned int) (regs->phys_addr >> 32UL),
1322 (unsigned int) (regs->phys_addr & 0xffffffffUL));
1325 /* "name@bus,addr" */
1326 static void __init i2c_path_component(struct device_node *dp, char *tmp_buf)
1328 struct property *prop;
1331 prop = of_find_property(dp, "reg", NULL);
1337 /* This actually isn't right... should look at the #address-cells
1338 * property of the i2c bus node etc. etc.
1340 sprintf(tmp_buf, "%s@%x,%x",
1341 dp->name, regs[0], regs[1]);
1344 /* "name@reg0[,reg1]" */
1345 static void __init usb_path_component(struct device_node *dp, char *tmp_buf)
1347 struct property *prop;
1350 prop = of_find_property(dp, "reg", NULL);
1356 if (prop->length == sizeof(u32) || regs[1] == 1) {
1357 sprintf(tmp_buf, "%s@%x",
1360 sprintf(tmp_buf, "%s@%x,%x",
1361 dp->name, regs[0], regs[1]);
1365 /* "name@reg0reg1[,reg2reg3]" */
1366 static void __init ieee1394_path_component(struct device_node *dp, char *tmp_buf)
1368 struct property *prop;
1371 prop = of_find_property(dp, "reg", NULL);
1377 if (regs[2] || regs[3]) {
1378 sprintf(tmp_buf, "%s@%08x%08x,%04x%08x",
1379 dp->name, regs[0], regs[1], regs[2], regs[3]);
1381 sprintf(tmp_buf, "%s@%08x%08x",
1382 dp->name, regs[0], regs[1]);
1386 static void __init __build_path_component(struct device_node *dp, char *tmp_buf)
1388 struct device_node *parent = dp->parent;
1390 if (parent != NULL) {
1391 if (!strcmp(parent->type, "pci") ||
1392 !strcmp(parent->type, "pciex"))
1393 return pci_path_component(dp, tmp_buf);
1394 if (!strcmp(parent->type, "sbus"))
1395 return sbus_path_component(dp, tmp_buf);
1396 if (!strcmp(parent->type, "upa"))
1397 return upa_path_component(dp, tmp_buf);
1398 if (!strcmp(parent->type, "ebus"))
1399 return ebus_path_component(dp, tmp_buf);
1400 if (!strcmp(parent->name, "usb") ||
1401 !strcmp(parent->name, "hub"))
1402 return usb_path_component(dp, tmp_buf);
1403 if (!strcmp(parent->type, "i2c"))
1404 return i2c_path_component(dp, tmp_buf);
1405 if (!strcmp(parent->type, "firewire"))
1406 return ieee1394_path_component(dp, tmp_buf);
1407 if (!strcmp(parent->type, "virtual-devices"))
1408 return vdev_path_component(dp, tmp_buf);
1410 /* "isa" is handled with platform naming */
1413 /* Use platform naming convention. */
1414 if (tlb_type == hypervisor)
1415 return sun4v_path_component(dp, tmp_buf);
1417 return sun4u_path_component(dp, tmp_buf);
1420 static char * __init build_path_component(struct device_node *dp)
1422 char tmp_buf[64], *n;
1425 __build_path_component(dp, tmp_buf);
1426 if (tmp_buf[0] == '\0')
1427 strcpy(tmp_buf, dp->name);
1429 n = prom_early_alloc(strlen(tmp_buf) + 1);
1435 static char * __init build_full_name(struct device_node *dp)
1437 int len, ourlen, plen;
1440 plen = strlen(dp->parent->full_name);
1441 ourlen = strlen(dp->path_component_name);
1442 len = ourlen + plen + 2;
1444 n = prom_early_alloc(len);
1445 strcpy(n, dp->parent->full_name);
1446 if (!is_root_node(dp->parent)) {
1447 strcpy(n + plen, "/");
1450 strcpy(n + plen, dp->path_component_name);
1455 static unsigned int unique_id;
1457 static struct property * __init build_one_prop(phandle node, char *prev, char *special_name, void *special_val, int special_len)
1459 static struct property *tmp = NULL;
1464 memset(p, 0, sizeof(*p) + 32);
1467 p = prom_early_alloc(sizeof(struct property) + 32);
1468 p->unique_id = unique_id++;
1471 p->name = (char *) (p + 1);
1473 strcpy(p->name, special_name);
1474 p->length = special_len;
1475 p->value = prom_early_alloc(special_len);
1476 memcpy(p->value, special_val, special_len);
1479 prom_firstprop(node, p->name);
1481 prom_nextprop(node, prev, p->name);
1483 if (strlen(p->name) == 0) {
1487 p->length = prom_getproplen(node, p->name);
1488 if (p->length <= 0) {
1491 p->value = prom_early_alloc(p->length + 1);
1492 prom_getproperty(node, p->name, p->value, p->length);
1493 ((unsigned char *)p->value)[p->length] = '\0';
1499 static struct property * __init build_prop_list(phandle node)
1501 struct property *head, *tail;
1503 head = tail = build_one_prop(node, NULL,
1504 ".node", &node, sizeof(node));
1506 tail->next = build_one_prop(node, NULL, NULL, NULL, 0);
1509 tail->next = build_one_prop(node, tail->name,
1517 static char * __init get_one_property(phandle node, const char *name)
1519 char *buf = "<NULL>";
1522 len = prom_getproplen(node, name);
1524 buf = prom_early_alloc(len);
1525 prom_getproperty(node, name, buf, len);
1531 static struct device_node * __init create_node(phandle node, struct device_node *parent)
1533 struct device_node *dp;
1538 dp = prom_early_alloc(sizeof(*dp));
1539 dp->unique_id = unique_id++;
1540 dp->parent = parent;
1542 kref_init(&dp->kref);
1544 dp->name = get_one_property(node, "name");
1545 dp->type = get_one_property(node, "device_type");
1548 dp->properties = build_prop_list(node);
1555 static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp)
1557 struct device_node *ret = NULL, *prev_sibling = NULL;
1558 struct device_node *dp;
1561 dp = create_node(node, parent);
1566 prev_sibling->sibling = dp;
1573 *nextp = &dp->allnext;
1575 dp->path_component_name = build_path_component(dp);
1576 dp->full_name = build_full_name(dp);
1578 dp->child = build_tree(dp, prom_getchild(node), nextp);
1580 node = prom_getsibling(node);
1586 static const char *get_mid_prop(void)
1588 return (tlb_type == spitfire ? "upa-portid" : "portid");
1591 struct device_node *of_find_node_by_cpuid(int cpuid)
1593 struct device_node *dp;
1594 const char *mid_prop = get_mid_prop();
1596 for_each_node_by_type(dp, "cpu") {
1597 int id = of_getintprop_default(dp, mid_prop, -1);
1598 const char *this_mid_prop = mid_prop;
1601 this_mid_prop = "cpuid";
1602 id = of_getintprop_default(dp, this_mid_prop, -1);
1606 prom_printf("OF: Serious problem, cpu lacks "
1607 "%s property", this_mid_prop);
1616 static void __init of_fill_in_cpu_data(void)
1618 struct device_node *dp;
1619 const char *mid_prop = get_mid_prop();
1622 for_each_node_by_type(dp, "cpu") {
1623 int cpuid = of_getintprop_default(dp, mid_prop, -1);
1624 const char *this_mid_prop = mid_prop;
1625 struct device_node *portid_parent;
1628 portid_parent = NULL;
1630 this_mid_prop = "cpuid";
1631 cpuid = of_getintprop_default(dp, this_mid_prop, -1);
1637 portid_parent = portid_parent->parent;
1640 portid = of_getintprop_default(portid_parent,
1649 prom_printf("OF: Serious problem, cpu lacks "
1650 "%s property", this_mid_prop);
1657 if (cpuid >= NR_CPUS)
1660 /* On uniprocessor we only want the values for the
1661 * real physical cpu the kernel booted onto, however
1662 * cpu_data() only has one entry at index 0.
1664 if (cpuid != real_hard_smp_processor_id())
1669 cpu_data(cpuid).clock_tick =
1670 of_getintprop_default(dp, "clock-frequency", 0);
1672 if (portid_parent) {
1673 cpu_data(cpuid).dcache_size =
1674 of_getintprop_default(dp, "l1-dcache-size",
1676 cpu_data(cpuid).dcache_line_size =
1677 of_getintprop_default(dp, "l1-dcache-line-size",
1679 cpu_data(cpuid).icache_size =
1680 of_getintprop_default(dp, "l1-icache-size",
1682 cpu_data(cpuid).icache_line_size =
1683 of_getintprop_default(dp, "l1-icache-line-size",
1685 cpu_data(cpuid).ecache_size =
1686 of_getintprop_default(dp, "l2-cache-size", 0);
1687 cpu_data(cpuid).ecache_line_size =
1688 of_getintprop_default(dp, "l2-cache-line-size", 0);
1689 if (!cpu_data(cpuid).ecache_size ||
1690 !cpu_data(cpuid).ecache_line_size) {
1691 cpu_data(cpuid).ecache_size =
1692 of_getintprop_default(portid_parent,
1695 cpu_data(cpuid).ecache_line_size =
1696 of_getintprop_default(portid_parent,
1697 "l2-cache-line-size", 64);
1700 cpu_data(cpuid).core_id = portid + 1;
1701 cpu_data(cpuid).proc_id = portid;
1703 sparc64_multi_core = 1;
1706 cpu_data(cpuid).dcache_size =
1707 of_getintprop_default(dp, "dcache-size", 16 * 1024);
1708 cpu_data(cpuid).dcache_line_size =
1709 of_getintprop_default(dp, "dcache-line-size", 32);
1711 cpu_data(cpuid).icache_size =
1712 of_getintprop_default(dp, "icache-size", 16 * 1024);
1713 cpu_data(cpuid).icache_line_size =
1714 of_getintprop_default(dp, "icache-line-size", 32);
1716 cpu_data(cpuid).ecache_size =
1717 of_getintprop_default(dp, "ecache-size",
1719 cpu_data(cpuid).ecache_line_size =
1720 of_getintprop_default(dp, "ecache-line-size", 64);
1722 cpu_data(cpuid).core_id = 0;
1723 cpu_data(cpuid).proc_id = -1;
1727 cpu_set(cpuid, cpu_present_map);
1728 cpu_set(cpuid, cpu_possible_map);
1732 smp_fill_in_sib_core_maps();
1735 void __init prom_build_devicetree(void)
1737 struct device_node **nextp;
1739 allnodes = create_node(prom_root_node, NULL);
1740 allnodes->path_component_name = "";
1741 allnodes->full_name = "/";
1743 nextp = &allnodes->allnext;
1744 allnodes->child = build_tree(allnodes,
1745 prom_getchild(allnodes->node),
1747 printk("PROM: Built device tree with %u bytes of memory.\n",
1748 prom_early_allocated);
1750 if (tlb_type != hypervisor)
1751 of_fill_in_cpu_data();