pci.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /* $Id: pci.c,v 1.39 2002/01/05 01:13:43 davem Exp $
  2. * pci.c: UltraSparc PCI controller support.
  3. *
  4. * Copyright (C) 1997, 1998, 1999 David S. Miller (davem@redhat.com)
  5. * Copyright (C) 1998, 1999 Eddie C. Dost (ecd@skynet.be)
  6. * Copyright (C) 1999 Jakub Jelinek (jj@ultra.linux.cz)
  7. */
  8. #include <linux/config.h>
  9. #include <linux/module.h>
  10. #include <linux/kernel.h>
  11. #include <linux/string.h>
  12. #include <linux/sched.h>
  13. #include <linux/capability.h>
  14. #include <linux/errno.h>
  15. #include <linux/smp_lock.h>
  16. #include <linux/init.h>
  17. #include <asm/uaccess.h>
  18. #include <asm/pbm.h>
  19. #include <asm/pgtable.h>
  20. #include <asm/irq.h>
  21. #include <asm/ebus.h>
  22. #include <asm/isa.h>
  23. #include <asm/prom.h>
  24. unsigned long pci_memspace_mask = 0xffffffffUL;
  25. #ifndef CONFIG_PCI
  26. /* A "nop" PCI implementation. */
  27. asmlinkage int sys_pciconfig_read(unsigned long bus, unsigned long dfn,
  28. unsigned long off, unsigned long len,
  29. unsigned char *buf)
  30. {
  31. return 0;
  32. }
  33. asmlinkage int sys_pciconfig_write(unsigned long bus, unsigned long dfn,
  34. unsigned long off, unsigned long len,
  35. unsigned char *buf)
  36. {
  37. return 0;
  38. }
  39. #else
  40. /* List of all PCI controllers found in the system. */
  41. struct pci_controller_info *pci_controller_root = NULL;
  42. /* Each PCI controller found gets a unique index. */
  43. int pci_num_controllers = 0;
  44. volatile int pci_poke_in_progress;
  45. volatile int pci_poke_cpu = -1;
  46. volatile int pci_poke_faulted;
  47. static DEFINE_SPINLOCK(pci_poke_lock);
  48. void pci_config_read8(u8 *addr, u8 *ret)
  49. {
  50. unsigned long flags;
  51. u8 byte;
  52. spin_lock_irqsave(&pci_poke_lock, flags);
  53. pci_poke_cpu = smp_processor_id();
  54. pci_poke_in_progress = 1;
  55. pci_poke_faulted = 0;
  56. __asm__ __volatile__("membar #Sync\n\t"
  57. "lduba [%1] %2, %0\n\t"
  58. "membar #Sync"
  59. : "=r" (byte)
  60. : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
  61. : "memory");
  62. pci_poke_in_progress = 0;
  63. pci_poke_cpu = -1;
  64. if (!pci_poke_faulted)
  65. *ret = byte;
  66. spin_unlock_irqrestore(&pci_poke_lock, flags);
  67. }
  68. void pci_config_read16(u16 *addr, u16 *ret)
  69. {
  70. unsigned long flags;
  71. u16 word;
  72. spin_lock_irqsave(&pci_poke_lock, flags);
  73. pci_poke_cpu = smp_processor_id();
  74. pci_poke_in_progress = 1;
  75. pci_poke_faulted = 0;
  76. __asm__ __volatile__("membar #Sync\n\t"
  77. "lduha [%1] %2, %0\n\t"
  78. "membar #Sync"
  79. : "=r" (word)
  80. : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
  81. : "memory");
  82. pci_poke_in_progress = 0;
  83. pci_poke_cpu = -1;
  84. if (!pci_poke_faulted)
  85. *ret = word;
  86. spin_unlock_irqrestore(&pci_poke_lock, flags);
  87. }
  88. void pci_config_read32(u32 *addr, u32 *ret)
  89. {
  90. unsigned long flags;
  91. u32 dword;
  92. spin_lock_irqsave(&pci_poke_lock, flags);
  93. pci_poke_cpu = smp_processor_id();
  94. pci_poke_in_progress = 1;
  95. pci_poke_faulted = 0;
  96. __asm__ __volatile__("membar #Sync\n\t"
  97. "lduwa [%1] %2, %0\n\t"
  98. "membar #Sync"
  99. : "=r" (dword)
  100. : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
  101. : "memory");
  102. pci_poke_in_progress = 0;
  103. pci_poke_cpu = -1;
  104. if (!pci_poke_faulted)
  105. *ret = dword;
  106. spin_unlock_irqrestore(&pci_poke_lock, flags);
  107. }
  108. void pci_config_write8(u8 *addr, u8 val)
  109. {
  110. unsigned long flags;
  111. spin_lock_irqsave(&pci_poke_lock, flags);
  112. pci_poke_cpu = smp_processor_id();
  113. pci_poke_in_progress = 1;
  114. pci_poke_faulted = 0;
  115. __asm__ __volatile__("membar #Sync\n\t"
  116. "stba %0, [%1] %2\n\t"
  117. "membar #Sync"
  118. : /* no outputs */
  119. : "r" (val), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
  120. : "memory");
  121. pci_poke_in_progress = 0;
  122. pci_poke_cpu = -1;
  123. spin_unlock_irqrestore(&pci_poke_lock, flags);
  124. }
  125. void pci_config_write16(u16 *addr, u16 val)
  126. {
  127. unsigned long flags;
  128. spin_lock_irqsave(&pci_poke_lock, flags);
  129. pci_poke_cpu = smp_processor_id();
  130. pci_poke_in_progress = 1;
  131. pci_poke_faulted = 0;
  132. __asm__ __volatile__("membar #Sync\n\t"
  133. "stha %0, [%1] %2\n\t"
  134. "membar #Sync"
  135. : /* no outputs */
  136. : "r" (val), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
  137. : "memory");
  138. pci_poke_in_progress = 0;
  139. pci_poke_cpu = -1;
  140. spin_unlock_irqrestore(&pci_poke_lock, flags);
  141. }
  142. void pci_config_write32(u32 *addr, u32 val)
  143. {
  144. unsigned long flags;
  145. spin_lock_irqsave(&pci_poke_lock, flags);
  146. pci_poke_cpu = smp_processor_id();
  147. pci_poke_in_progress = 1;
  148. pci_poke_faulted = 0;
  149. __asm__ __volatile__("membar #Sync\n\t"
  150. "stwa %0, [%1] %2\n\t"
  151. "membar #Sync"
  152. : /* no outputs */
  153. : "r" (val), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
  154. : "memory");
  155. pci_poke_in_progress = 0;
  156. pci_poke_cpu = -1;
  157. spin_unlock_irqrestore(&pci_poke_lock, flags);
  158. }
  159. /* Probe for all PCI controllers in the system. */
  160. extern void sabre_init(struct device_node *, const char *);
  161. extern void psycho_init(struct device_node *, const char *);
  162. extern void schizo_init(struct device_node *, const char *);
  163. extern void schizo_plus_init(struct device_node *, const char *);
  164. extern void tomatillo_init(struct device_node *, const char *);
  165. extern void sun4v_pci_init(struct device_node *, const char *);
  166. static struct {
  167. char *model_name;
  168. void (*init)(struct device_node *, const char *);
  169. } pci_controller_table[] __initdata = {
  170. { "SUNW,sabre", sabre_init },
  171. { "pci108e,a000", sabre_init },
  172. { "pci108e,a001", sabre_init },
  173. { "SUNW,psycho", psycho_init },
  174. { "pci108e,8000", psycho_init },
  175. { "SUNW,schizo", schizo_init },
  176. { "pci108e,8001", schizo_init },
  177. { "SUNW,schizo+", schizo_plus_init },
  178. { "pci108e,8002", schizo_plus_init },
  179. { "SUNW,tomatillo", tomatillo_init },
  180. { "pci108e,a801", tomatillo_init },
  181. { "SUNW,sun4v-pci", sun4v_pci_init },
  182. };
  183. #define PCI_NUM_CONTROLLER_TYPES (sizeof(pci_controller_table) / \
  184. sizeof(pci_controller_table[0]))
  185. static int __init pci_controller_init(const char *model_name, int namelen, struct device_node *dp)
  186. {
  187. int i;
  188. for (i = 0; i < PCI_NUM_CONTROLLER_TYPES; i++) {
  189. if (!strncmp(model_name,
  190. pci_controller_table[i].model_name,
  191. namelen)) {
  192. pci_controller_table[i].init(dp, model_name);
  193. return 1;
  194. }
  195. }
  196. return 0;
  197. }
  198. static int __init pci_is_controller(const char *model_name, int namelen, struct device_node *dp)
  199. {
  200. int i;
  201. for (i = 0; i < PCI_NUM_CONTROLLER_TYPES; i++) {
  202. if (!strncmp(model_name,
  203. pci_controller_table[i].model_name,
  204. namelen)) {
  205. return 1;
  206. }
  207. }
  208. return 0;
  209. }
  210. static int __init pci_controller_scan(int (*handler)(const char *, int, struct device_node *))
  211. {
  212. struct device_node *dp;
  213. int count = 0;
  214. for_each_node_by_name(dp, "pci") {
  215. struct property *prop;
  216. int len;
  217. prop = of_find_property(dp, "model", &len);
  218. if (!prop)
  219. prop = of_find_property(dp, "compatible", &len);
  220. if (prop) {
  221. const char *model = prop->value;
  222. int item_len = 0;
  223. /* Our value may be a multi-valued string in the
  224. * case of some compatible properties. For sanity,
  225. * only try the first one.
  226. */
  227. while (model[item_len] && len) {
  228. len--;
  229. item_len++;
  230. }
  231. if (handler(model, item_len, dp))
  232. count++;
  233. }
  234. }
  235. return count;
  236. }
  237. /* Is there some PCI controller in the system? */
  238. int __init pcic_present(void)
  239. {
  240. return pci_controller_scan(pci_is_controller);
  241. }
  242. struct pci_iommu_ops *pci_iommu_ops;
  243. EXPORT_SYMBOL(pci_iommu_ops);
  244. extern struct pci_iommu_ops pci_sun4u_iommu_ops,
  245. pci_sun4v_iommu_ops;
  246. /* Find each controller in the system, attach and initialize
  247. * software state structure for each and link into the
  248. * pci_controller_root. Setup the controller enough such
  249. * that bus scanning can be done.
  250. */
  251. static void __init pci_controller_probe(void)
  252. {
  253. if (tlb_type == hypervisor)
  254. pci_iommu_ops = &pci_sun4v_iommu_ops;
  255. else
  256. pci_iommu_ops = &pci_sun4u_iommu_ops;
  257. printk("PCI: Probing for controllers.\n");
  258. pci_controller_scan(pci_controller_init);
  259. }
  260. static void __init pci_scan_each_controller_bus(void)
  261. {
  262. struct pci_controller_info *p;
  263. for (p = pci_controller_root; p; p = p->next)
  264. p->scan_bus(p);
  265. }
  266. extern void clock_probe(void);
  267. extern void power_init(void);
  268. static int __init pcibios_init(void)
  269. {
  270. pci_controller_probe();
  271. if (pci_controller_root == NULL)
  272. return 0;
  273. pci_scan_each_controller_bus();
  274. isa_init();
  275. ebus_init();
  276. clock_probe();
  277. power_init();
  278. return 0;
  279. }
  280. subsys_initcall(pcibios_init);
  281. void pcibios_fixup_bus(struct pci_bus *pbus)
  282. {
  283. struct pci_pbm_info *pbm = pbus->sysdata;
  284. /* Generic PCI bus probing sets these to point at
  285. * &io{port,mem}_resouce which is wrong for us.
  286. */
  287. pbus->resource[0] = &pbm->io_space;
  288. pbus->resource[1] = &pbm->mem_space;
  289. }
  290. struct resource *pcibios_select_root(struct pci_dev *pdev, struct resource *r)
  291. {
  292. struct pci_pbm_info *pbm = pdev->bus->sysdata;
  293. struct resource *root = NULL;
  294. if (r->flags & IORESOURCE_IO)
  295. root = &pbm->io_space;
  296. if (r->flags & IORESOURCE_MEM)
  297. root = &pbm->mem_space;
  298. return root;
  299. }
  300. void pcibios_update_irq(struct pci_dev *pdev, int irq)
  301. {
  302. }
  303. void pcibios_align_resource(void *data, struct resource *res,
  304. unsigned long size, unsigned long align)
  305. {
  306. }
  307. int pcibios_enable_device(struct pci_dev *pdev, int mask)
  308. {
  309. return 0;
  310. }
  311. void pcibios_resource_to_bus(struct pci_dev *pdev, struct pci_bus_region *region,
  312. struct resource *res)
  313. {
  314. struct pci_pbm_info *pbm = pdev->bus->sysdata;
  315. struct resource zero_res, *root;
  316. zero_res.start = 0;
  317. zero_res.end = 0;
  318. zero_res.flags = res->flags;
  319. if (res->flags & IORESOURCE_IO)
  320. root = &pbm->io_space;
  321. else
  322. root = &pbm->mem_space;
  323. pbm->parent->resource_adjust(pdev, &zero_res, root);
  324. region->start = res->start - zero_res.start;
  325. region->end = res->end - zero_res.start;
  326. }
  327. EXPORT_SYMBOL(pcibios_resource_to_bus);
  328. void pcibios_bus_to_resource(struct pci_dev *pdev, struct resource *res,
  329. struct pci_bus_region *region)
  330. {
  331. struct pci_pbm_info *pbm = pdev->bus->sysdata;
  332. struct resource *root;
  333. res->start = region->start;
  334. res->end = region->end;
  335. if (res->flags & IORESOURCE_IO)
  336. root = &pbm->io_space;
  337. else
  338. root = &pbm->mem_space;
  339. pbm->parent->resource_adjust(pdev, res, root);
  340. }
  341. EXPORT_SYMBOL(pcibios_bus_to_resource);
  342. extern int pci_irq_verbose;
  343. char * __init pcibios_setup(char *str)
  344. {
  345. if (!strcmp(str, "irq_verbose")) {
  346. pci_irq_verbose = 1;
  347. return NULL;
  348. }
  349. return str;
  350. }
  351. /* Platform support for /proc/bus/pci/X/Y mmap()s. */
  352. /* If the user uses a host-bridge as the PCI device, he may use
  353. * this to perform a raw mmap() of the I/O or MEM space behind
  354. * that controller.
  355. *
  356. * This can be useful for execution of x86 PCI bios initialization code
  357. * on a PCI card, like the xfree86 int10 stuff does.
  358. */
  359. static int __pci_mmap_make_offset_bus(struct pci_dev *pdev, struct vm_area_struct *vma,
  360. enum pci_mmap_state mmap_state)
  361. {
  362. struct pcidev_cookie *pcp = pdev->sysdata;
  363. struct pci_pbm_info *pbm;
  364. struct pci_controller_info *p;
  365. unsigned long space_size, user_offset, user_size;
  366. if (!pcp)
  367. return -ENXIO;
  368. pbm = pcp->pbm;
  369. if (!pbm)
  370. return -ENXIO;
  371. p = pbm->parent;
  372. if (p->pbms_same_domain) {
  373. unsigned long lowest, highest;
  374. lowest = ~0UL; highest = 0UL;
  375. if (mmap_state == pci_mmap_io) {
  376. if (p->pbm_A.io_space.flags) {
  377. lowest = p->pbm_A.io_space.start;
  378. highest = p->pbm_A.io_space.end + 1;
  379. }
  380. if (p->pbm_B.io_space.flags) {
  381. if (lowest > p->pbm_B.io_space.start)
  382. lowest = p->pbm_B.io_space.start;
  383. if (highest < p->pbm_B.io_space.end + 1)
  384. highest = p->pbm_B.io_space.end + 1;
  385. }
  386. space_size = highest - lowest;
  387. } else {
  388. if (p->pbm_A.mem_space.flags) {
  389. lowest = p->pbm_A.mem_space.start;
  390. highest = p->pbm_A.mem_space.end + 1;
  391. }
  392. if (p->pbm_B.mem_space.flags) {
  393. if (lowest > p->pbm_B.mem_space.start)
  394. lowest = p->pbm_B.mem_space.start;
  395. if (highest < p->pbm_B.mem_space.end + 1)
  396. highest = p->pbm_B.mem_space.end + 1;
  397. }
  398. space_size = highest - lowest;
  399. }
  400. } else {
  401. if (mmap_state == pci_mmap_io) {
  402. space_size = (pbm->io_space.end -
  403. pbm->io_space.start) + 1;
  404. } else {
  405. space_size = (pbm->mem_space.end -
  406. pbm->mem_space.start) + 1;
  407. }
  408. }
  409. /* Make sure the request is in range. */
  410. user_offset = vma->vm_pgoff << PAGE_SHIFT;
  411. user_size = vma->vm_end - vma->vm_start;
  412. if (user_offset >= space_size ||
  413. (user_offset + user_size) > space_size)
  414. return -EINVAL;
  415. if (p->pbms_same_domain) {
  416. unsigned long lowest = ~0UL;
  417. if (mmap_state == pci_mmap_io) {
  418. if (p->pbm_A.io_space.flags)
  419. lowest = p->pbm_A.io_space.start;
  420. if (p->pbm_B.io_space.flags &&
  421. lowest > p->pbm_B.io_space.start)
  422. lowest = p->pbm_B.io_space.start;
  423. } else {
  424. if (p->pbm_A.mem_space.flags)
  425. lowest = p->pbm_A.mem_space.start;
  426. if (p->pbm_B.mem_space.flags &&
  427. lowest > p->pbm_B.mem_space.start)
  428. lowest = p->pbm_B.mem_space.start;
  429. }
  430. vma->vm_pgoff = (lowest + user_offset) >> PAGE_SHIFT;
  431. } else {
  432. if (mmap_state == pci_mmap_io) {
  433. vma->vm_pgoff = (pbm->io_space.start +
  434. user_offset) >> PAGE_SHIFT;
  435. } else {
  436. vma->vm_pgoff = (pbm->mem_space.start +
  437. user_offset) >> PAGE_SHIFT;
  438. }
  439. }
  440. return 0;
  441. }
  442. /* Adjust vm_pgoff of VMA such that it is the physical page offset corresponding
  443. * to the 32-bit pci bus offset for DEV requested by the user.
  444. *
  445. * Basically, the user finds the base address for his device which he wishes
  446. * to mmap. They read the 32-bit value from the config space base register,
  447. * add whatever PAGE_SIZE multiple offset they wish, and feed this into the
  448. * offset parameter of mmap on /proc/bus/pci/XXX for that device.
  449. *
  450. * Returns negative error code on failure, zero on success.
  451. */
  452. static int __pci_mmap_make_offset(struct pci_dev *dev, struct vm_area_struct *vma,
  453. enum pci_mmap_state mmap_state)
  454. {
  455. unsigned long user_offset = vma->vm_pgoff << PAGE_SHIFT;
  456. unsigned long user32 = user_offset & pci_memspace_mask;
  457. unsigned long largest_base, this_base, addr32;
  458. int i;
  459. if ((dev->class >> 8) == PCI_CLASS_BRIDGE_HOST)
  460. return __pci_mmap_make_offset_bus(dev, vma, mmap_state);
  461. /* Figure out which base address this is for. */
  462. largest_base = 0UL;
  463. for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
  464. struct resource *rp = &dev->resource[i];
  465. /* Active? */
  466. if (!rp->flags)
  467. continue;
  468. /* Same type? */
  469. if (i == PCI_ROM_RESOURCE) {
  470. if (mmap_state != pci_mmap_mem)
  471. continue;
  472. } else {
  473. if ((mmap_state == pci_mmap_io &&
  474. (rp->flags & IORESOURCE_IO) == 0) ||
  475. (mmap_state == pci_mmap_mem &&
  476. (rp->flags & IORESOURCE_MEM) == 0))
  477. continue;
  478. }
  479. this_base = rp->start;
  480. addr32 = (this_base & PAGE_MASK) & pci_memspace_mask;
  481. if (mmap_state == pci_mmap_io)
  482. addr32 &= 0xffffff;
  483. if (addr32 <= user32 && this_base > largest_base)
  484. largest_base = this_base;
  485. }
  486. if (largest_base == 0UL)
  487. return -EINVAL;
  488. /* Now construct the final physical address. */
  489. if (mmap_state == pci_mmap_io)
  490. vma->vm_pgoff = (((largest_base & ~0xffffffUL) | user32) >> PAGE_SHIFT);
  491. else
  492. vma->vm_pgoff = (((largest_base & ~(pci_memspace_mask)) | user32) >> PAGE_SHIFT);
  493. return 0;
  494. }
  495. /* Set vm_flags of VMA, as appropriate for this architecture, for a pci device
  496. * mapping.
  497. */
  498. static void __pci_mmap_set_flags(struct pci_dev *dev, struct vm_area_struct *vma,
  499. enum pci_mmap_state mmap_state)
  500. {
  501. vma->vm_flags |= (VM_IO | VM_RESERVED);
  502. }
  503. /* Set vm_page_prot of VMA, as appropriate for this architecture, for a pci
  504. * device mapping.
  505. */
  506. static void __pci_mmap_set_pgprot(struct pci_dev *dev, struct vm_area_struct *vma,
  507. enum pci_mmap_state mmap_state)
  508. {
  509. /* Our io_remap_pfn_range takes care of this, do nothing. */
  510. }
  511. /* Perform the actual remap of the pages for a PCI device mapping, as appropriate
  512. * for this architecture. The region in the process to map is described by vm_start
  513. * and vm_end members of VMA, the base physical address is found in vm_pgoff.
  514. * The pci device structure is provided so that architectures may make mapping
  515. * decisions on a per-device or per-bus basis.
  516. *
  517. * Returns a negative error code on failure, zero on success.
  518. */
  519. int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
  520. enum pci_mmap_state mmap_state,
  521. int write_combine)
  522. {
  523. int ret;
  524. ret = __pci_mmap_make_offset(dev, vma, mmap_state);
  525. if (ret < 0)
  526. return ret;
  527. __pci_mmap_set_flags(dev, vma, mmap_state);
  528. __pci_mmap_set_pgprot(dev, vma, mmap_state);
  529. vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
  530. ret = io_remap_pfn_range(vma, vma->vm_start,
  531. vma->vm_pgoff,
  532. vma->vm_end - vma->vm_start,
  533. vma->vm_page_prot);
  534. if (ret)
  535. return ret;
  536. return 0;
  537. }
  538. /* Return the domain nuber for this pci bus */
  539. int pci_domain_nr(struct pci_bus *pbus)
  540. {
  541. struct pci_pbm_info *pbm = pbus->sysdata;
  542. int ret;
  543. if (pbm == NULL || pbm->parent == NULL) {
  544. ret = -ENXIO;
  545. } else {
  546. struct pci_controller_info *p = pbm->parent;
  547. ret = p->index;
  548. if (p->pbms_same_domain == 0)
  549. ret = ((ret << 1) +
  550. ((pbm == &pbm->parent->pbm_B) ? 1 : 0));
  551. }
  552. return ret;
  553. }
  554. EXPORT_SYMBOL(pci_domain_nr);
  555. int pcibios_prep_mwi(struct pci_dev *dev)
  556. {
  557. /* We set correct PCI_CACHE_LINE_SIZE register values for every
  558. * device probed on this platform. So there is nothing to check
  559. * and this always succeeds.
  560. */
  561. return 0;
  562. }
  563. #endif /* !(CONFIG_PCI) */