pci.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. /*
  2. * Copyright (C) 2001 Allan Trautman, IBM Corporation
  3. *
  4. * iSeries specific routines for PCI.
  5. *
  6. * Based on code from pci.c and iSeries_pci.c 32bit
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/list.h>
  24. #include <linux/string.h>
  25. #include <linux/init.h>
  26. #include <linux/module.h>
  27. #include <linux/pci.h>
  28. #include <asm/io.h>
  29. #include <asm/irq.h>
  30. #include <asm/prom.h>
  31. #include <asm/machdep.h>
  32. #include <asm/pci-bridge.h>
  33. #include <asm/iommu.h>
  34. #include <asm/abs_addr.h>
  35. #include <asm/firmware.h>
  36. #include <asm/iseries/hv_call_xm.h>
  37. #include <asm/iseries/mf.h>
  38. #include <asm/iseries/iommu.h>
  39. #include <asm/ppc-pci.h>
  40. #include "irq.h"
  41. #include "pci.h"
  42. #include "call_pci.h"
  43. #define PCI_RETRY_MAX 3
  44. static int limit_pci_retries = 1; /* Set Retry Error on. */
  45. /*
  46. * Table defines
  47. * Each Entry size is 4 MB * 1024 Entries = 4GB I/O address space.
  48. */
  49. #define IOMM_TABLE_MAX_ENTRIES 1024
  50. #define IOMM_TABLE_ENTRY_SIZE 0x0000000000400000UL
  51. #define BASE_IO_MEMORY 0xE000000000000000UL
  52. static unsigned long max_io_memory = BASE_IO_MEMORY;
  53. static long current_iomm_table_entry;
  54. /*
  55. * Lookup Tables.
  56. */
  57. static struct device_node *iomm_table[IOMM_TABLE_MAX_ENTRIES];
  58. static u8 iobar_table[IOMM_TABLE_MAX_ENTRIES];
  59. static const char pci_io_text[] = "iSeries PCI I/O";
  60. static DEFINE_SPINLOCK(iomm_table_lock);
  61. /*
  62. * Generate a Direct Select Address for the Hypervisor
  63. */
  64. static inline u64 iseries_ds_addr(struct device_node *node)
  65. {
  66. struct pci_dn *pdn = PCI_DN(node);
  67. return ((u64)pdn->busno << 48) + ((u64)pdn->bussubno << 40)
  68. + ((u64)0x10 << 32);
  69. }
  70. /*
  71. * iomm_table_allocate_entry
  72. *
  73. * Adds pci_dev entry in address translation table
  74. *
  75. * - Allocates the number of entries required in table base on BAR
  76. * size.
  77. * - Allocates starting at BASE_IO_MEMORY and increases.
  78. * - The size is round up to be a multiple of entry size.
  79. * - CurrentIndex is incremented to keep track of the last entry.
  80. * - Builds the resource entry for allocated BARs.
  81. */
  82. static void __init iomm_table_allocate_entry(struct pci_dev *dev, int bar_num)
  83. {
  84. struct resource *bar_res = &dev->resource[bar_num];
  85. long bar_size = pci_resource_len(dev, bar_num);
  86. /*
  87. * No space to allocate, quick exit, skip Allocation.
  88. */
  89. if (bar_size == 0)
  90. return;
  91. /*
  92. * Set Resource values.
  93. */
  94. spin_lock(&iomm_table_lock);
  95. bar_res->name = pci_io_text;
  96. bar_res->start = BASE_IO_MEMORY +
  97. IOMM_TABLE_ENTRY_SIZE * current_iomm_table_entry;
  98. bar_res->end = bar_res->start + bar_size - 1;
  99. /*
  100. * Allocate the number of table entries needed for BAR.
  101. */
  102. while (bar_size > 0 ) {
  103. iomm_table[current_iomm_table_entry] = dev->sysdata;
  104. iobar_table[current_iomm_table_entry] = bar_num;
  105. bar_size -= IOMM_TABLE_ENTRY_SIZE;
  106. ++current_iomm_table_entry;
  107. }
  108. max_io_memory = BASE_IO_MEMORY +
  109. IOMM_TABLE_ENTRY_SIZE * current_iomm_table_entry;
  110. spin_unlock(&iomm_table_lock);
  111. }
  112. /*
  113. * allocate_device_bars
  114. *
  115. * - Allocates ALL pci_dev BAR's and updates the resources with the
  116. * BAR value. BARS with zero length will have the resources
  117. * The HvCallPci_getBarParms is used to get the size of the BAR
  118. * space. It calls iomm_table_allocate_entry to allocate
  119. * each entry.
  120. * - Loops through The Bar resources(0 - 5) including the ROM
  121. * is resource(6).
  122. */
  123. static void __init allocate_device_bars(struct pci_dev *dev)
  124. {
  125. int bar_num;
  126. for (bar_num = 0; bar_num <= PCI_ROM_RESOURCE; ++bar_num)
  127. iomm_table_allocate_entry(dev, bar_num);
  128. }
  129. /*
  130. * Log error information to system console.
  131. * Filter out the device not there errors.
  132. * PCI: EADs Connect Failed 0x18.58.10 Rc: 0x00xx
  133. * PCI: Read Vendor Failed 0x18.58.10 Rc: 0x00xx
  134. * PCI: Connect Bus Unit Failed 0x18.58.10 Rc: 0x00xx
  135. */
  136. static void pci_log_error(char *error, int bus, int subbus,
  137. int agent, int hv_res)
  138. {
  139. if (hv_res == 0x0302)
  140. return;
  141. printk(KERN_ERR "PCI: %s Failed: 0x%02X.%02X.%02X Rc: 0x%04X",
  142. error, bus, subbus, agent, hv_res);
  143. }
  144. /*
  145. * Look down the chain to find the matching Device Device
  146. */
  147. static struct device_node *find_device_node(int bus, int devfn)
  148. {
  149. struct device_node *node;
  150. for (node = NULL; (node = of_find_all_nodes(node)); ) {
  151. struct pci_dn *pdn = PCI_DN(node);
  152. if (pdn && (bus == pdn->busno) && (devfn == pdn->devfn))
  153. return node;
  154. }
  155. return NULL;
  156. }
  157. /*
  158. * iSeries_pci_final_fixup(void)
  159. */
  160. void __init iSeries_pci_final_fixup(void)
  161. {
  162. struct pci_dev *pdev = NULL;
  163. struct device_node *node;
  164. int num_dev = 0;
  165. /* Fix up at the device node and pci_dev relationship */
  166. mf_display_src(0xC9000100);
  167. printk("pcibios_final_fixup\n");
  168. for_each_pci_dev(pdev) {
  169. struct pci_dn *pdn;
  170. const u32 *agent;
  171. node = find_device_node(pdev->bus->number, pdev->devfn);
  172. printk("pci dev %p (%x.%x), node %p\n", pdev,
  173. pdev->bus->number, pdev->devfn, node);
  174. if (!node) {
  175. printk("PCI: Device Tree not found for 0x%016lX\n",
  176. (unsigned long)pdev);
  177. continue;
  178. }
  179. pdn = PCI_DN(node);
  180. agent = of_get_property(node, "linux,agent-id", NULL);
  181. if (pdn && agent) {
  182. u8 irq = iSeries_allocate_IRQ(pdn->busno, 0,
  183. pdn->bussubno);
  184. int err;
  185. err = HvCallXm_connectBusUnit(pdn->busno, pdn->bussubno,
  186. *agent, irq);
  187. if (err)
  188. pci_log_error("Connect Bus Unit",
  189. pdn->busno, pdn->bussubno, *agent, err);
  190. else {
  191. err = HvCallPci_configStore8(pdn->busno,
  192. pdn->bussubno, *agent,
  193. PCI_INTERRUPT_LINE, irq);
  194. if (err)
  195. pci_log_error("PciCfgStore Irq Failed!",
  196. pdn->busno, pdn->bussubno,
  197. *agent, err);
  198. else
  199. pdev->irq = irq;
  200. }
  201. }
  202. num_dev++;
  203. pdev->sysdata = node;
  204. PCI_DN(node)->pcidev = pdev;
  205. allocate_device_bars(pdev);
  206. iSeries_Device_Information(pdev, num_dev, pdn->busno,
  207. pdn->bussubno);
  208. iommu_devnode_init_iSeries(pdev, node);
  209. }
  210. iSeries_activate_IRQs();
  211. mf_display_src(0xC9000200);
  212. }
  213. /*
  214. * Config space read and write functions.
  215. * For now at least, we look for the device node for the bus and devfn
  216. * that we are asked to access. It may be possible to translate the devfn
  217. * to a subbus and deviceid more directly.
  218. */
  219. static u64 hv_cfg_read_func[4] = {
  220. HvCallPciConfigLoad8, HvCallPciConfigLoad16,
  221. HvCallPciConfigLoad32, HvCallPciConfigLoad32
  222. };
  223. static u64 hv_cfg_write_func[4] = {
  224. HvCallPciConfigStore8, HvCallPciConfigStore16,
  225. HvCallPciConfigStore32, HvCallPciConfigStore32
  226. };
  227. /*
  228. * Read PCI config space
  229. */
  230. static int iSeries_pci_read_config(struct pci_bus *bus, unsigned int devfn,
  231. int offset, int size, u32 *val)
  232. {
  233. struct device_node *node = find_device_node(bus->number, devfn);
  234. u64 fn;
  235. struct HvCallPci_LoadReturn ret;
  236. if (node == NULL)
  237. return PCIBIOS_DEVICE_NOT_FOUND;
  238. if (offset > 255) {
  239. *val = ~0;
  240. return PCIBIOS_BAD_REGISTER_NUMBER;
  241. }
  242. fn = hv_cfg_read_func[(size - 1) & 3];
  243. HvCall3Ret16(fn, &ret, iseries_ds_addr(node), offset, 0);
  244. if (ret.rc != 0) {
  245. *val = ~0;
  246. return PCIBIOS_DEVICE_NOT_FOUND; /* or something */
  247. }
  248. *val = ret.value;
  249. return 0;
  250. }
  251. /*
  252. * Write PCI config space
  253. */
  254. static int iSeries_pci_write_config(struct pci_bus *bus, unsigned int devfn,
  255. int offset, int size, u32 val)
  256. {
  257. struct device_node *node = find_device_node(bus->number, devfn);
  258. u64 fn;
  259. u64 ret;
  260. if (node == NULL)
  261. return PCIBIOS_DEVICE_NOT_FOUND;
  262. if (offset > 255)
  263. return PCIBIOS_BAD_REGISTER_NUMBER;
  264. fn = hv_cfg_write_func[(size - 1) & 3];
  265. ret = HvCall4(fn, iseries_ds_addr(node), offset, val, 0);
  266. if (ret != 0)
  267. return PCIBIOS_DEVICE_NOT_FOUND;
  268. return 0;
  269. }
  270. static struct pci_ops iSeries_pci_ops = {
  271. .read = iSeries_pci_read_config,
  272. .write = iSeries_pci_write_config
  273. };
  274. /*
  275. * Check Return Code
  276. * -> On Failure, print and log information.
  277. * Increment Retry Count, if exceeds max, panic partition.
  278. *
  279. * PCI: Device 23.90 ReadL I/O Error( 0): 0x1234
  280. * PCI: Device 23.90 ReadL Retry( 1)
  281. * PCI: Device 23.90 ReadL Retry Successful(1)
  282. */
  283. static int check_return_code(char *type, struct device_node *dn,
  284. int *retry, u64 ret)
  285. {
  286. if (ret != 0) {
  287. struct pci_dn *pdn = PCI_DN(dn);
  288. (*retry)++;
  289. printk("PCI: %s: Device 0x%04X:%02X I/O Error(%2d): 0x%04X\n",
  290. type, pdn->busno, pdn->devfn,
  291. *retry, (int)ret);
  292. /*
  293. * Bump the retry and check for retry count exceeded.
  294. * If, Exceeded, panic the system.
  295. */
  296. if (((*retry) > PCI_RETRY_MAX) &&
  297. (limit_pci_retries > 0)) {
  298. mf_display_src(0xB6000103);
  299. panic_timeout = 0;
  300. panic("PCI: Hardware I/O Error, SRC B6000103, "
  301. "Automatic Reboot Disabled.\n");
  302. }
  303. return -1; /* Retry Try */
  304. }
  305. return 0;
  306. }
  307. /*
  308. * Translate the I/O Address into a device node, bar, and bar offset.
  309. * Note: Make sure the passed variable end up on the stack to avoid
  310. * the exposure of being device global.
  311. */
  312. static inline struct device_node *xlate_iomm_address(
  313. const volatile void __iomem *addr,
  314. u64 *dsaptr, u64 *bar_offset, const char *func)
  315. {
  316. unsigned long orig_addr;
  317. unsigned long base_addr;
  318. unsigned long ind;
  319. struct device_node *dn;
  320. orig_addr = (unsigned long __force)addr;
  321. if ((orig_addr < BASE_IO_MEMORY) || (orig_addr >= max_io_memory)) {
  322. static unsigned long last_jiffies;
  323. static int num_printed;
  324. if ((jiffies - last_jiffies) > 60 * HZ) {
  325. last_jiffies = jiffies;
  326. num_printed = 0;
  327. }
  328. if (num_printed++ < 10)
  329. printk(KERN_ERR
  330. "iSeries_%s: invalid access at IO address %p\n",
  331. func, addr);
  332. return NULL;
  333. }
  334. base_addr = orig_addr - BASE_IO_MEMORY;
  335. ind = base_addr / IOMM_TABLE_ENTRY_SIZE;
  336. dn = iomm_table[ind];
  337. if (dn != NULL) {
  338. int barnum = iobar_table[ind];
  339. *dsaptr = iseries_ds_addr(dn) | (barnum << 24);
  340. *bar_offset = base_addr % IOMM_TABLE_ENTRY_SIZE;
  341. } else
  342. panic("PCI: Invalid PCI IO address detected!\n");
  343. return dn;
  344. }
  345. /*
  346. * Read MM I/O Instructions for the iSeries
  347. * On MM I/O error, all ones are returned and iSeries_pci_IoError is cal
  348. * else, data is returned in Big Endian format.
  349. */
  350. static u8 iseries_readb(const volatile void __iomem *addr)
  351. {
  352. u64 bar_offset;
  353. u64 dsa;
  354. int retry = 0;
  355. struct HvCallPci_LoadReturn ret;
  356. struct device_node *dn =
  357. xlate_iomm_address(addr, &dsa, &bar_offset, "read_byte");
  358. if (dn == NULL)
  359. return 0xff;
  360. do {
  361. HvCall3Ret16(HvCallPciBarLoad8, &ret, dsa, bar_offset, 0);
  362. } while (check_return_code("RDB", dn, &retry, ret.rc) != 0);
  363. return ret.value;
  364. }
  365. static u16 iseries_readw_be(const volatile void __iomem *addr)
  366. {
  367. u64 bar_offset;
  368. u64 dsa;
  369. int retry = 0;
  370. struct HvCallPci_LoadReturn ret;
  371. struct device_node *dn =
  372. xlate_iomm_address(addr, &dsa, &bar_offset, "read_word");
  373. if (dn == NULL)
  374. return 0xffff;
  375. do {
  376. HvCall3Ret16(HvCallPciBarLoad16, &ret, dsa,
  377. bar_offset, 0);
  378. } while (check_return_code("RDW", dn, &retry, ret.rc) != 0);
  379. return ret.value;
  380. }
  381. static u32 iseries_readl_be(const volatile void __iomem *addr)
  382. {
  383. u64 bar_offset;
  384. u64 dsa;
  385. int retry = 0;
  386. struct HvCallPci_LoadReturn ret;
  387. struct device_node *dn =
  388. xlate_iomm_address(addr, &dsa, &bar_offset, "read_long");
  389. if (dn == NULL)
  390. return 0xffffffff;
  391. do {
  392. HvCall3Ret16(HvCallPciBarLoad32, &ret, dsa,
  393. bar_offset, 0);
  394. } while (check_return_code("RDL", dn, &retry, ret.rc) != 0);
  395. return ret.value;
  396. }
  397. /*
  398. * Write MM I/O Instructions for the iSeries
  399. *
  400. */
  401. static void iseries_writeb(u8 data, volatile void __iomem *addr)
  402. {
  403. u64 bar_offset;
  404. u64 dsa;
  405. int retry = 0;
  406. u64 rc;
  407. struct device_node *dn =
  408. xlate_iomm_address(addr, &dsa, &bar_offset, "write_byte");
  409. if (dn == NULL)
  410. return;
  411. do {
  412. rc = HvCall4(HvCallPciBarStore8, dsa, bar_offset, data, 0);
  413. } while (check_return_code("WWB", dn, &retry, rc) != 0);
  414. }
  415. static void iseries_writew_be(u16 data, volatile void __iomem *addr)
  416. {
  417. u64 bar_offset;
  418. u64 dsa;
  419. int retry = 0;
  420. u64 rc;
  421. struct device_node *dn =
  422. xlate_iomm_address(addr, &dsa, &bar_offset, "write_word");
  423. if (dn == NULL)
  424. return;
  425. do {
  426. rc = HvCall4(HvCallPciBarStore16, dsa, bar_offset, data, 0);
  427. } while (check_return_code("WWW", dn, &retry, rc) != 0);
  428. }
  429. static void iseries_writel_be(u32 data, volatile void __iomem *addr)
  430. {
  431. u64 bar_offset;
  432. u64 dsa;
  433. int retry = 0;
  434. u64 rc;
  435. struct device_node *dn =
  436. xlate_iomm_address(addr, &dsa, &bar_offset, "write_long");
  437. if (dn == NULL)
  438. return;
  439. do {
  440. rc = HvCall4(HvCallPciBarStore32, dsa, bar_offset, data, 0);
  441. } while (check_return_code("WWL", dn, &retry, rc) != 0);
  442. }
  443. static u16 iseries_readw(const volatile void __iomem *addr)
  444. {
  445. return le16_to_cpu(iseries_readw_be(addr));
  446. }
  447. static u32 iseries_readl(const volatile void __iomem *addr)
  448. {
  449. return le32_to_cpu(iseries_readl_be(addr));
  450. }
  451. static void iseries_writew(u16 data, volatile void __iomem *addr)
  452. {
  453. iseries_writew_be(cpu_to_le16(data), addr);
  454. }
  455. static void iseries_writel(u32 data, volatile void __iomem *addr)
  456. {
  457. iseries_writel(cpu_to_le32(data), addr);
  458. }
  459. static void iseries_readsb(const volatile void __iomem *addr, void *buf,
  460. unsigned long count)
  461. {
  462. u8 *dst = buf;
  463. while(count-- > 0)
  464. *(dst++) = iseries_readb(addr);
  465. }
  466. static void iseries_readsw(const volatile void __iomem *addr, void *buf,
  467. unsigned long count)
  468. {
  469. u16 *dst = buf;
  470. while(count-- > 0)
  471. *(dst++) = iseries_readw_be(addr);
  472. }
  473. static void iseries_readsl(const volatile void __iomem *addr, void *buf,
  474. unsigned long count)
  475. {
  476. u32 *dst = buf;
  477. while(count-- > 0)
  478. *(dst++) = iseries_readl_be(addr);
  479. }
  480. static void iseries_writesb(volatile void __iomem *addr, const void *buf,
  481. unsigned long count)
  482. {
  483. const u8 *src = buf;
  484. while(count-- > 0)
  485. iseries_writeb(*(src++), addr);
  486. }
  487. static void iseries_writesw(volatile void __iomem *addr, const void *buf,
  488. unsigned long count)
  489. {
  490. const u16 *src = buf;
  491. while(count-- > 0)
  492. iseries_writew_be(*(src++), addr);
  493. }
  494. static void iseries_writesl(volatile void __iomem *addr, const void *buf,
  495. unsigned long count)
  496. {
  497. const u32 *src = buf;
  498. while(count-- > 0)
  499. iseries_writel_be(*(src++), addr);
  500. }
  501. static void iseries_memset_io(volatile void __iomem *addr, int c,
  502. unsigned long n)
  503. {
  504. volatile char __iomem *d = addr;
  505. while (n-- > 0)
  506. iseries_writeb(c, d++);
  507. }
  508. static void iseries_memcpy_fromio(void *dest, const volatile void __iomem *src,
  509. unsigned long n)
  510. {
  511. char *d = dest;
  512. const volatile char __iomem *s = src;
  513. while (n-- > 0)
  514. *d++ = iseries_readb(s++);
  515. }
  516. static void iseries_memcpy_toio(volatile void __iomem *dest, const void *src,
  517. unsigned long n)
  518. {
  519. const char *s = src;
  520. volatile char __iomem *d = dest;
  521. while (n-- > 0)
  522. iseries_writeb(*s++, d++);
  523. }
  524. /* We only set MMIO ops. The default PIO ops will be default
  525. * to the MMIO ops + pci_io_base which is 0 on iSeries as
  526. * expected so both should work.
  527. *
  528. * Note that we don't implement the readq/writeq versions as
  529. * I don't know of an HV call for doing so. Thus, the default
  530. * operation will be used instead, which will fault a the value
  531. * return by iSeries for MMIO addresses always hits a non mapped
  532. * area. This is as good as the BUG() we used to have there.
  533. */
  534. static struct ppc_pci_io __initdata iseries_pci_io = {
  535. .readb = iseries_readb,
  536. .readw = iseries_readw,
  537. .readl = iseries_readl,
  538. .readw_be = iseries_readw_be,
  539. .readl_be = iseries_readl_be,
  540. .writeb = iseries_writeb,
  541. .writew = iseries_writew,
  542. .writel = iseries_writel,
  543. .writew_be = iseries_writew_be,
  544. .writel_be = iseries_writel_be,
  545. .readsb = iseries_readsb,
  546. .readsw = iseries_readsw,
  547. .readsl = iseries_readsl,
  548. .writesb = iseries_writesb,
  549. .writesw = iseries_writesw,
  550. .writesl = iseries_writesl,
  551. .memset_io = iseries_memset_io,
  552. .memcpy_fromio = iseries_memcpy_fromio,
  553. .memcpy_toio = iseries_memcpy_toio,
  554. };
  555. /*
  556. * iSeries_pcibios_init
  557. *
  558. * Description:
  559. * This function checks for all possible system PCI host bridges that connect
  560. * PCI buses. The system hypervisor is queried as to the guest partition
  561. * ownership status. A pci_controller is built for any bus which is partially
  562. * owned or fully owned by this guest partition.
  563. */
  564. void __init iSeries_pcibios_init(void)
  565. {
  566. struct pci_controller *phb;
  567. struct device_node *root = of_find_node_by_path("/");
  568. struct device_node *node = NULL;
  569. /* Install IO hooks */
  570. ppc_pci_io = iseries_pci_io;
  571. /* iSeries has no IO space in the common sense, it needs to set
  572. * the IO base to 0
  573. */
  574. pci_io_base = 0;
  575. if (root == NULL) {
  576. printk(KERN_CRIT "iSeries_pcibios_init: can't find root "
  577. "of device tree\n");
  578. return;
  579. }
  580. while ((node = of_get_next_child(root, node)) != NULL) {
  581. HvBusNumber bus;
  582. const u32 *busp;
  583. if ((node->type == NULL) || (strcmp(node->type, "pci") != 0))
  584. continue;
  585. busp = of_get_property(node, "bus-range", NULL);
  586. if (busp == NULL)
  587. continue;
  588. bus = *busp;
  589. printk("bus %d appears to exist\n", bus);
  590. phb = pcibios_alloc_controller(node);
  591. if (phb == NULL)
  592. continue;
  593. phb->pci_mem_offset = bus;
  594. phb->first_busno = bus;
  595. phb->last_busno = bus;
  596. phb->ops = &iSeries_pci_ops;
  597. }
  598. of_node_put(root);
  599. pci_devs_phb_init();
  600. }