pci.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #ifndef _ASM_X86_PCI_H
  2. #define _ASM_X86_PCI_H
  3. #include <linux/mm.h> /* for struct page */
  4. #include <linux/types.h>
  5. #include <linux/slab.h>
  6. #include <linux/string.h>
  7. #include <asm/scatterlist.h>
  8. #include <asm/io.h>
  9. #include <asm/x86_init.h>
  10. #ifdef __KERNEL__
  11. struct pci_sysdata {
  12. int domain; /* PCI domain */
  13. int node; /* NUMA node */
  14. #ifdef CONFIG_X86_64
  15. void *iommu; /* IOMMU private data */
  16. #endif
  17. };
  18. extern int pci_routeirq;
  19. extern int noioapicquirk;
  20. extern int noioapicreroute;
  21. /* scan a bus after allocating a pci_sysdata for it */
  22. extern struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops,
  23. int node);
  24. extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
  25. #ifdef CONFIG_PCI
  26. #ifdef CONFIG_PCI_DOMAINS
  27. static inline int pci_domain_nr(struct pci_bus *bus)
  28. {
  29. struct pci_sysdata *sd = bus->sysdata;
  30. return sd->domain;
  31. }
  32. static inline int pci_proc_domain(struct pci_bus *bus)
  33. {
  34. return pci_domain_nr(bus);
  35. }
  36. #endif
  37. /* Can be used to override the logic in pci_scan_bus for skipping
  38. already-configured bus numbers - to be used for buggy BIOSes
  39. or architectures with incomplete PCI setup by the loader */
  40. extern unsigned int pcibios_assign_all_busses(void);
  41. extern int pci_legacy_init(void);
  42. # ifdef CONFIG_ACPI
  43. # define x86_default_pci_init pci_acpi_init
  44. # else
  45. # define x86_default_pci_init pci_legacy_init
  46. # endif
  47. #else
  48. # define pcibios_assign_all_busses() 0
  49. # define x86_default_pci_init NULL
  50. #endif
  51. extern unsigned long pci_mem_start;
  52. #define PCIBIOS_MIN_IO 0x1000
  53. #define PCIBIOS_MIN_MEM (pci_mem_start)
  54. #define PCIBIOS_MIN_CARDBUS_IO 0x4000
  55. void pcibios_config_init(void);
  56. struct pci_bus *pcibios_scan_root(int bus);
  57. void pcibios_set_master(struct pci_dev *dev);
  58. void pcibios_penalize_isa_irq(int irq, int active);
  59. struct irq_routing_table *pcibios_get_irq_routing_table(void);
  60. int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
  61. #define HAVE_PCI_MMAP
  62. extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
  63. enum pci_mmap_state mmap_state,
  64. int write_combine);
  65. #ifdef CONFIG_PCI
  66. extern void early_quirks(void);
  67. static inline void pci_dma_burst_advice(struct pci_dev *pdev,
  68. enum pci_dma_burst_strategy *strat,
  69. unsigned long *strategy_parameter)
  70. {
  71. *strat = PCI_DMA_BURST_INFINITY;
  72. *strategy_parameter = ~0UL;
  73. }
  74. #else
  75. static inline void early_quirks(void) { }
  76. #endif
  77. extern void pci_iommu_alloc(void);
  78. #ifdef CONFIG_PCI_MSI
  79. /* MSI arch specific hooks */
  80. static inline int x86_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
  81. {
  82. return x86_msi.setup_msi_irqs(dev, nvec, type);
  83. }
  84. static inline void x86_teardown_msi_irqs(struct pci_dev *dev)
  85. {
  86. x86_msi.teardown_msi_irqs(dev);
  87. }
  88. static inline void x86_teardown_msi_irq(unsigned int irq)
  89. {
  90. x86_msi.teardown_msi_irq(irq);
  91. }
  92. #define arch_setup_msi_irqs x86_setup_msi_irqs
  93. #define arch_teardown_msi_irqs x86_teardown_msi_irqs
  94. #define arch_teardown_msi_irq x86_teardown_msi_irq
  95. /* implemented in arch/x86/kernel/apic/io_apic. */
  96. int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
  97. void native_teardown_msi_irq(unsigned int irq);
  98. /* default to the implementation in drivers/lib/msi.c */
  99. #define HAVE_DEFAULT_MSI_TEARDOWN_IRQS
  100. void default_teardown_msi_irqs(struct pci_dev *dev);
  101. #else
  102. #define native_setup_msi_irqs NULL
  103. #define native_teardown_msi_irq NULL
  104. #define default_teardown_msi_irqs NULL
  105. #endif
  106. #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
  107. #endif /* __KERNEL__ */
  108. #ifdef CONFIG_X86_64
  109. #include "pci_64.h"
  110. #endif
  111. void dma32_reserve_bootmem(void);
  112. /* implement the pci_ DMA API in terms of the generic device dma_ one */
  113. #include <asm-generic/pci-dma-compat.h>
  114. /* generic pci stuff */
  115. #include <asm-generic/pci.h>
  116. #define PCIBIOS_MAX_MEM_32 0xffffffff
  117. #ifdef CONFIG_NUMA
  118. /* Returns the node based on pci bus */
  119. static inline int __pcibus_to_node(const struct pci_bus *bus)
  120. {
  121. const struct pci_sysdata *sd = bus->sysdata;
  122. return sd->node;
  123. }
  124. static inline const struct cpumask *
  125. cpumask_of_pcibus(const struct pci_bus *bus)
  126. {
  127. int node;
  128. node = __pcibus_to_node(bus);
  129. return (node == -1) ? cpu_online_mask :
  130. cpumask_of_node(node);
  131. }
  132. #endif
  133. #endif /* _ASM_X86_PCI_H */