ebus.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /* $Id: ebus.c,v 1.64 2001/11/08 04:41:33 davem Exp $
  2. * ebus.c: PCI to EBus bridge device.
  3. *
  4. * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
  5. * Copyright (C) 1999 David S. Miller (davem@redhat.com)
  6. */
  7. #include <linux/config.h>
  8. #include <linux/module.h>
  9. #include <linux/kernel.h>
  10. #include <linux/types.h>
  11. #include <linux/init.h>
  12. #include <linux/slab.h>
  13. #include <linux/string.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/delay.h>
  16. #include <asm/system.h>
  17. #include <asm/page.h>
  18. #include <asm/pbm.h>
  19. #include <asm/ebus.h>
  20. #include <asm/oplib.h>
  21. #include <asm/bpp.h>
  22. #include <asm/irq.h>
  23. /* EBUS dma library. */
  24. #define EBDMA_CSR 0x00UL /* Control/Status */
  25. #define EBDMA_ADDR 0x04UL /* DMA Address */
  26. #define EBDMA_COUNT 0x08UL /* DMA Count */
  27. #define EBDMA_CSR_INT_PEND 0x00000001
  28. #define EBDMA_CSR_ERR_PEND 0x00000002
  29. #define EBDMA_CSR_DRAIN 0x00000004
  30. #define EBDMA_CSR_INT_EN 0x00000010
  31. #define EBDMA_CSR_RESET 0x00000080
  32. #define EBDMA_CSR_WRITE 0x00000100
  33. #define EBDMA_CSR_EN_DMA 0x00000200
  34. #define EBDMA_CSR_CYC_PEND 0x00000400
  35. #define EBDMA_CSR_DIAG_RD_DONE 0x00000800
  36. #define EBDMA_CSR_DIAG_WR_DONE 0x00001000
  37. #define EBDMA_CSR_EN_CNT 0x00002000
  38. #define EBDMA_CSR_TC 0x00004000
  39. #define EBDMA_CSR_DIS_CSR_DRN 0x00010000
  40. #define EBDMA_CSR_BURST_SZ_MASK 0x000c0000
  41. #define EBDMA_CSR_BURST_SZ_1 0x00080000
  42. #define EBDMA_CSR_BURST_SZ_4 0x00000000
  43. #define EBDMA_CSR_BURST_SZ_8 0x00040000
  44. #define EBDMA_CSR_BURST_SZ_16 0x000c0000
  45. #define EBDMA_CSR_DIAG_EN 0x00100000
  46. #define EBDMA_CSR_DIS_ERR_PEND 0x00400000
  47. #define EBDMA_CSR_TCI_DIS 0x00800000
  48. #define EBDMA_CSR_EN_NEXT 0x01000000
  49. #define EBDMA_CSR_DMA_ON 0x02000000
  50. #define EBDMA_CSR_A_LOADED 0x04000000
  51. #define EBDMA_CSR_NA_LOADED 0x08000000
  52. #define EBDMA_CSR_DEV_ID_MASK 0xf0000000
  53. #define EBUS_DMA_RESET_TIMEOUT 10000
  54. static void __ebus_dma_reset(struct ebus_dma_info *p, int no_drain)
  55. {
  56. int i;
  57. u32 val = 0;
  58. writel(EBDMA_CSR_RESET, p->regs + EBDMA_CSR);
  59. udelay(1);
  60. if (no_drain)
  61. return;
  62. for (i = EBUS_DMA_RESET_TIMEOUT; i > 0; i--) {
  63. val = readl(p->regs + EBDMA_CSR);
  64. if (!(val & (EBDMA_CSR_DRAIN | EBDMA_CSR_CYC_PEND)))
  65. break;
  66. udelay(10);
  67. }
  68. }
  69. static irqreturn_t ebus_dma_irq(int irq, void *dev_id, struct pt_regs *regs)
  70. {
  71. struct ebus_dma_info *p = dev_id;
  72. unsigned long flags;
  73. u32 csr = 0;
  74. spin_lock_irqsave(&p->lock, flags);
  75. csr = readl(p->regs + EBDMA_CSR);
  76. writel(csr, p->regs + EBDMA_CSR);
  77. spin_unlock_irqrestore(&p->lock, flags);
  78. if (csr & EBDMA_CSR_ERR_PEND) {
  79. printk(KERN_CRIT "ebus_dma(%s): DMA error!\n", p->name);
  80. p->callback(p, EBUS_DMA_EVENT_ERROR, p->client_cookie);
  81. return IRQ_HANDLED;
  82. } else if (csr & EBDMA_CSR_INT_PEND) {
  83. p->callback(p,
  84. (csr & EBDMA_CSR_TC) ?
  85. EBUS_DMA_EVENT_DMA : EBUS_DMA_EVENT_DEVICE,
  86. p->client_cookie);
  87. return IRQ_HANDLED;
  88. }
  89. return IRQ_NONE;
  90. }
  91. int ebus_dma_register(struct ebus_dma_info *p)
  92. {
  93. u32 csr;
  94. if (!p->regs)
  95. return -EINVAL;
  96. if (p->flags & ~(EBUS_DMA_FLAG_USE_EBDMA_HANDLER |
  97. EBUS_DMA_FLAG_TCI_DISABLE))
  98. return -EINVAL;
  99. if ((p->flags & EBUS_DMA_FLAG_USE_EBDMA_HANDLER) && !p->callback)
  100. return -EINVAL;
  101. if (!strlen(p->name))
  102. return -EINVAL;
  103. __ebus_dma_reset(p, 1);
  104. csr = EBDMA_CSR_BURST_SZ_16 | EBDMA_CSR_EN_CNT;
  105. if (p->flags & EBUS_DMA_FLAG_TCI_DISABLE)
  106. csr |= EBDMA_CSR_TCI_DIS;
  107. writel(csr, p->regs + EBDMA_CSR);
  108. return 0;
  109. }
  110. EXPORT_SYMBOL(ebus_dma_register);
  111. int ebus_dma_irq_enable(struct ebus_dma_info *p, int on)
  112. {
  113. unsigned long flags;
  114. u32 csr;
  115. if (on) {
  116. if (p->flags & EBUS_DMA_FLAG_USE_EBDMA_HANDLER) {
  117. if (request_irq(p->irq, ebus_dma_irq, SA_SHIRQ, p->name, p))
  118. return -EBUSY;
  119. }
  120. spin_lock_irqsave(&p->lock, flags);
  121. csr = readl(p->regs + EBDMA_CSR);
  122. csr |= EBDMA_CSR_INT_EN;
  123. writel(csr, p->regs + EBDMA_CSR);
  124. spin_unlock_irqrestore(&p->lock, flags);
  125. } else {
  126. spin_lock_irqsave(&p->lock, flags);
  127. csr = readl(p->regs + EBDMA_CSR);
  128. csr &= ~EBDMA_CSR_INT_EN;
  129. writel(csr, p->regs + EBDMA_CSR);
  130. spin_unlock_irqrestore(&p->lock, flags);
  131. if (p->flags & EBUS_DMA_FLAG_USE_EBDMA_HANDLER) {
  132. free_irq(p->irq, p);
  133. }
  134. }
  135. return 0;
  136. }
  137. EXPORT_SYMBOL(ebus_dma_irq_enable);
  138. void ebus_dma_unregister(struct ebus_dma_info *p)
  139. {
  140. unsigned long flags;
  141. u32 csr;
  142. int irq_on = 0;
  143. spin_lock_irqsave(&p->lock, flags);
  144. csr = readl(p->regs + EBDMA_CSR);
  145. if (csr & EBDMA_CSR_INT_EN) {
  146. csr &= ~EBDMA_CSR_INT_EN;
  147. writel(csr, p->regs + EBDMA_CSR);
  148. irq_on = 1;
  149. }
  150. spin_unlock_irqrestore(&p->lock, flags);
  151. if (irq_on)
  152. free_irq(p->irq, p);
  153. }
  154. EXPORT_SYMBOL(ebus_dma_unregister);
  155. int ebus_dma_request(struct ebus_dma_info *p, dma_addr_t bus_addr, size_t len)
  156. {
  157. unsigned long flags;
  158. u32 csr;
  159. int err;
  160. if (len >= (1 << 24))
  161. return -EINVAL;
  162. spin_lock_irqsave(&p->lock, flags);
  163. csr = readl(p->regs + EBDMA_CSR);
  164. err = -EINVAL;
  165. if (!(csr & EBDMA_CSR_EN_DMA))
  166. goto out;
  167. err = -EBUSY;
  168. if (csr & EBDMA_CSR_NA_LOADED)
  169. goto out;
  170. writel(len, p->regs + EBDMA_COUNT);
  171. writel(bus_addr, p->regs + EBDMA_ADDR);
  172. err = 0;
  173. out:
  174. spin_unlock_irqrestore(&p->lock, flags);
  175. return err;
  176. }
  177. EXPORT_SYMBOL(ebus_dma_request);
  178. void ebus_dma_prepare(struct ebus_dma_info *p, int write)
  179. {
  180. unsigned long flags;
  181. u32 csr;
  182. spin_lock_irqsave(&p->lock, flags);
  183. __ebus_dma_reset(p, 0);
  184. csr = (EBDMA_CSR_INT_EN |
  185. EBDMA_CSR_EN_CNT |
  186. EBDMA_CSR_BURST_SZ_16 |
  187. EBDMA_CSR_EN_NEXT);
  188. if (write)
  189. csr |= EBDMA_CSR_WRITE;
  190. if (p->flags & EBUS_DMA_FLAG_TCI_DISABLE)
  191. csr |= EBDMA_CSR_TCI_DIS;
  192. writel(csr, p->regs + EBDMA_CSR);
  193. spin_unlock_irqrestore(&p->lock, flags);
  194. }
  195. EXPORT_SYMBOL(ebus_dma_prepare);
  196. unsigned int ebus_dma_residue(struct ebus_dma_info *p)
  197. {
  198. return readl(p->regs + EBDMA_COUNT);
  199. }
  200. EXPORT_SYMBOL(ebus_dma_residue);
  201. unsigned int ebus_dma_addr(struct ebus_dma_info *p)
  202. {
  203. return readl(p->regs + EBDMA_ADDR);
  204. }
  205. EXPORT_SYMBOL(ebus_dma_addr);
  206. void ebus_dma_enable(struct ebus_dma_info *p, int on)
  207. {
  208. unsigned long flags;
  209. u32 orig_csr, csr;
  210. spin_lock_irqsave(&p->lock, flags);
  211. orig_csr = csr = readl(p->regs + EBDMA_CSR);
  212. if (on)
  213. csr |= EBDMA_CSR_EN_DMA;
  214. else
  215. csr &= ~EBDMA_CSR_EN_DMA;
  216. if ((orig_csr & EBDMA_CSR_EN_DMA) !=
  217. (csr & EBDMA_CSR_EN_DMA))
  218. writel(csr, p->regs + EBDMA_CSR);
  219. spin_unlock_irqrestore(&p->lock, flags);
  220. }
  221. EXPORT_SYMBOL(ebus_dma_enable);
  222. struct linux_ebus *ebus_chain = NULL;
  223. #ifdef CONFIG_SUN_AUXIO
  224. extern void auxio_probe(void);
  225. #endif
  226. static inline void *ebus_alloc(size_t size)
  227. {
  228. void *mem;
  229. mem = kzalloc(size, GFP_ATOMIC);
  230. if (!mem)
  231. panic("ebus_alloc: out of memory");
  232. return mem;
  233. }
  234. static void __init ebus_ranges_init(struct linux_ebus *ebus)
  235. {
  236. int success;
  237. ebus->num_ebus_ranges = 0;
  238. success = prom_getproperty(ebus->prom_node, "ranges",
  239. (char *)ebus->ebus_ranges,
  240. sizeof(ebus->ebus_ranges));
  241. if (success != -1)
  242. ebus->num_ebus_ranges = (success/sizeof(struct linux_prom_ebus_ranges));
  243. }
  244. static void __init ebus_intmap_init(struct linux_ebus *ebus)
  245. {
  246. int success;
  247. ebus->num_ebus_intmap = 0;
  248. success = prom_getproperty(ebus->prom_node, "interrupt-map",
  249. (char *)ebus->ebus_intmap,
  250. sizeof(ebus->ebus_intmap));
  251. if (success == -1)
  252. return;
  253. ebus->num_ebus_intmap = (success/sizeof(struct linux_prom_ebus_intmap));
  254. success = prom_getproperty(ebus->prom_node, "interrupt-map-mask",
  255. (char *)&ebus->ebus_intmask,
  256. sizeof(ebus->ebus_intmask));
  257. if (success == -1) {
  258. prom_printf("%s: can't get interrupt-map-mask\n", __FUNCTION__);
  259. prom_halt();
  260. }
  261. }
  262. int __init ebus_intmap_match(struct linux_ebus *ebus,
  263. struct linux_prom_registers *reg,
  264. int *interrupt)
  265. {
  266. unsigned int hi, lo, irq;
  267. int i;
  268. if (!ebus->num_ebus_intmap)
  269. return 0;
  270. hi = reg->which_io & ebus->ebus_intmask.phys_hi;
  271. lo = reg->phys_addr & ebus->ebus_intmask.phys_lo;
  272. irq = *interrupt & ebus->ebus_intmask.interrupt;
  273. for (i = 0; i < ebus->num_ebus_intmap; i++) {
  274. if ((ebus->ebus_intmap[i].phys_hi == hi) &&
  275. (ebus->ebus_intmap[i].phys_lo == lo) &&
  276. (ebus->ebus_intmap[i].interrupt == irq)) {
  277. *interrupt = ebus->ebus_intmap[i].cinterrupt;
  278. return 0;
  279. }
  280. }
  281. return -1;
  282. }
  283. void __init fill_ebus_child(int node, struct linux_prom_registers *preg,
  284. struct linux_ebus_child *dev, int non_standard_regs)
  285. {
  286. int regs[PROMREG_MAX];
  287. int irqs[PROMREG_MAX];
  288. int i, len;
  289. dev->prom_node = node;
  290. prom_getstring(node, "name", dev->prom_name, sizeof(dev->prom_name));
  291. printk(" (%s)", dev->prom_name);
  292. len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs));
  293. dev->num_addrs = len / sizeof(regs[0]);
  294. if (non_standard_regs) {
  295. /* This is to handle reg properties which are not
  296. * in the parent relative format. One example are
  297. * children of the i2c device on CompactPCI systems.
  298. *
  299. * So, for such devices we just record the property
  300. * raw in the child resources.
  301. */
  302. for (i = 0; i < dev->num_addrs; i++)
  303. dev->resource[i].start = regs[i];
  304. } else {
  305. for (i = 0; i < dev->num_addrs; i++) {
  306. int rnum = regs[i];
  307. if (rnum >= dev->parent->num_addrs) {
  308. prom_printf("UGH: property for %s was %d, need < %d\n",
  309. dev->prom_name, len, dev->parent->num_addrs);
  310. panic(__FUNCTION__);
  311. }
  312. dev->resource[i].start = dev->parent->resource[i].start;
  313. dev->resource[i].end = dev->parent->resource[i].end;
  314. dev->resource[i].flags = IORESOURCE_MEM;
  315. dev->resource[i].name = dev->prom_name;
  316. }
  317. }
  318. for (i = 0; i < PROMINTR_MAX; i++)
  319. dev->irqs[i] = PCI_IRQ_NONE;
  320. len = prom_getproperty(node, "interrupts", (char *)&irqs, sizeof(irqs));
  321. if ((len == -1) || (len == 0)) {
  322. dev->num_irqs = 0;
  323. /*
  324. * Oh, well, some PROMs don't export interrupts
  325. * property to children of EBus devices...
  326. *
  327. * Be smart about PS/2 keyboard and mouse.
  328. */
  329. if (!strcmp(dev->parent->prom_name, "8042")) {
  330. if (!strcmp(dev->prom_name, "kb_ps2")) {
  331. dev->num_irqs = 1;
  332. dev->irqs[0] = dev->parent->irqs[0];
  333. } else {
  334. dev->num_irqs = 1;
  335. dev->irqs[0] = dev->parent->irqs[1];
  336. }
  337. }
  338. } else {
  339. dev->num_irqs = len / sizeof(irqs[0]);
  340. for (i = 0; i < dev->num_irqs; i++) {
  341. struct pci_pbm_info *pbm = dev->bus->parent;
  342. struct pci_controller_info *p = pbm->parent;
  343. if (ebus_intmap_match(dev->bus, preg, &irqs[i]) != -1) {
  344. dev->irqs[i] = p->irq_build(pbm,
  345. dev->bus->self,
  346. irqs[i]);
  347. } else {
  348. /* If we get a bogus interrupt property, just
  349. * record the raw value instead of punting.
  350. */
  351. dev->irqs[i] = irqs[i];
  352. }
  353. }
  354. }
  355. }
  356. static int __init child_regs_nonstandard(struct linux_ebus_device *dev)
  357. {
  358. if (!strcmp(dev->prom_name, "i2c") ||
  359. !strcmp(dev->prom_name, "SUNW,lombus"))
  360. return 1;
  361. return 0;
  362. }
  363. void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
  364. {
  365. struct linux_prom_registers regs[PROMREG_MAX];
  366. struct linux_ebus_child *child;
  367. int irqs[PROMINTR_MAX];
  368. int i, n, len;
  369. dev->prom_node = node;
  370. prom_getstring(node, "name", dev->prom_name, sizeof(dev->prom_name));
  371. printk(" [%s", dev->prom_name);
  372. len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs));
  373. if (len == -1) {
  374. dev->num_addrs = 0;
  375. goto probe_interrupts;
  376. }
  377. if (len % sizeof(struct linux_prom_registers)) {
  378. prom_printf("UGH: proplen for %s was %d, need multiple of %d\n",
  379. dev->prom_name, len,
  380. (int)sizeof(struct linux_prom_registers));
  381. prom_halt();
  382. }
  383. dev->num_addrs = len / sizeof(struct linux_prom_registers);
  384. for (i = 0; i < dev->num_addrs; i++) {
  385. /* XXX Learn how to interpret ebus ranges... -DaveM */
  386. if (regs[i].which_io >= 0x10)
  387. n = (regs[i].which_io - 0x10) >> 2;
  388. else
  389. n = regs[i].which_io;
  390. dev->resource[i].start = dev->bus->self->resource[n].start;
  391. dev->resource[i].start += (unsigned long)regs[i].phys_addr;
  392. dev->resource[i].end =
  393. (dev->resource[i].start + (unsigned long)regs[i].reg_size - 1UL);
  394. dev->resource[i].flags = IORESOURCE_MEM;
  395. dev->resource[i].name = dev->prom_name;
  396. request_resource(&dev->bus->self->resource[n],
  397. &dev->resource[i]);
  398. }
  399. probe_interrupts:
  400. for (i = 0; i < PROMINTR_MAX; i++)
  401. dev->irqs[i] = PCI_IRQ_NONE;
  402. len = prom_getproperty(node, "interrupts", (char *)&irqs, sizeof(irqs));
  403. if ((len == -1) || (len == 0)) {
  404. dev->num_irqs = 0;
  405. } else {
  406. dev->num_irqs = len / sizeof(irqs[0]);
  407. for (i = 0; i < dev->num_irqs; i++) {
  408. struct pci_pbm_info *pbm = dev->bus->parent;
  409. struct pci_controller_info *p = pbm->parent;
  410. if (ebus_intmap_match(dev->bus, &regs[0], &irqs[i]) != -1) {
  411. dev->irqs[i] = p->irq_build(pbm,
  412. dev->bus->self,
  413. irqs[i]);
  414. } else {
  415. /* If we get a bogus interrupt property, just
  416. * record the raw value instead of punting.
  417. */
  418. dev->irqs[i] = irqs[i];
  419. }
  420. }
  421. }
  422. if ((node = prom_getchild(node))) {
  423. printk(" ->");
  424. dev->children = ebus_alloc(sizeof(struct linux_ebus_child));
  425. child = dev->children;
  426. child->next = NULL;
  427. child->parent = dev;
  428. child->bus = dev->bus;
  429. fill_ebus_child(node, &regs[0],
  430. child, child_regs_nonstandard(dev));
  431. while ((node = prom_getsibling(node)) != 0) {
  432. child->next = ebus_alloc(sizeof(struct linux_ebus_child));
  433. child = child->next;
  434. child->next = NULL;
  435. child->parent = dev;
  436. child->bus = dev->bus;
  437. fill_ebus_child(node, &regs[0],
  438. child, child_regs_nonstandard(dev));
  439. }
  440. }
  441. printk("]");
  442. }
  443. static struct pci_dev *find_next_ebus(struct pci_dev *start, int *is_rio_p)
  444. {
  445. struct pci_dev *pdev = start;
  446. while ((pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_ANY_ID, pdev)))
  447. if (pdev->device == PCI_DEVICE_ID_SUN_EBUS ||
  448. pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS)
  449. break;
  450. *is_rio_p = !!(pdev && (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS));
  451. return pdev;
  452. }
  453. void __init ebus_init(void)
  454. {
  455. struct pci_pbm_info *pbm;
  456. struct linux_ebus_device *dev;
  457. struct linux_ebus *ebus;
  458. struct pci_dev *pdev;
  459. struct pcidev_cookie *cookie;
  460. int nd, ebusnd, is_rio;
  461. int num_ebus = 0;
  462. pdev = find_next_ebus(NULL, &is_rio);
  463. if (!pdev) {
  464. printk("ebus: No EBus's found.\n");
  465. return;
  466. }
  467. cookie = pdev->sysdata;
  468. ebusnd = cookie->prom_node;
  469. ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus));
  470. ebus->next = NULL;
  471. ebus->is_rio = is_rio;
  472. while (ebusnd) {
  473. /* SUNW,pci-qfe uses four empty ebuses on it.
  474. I think we should not consider them here,
  475. as they have half of the properties this
  476. code expects and once we do PCI hot-plug,
  477. we'd have to tweak with the ebus_chain
  478. in the runtime after initialization. -jj */
  479. if (!prom_getchild (ebusnd)) {
  480. pdev = find_next_ebus(pdev, &is_rio);
  481. if (!pdev) {
  482. if (ebus == ebus_chain) {
  483. ebus_chain = NULL;
  484. printk("ebus: No EBus's found.\n");
  485. return;
  486. }
  487. break;
  488. }
  489. ebus->is_rio = is_rio;
  490. cookie = pdev->sysdata;
  491. ebusnd = cookie->prom_node;
  492. continue;
  493. }
  494. printk("ebus%d:", num_ebus);
  495. prom_getstring(ebusnd, "name", ebus->prom_name, sizeof(ebus->prom_name));
  496. ebus->index = num_ebus;
  497. ebus->prom_node = ebusnd;
  498. ebus->self = pdev;
  499. ebus->parent = pbm = cookie->pbm;
  500. ebus_ranges_init(ebus);
  501. ebus_intmap_init(ebus);
  502. nd = prom_getchild(ebusnd);
  503. if (!nd)
  504. goto next_ebus;
  505. ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device));
  506. dev = ebus->devices;
  507. dev->next = NULL;
  508. dev->children = NULL;
  509. dev->bus = ebus;
  510. fill_ebus_device(nd, dev);
  511. while ((nd = prom_getsibling(nd)) != 0) {
  512. dev->next = ebus_alloc(sizeof(struct linux_ebus_device));
  513. dev = dev->next;
  514. dev->next = NULL;
  515. dev->children = NULL;
  516. dev->bus = ebus;
  517. fill_ebus_device(nd, dev);
  518. }
  519. next_ebus:
  520. printk("\n");
  521. pdev = find_next_ebus(pdev, &is_rio);
  522. if (!pdev)
  523. break;
  524. cookie = pdev->sysdata;
  525. ebusnd = cookie->prom_node;
  526. ebus->next = ebus_alloc(sizeof(struct linux_ebus));
  527. ebus = ebus->next;
  528. ebus->next = NULL;
  529. ebus->is_rio = is_rio;
  530. ++num_ebus;
  531. }
  532. pci_dev_put(pdev); /* XXX for the case, when ebusnd is 0, is it OK? */
  533. #ifdef CONFIG_SUN_AUXIO
  534. auxio_probe();
  535. #endif
  536. }