Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sparc: Remove generic SBUS probing layer.

The individual SBUS IOMMU arch code now sets the IOMMU information
directly into the OF device objects.

Signed-off-by: David S. Miller <davem@davemloft.net>

+108 -286
-2
arch/sparc/include/asm/io-unit.h
··· 59 59 #define iounit_map_dma_finish(sbus, addr, len) mmu_release_scsi_one(addr, len, sbus) 60 60 extern __u32 iounit_map_dma_page(__u32, void *, struct sbus_bus *); 61 61 62 - extern void iounit_init(struct sbus_bus *sbus); 63 - 64 62 #endif /* !(_SPARC_IO_UNIT_H) */
-2
arch/sparc/include/asm/iommu_32.h
··· 118 118 regs->pageflush = (ba & PAGE_MASK); 119 119 } 120 120 121 - extern void iommu_init(struct device_node *dp, struct sbus_bus *sbus); 122 - 123 121 #endif /* !(_SPARC_IOMMU_H) */
-1
arch/sparc/include/asm/irq_64.h
··· 56 56 unsigned long imap_base, 57 57 unsigned long iclr_base); 58 58 extern void sun4u_destroy_msi(unsigned int virt_irq); 59 - extern unsigned int sbus_build_irq(void *sbus, unsigned int ino); 60 59 61 60 extern unsigned char virt_irq_alloc(unsigned int dev_handle, 62 61 unsigned int dev_ino);
-23
arch/sparc/kernel/ioport.c
··· 377 377 { 378 378 } 379 379 380 - /* Support code for sbus_init(). */ 381 - void __init sbus_setup_iommu(struct sbus_bus *sbus, struct device_node *dp) 382 - { 383 - #ifndef CONFIG_SUN4 384 - struct device_node *parent = dp->parent; 385 - 386 - if (sparc_cpu_model != sun4d && 387 - parent != NULL && 388 - !strcmp(parent->name, "iommu")) 389 - iommu_init(parent, sbus); 390 - 391 - if (sparc_cpu_model == sun4d) 392 - iounit_init(sbus); 393 - #endif 394 - } 395 - 396 380 static int __init sparc_register_ioport(void) 397 381 { 398 382 register_proc_sparc_ioport(); ··· 386 402 387 403 arch_initcall(sparc_register_ioport); 388 404 389 - void __init sbus_arch_postinit(void) 390 - { 391 - if (sparc_cpu_model == sun4d) { 392 - extern void sun4d_init_sbi_irq(void); 393 - sun4d_init_sbi_irq(); 394 - } 395 - } 396 405 #endif /* CONFIG_SBUS */ 397 406 398 407 #ifdef CONFIG_PCI
+20 -10
arch/sparc/mm/io-unit.c
··· 34 34 #define IOPERM (IOUPTE_CACHE | IOUPTE_WRITE | IOUPTE_VALID) 35 35 #define MKIOPTE(phys) __iopte((((phys)>>4) & IOUPTE_PAGE) | IOPERM) 36 36 37 - void __init iounit_init(struct sbus_bus *sbus) 37 + static void __init iounit_iommu_init(struct of_device *op) 38 38 { 39 - struct device_node *dp = sbus->ofdev.node; 40 39 struct iounit_struct *iounit; 41 40 iopte_t *xpt, *xptend; 42 - struct of_device *op; 43 - 44 - op = of_find_device_by_node(dp); 45 - if (!op) { 46 - prom_printf("SUN4D: Cannot find SBI of_device.\n"); 47 - prom_halt(); 48 - } 49 41 50 42 iounit = kzalloc(sizeof(struct iounit_struct), GFP_ATOMIC); 51 43 if (!iounit) { ··· 58 66 prom_halt(); 59 67 } 60 68 61 - sbus->ofdev.dev.archdata.iommu = iounit; 62 69 op->dev.archdata.iommu = iounit; 63 70 iounit->page_table = xpt; 64 71 spin_lock_init(&iounit->lock); ··· 66 75 xpt < xptend;) 67 76 iopte_val(*xpt++) = 0; 68 77 } 78 + 79 + static int __init iounit_init(void) 80 + { 81 + extern void sun4d_init_sbi_irq(void); 82 + struct device_node *dp; 83 + 84 + for_each_node_by_name(dp, "sbi") { 85 + struct of_device *op = of_find_device_by_node(dp); 86 + 87 + iounit_iommu_init(op); 88 + of_propagate_archdata(op); 89 + } 90 + 91 + sun4d_init_sbi_irq(); 92 + 93 + return 0; 94 + } 95 + 96 + subsys_initcall(iounit_init); 69 97 70 98 /* One has to hold iounit->lock to call this */ 71 99 static unsigned long iounit_get_area(struct iounit_struct *iounit, unsigned long vaddr, int size)
+21 -19
arch/sparc/mm/iommu.c
··· 55 55 #define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID) 56 56 #define MKIOPTE(pfn, perm) (((((pfn)<<8) & IOPTE_PAGE) | (perm)) & ~IOPTE_WAZ) 57 57 58 - void __init iommu_init(struct device_node *parent, struct sbus_bus *sbus) 58 + static void __init sbus_iommu_init(struct of_device *op) 59 59 { 60 - struct of_device *parent_op, *op; 61 60 struct iommu_struct *iommu; 62 61 unsigned int impl, vers; 63 62 unsigned long *bitmap; 64 63 unsigned long tmp; 65 - 66 - parent_op = of_find_device_by_node(parent); 67 - if (!parent_op) { 68 - prom_printf("Unable to find IOMMU of_device\n"); 69 - prom_halt(); 70 - } 71 - 72 - op = of_find_device_by_node(sbus->ofdev.node); 73 - if (!op) { 74 - prom_printf("Unable to find SBUS of_device\n"); 75 - prom_halt(); 76 - } 77 64 78 65 iommu = kmalloc(sizeof(struct iommu_struct), GFP_ATOMIC); 79 66 if (!iommu) { ··· 68 81 prom_halt(); 69 82 } 70 83 71 - iommu->regs = of_ioremap(&parent_op->resource[0], 0, PAGE_SIZE * 3, 84 + iommu->regs = of_ioremap(&op->resource[0], 0, PAGE_SIZE * 3, 72 85 "iommu_regs"); 73 86 if (!iommu->regs) { 74 87 prom_printf("Cannot map IOMMU registers\n"); ··· 119 132 else 120 133 iommu->usemap.num_colors = 1; 121 134 122 - printk("IOMMU: impl %d vers %d table 0x%p[%d B] map [%d b]\n", 123 - impl, vers, iommu->page_table, 124 - (int)(IOMMU_NPTES*sizeof(iopte_t)), (int)IOMMU_NPTES); 135 + printk(KERN_INFO "IOMMU: impl %d vers %d table 0x%p[%d B] map [%d b]\n", 136 + impl, vers, iommu->page_table, 137 + (int)(IOMMU_NPTES*sizeof(iopte_t)), (int)IOMMU_NPTES); 125 138 126 - sbus->ofdev.dev.archdata.iommu = iommu; 127 139 op->dev.archdata.iommu = iommu; 128 140 } 141 + 142 + static int __init iommu_init(void) 143 + { 144 + struct device_node *dp; 145 + 146 + for_each_node_by_name(dp, "iommu") { 147 + struct of_device *op = of_find_device_by_node(dp); 148 + 149 + sbus_iommu_init(op); 150 + of_propagate_archdata(op); 151 + } 152 + 153 + return 0; 154 + } 155 + 156 + subsys_initcall(iommu_init); 129 157 130 158 /* This begs to be btfixup-ed by srmmu. */ 131 159 /* Flush the iotlb entries to ram. */
+67 -55
arch/sparc64/kernel/sbus.c
··· 201 201 return imap + diff; 202 202 } 203 203 204 - unsigned int sbus_build_irq(void *buscookie, unsigned int ino) 204 + static unsigned int sbus_build_irq(struct of_device *op, unsigned int ino) 205 205 { 206 - struct sbus_bus *sbus = (struct sbus_bus *)buscookie; 207 - struct iommu *iommu = sbus->ofdev.dev.archdata.iommu; 206 + struct iommu *iommu = op->dev.archdata.iommu; 208 207 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 209 208 unsigned long imap, iclr; 210 209 int sbus_level = 0; ··· 264 265 #define SYSIO_UEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */ 265 266 static irqreturn_t sysio_ue_handler(int irq, void *dev_id) 266 267 { 267 - struct sbus_bus *sbus = dev_id; 268 - struct iommu *iommu = sbus->ofdev.dev.archdata.iommu; 268 + struct of_device *op = dev_id; 269 + struct iommu *iommu = op->dev.archdata.iommu; 269 270 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 270 271 unsigned long afsr_reg, afar_reg; 271 272 unsigned long afsr, afar, error_bits; 272 - int reported; 273 + int reported, portid; 273 274 274 275 afsr_reg = reg_base + SYSIO_UE_AFSR; 275 276 afar_reg = reg_base + SYSIO_UE_AFAR; ··· 284 285 SYSIO_UEAFSR_SPIO | SYSIO_UEAFSR_SDRD | SYSIO_UEAFSR_SDWR); 285 286 upa_writeq(error_bits, afsr_reg); 286 287 288 + portid = of_getintprop_default(op->node, "portid", -1); 289 + 287 290 /* Log the error. */ 288 291 printk("SYSIO[%x]: Uncorrectable ECC Error, primary error type[%s]\n", 289 - sbus->portid, 292 + portid, 290 293 (((error_bits & SYSIO_UEAFSR_PPIO) ? 291 294 "PIO" : 292 295 ((error_bits & SYSIO_UEAFSR_PDRD) ? ··· 296 295 ((error_bits & SYSIO_UEAFSR_PDWR) ? 297 296 "DVMA Write" : "???"))))); 298 297 printk("SYSIO[%x]: DOFF[%lx] SIZE[%lx] MID[%lx]\n", 299 - sbus->portid, 298 + portid, 300 299 (afsr & SYSIO_UEAFSR_DOFF) >> 45UL, 301 300 (afsr & SYSIO_UEAFSR_SIZE) >> 42UL, 302 301 (afsr & SYSIO_UEAFSR_MID) >> 37UL); 303 - printk("SYSIO[%x]: AFAR[%016lx]\n", sbus->portid, afar); 304 - printk("SYSIO[%x]: Secondary UE errors [", sbus->portid); 302 + printk("SYSIO[%x]: AFAR[%016lx]\n", portid, afar); 303 + printk("SYSIO[%x]: Secondary UE errors [", portid); 305 304 reported = 0; 306 305 if (afsr & SYSIO_UEAFSR_SPIO) { 307 306 reported++; ··· 338 337 #define SYSIO_CEAFSR_RESV2 0x0000001fffffffffUL /* Reserved */ 339 338 static irqreturn_t sysio_ce_handler(int irq, void *dev_id) 340 339 { 341 - struct sbus_bus *sbus = dev_id; 342 - struct iommu *iommu = sbus->ofdev.dev.archdata.iommu; 340 + struct of_device *op = dev_id; 341 + struct iommu *iommu = op->dev.archdata.iommu; 343 342 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 344 343 unsigned long afsr_reg, afar_reg; 345 344 unsigned long afsr, afar, error_bits; 346 - int reported; 345 + int reported, portid; 347 346 348 347 afsr_reg = reg_base + SYSIO_CE_AFSR; 349 348 afar_reg = reg_base + SYSIO_CE_AFAR; ··· 358 357 SYSIO_CEAFSR_SPIO | SYSIO_CEAFSR_SDRD | SYSIO_CEAFSR_SDWR); 359 358 upa_writeq(error_bits, afsr_reg); 360 359 360 + portid = of_getintprop_default(op->node, "portid", -1); 361 + 361 362 printk("SYSIO[%x]: Correctable ECC Error, primary error type[%s]\n", 362 - sbus->portid, 363 + portid, 363 364 (((error_bits & SYSIO_CEAFSR_PPIO) ? 364 365 "PIO" : 365 366 ((error_bits & SYSIO_CEAFSR_PDRD) ? ··· 373 370 * XXX UDB CE trap handler does... -DaveM 374 371 */ 375 372 printk("SYSIO[%x]: DOFF[%lx] ECC Syndrome[%lx] Size[%lx] MID[%lx]\n", 376 - sbus->portid, 373 + portid, 377 374 (afsr & SYSIO_CEAFSR_DOFF) >> 45UL, 378 375 (afsr & SYSIO_CEAFSR_ESYND) >> 48UL, 379 376 (afsr & SYSIO_CEAFSR_SIZE) >> 42UL, 380 377 (afsr & SYSIO_CEAFSR_MID) >> 37UL); 381 - printk("SYSIO[%x]: AFAR[%016lx]\n", sbus->portid, afar); 378 + printk("SYSIO[%x]: AFAR[%016lx]\n", portid, afar); 382 379 383 - printk("SYSIO[%x]: Secondary CE errors [", sbus->portid); 380 + printk("SYSIO[%x]: Secondary CE errors [", portid); 384 381 reported = 0; 385 382 if (afsr & SYSIO_CEAFSR_SPIO) { 386 383 reported++; ··· 417 414 #define SYSIO_SBAFSR_RESV3 0x0000001fffffffffUL /* Reserved */ 418 415 static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id) 419 416 { 420 - struct sbus_bus *sbus = dev_id; 421 - struct iommu *iommu = sbus->ofdev.dev.archdata.iommu; 417 + struct of_device *op = dev_id; 418 + struct iommu *iommu = op->dev.archdata.iommu; 422 419 unsigned long afsr_reg, afar_reg, reg_base; 423 420 unsigned long afsr, afar, error_bits; 424 - int reported; 421 + int reported, portid; 425 422 426 423 reg_base = iommu->write_complete_reg - 0x2000UL; 427 424 afsr_reg = reg_base + SYSIO_SBUS_AFSR; ··· 436 433 SYSIO_SBAFSR_SLE | SYSIO_SBAFSR_STO | SYSIO_SBAFSR_SBERR); 437 434 upa_writeq(error_bits, afsr_reg); 438 435 436 + portid = of_getintprop_default(op->node, "portid", -1); 437 + 439 438 /* Log the error. */ 440 439 printk("SYSIO[%x]: SBUS Error, primary error type[%s] read(%d)\n", 441 - sbus->portid, 440 + portid, 442 441 (((error_bits & SYSIO_SBAFSR_PLE) ? 443 442 "Late PIO Error" : 444 443 ((error_bits & SYSIO_SBAFSR_PTO) ? ··· 449 444 "Error Ack" : "???")))), 450 445 (afsr & SYSIO_SBAFSR_RD) ? 1 : 0); 451 446 printk("SYSIO[%x]: size[%lx] MID[%lx]\n", 452 - sbus->portid, 447 + portid, 453 448 (afsr & SYSIO_SBAFSR_SIZE) >> 42UL, 454 449 (afsr & SYSIO_SBAFSR_MID) >> 37UL); 455 - printk("SYSIO[%x]: AFAR[%016lx]\n", sbus->portid, afar); 456 - printk("SYSIO[%x]: Secondary SBUS errors [", sbus->portid); 450 + printk("SYSIO[%x]: AFAR[%016lx]\n", portid, afar); 451 + printk("SYSIO[%x]: Secondary SBUS errors [", portid); 457 452 reported = 0; 458 453 if (afsr & SYSIO_SBAFSR_SLE) { 459 454 reported++; ··· 485 480 #define SYSIO_CE_INO 0x35 486 481 #define SYSIO_SBUSERR_INO 0x36 487 482 488 - static void __init sysio_register_error_handlers(struct sbus_bus *sbus) 483 + static void __init sysio_register_error_handlers(struct of_device *op) 489 484 { 490 - struct iommu *iommu = sbus->ofdev.dev.archdata.iommu; 485 + struct iommu *iommu = op->dev.archdata.iommu; 491 486 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 492 487 unsigned int irq; 493 488 u64 control; 489 + int portid; 494 490 495 - irq = sbus_build_irq(sbus, SYSIO_UE_INO); 491 + portid = of_getintprop_default(op->node, "portid", -1); 492 + 493 + irq = sbus_build_irq(op, SYSIO_UE_INO); 496 494 if (request_irq(irq, sysio_ue_handler, 0, 497 - "SYSIO_UE", sbus) < 0) { 495 + "SYSIO_UE", op) < 0) { 498 496 prom_printf("SYSIO[%x]: Cannot register UE interrupt.\n", 499 - sbus->portid); 497 + portid); 500 498 prom_halt(); 501 499 } 502 500 503 - irq = sbus_build_irq(sbus, SYSIO_CE_INO); 501 + irq = sbus_build_irq(op, SYSIO_CE_INO); 504 502 if (request_irq(irq, sysio_ce_handler, 0, 505 - "SYSIO_CE", sbus) < 0) { 503 + "SYSIO_CE", op) < 0) { 506 504 prom_printf("SYSIO[%x]: Cannot register CE interrupt.\n", 507 - sbus->portid); 505 + portid); 508 506 prom_halt(); 509 507 } 510 508 511 - irq = sbus_build_irq(sbus, SYSIO_SBUSERR_INO); 509 + irq = sbus_build_irq(op, SYSIO_SBUSERR_INO); 512 510 if (request_irq(irq, sysio_sbus_error_handler, 0, 513 - "SYSIO_SBERR", sbus) < 0) { 511 + "SYSIO_SBERR", op) < 0) { 514 512 prom_printf("SYSIO[%x]: Cannot register SBUS Error interrupt.\n", 515 - sbus->portid); 513 + portid); 516 514 prom_halt(); 517 515 } 518 516 ··· 531 523 } 532 524 533 525 /* Boot time initialization. */ 534 - static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus) 526 + static void __init sbus_iommu_init(struct of_device *op) 535 527 { 536 528 const struct linux_prom64_registers *pr; 537 - struct device_node *dp; 529 + struct device_node *dp = op->node; 538 530 struct iommu *iommu; 539 531 struct strbuf *strbuf; 540 532 unsigned long regs, reg_base; 533 + int i, portid; 541 534 u64 control; 542 - int i; 543 - 544 - dp = of_find_node_by_phandle(__node); 545 - 546 - sbus->portid = of_getintprop_default(dp, "upa-portid", -1); 547 535 548 536 pr = of_get_property(dp, "reg", NULL); 549 537 if (!pr) { ··· 556 552 if (!strbuf) 557 553 goto fatal_memory_error; 558 554 559 - sbus->ofdev.dev.archdata.iommu = iommu; 560 - sbus->ofdev.dev.archdata.stc = strbuf; 561 - sbus->ofdev.dev.archdata.numa_node = -1; 555 + op->dev.archdata.iommu = iommu; 556 + op->dev.archdata.stc = strbuf; 557 + op->dev.archdata.numa_node = -1; 562 558 563 559 reg_base = regs + SYSIO_IOMMUREG_BASE; 564 560 iommu->iommu_control = reg_base + IOMMU_CONTROL; ··· 586 582 */ 587 583 iommu->write_complete_reg = regs + 0x2000UL; 588 584 589 - printk("SYSIO: UPA portID %x, at %016lx\n", 590 - sbus->portid, regs); 585 + portid = of_getintprop_default(op->node, "portid", -1); 586 + printk(KERN_INFO "SYSIO: UPA portID %x, at %016lx\n", 587 + portid, regs); 591 588 592 589 /* Setup for TSB_SIZE=7, TBW_SIZE=0, MMU_DE=1, MMU_EN=1 */ 593 590 if (iommu_table_init(iommu, IO_TSB_SIZE, MAP_BASE, 0xffffffff, -1)) ··· 646 641 647 642 /* Now some Xfire specific grot... */ 648 643 if (this_is_starfire) 649 - starfire_hookup(sbus->portid); 644 + starfire_hookup(portid); 650 645 651 - sysio_register_error_handlers(sbus); 646 + sysio_register_error_handlers(op); 652 647 return; 653 648 654 649 fatal_memory_error: 655 650 prom_printf("sbus_iommu_init: Fatal memory allocation error.\n"); 656 651 } 657 652 658 - void __init sbus_setup_iommu(struct sbus_bus *sbus, struct device_node *dp) 659 - { 660 - sbus_iommu_init(dp->node, sbus); 661 - } 662 - 663 - void __init sbus_arch_postinit(void) 653 + static int __init sbus_init(void) 664 654 { 665 655 extern void firetruck_init(void); 656 + struct device_node *dp; 657 + 658 + for_each_node_by_name(dp, "sbus") { 659 + struct of_device *op = of_find_device_by_node(dp); 660 + 661 + sbus_iommu_init(op); 662 + of_propagate_archdata(op); 663 + } 666 664 667 665 firetruck_init(); 666 + 667 + return 0; 668 668 } 669 + 670 + subsys_initcall(sbus_init);
-4
drivers/sbus/Makefile
··· 2 2 # Makefile for the linux kernel. 3 3 # 4 4 5 - ifneq ($(ARCH),m68k) 6 - obj-y := sbus.o 7 - endif 8 - 9 5 obj-$(CONFIG_SBUSCHAR) += char/
-170
drivers/sbus/sbus.c
··· 1 - /* sbus.c: SBus support routines. 2 - * 3 - * Copyright (C) 1995, 2006 David S. Miller (davem@davemloft.net) 4 - */ 5 - 6 - #include <linux/kernel.h> 7 - #include <linux/slab.h> 8 - #include <linux/init.h> 9 - #include <linux/device.h> 10 - #include <linux/of_device.h> 11 - 12 - #include <asm/system.h> 13 - #include <asm/sbus.h> 14 - #include <asm/dma.h> 15 - #include <asm/oplib.h> 16 - #include <asm/prom.h> 17 - #include <asm/irq.h> 18 - 19 - static ssize_t 20 - show_sbusobppath_attr(struct device * dev, struct device_attribute * attr, char * buf) 21 - { 22 - struct sbus_dev *sbus; 23 - 24 - sbus = to_sbus_device(dev); 25 - 26 - return snprintf (buf, PAGE_SIZE, "%s\n", sbus->ofdev.node->full_name); 27 - } 28 - 29 - static DEVICE_ATTR(obppath, S_IRUSR | S_IRGRP | S_IROTH, show_sbusobppath_attr, NULL); 30 - 31 - static void __init fill_sbus_device_iommu(struct sbus_dev *sdev) 32 - { 33 - struct of_device *op = of_find_device_by_node(sdev->ofdev.node); 34 - struct dev_archdata *sd, *bus_sd; 35 - struct sbus_bus *sbus; 36 - 37 - sbus = sdev->bus; 38 - bus_sd = &sbus->ofdev.dev.archdata; 39 - 40 - sd = &sdev->ofdev.dev.archdata; 41 - sd->iommu = bus_sd->iommu; 42 - sd->stc = bus_sd->stc; 43 - 44 - sd = &op->dev.archdata; 45 - sd->iommu = bus_sd->iommu; 46 - sd->stc = bus_sd->stc; 47 - } 48 - 49 - static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sdev) 50 - { 51 - struct dev_archdata *sd; 52 - int err; 53 - 54 - sd = &sdev->ofdev.dev.archdata; 55 - sd->prom_node = dp; 56 - sd->op = &sdev->ofdev; 57 - 58 - sdev->ofdev.node = dp; 59 - if (sdev->parent) 60 - sdev->ofdev.dev.parent = &sdev->parent->ofdev.dev; 61 - else 62 - sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev; 63 - sdev->ofdev.dev.bus = &sbus_bus_type; 64 - dev_set_name(&sdev->ofdev.dev, "sbus[%08x]", dp->node); 65 - 66 - if (of_device_register(&sdev->ofdev) != 0) 67 - printk(KERN_DEBUG "sbus: device registration error for %s!\n", 68 - dp->path_component_name); 69 - 70 - /* WE HAVE BEEN INVADED BY ALIENS! */ 71 - err = sysfs_create_file(&sdev->ofdev.dev.kobj, &dev_attr_obppath.attr); 72 - 73 - fill_sbus_device_iommu(sdev); 74 - } 75 - 76 - static void __init sdev_insert(struct sbus_dev *sdev, struct sbus_dev **root) 77 - { 78 - while (*root) 79 - root = &(*root)->next; 80 - *root = sdev; 81 - sdev->next = NULL; 82 - } 83 - 84 - static void __init walk_children(struct device_node *dp, struct sbus_dev *parent, struct sbus_bus *sbus) 85 - { 86 - dp = dp->child; 87 - while (dp) { 88 - struct sbus_dev *sdev; 89 - 90 - sdev = kzalloc(sizeof(struct sbus_dev), GFP_ATOMIC); 91 - if (sdev) { 92 - sdev_insert(sdev, &parent->child); 93 - 94 - sdev->bus = sbus; 95 - sdev->parent = parent; 96 - 97 - fill_sbus_device(dp, sdev); 98 - 99 - walk_children(dp, sdev, sbus); 100 - } 101 - dp = dp->sibling; 102 - } 103 - } 104 - 105 - static void __init build_one_sbus(struct device_node *dp, int num_sbus) 106 - { 107 - struct device_node *dev_dp; 108 - struct sbus_bus *sbus; 109 - 110 - sbus = kzalloc(sizeof(struct sbus_bus), GFP_ATOMIC); 111 - if (!sbus) 112 - return; 113 - 114 - sbus_setup_iommu(sbus, dp); 115 - 116 - printk("sbus%d: ", num_sbus); 117 - 118 - sbus->ofdev.node = dp; 119 - sbus->ofdev.dev.parent = NULL; 120 - sbus->ofdev.dev.bus = &sbus_bus_type; 121 - dev_set_name(&sbus->ofdev.dev, "sbus%d", num_sbus); 122 - 123 - if (of_device_register(&sbus->ofdev) != 0) 124 - printk(KERN_DEBUG "sbus: device registration error for %s!\n", 125 - dev_name(&sbus->ofdev.dev)); 126 - 127 - dev_dp = dp->child; 128 - while (dev_dp) { 129 - struct sbus_dev *sdev; 130 - 131 - sdev = kzalloc(sizeof(struct sbus_dev), GFP_ATOMIC); 132 - if (sdev) { 133 - sdev_insert(sdev, &sbus->devices); 134 - 135 - sdev->bus = sbus; 136 - sdev->parent = NULL; 137 - sdev->ofdev.dev.archdata.iommu = 138 - sbus->ofdev.dev.archdata.iommu; 139 - sdev->ofdev.dev.archdata.stc = 140 - sbus->ofdev.dev.archdata.stc; 141 - 142 - fill_sbus_device(dev_dp, sdev); 143 - 144 - walk_children(dev_dp, sdev, sbus); 145 - } 146 - dev_dp = dev_dp->sibling; 147 - } 148 - } 149 - 150 - static int __init sbus_init(void) 151 - { 152 - struct device_node *dp; 153 - const char *sbus_name = "sbus"; 154 - int num_sbus = 0; 155 - 156 - if (sparc_cpu_model == sun4d) 157 - sbus_name = "sbi"; 158 - 159 - for_each_node_by_name(dp, sbus_name) { 160 - build_one_sbus(dp, num_sbus); 161 - num_sbus++; 162 - 163 - } 164 - 165 - sbus_arch_postinit(); 166 - 167 - return 0; 168 - } 169 - 170 - subsys_initcall(sbus_init);