ebus.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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 = kmalloc(size, GFP_ATOMIC);
  230. if (!mem)
  231. panic("ebus_alloc: out of memory");
  232. memset((char *)mem, 0, size);
  233. return mem;
  234. }
  235. static void __init ebus_ranges_init(struct linux_ebus *ebus)
  236. {
  237. int success;
  238. ebus->num_ebus_ranges = 0;
  239. success = prom_getproperty(ebus->prom_node, "ranges",
  240. (char *)ebus->ebus_ranges,
  241. sizeof(ebus->ebus_ranges));
  242. if (success != -1)
  243. ebus->num_ebus_ranges = (success/sizeof(struct linux_prom_ebus_ranges));
  244. }
  245. static void __init ebus_intmap_init(struct linux_ebus *ebus)
  246. {
  247. int success;
  248. ebus->num_ebus_intmap = 0;
  249. success = prom_getproperty(ebus->prom_node, "interrupt-map",
  250. (char *)ebus->ebus_intmap,
  251. sizeof(ebus->ebus_intmap));
  252. if (success == -1)
  253. return;
  254. ebus->num_ebus_intmap = (success/sizeof(struct linux_prom_ebus_intmap));
  255. success = prom_getproperty(ebus->prom_node, "interrupt-map-mask",
  256. (char *)&ebus->ebus_intmask,
  257. sizeof(ebus->ebus_intmask));
  258. if (success == -1) {
  259. prom_printf("%s: can't get interrupt-map-mask\n", __FUNCTION__);
  260. prom_halt();
  261. }
  262. }
  263. int __init ebus_intmap_match(struct linux_ebus *ebus,
  264. struct linux_prom_registers *reg,
  265. int *interrupt)
  266. {
  267. unsigned int hi, lo, irq;
  268. int i;
  269. if (!ebus->num_ebus_intmap)
  270. return 0;
  271. hi = reg->which_io & ebus->ebus_intmask.phys_hi;
  272. lo = reg->phys_addr & ebus->ebus_intmask.phys_lo;
  273. irq = *interrupt & ebus->ebus_intmask.interrupt;
  274. for (i = 0; i < ebus->num_ebus_intmap; i++) {
  275. if ((ebus->ebus_intmap[i].phys_hi == hi) &&
  276. (ebus->ebus_intmap[i].phys_lo == lo) &&
  277. (ebus->ebus_intmap[i].interrupt == irq)) {
  278. *interrupt = ebus->ebus_intmap[i].cinterrupt;
  279. return 0;
  280. }
  281. }
  282. return -1;
  283. }
  284. void __init fill_ebus_child(int node, struct linux_prom_registers *preg,
  285. struct linux_ebus_child *dev, int non_standard_regs)
  286. {
  287. int regs[PROMREG_MAX];
  288. int irqs[PROMREG_MAX];
  289. int i, len;
  290. dev->prom_node = node;
  291. prom_getstring(node, "name", dev->prom_name, sizeof(dev->prom_name));
  292. printk(" (%s)", dev->prom_name);
  293. len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs));
  294. dev->num_addrs = len / sizeof(regs[0]);
  295. if (non_standard_regs) {
  296. /* This is to handle reg properties which are not
  297. * in the parent relative format. One example are
  298. * children of the i2c device on CompactPCI systems.
  299. *
  300. * So, for such devices we just record the property
  301. * raw in the child resources.
  302. */
  303. for (i = 0; i < dev->num_addrs; i++)
  304. dev->resource[i].start = regs[i];
  305. } else {
  306. for (i = 0; i < dev->num_addrs; i++) {
  307. int rnum = regs[i];
  308. if (rnum >= dev->parent->num_addrs) {
  309. prom_printf("UGH: property for %s was %d, need < %d\n",
  310. dev->prom_name, len, dev->parent->num_addrs);
  311. panic(__FUNCTION__);
  312. }
  313. dev->resource[i].start = dev->parent->resource[i].start;
  314. dev->resource[i].end = dev->parent->resource[i].end;
  315. dev->resource[i].flags = IORESOURCE_MEM;
  316. dev->resource[i].name = dev->prom_name;
  317. }
  318. }
  319. for (i = 0; i < PROMINTR_MAX; i++)
  320. dev->irqs[i] = PCI_IRQ_NONE;
  321. len = prom_getproperty(node, "interrupts", (char *)&irqs, sizeof(irqs));
  322. if ((len == -1) || (len == 0)) {
  323. dev->num_irqs = 0;
  324. /*
  325. * Oh, well, some PROMs don't export interrupts
  326. * property to children of EBus devices...
  327. *
  328. * Be smart about PS/2 keyboard and mouse.
  329. */
  330. if (!strcmp(dev->parent->prom_name, "8042")) {
  331. if (!strcmp(dev->prom_name, "kb_ps2")) {
  332. dev->num_irqs = 1;
  333. dev->irqs[0] = dev->parent->irqs[0];
  334. } else {
  335. dev->num_irqs = 1;
  336. dev->irqs[0] = dev->parent->irqs[1];
  337. }
  338. }
  339. } else {
  340. dev->num_irqs = len / sizeof(irqs[0]);
  341. for (i = 0; i < dev->num_irqs; i++) {
  342. struct pci_pbm_info *pbm = dev->bus->parent;
  343. struct pci_controller_info *p = pbm->parent;
  344. if (ebus_intmap_match(dev->bus, preg, &irqs[i]) != -1) {
  345. dev->irqs[i] = p->irq_build(pbm,
  346. dev->bus->self,
  347. irqs[i]);
  348. } else {
  349. /* If we get a bogus interrupt property, just
  350. * record the raw value instead of punting.
  351. */
  352. dev->irqs[i] = irqs[i];
  353. }
  354. }
  355. }
  356. }
  357. static int __init child_regs_nonstandard(struct linux_ebus_device *dev)
  358. {
  359. if (!strcmp(dev->prom_name, "i2c") ||
  360. !strcmp(dev->prom_name, "SUNW,lombus"))
  361. return 1;
  362. return 0;
  363. }
  364. void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
  365. {
  366. struct linux_prom_registers regs[PROMREG_MAX];
  367. struct linux_ebus_child *child;
  368. int irqs[PROMINTR_MAX];
  369. int i, n, len;
  370. dev->prom_node = node;
  371. prom_getstring(node, "name", dev->prom_name, sizeof(dev->prom_name));
  372. printk(" [%s", dev->prom_name);
  373. len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs));
  374. if (len == -1) {
  375. dev->num_addrs = 0;
  376. goto probe_interrupts;
  377. }
  378. if (len % sizeof(struct linux_prom_registers)) {
  379. prom_printf("UGH: proplen for %s was %d, need multiple of %d\n",
  380. dev->prom_name, len,
  381. (int)sizeof(struct linux_prom_registers));
  382. prom_halt();
  383. }
  384. dev->num_addrs = len / sizeof(struct linux_prom_registers);
  385. for (i = 0; i < dev->num_addrs; i++) {
  386. /* XXX Learn how to interpret ebus ranges... -DaveM */
  387. if (regs[i].which_io >= 0x10)
  388. n = (regs[i].which_io - 0x10) >> 2;
  389. else
  390. n = regs[i].which_io;
  391. dev->resource[i].start = dev->bus->self->resource[n].start;
  392. dev->resource[i].start += (unsigned long)regs[i].phys_addr;
  393. dev->resource[i].end =
  394. (dev->resource[i].start + (unsigned long)regs[i].reg_size - 1UL);
  395. dev->resource[i].flags = IORESOURCE_MEM;
  396. dev->resource[i].name = dev->prom_name;
  397. request_resource(&dev->bus->self->resource[n],
  398. &dev->resource[i]);
  399. }
  400. probe_interrupts:
  401. for (i = 0; i < PROMINTR_MAX; i++)
  402. dev->irqs[i] = PCI_IRQ_NONE;
  403. len = prom_getproperty(node, "interrupts", (char *)&irqs, sizeof(irqs));
  404. if ((len == -1) || (len == 0)) {
  405. dev->num_irqs = 0;
  406. } else {
  407. dev->num_irqs = len / sizeof(irqs[0]);
  408. for (i = 0; i < dev->num_irqs; i++) {
  409. struct pci_pbm_info *pbm = dev->bus->parent;
  410. struct pci_controller_info *p = pbm->parent;
  411. if (ebus_intmap_match(dev->bus, &regs[0], &irqs[i]) != -1) {
  412. dev->irqs[i] = p->irq_build(pbm,
  413. dev->bus->self,
  414. irqs[i]);
  415. } else {
  416. /* If we get a bogus interrupt property, just
  417. * record the raw value instead of punting.
  418. */
  419. dev->irqs[i] = irqs[i];
  420. }
  421. }
  422. }
  423. if ((node = prom_getchild(node))) {
  424. printk(" ->");
  425. dev->children = ebus_alloc(sizeof(struct linux_ebus_child));
  426. child = dev->children;
  427. child->next = NULL;
  428. child->parent = dev;
  429. child->bus = dev->bus;
  430. fill_ebus_child(node, &regs[0],
  431. child, child_regs_nonstandard(dev));
  432. while ((node = prom_getsibling(node)) != 0) {
  433. child->next = ebus_alloc(sizeof(struct linux_ebus_child));
  434. child = child->next;
  435. child->next = NULL;
  436. child->parent = dev;
  437. child->bus = dev->bus;
  438. fill_ebus_child(node, &regs[0],
  439. child, child_regs_nonstandard(dev));
  440. }
  441. }
  442. printk("]");
  443. }
  444. static struct pci_dev *find_next_ebus(struct pci_dev *start, int *is_rio_p)
  445. {
  446. struct pci_dev *pdev = start;
  447. do {
  448. pdev = pci_find_device(PCI_VENDOR_ID_SUN, PCI_ANY_ID, pdev);
  449. if (pdev &&
  450. (pdev->device == PCI_DEVICE_ID_SUN_EBUS ||
  451. pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS))
  452. break;
  453. } while (pdev != NULL);
  454. if (pdev && (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS))
  455. *is_rio_p = 1;
  456. else
  457. *is_rio_p = 0;
  458. return pdev;
  459. }
  460. void __init ebus_init(void)
  461. {
  462. struct pci_pbm_info *pbm;
  463. struct linux_ebus_device *dev;
  464. struct linux_ebus *ebus;
  465. struct pci_dev *pdev;
  466. struct pcidev_cookie *cookie;
  467. int nd, ebusnd, is_rio;
  468. int num_ebus = 0;
  469. pdev = find_next_ebus(NULL, &is_rio);
  470. if (!pdev) {
  471. printk("ebus: No EBus's found.\n");
  472. return;
  473. }
  474. cookie = pdev->sysdata;
  475. ebusnd = cookie->prom_node;
  476. ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus));
  477. ebus->next = NULL;
  478. ebus->is_rio = is_rio;
  479. while (ebusnd) {
  480. /* SUNW,pci-qfe uses four empty ebuses on it.
  481. I think we should not consider them here,
  482. as they have half of the properties this
  483. code expects and once we do PCI hot-plug,
  484. we'd have to tweak with the ebus_chain
  485. in the runtime after initialization. -jj */
  486. if (!prom_getchild (ebusnd)) {
  487. pdev = find_next_ebus(pdev, &is_rio);
  488. if (!pdev) {
  489. if (ebus == ebus_chain) {
  490. ebus_chain = NULL;
  491. printk("ebus: No EBus's found.\n");
  492. return;
  493. }
  494. break;
  495. }
  496. ebus->is_rio = is_rio;
  497. cookie = pdev->sysdata;
  498. ebusnd = cookie->prom_node;
  499. continue;
  500. }
  501. printk("ebus%d:", num_ebus);
  502. prom_getstring(ebusnd, "name", ebus->prom_name, sizeof(ebus->prom_name));
  503. ebus->index = num_ebus;
  504. ebus->prom_node = ebusnd;
  505. ebus->self = pdev;
  506. ebus->parent = pbm = cookie->pbm;
  507. ebus_ranges_init(ebus);
  508. ebus_intmap_init(ebus);
  509. nd = prom_getchild(ebusnd);
  510. if (!nd)
  511. goto next_ebus;
  512. ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device));
  513. dev = ebus->devices;
  514. dev->next = NULL;
  515. dev->children = NULL;
  516. dev->bus = ebus;
  517. fill_ebus_device(nd, dev);
  518. while ((nd = prom_getsibling(nd)) != 0) {
  519. dev->next = ebus_alloc(sizeof(struct linux_ebus_device));
  520. dev = dev->next;
  521. dev->next = NULL;
  522. dev->children = NULL;
  523. dev->bus = ebus;
  524. fill_ebus_device(nd, dev);
  525. }
  526. next_ebus:
  527. printk("\n");
  528. pdev = find_next_ebus(pdev, &is_rio);
  529. if (!pdev)
  530. break;
  531. cookie = pdev->sysdata;
  532. ebusnd = cookie->prom_node;
  533. ebus->next = ebus_alloc(sizeof(struct linux_ebus));
  534. ebus = ebus->next;
  535. ebus->next = NULL;
  536. ebus->is_rio = is_rio;
  537. ++num_ebus;
  538. }
  539. #ifdef CONFIG_SUN_AUXIO
  540. auxio_probe();
  541. #endif
  542. }