void __init ebus_init(void) { struct pci_pbm_info *pbm; struct linux_ebus_device *dev; struct linux_ebus *ebus; struct pci_dev *pdev; struct pcidev_cookie *cookie; int nd, ebusnd, is_rio; int num_ebus = 0; pdev = find_next_ebus(NULL, &is_rio); if (!pdev) { printk("ebus: No EBus's found.\n"); return; } cookie = pdev->sysdata; ebusnd = cookie->prom_node; ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus)); ebus->next = NULL; ebus->is_rio = is_rio; while (ebusnd) { /* SUNW,pci-qfe uses four empty ebuses on it. I think we should not consider them here, as they have half of the properties this code expects and once we do PCI hot-plug, we'd have to tweak with the ebus_chain in the runtime after initialization. -jj */ if (!prom_getchild (ebusnd)) { pdev = find_next_ebus(pdev, &is_rio); if (!pdev) { if (ebus == ebus_chain) { ebus_chain = NULL; printk("ebus: No EBus's found.\n"); return; } break; } ebus->is_rio = is_rio; cookie = pdev->sysdata; ebusnd = cookie->prom_node; continue; } printk("ebus%d:", num_ebus); prom_getstring(ebusnd, "name", ebus->prom_name, sizeof(ebus->prom_name)); ebus->index = num_ebus; ebus->prom_node = ebusnd; ebus->self = pdev; ebus->parent = pbm = cookie->pbm; ebus_ranges_init(ebus); ebus_intmap_init(ebus); nd = prom_getchild(ebusnd); if (!nd) goto next_ebus; ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device)); dev = ebus->devices; dev->next = NULL; dev->children = NULL; dev->bus = ebus; fill_ebus_device(nd, dev); while ((nd = prom_getsibling(nd)) != 0) { dev->next = ebus_alloc(sizeof(struct linux_ebus_device)); dev = dev->next; dev->next = NULL; dev->children = NULL; dev->bus = ebus; fill_ebus_device(nd, dev); } next_ebus: printk("\n"); pdev = find_next_ebus(pdev, &is_rio); if (!pdev) break; cookie = pdev->sysdata; ebusnd = cookie->prom_node; ebus->next = ebus_alloc(sizeof(struct linux_ebus)); ebus = ebus->next; ebus->next = NULL; ebus->is_rio = is_rio; ++num_ebus; } #ifdef CONFIG_SUN_AUXIO auxio_probe(); #endif }
void __init ebus_init(void) { struct pci_pbm_info *pbm; struct linux_ebus_device *dev; struct linux_ebus *ebus; struct pci_dev *pdev; struct pcidev_cookie *cookie; struct device_node *dp; int is_rio; int num_ebus = 0; pdev = find_next_ebus(NULL, &is_rio); if (!pdev) { printk("ebus: No EBus's found.\n"); return; } cookie = pdev->sysdata; dp = cookie->prom_node; ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus)); ebus->next = NULL; ebus->is_rio = is_rio; while (dp) { struct device_node *child; /* SUNW,pci-qfe uses four empty ebuses on it. I think we should not consider them here, as they have half of the properties this code expects and once we do PCI hot-plug, we'd have to tweak with the ebus_chain in the runtime after initialization. -jj */ if (!dp->child) { pdev = find_next_ebus(pdev, &is_rio); if (!pdev) { if (ebus == ebus_chain) { ebus_chain = NULL; printk("ebus: No EBus's found.\n"); return; } break; } ebus->is_rio = is_rio; cookie = pdev->sysdata; dp = cookie->prom_node; continue; } printk("ebus%d:", num_ebus); ebus->index = num_ebus; ebus->prom_node = dp; ebus->self = pdev; ebus->parent = pbm = cookie->pbm; ebus->ofdev.node = dp; ebus->ofdev.dev.parent = &pdev->dev; ebus->ofdev.dev.bus = &ebus_bus_type; sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus); /* Register with core */ if (of_device_register(&ebus->ofdev) != 0) printk(KERN_DEBUG "ebus: device registration error for %s!\n", dp->path_component_name); child = dp->child; if (!child) goto next_ebus; ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device)); dev = ebus->devices; dev->next = NULL; dev->children = NULL; dev->bus = ebus; fill_ebus_device(child, dev); while ((child = child->sibling) != NULL) { dev->next = ebus_alloc(sizeof(struct linux_ebus_device)); dev = dev->next; dev->next = NULL; dev->children = NULL; dev->bus = ebus; fill_ebus_device(child, dev); } next_ebus: printk("\n"); pdev = find_next_ebus(pdev, &is_rio); if (!pdev) break; cookie = pdev->sysdata; dp = cookie->prom_node; ebus->next = ebus_alloc(sizeof(struct linux_ebus)); ebus = ebus->next; ebus->next = NULL; ebus->is_rio = is_rio; ++num_ebus; } pci_dev_put(pdev); /* XXX for the case, when ebusnd is 0, is it OK? */ }