pci_64.c 16 KB

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