Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: ebus.c,v 1.20 2002/01/05 01:13:43 davem Exp $ |
| 2 | * ebus.c: PCI to EBus bridge device. |
| 3 | * |
| 4 | * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) |
| 5 | * |
| 6 | * Adopted for sparc by V. Roganov and G. Raiko. |
| 7 | * Fixes for different platforms by Pete Zaitcev. |
| 8 | */ |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/kernel.h> |
| 11 | #include <linux/types.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/slab.h> |
| 14 | #include <linux/string.h> |
| 15 | |
| 16 | #include <asm/system.h> |
| 17 | #include <asm/page.h> |
| 18 | #include <asm/pbm.h> |
| 19 | #include <asm/ebus.h> |
| 20 | #include <asm/io.h> |
| 21 | #include <asm/oplib.h> |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 22 | #include <asm/prom.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <asm/bpp.h> |
| 24 | |
Al Viro | e4fe342f | 2005-12-04 18:48:45 -0500 | [diff] [blame] | 25 | struct linux_ebus *ebus_chain = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | /* We are together with pcic.c under CONFIG_PCI. */ |
| 28 | extern unsigned int pcic_pin_to_irq(unsigned int, char *name); |
| 29 | |
| 30 | /* |
| 31 | * IRQ Blacklist |
| 32 | * Here we list PROMs and systems that are known to supply crap as IRQ numbers. |
| 33 | */ |
| 34 | struct ebus_device_irq { |
| 35 | char *name; |
| 36 | unsigned int pin; |
| 37 | }; |
| 38 | |
| 39 | struct ebus_system_entry { |
| 40 | char *esname; |
| 41 | struct ebus_device_irq *ipt; |
| 42 | }; |
| 43 | |
| 44 | static struct ebus_device_irq je1_1[] = { |
| 45 | { "8042", 3 }, |
| 46 | { "SUNW,CS4231", 0 }, |
| 47 | { "parallel", 0 }, |
| 48 | { "se", 2 }, |
Al Viro | e4fe342f | 2005-12-04 18:48:45 -0500 | [diff] [blame] | 49 | { NULL, 0 } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | /* |
| 53 | * Gleb's JE1 supplied reasonable pin numbers, but mine did not (OBP 2.32). |
| 54 | * Blacklist the sucker... Note that Gleb's system will work. |
| 55 | */ |
| 56 | static struct ebus_system_entry ebus_blacklist[] = { |
| 57 | { "SUNW,JavaEngine1", je1_1 }, |
Al Viro | e4fe342f | 2005-12-04 18:48:45 -0500 | [diff] [blame] | 58 | { NULL, NULL } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | static struct ebus_device_irq *ebus_blackp = NULL; |
| 62 | |
| 63 | /* |
| 64 | */ |
| 65 | static inline unsigned long ebus_alloc(size_t size) |
| 66 | { |
| 67 | return (unsigned long)kmalloc(size, GFP_ATOMIC); |
| 68 | } |
| 69 | |
| 70 | /* |
| 71 | */ |
| 72 | int __init ebus_blacklist_irq(char *name) |
| 73 | { |
| 74 | struct ebus_device_irq *dp; |
| 75 | |
| 76 | if ((dp = ebus_blackp) != NULL) { |
| 77 | for (; dp->name != NULL; dp++) { |
| 78 | if (strcmp(name, dp->name) == 0) { |
| 79 | return pcic_pin_to_irq(dp->pin, name); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | return 0; |
| 84 | } |
| 85 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 86 | void __init fill_ebus_child(struct device_node *dp, |
| 87 | struct linux_ebus_child *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | { |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 89 | int *regs; |
| 90 | int *irqs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | int i, len; |
| 92 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 93 | dev->prom_node = dp; |
| 94 | regs = of_get_property(dp, "reg", &len); |
| 95 | if (!regs) |
| 96 | len = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | dev->num_addrs = len / sizeof(regs[0]); |
| 98 | |
| 99 | for (i = 0; i < dev->num_addrs; i++) { |
| 100 | if (regs[i] >= dev->parent->num_addrs) { |
| 101 | prom_printf("UGH: property for %s was %d, need < %d\n", |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 102 | dev->prom_node->name, len, |
| 103 | dev->parent->num_addrs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | panic(__FUNCTION__); |
| 105 | } |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 106 | |
| 107 | /* XXX resource */ |
| 108 | dev->resource[i].start = |
| 109 | dev->parent->resource[regs[i]].start; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | for (i = 0; i < PROMINTR_MAX; i++) |
| 113 | dev->irqs[i] = PCI_IRQ_NONE; |
| 114 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 115 | if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | dev->num_irqs = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | } else { |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 118 | irqs = of_get_property(dp, "interrupts", &len); |
| 119 | if (!irqs) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | dev->num_irqs = 0; |
| 121 | dev->irqs[0] = 0; |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 122 | if (dev->parent->num_irqs != 0) { |
| 123 | dev->num_irqs = 1; |
| 124 | dev->irqs[0] = dev->parent->irqs[0]; |
| 125 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | } else { |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 127 | dev->num_irqs = len / sizeof(irqs[0]); |
| 128 | if (irqs[0] == 0 || irqs[0] >= 8) { |
| 129 | /* |
| 130 | * XXX Zero is a valid pin number... |
| 131 | * This works as long as Ebus is not wired |
| 132 | * to INTA#. |
| 133 | */ |
| 134 | printk("EBUS: %s got bad irq %d from PROM\n", |
| 135 | dev->prom_node->name, irqs[0]); |
| 136 | dev->num_irqs = 0; |
| 137 | dev->irqs[0] = 0; |
| 138 | } else { |
| 139 | dev->irqs[0] = |
| 140 | pcic_pin_to_irq(irqs[0], |
| 141 | dev->prom_node->name); |
| 142 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 147 | void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | { |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 149 | struct linux_prom_registers *regs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | struct linux_ebus_child *child; |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 151 | int *irqs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | int i, n, len; |
| 153 | unsigned long baseaddr; |
| 154 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 155 | dev->prom_node = dp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 157 | regs = of_get_property(dp, "reg", &len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | if (len % sizeof(struct linux_prom_registers)) { |
| 159 | prom_printf("UGH: proplen for %s was %d, need multiple of %d\n", |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 160 | dev->prom_node->name, len, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | (int)sizeof(struct linux_prom_registers)); |
| 162 | panic(__FUNCTION__); |
| 163 | } |
| 164 | dev->num_addrs = len / sizeof(struct linux_prom_registers); |
| 165 | |
| 166 | for (i = 0; i < dev->num_addrs; i++) { |
| 167 | /* |
| 168 | * XXX Collect JE-1 PROM |
| 169 | * |
| 170 | * Example - JS-E with 3.11: |
| 171 | * /ebus |
| 172 | * regs |
| 173 | * 0x00000000, 0x0, 0x00000000, 0x0, 0x00000000, |
| 174 | * 0x82000010, 0x0, 0xf0000000, 0x0, 0x01000000, |
| 175 | * 0x82000014, 0x0, 0x38800000, 0x0, 0x00800000, |
| 176 | * ranges |
| 177 | * 0x00, 0x00000000, 0x02000010, 0x0, 0x0, 0x01000000, |
| 178 | * 0x01, 0x01000000, 0x02000014, 0x0, 0x0, 0x00800000, |
| 179 | * /ebus/8042 |
| 180 | * regs |
| 181 | * 0x00000001, 0x00300060, 0x00000008, |
| 182 | * 0x00000001, 0x00300060, 0x00000008, |
| 183 | */ |
| 184 | n = regs[i].which_io; |
| 185 | if (n >= 4) { |
| 186 | /* XXX This is copied from old JE-1 by Gleb. */ |
| 187 | n = (regs[i].which_io - 0x10) >> 2; |
| 188 | } else { |
| 189 | ; |
| 190 | } |
| 191 | |
| 192 | /* |
| 193 | * XXX Now as we have regions, why don't we make an on-demand allocation... |
| 194 | */ |
| 195 | dev->resource[i].start = 0; |
| 196 | if ((baseaddr = dev->bus->self->resource[n].start + |
| 197 | regs[i].phys_addr) != 0) { |
| 198 | /* dev->resource[i].name = dev->prom_name; */ |
| 199 | if ((baseaddr = (unsigned long) ioremap(baseaddr, |
| 200 | regs[i].reg_size)) == 0) { |
| 201 | panic("ebus: unable to remap dev %s", |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 202 | dev->prom_node->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | dev->resource[i].start = baseaddr; /* XXX Unaligned */ |
| 206 | } |
| 207 | |
| 208 | for (i = 0; i < PROMINTR_MAX; i++) |
| 209 | dev->irqs[i] = PCI_IRQ_NONE; |
| 210 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 211 | if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | dev->num_irqs = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | } else { |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 214 | irqs = of_get_property(dp, "interrupts", &len); |
| 215 | if (!irqs) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | dev->num_irqs = 0; |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 217 | if ((dev->irqs[0] = dev->bus->self->irq) != 0) { |
| 218 | dev->num_irqs = 1; |
| 219 | /* P3 */ /* printk("EBUS: child %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */ |
| 220 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | } else { |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 222 | dev->num_irqs = 1; /* dev->num_irqs = len / sizeof(irqs[0]); */ |
| 223 | if (irqs[0] == 0 || irqs[0] >= 8) { |
| 224 | /* See above for the parent. XXX */ |
| 225 | printk("EBUS: %s got bad irq %d from PROM\n", |
| 226 | dev->prom_node->name, irqs[0]); |
| 227 | dev->num_irqs = 0; |
| 228 | dev->irqs[0] = 0; |
| 229 | } else { |
| 230 | dev->irqs[0] = |
| 231 | pcic_pin_to_irq(irqs[0], |
| 232 | dev->prom_node->name); |
| 233 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | } |
| 235 | } |
| 236 | |
David S. Miller | fd53143 | 2006-06-23 15:55:17 -0700 | [diff] [blame] | 237 | dev->ofdev.node = dp; |
| 238 | dev->ofdev.dev.parent = &dev->bus->ofdev.dev; |
| 239 | dev->ofdev.dev.bus = &ebus_bus_type; |
| 240 | strcpy(dev->ofdev.dev.bus_id, dp->path_component_name); |
| 241 | |
| 242 | /* Register with core */ |
| 243 | if (of_device_register(&dev->ofdev) != 0) |
| 244 | printk(KERN_DEBUG "ebus: device registration error for %s!\n", |
| 245 | dev->ofdev.dev.bus_id); |
| 246 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 247 | if ((dp = dp->child) != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | dev->children = (struct linux_ebus_child *) |
| 249 | ebus_alloc(sizeof(struct linux_ebus_child)); |
| 250 | |
| 251 | child = dev->children; |
Al Viro | e4fe342f | 2005-12-04 18:48:45 -0500 | [diff] [blame] | 252 | child->next = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | child->parent = dev; |
| 254 | child->bus = dev->bus; |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 255 | fill_ebus_child(dp, child); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 257 | while ((dp = dp->sibling) != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | child->next = (struct linux_ebus_child *) |
| 259 | ebus_alloc(sizeof(struct linux_ebus_child)); |
| 260 | |
| 261 | child = child->next; |
Al Viro | e4fe342f | 2005-12-04 18:48:45 -0500 | [diff] [blame] | 262 | child->next = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | child->parent = dev; |
| 264 | child->bus = dev->bus; |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 265 | fill_ebus_child(dp, child); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | void __init ebus_init(void) |
| 271 | { |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 272 | struct linux_prom_pci_registers *regs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | struct linux_pbm_info *pbm; |
| 274 | struct linux_ebus_device *dev; |
| 275 | struct linux_ebus *ebus; |
| 276 | struct ebus_system_entry *sp; |
| 277 | struct pci_dev *pdev; |
| 278 | struct pcidev_cookie *cookie; |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 279 | struct device_node *dp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | unsigned long addr, *base; |
| 281 | unsigned short pci_command; |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 282 | int len, reg, nreg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | int num_ebus = 0; |
| 284 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 285 | dp = of_find_node_by_path("/"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | for (sp = ebus_blacklist; sp->esname != NULL; sp++) { |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 287 | if (strcmp(dp->name, sp->esname) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | ebus_blackp = sp->ipt; |
| 289 | break; |
| 290 | } |
| 291 | } |
| 292 | |
Al Viro | e4fe342f | 2005-12-04 18:48:45 -0500 | [diff] [blame] | 293 | pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, NULL); |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 294 | if (!pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | return; |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 296 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | cookie = pdev->sysdata; |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 298 | dp = cookie->prom_node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | |
| 300 | ebus_chain = ebus = (struct linux_ebus *) |
| 301 | ebus_alloc(sizeof(struct linux_ebus)); |
Al Viro | e4fe342f | 2005-12-04 18:48:45 -0500 | [diff] [blame] | 302 | ebus->next = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 304 | while (dp) { |
| 305 | struct device_node *nd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 307 | ebus->prom_node = dp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | ebus->self = pdev; |
| 309 | ebus->parent = pbm = cookie->pbm; |
| 310 | |
| 311 | /* Enable BUS Master. */ |
| 312 | pci_read_config_word(pdev, PCI_COMMAND, &pci_command); |
| 313 | pci_command |= PCI_COMMAND_MASTER; |
| 314 | pci_write_config_word(pdev, PCI_COMMAND, pci_command); |
| 315 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 316 | regs = of_get_property(dp, "reg", &len); |
| 317 | if (!regs) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | prom_printf("%s: can't find reg property\n", |
| 319 | __FUNCTION__); |
| 320 | prom_halt(); |
| 321 | } |
| 322 | nreg = len / sizeof(struct linux_prom_pci_registers); |
| 323 | |
| 324 | base = &ebus->self->resource[0].start; |
| 325 | for (reg = 0; reg < nreg; reg++) { |
| 326 | if (!(regs[reg].which_io & 0x03000000)) |
| 327 | continue; |
| 328 | |
| 329 | addr = regs[reg].phys_lo; |
| 330 | *base++ = addr; |
| 331 | } |
| 332 | |
David S. Miller | fd53143 | 2006-06-23 15:55:17 -0700 | [diff] [blame] | 333 | ebus->ofdev.node = dp; |
| 334 | ebus->ofdev.dev.parent = &pdev->dev; |
| 335 | ebus->ofdev.dev.bus = &ebus_bus_type; |
| 336 | strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name); |
| 337 | |
| 338 | /* Register with core */ |
| 339 | if (of_device_register(&ebus->ofdev) != 0) |
| 340 | printk(KERN_DEBUG "ebus: device registration error for %s!\n", |
| 341 | ebus->ofdev.dev.bus_id); |
| 342 | |
| 343 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 344 | nd = dp->child; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | if (!nd) |
| 346 | goto next_ebus; |
| 347 | |
| 348 | ebus->devices = (struct linux_ebus_device *) |
| 349 | ebus_alloc(sizeof(struct linux_ebus_device)); |
| 350 | |
| 351 | dev = ebus->devices; |
Al Viro | e4fe342f | 2005-12-04 18:48:45 -0500 | [diff] [blame] | 352 | dev->next = NULL; |
| 353 | dev->children = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | dev->bus = ebus; |
| 355 | fill_ebus_device(nd, dev); |
| 356 | |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 357 | while ((nd = nd->sibling) != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | dev->next = (struct linux_ebus_device *) |
| 359 | ebus_alloc(sizeof(struct linux_ebus_device)); |
| 360 | |
| 361 | dev = dev->next; |
Al Viro | e4fe342f | 2005-12-04 18:48:45 -0500 | [diff] [blame] | 362 | dev->next = NULL; |
| 363 | dev->children = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | dev->bus = ebus; |
| 365 | fill_ebus_device(nd, dev); |
| 366 | } |
| 367 | |
| 368 | next_ebus: |
| 369 | pdev = pci_get_device(PCI_VENDOR_ID_SUN, |
| 370 | PCI_DEVICE_ID_SUN_EBUS, pdev); |
| 371 | if (!pdev) |
| 372 | break; |
| 373 | |
| 374 | cookie = pdev->sysdata; |
David S. Miller | 942a6bd | 2006-06-23 15:53:31 -0700 | [diff] [blame] | 375 | dp = cookie->prom_node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | |
| 377 | ebus->next = (struct linux_ebus *) |
| 378 | ebus_alloc(sizeof(struct linux_ebus)); |
| 379 | ebus = ebus->next; |
Al Viro | e4fe342f | 2005-12-04 18:48:45 -0500 | [diff] [blame] | 380 | ebus->next = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | ++num_ebus; |
| 382 | } |
| 383 | if (pdev) |
| 384 | pci_dev_put(pdev); |
| 385 | } |