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