pci_64.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. /*
  2. * Port for PPC64 David Engebretsen, IBM Corp.
  3. * Contains common pci routines for ppc64 platform, pSeries and iSeries brands.
  4. *
  5. * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
  6. * Rework, based on alpha PCI code.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. */
  13. #undef DEBUG
  14. #include <linux/kernel.h>
  15. #include <linux/pci.h>
  16. #include <linux/string.h>
  17. #include <linux/init.h>
  18. #include <linux/bootmem.h>
  19. #include <linux/mm.h>
  20. #include <linux/list.h>
  21. #include <linux/syscalls.h>
  22. #include <linux/irq.h>
  23. #include <linux/vmalloc.h>
  24. #include <asm/processor.h>
  25. #include <asm/io.h>
  26. #include <asm/prom.h>
  27. #include <asm/pci-bridge.h>
  28. #include <asm/byteorder.h>
  29. #include <asm/machdep.h>
  30. #include <asm/ppc-pci.h>
  31. unsigned long pci_probe_only = 1;
  32. /* pci_io_base -- the base address from which io bars are offsets.
  33. * This is the lowest I/O base address (so bar values are always positive),
  34. * and it *must* be the start of ISA space if an ISA bus exists because
  35. * ISA drivers use hard coded offsets. If no ISA bus exists nothing
  36. * is mapped on the first 64K of IO space
  37. */
  38. unsigned long pci_io_base = ISA_IO_BASE;
  39. EXPORT_SYMBOL(pci_io_base);
  40. LIST_HEAD(hose_list);
  41. static void fixup_broken_pcnet32(struct pci_dev* dev)
  42. {
  43. if ((dev->class>>8 == PCI_CLASS_NETWORK_ETHERNET)) {
  44. dev->vendor = PCI_VENDOR_ID_AMD;
  45. pci_write_config_word(dev, PCI_VENDOR_ID, PCI_VENDOR_ID_AMD);
  46. }
  47. }
  48. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TRIDENT, PCI_ANY_ID, fixup_broken_pcnet32);
  49. static u32 get_int_prop(struct device_node *np, const char *name, u32 def)
  50. {
  51. const u32 *prop;
  52. int len;
  53. prop = of_get_property(np, name, &len);
  54. if (prop && len >= 4)
  55. return *prop;
  56. return def;
  57. }
  58. static unsigned int pci_parse_of_flags(u32 addr0)
  59. {
  60. unsigned int flags = 0;
  61. if (addr0 & 0x02000000) {
  62. flags = IORESOURCE_MEM | PCI_BASE_ADDRESS_SPACE_MEMORY;
  63. flags |= (addr0 >> 22) & PCI_BASE_ADDRESS_MEM_TYPE_64;
  64. flags |= (addr0 >> 28) & PCI_BASE_ADDRESS_MEM_TYPE_1M;
  65. if (addr0 & 0x40000000)
  66. flags |= IORESOURCE_PREFETCH
  67. | PCI_BASE_ADDRESS_MEM_PREFETCH;
  68. } else if (addr0 & 0x01000000)
  69. flags = IORESOURCE_IO | PCI_BASE_ADDRESS_SPACE_IO;
  70. return flags;
  71. }
  72. static void pci_parse_of_addrs(struct device_node *node, struct pci_dev *dev)
  73. {
  74. u64 base, size;
  75. unsigned int flags;
  76. struct resource *res;
  77. const u32 *addrs;
  78. u32 i;
  79. int proplen;
  80. addrs = of_get_property(node, "assigned-addresses", &proplen);
  81. if (!addrs)
  82. return;
  83. pr_debug(" parse addresses (%d bytes) @ %p\n", proplen, addrs);
  84. for (; proplen >= 20; proplen -= 20, addrs += 5) {
  85. flags = pci_parse_of_flags(addrs[0]);
  86. if (!flags)
  87. continue;
  88. base = of_read_number(&addrs[1], 2);
  89. size = of_read_number(&addrs[3], 2);
  90. if (!size)
  91. continue;
  92. i = addrs[0] & 0xff;
  93. pr_debug(" base: %llx, size: %llx, i: %x\n",
  94. (unsigned long long)base,
  95. (unsigned long long)size, i);
  96. if (PCI_BASE_ADDRESS_0 <= i && i <= PCI_BASE_ADDRESS_5) {
  97. res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2];
  98. } else if (i == dev->rom_base_reg) {
  99. res = &dev->resource[PCI_ROM_RESOURCE];
  100. flags |= IORESOURCE_READONLY | IORESOURCE_CACHEABLE;
  101. } else {
  102. printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i);
  103. continue;
  104. }
  105. res->start = base;
  106. res->end = base + size - 1;
  107. res->flags = flags;
  108. res->name = pci_name(dev);
  109. }
  110. }
  111. struct pci_dev *of_create_pci_dev(struct device_node *node,
  112. struct pci_bus *bus, int devfn)
  113. {
  114. struct pci_dev *dev;
  115. const char *type;
  116. dev = alloc_pci_dev();
  117. if (!dev)
  118. return NULL;
  119. type = of_get_property(node, "device_type", NULL);
  120. if (type == NULL)
  121. type = "";
  122. pr_debug(" create device, devfn: %x, type: %s\n", devfn, type);
  123. dev->bus = bus;
  124. dev->sysdata = node;
  125. dev->dev.parent = bus->bridge;
  126. dev->dev.bus = &pci_bus_type;
  127. dev->devfn = devfn;
  128. dev->multifunction = 0; /* maybe a lie? */
  129. dev->vendor = get_int_prop(node, "vendor-id", 0xffff);
  130. dev->device = get_int_prop(node, "device-id", 0xffff);
  131. dev->subsystem_vendor = get_int_prop(node, "subsystem-vendor-id", 0);
  132. dev->subsystem_device = get_int_prop(node, "subsystem-id", 0);
  133. dev->cfg_size = pci_cfg_space_size(dev);
  134. dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(bus),
  135. dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
  136. dev->class = get_int_prop(node, "class-code", 0);
  137. dev->revision = get_int_prop(node, "revision-id", 0);
  138. pr_debug(" class: 0x%x\n", dev->class);
  139. pr_debug(" revision: 0x%x\n", dev->revision);
  140. dev->current_state = 4; /* unknown power state */
  141. dev->error_state = pci_channel_io_normal;
  142. dev->dma_mask = 0xffffffff;
  143. if (!strcmp(type, "pci") || !strcmp(type, "pciex")) {
  144. /* a PCI-PCI bridge */
  145. dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;
  146. dev->rom_base_reg = PCI_ROM_ADDRESS1;
  147. } else if (!strcmp(type, "cardbus")) {
  148. dev->hdr_type = PCI_HEADER_TYPE_CARDBUS;
  149. } else {
  150. dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
  151. dev->rom_base_reg = PCI_ROM_ADDRESS;
  152. /* Maybe do a default OF mapping here */
  153. dev->irq = NO_IRQ;
  154. }
  155. pci_parse_of_addrs(node, dev);
  156. pr_debug(" adding to system ...\n");
  157. pci_device_add(dev, bus);
  158. return dev;
  159. }
  160. EXPORT_SYMBOL(of_create_pci_dev);
  161. void __devinit of_scan_bus(struct device_node *node,
  162. struct pci_bus *bus)
  163. {
  164. struct device_node *child;
  165. const u32 *reg;
  166. int reglen, devfn;
  167. struct pci_dev *dev;
  168. pr_debug("of_scan_bus(%s) bus no %d... \n",
  169. node->full_name, bus->number);
  170. /* Scan direct children */
  171. for_each_child_of_node(node, child) {
  172. pr_debug(" * %s\n", child->full_name);
  173. reg = of_get_property(child, "reg", &reglen);
  174. if (reg == NULL || reglen < 20)
  175. continue;
  176. devfn = (reg[0] >> 8) & 0xff;
  177. /* create a new pci_dev for this device */
  178. dev = of_create_pci_dev(child, bus, devfn);
  179. if (!dev)
  180. continue;
  181. pr_debug(" dev header type: %x\n", dev->hdr_type);
  182. }
  183. /* Ally all fixups */
  184. pcibios_fixup_of_probed_bus(bus);
  185. /* Now scan child busses */
  186. list_for_each_entry(dev, &bus->devices, bus_list) {
  187. if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
  188. dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
  189. struct device_node *child = pci_device_to_OF_node(dev);
  190. if (dev)
  191. of_scan_pci_bridge(child, dev);
  192. }
  193. }
  194. }
  195. EXPORT_SYMBOL(of_scan_bus);
  196. void __devinit of_scan_pci_bridge(struct device_node *node,
  197. struct pci_dev *dev)
  198. {
  199. struct pci_bus *bus;
  200. const u32 *busrange, *ranges;
  201. int len, i, mode;
  202. struct resource *res;
  203. unsigned int flags;
  204. u64 size;
  205. pr_debug("of_scan_pci_bridge(%s)\n", node->full_name);
  206. /* parse bus-range property */
  207. busrange = of_get_property(node, "bus-range", &len);
  208. if (busrange == NULL || len != 8) {
  209. printk(KERN_DEBUG "Can't get bus-range for PCI-PCI bridge %s\n",
  210. node->full_name);
  211. return;
  212. }
  213. ranges = of_get_property(node, "ranges", &len);
  214. if (ranges == NULL) {
  215. printk(KERN_DEBUG "Can't get ranges for PCI-PCI bridge %s\n",
  216. node->full_name);
  217. return;
  218. }
  219. bus = pci_add_new_bus(dev->bus, dev, busrange[0]);
  220. if (!bus) {
  221. printk(KERN_ERR "Failed to create pci bus for %s\n",
  222. node->full_name);
  223. return;
  224. }
  225. bus->primary = dev->bus->number;
  226. bus->subordinate = busrange[1];
  227. bus->bridge_ctl = 0;
  228. bus->sysdata = node;
  229. /* parse ranges property */
  230. /* PCI #address-cells == 3 and #size-cells == 2 always */
  231. res = &dev->resource[PCI_BRIDGE_RESOURCES];
  232. for (i = 0; i < PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES; ++i) {
  233. res->flags = 0;
  234. bus->resource[i] = res;
  235. ++res;
  236. }
  237. i = 1;
  238. for (; len >= 32; len -= 32, ranges += 8) {
  239. flags = pci_parse_of_flags(ranges[0]);
  240. size = of_read_number(&ranges[6], 2);
  241. if (flags == 0 || size == 0)
  242. continue;
  243. if (flags & IORESOURCE_IO) {
  244. res = bus->resource[0];
  245. if (res->flags) {
  246. printk(KERN_ERR "PCI: ignoring extra I/O range"
  247. " for bridge %s\n", node->full_name);
  248. continue;
  249. }
  250. } else {
  251. if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) {
  252. printk(KERN_ERR "PCI: too many memory ranges"
  253. " for bridge %s\n", node->full_name);
  254. continue;
  255. }
  256. res = bus->resource[i];
  257. ++i;
  258. }
  259. res->start = of_read_number(&ranges[1], 2);
  260. res->end = res->start + size - 1;
  261. res->flags = flags;
  262. }
  263. sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
  264. bus->number);
  265. pr_debug(" bus name: %s\n", bus->name);
  266. mode = PCI_PROBE_NORMAL;
  267. if (ppc_md.pci_probe_mode)
  268. mode = ppc_md.pci_probe_mode(bus);
  269. pr_debug(" probe mode: %d\n", mode);
  270. if (mode == PCI_PROBE_DEVTREE)
  271. of_scan_bus(node, bus);
  272. else if (mode == PCI_PROBE_NORMAL)
  273. pci_scan_child_bus(bus);
  274. }
  275. EXPORT_SYMBOL(of_scan_pci_bridge);
  276. void __devinit scan_phb(struct pci_controller *hose)
  277. {
  278. struct pci_bus *bus;
  279. struct device_node *node = hose->dn;
  280. int i, mode;
  281. pr_debug("PCI: Scanning PHB %s\n",
  282. node ? node->full_name : "<NO NAME>");
  283. /* Create an empty bus for the toplevel */
  284. bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, node);
  285. if (bus == NULL) {
  286. printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
  287. hose->global_number);
  288. return;
  289. }
  290. bus->secondary = hose->first_busno;
  291. hose->bus = bus;
  292. /* Get some IO space for the new PHB */
  293. pcibios_map_io_space(bus);
  294. /* Wire up PHB bus resources */
  295. pr_debug("PCI: PHB IO resource = %016lx-%016lx [%lx]\n",
  296. hose->io_resource.start, hose->io_resource.end,
  297. hose->io_resource.flags);
  298. bus->resource[0] = &hose->io_resource;
  299. for (i = 0; i < 3; ++i) {
  300. pr_debug("PCI: PHB MEM resource %d = %016lx-%016lx [%lx]\n", i,
  301. hose->mem_resources[i].start,
  302. hose->mem_resources[i].end,
  303. hose->mem_resources[i].flags);
  304. bus->resource[i+1] = &hose->mem_resources[i];
  305. }
  306. pr_debug("PCI: PHB MEM offset = %016lx\n", hose->pci_mem_offset);
  307. pr_debug("PCI: PHB IO offset = %08lx\n",
  308. (unsigned long)hose->io_base_virt - _IO_BASE);
  309. /* Get probe mode and perform scan */
  310. mode = PCI_PROBE_NORMAL;
  311. if (node && ppc_md.pci_probe_mode)
  312. mode = ppc_md.pci_probe_mode(bus);
  313. pr_debug(" probe mode: %d\n", mode);
  314. if (mode == PCI_PROBE_DEVTREE) {
  315. bus->subordinate = hose->last_busno;
  316. of_scan_bus(node, bus);
  317. }
  318. if (mode == PCI_PROBE_NORMAL)
  319. hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
  320. }
  321. static int __init pcibios_init(void)
  322. {
  323. struct pci_controller *hose, *tmp;
  324. printk(KERN_INFO "PCI: Probing PCI hardware\n");
  325. /* For now, override phys_mem_access_prot. If we need it,
  326. * later, we may move that initialization to each ppc_md
  327. */
  328. ppc_md.phys_mem_access_prot = pci_phys_mem_access_prot;
  329. if (pci_probe_only)
  330. ppc_pci_flags |= PPC_PCI_PROBE_ONLY;
  331. /* On ppc64, we always enable PCI domains and we keep domain 0
  332. * backward compatible in /proc for video cards
  333. */
  334. ppc_pci_flags |= PPC_PCI_ENABLE_PROC_DOMAINS | PPC_PCI_COMPAT_DOMAIN_0;
  335. /* Scan all of the recorded PCI controllers. */
  336. list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
  337. scan_phb(hose);
  338. pci_bus_add_devices(hose->bus);
  339. }
  340. /* Call common code to handle resource allocation */
  341. pcibios_resource_survey();
  342. printk(KERN_DEBUG "PCI: Probing PCI hardware done\n");
  343. return 0;
  344. }
  345. subsys_initcall(pcibios_init);
  346. #ifdef CONFIG_HOTPLUG
  347. int pcibios_unmap_io_space(struct pci_bus *bus)
  348. {
  349. struct pci_controller *hose;
  350. WARN_ON(bus == NULL);
  351. /* If this is not a PHB, we only flush the hash table over
  352. * the area mapped by this bridge. We don't play with the PTE
  353. * mappings since we might have to deal with sub-page alignemnts
  354. * so flushing the hash table is the only sane way to make sure
  355. * that no hash entries are covering that removed bridge area
  356. * while still allowing other busses overlapping those pages
  357. */
  358. if (bus->self) {
  359. struct resource *res = bus->resource[0];
  360. pr_debug("IO unmapping for PCI-PCI bridge %s\n",
  361. pci_name(bus->self));
  362. __flush_hash_table_range(&init_mm, res->start + _IO_BASE,
  363. res->end + _IO_BASE + 1);
  364. return 0;
  365. }
  366. /* Get the host bridge */
  367. hose = pci_bus_to_host(bus);
  368. /* Check if we have IOs allocated */
  369. if (hose->io_base_alloc == 0)
  370. return 0;
  371. pr_debug("IO unmapping for PHB %s\n", hose->dn->full_name);
  372. pr_debug(" alloc=0x%p\n", hose->io_base_alloc);
  373. /* This is a PHB, we fully unmap the IO area */
  374. vunmap(hose->io_base_alloc);
  375. return 0;
  376. }
  377. EXPORT_SYMBOL_GPL(pcibios_unmap_io_space);
  378. #endif /* CONFIG_HOTPLUG */
  379. int __devinit pcibios_map_io_space(struct pci_bus *bus)
  380. {
  381. struct vm_struct *area;
  382. unsigned long phys_page;
  383. unsigned long size_page;
  384. unsigned long io_virt_offset;
  385. struct pci_controller *hose;
  386. WARN_ON(bus == NULL);
  387. /* If this not a PHB, nothing to do, page tables still exist and
  388. * thus HPTEs will be faulted in when needed
  389. */
  390. if (bus->self) {
  391. pr_debug("IO mapping for PCI-PCI bridge %s\n",
  392. pci_name(bus->self));
  393. pr_debug(" virt=0x%016lx...0x%016lx\n",
  394. bus->resource[0]->start + _IO_BASE,
  395. bus->resource[0]->end + _IO_BASE);
  396. return 0;
  397. }
  398. /* Get the host bridge */
  399. hose = pci_bus_to_host(bus);
  400. phys_page = _ALIGN_DOWN(hose->io_base_phys, PAGE_SIZE);
  401. size_page = _ALIGN_UP(hose->pci_io_size, PAGE_SIZE);
  402. /* Make sure IO area address is clear */
  403. hose->io_base_alloc = NULL;
  404. /* If there's no IO to map on that bus, get away too */
  405. if (hose->pci_io_size == 0 || hose->io_base_phys == 0)
  406. return 0;
  407. /* Let's allocate some IO space for that guy. We don't pass
  408. * VM_IOREMAP because we don't care about alignment tricks that
  409. * the core does in that case. Maybe we should due to stupid card
  410. * with incomplete address decoding but I'd rather not deal with
  411. * those outside of the reserved 64K legacy region.
  412. */
  413. area = __get_vm_area(size_page, 0, PHB_IO_BASE, PHB_IO_END);
  414. if (area == NULL)
  415. return -ENOMEM;
  416. hose->io_base_alloc = area->addr;
  417. hose->io_base_virt = (void __iomem *)(area->addr +
  418. hose->io_base_phys - phys_page);
  419. pr_debug("IO mapping for PHB %s\n", hose->dn->full_name);
  420. pr_debug(" phys=0x%016lx, virt=0x%p (alloc=0x%p)\n",
  421. hose->io_base_phys, hose->io_base_virt, hose->io_base_alloc);
  422. pr_debug(" size=0x%016lx (alloc=0x%016lx)\n",
  423. hose->pci_io_size, size_page);
  424. /* Establish the mapping */
  425. if (__ioremap_at(phys_page, area->addr, size_page,
  426. _PAGE_NO_CACHE | _PAGE_GUARDED) == NULL)
  427. return -ENOMEM;
  428. /* Fixup hose IO resource */
  429. io_virt_offset = (unsigned long)hose->io_base_virt - _IO_BASE;
  430. hose->io_resource.start += io_virt_offset;
  431. hose->io_resource.end += io_virt_offset;
  432. pr_debug(" hose->io_resource=0x%016lx...0x%016lx\n",
  433. hose->io_resource.start, hose->io_resource.end);
  434. return 0;
  435. }
  436. EXPORT_SYMBOL_GPL(pcibios_map_io_space);
  437. void __devinit pcibios_do_bus_setup(struct pci_bus *bus)
  438. {
  439. struct pci_dev *dev;
  440. if (ppc_md.pci_dma_bus_setup)
  441. ppc_md.pci_dma_bus_setup(bus);
  442. list_for_each_entry(dev, &bus->devices, bus_list)
  443. pcibios_setup_new_device(dev);
  444. }
  445. unsigned long pci_address_to_pio(phys_addr_t address)
  446. {
  447. struct pci_controller *hose, *tmp;
  448. list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
  449. if (address >= hose->io_base_phys &&
  450. address < (hose->io_base_phys + hose->pci_io_size)) {
  451. unsigned long base =
  452. (unsigned long)hose->io_base_virt - _IO_BASE;
  453. return base + (address - hose->io_base_phys);
  454. }
  455. }
  456. return (unsigned int)-1;
  457. }
  458. EXPORT_SYMBOL_GPL(pci_address_to_pio);
  459. #define IOBASE_BRIDGE_NUMBER 0
  460. #define IOBASE_MEMORY 1
  461. #define IOBASE_IO 2
  462. #define IOBASE_ISA_IO 3
  463. #define IOBASE_ISA_MEM 4
  464. long sys_pciconfig_iobase(long which, unsigned long in_bus,
  465. unsigned long in_devfn)
  466. {
  467. struct pci_controller* hose;
  468. struct list_head *ln;
  469. struct pci_bus *bus = NULL;
  470. struct device_node *hose_node;
  471. /* Argh ! Please forgive me for that hack, but that's the
  472. * simplest way to get existing XFree to not lockup on some
  473. * G5 machines... So when something asks for bus 0 io base
  474. * (bus 0 is HT root), we return the AGP one instead.
  475. */
  476. if (machine_is_compatible("MacRISC4"))
  477. if (in_bus == 0)
  478. in_bus = 0xf0;
  479. /* That syscall isn't quite compatible with PCI domains, but it's
  480. * used on pre-domains setup. We return the first match
  481. */
  482. for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
  483. bus = pci_bus_b(ln);
  484. if (in_bus >= bus->number && in_bus <= bus->subordinate)
  485. break;
  486. bus = NULL;
  487. }
  488. if (bus == NULL || bus->sysdata == NULL)
  489. return -ENODEV;
  490. hose_node = (struct device_node *)bus->sysdata;
  491. hose = PCI_DN(hose_node)->phb;
  492. switch (which) {
  493. case IOBASE_BRIDGE_NUMBER:
  494. return (long)hose->first_busno;
  495. case IOBASE_MEMORY:
  496. return (long)hose->pci_mem_offset;
  497. case IOBASE_IO:
  498. return (long)hose->io_base_phys;
  499. case IOBASE_ISA_IO:
  500. return (long)isa_io_base;
  501. case IOBASE_ISA_MEM:
  502. return -EINVAL;
  503. }
  504. return -EOPNOTSUPP;
  505. }
  506. #ifdef CONFIG_NUMA
  507. int pcibus_to_node(struct pci_bus *bus)
  508. {
  509. struct pci_controller *phb = pci_bus_to_host(bus);
  510. return phb->node;
  511. }
  512. EXPORT_SYMBOL(pcibus_to_node);
  513. #endif