pci.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 <linux/scatterlist.h>
  8. #include <asm/io.h>
  9. #include <asm/pat.h>
  10. #include <asm/x86_init.h>
  11. #ifdef __KERNEL__
  12. struct pci_sysdata {
  13. int domain; /* PCI domain */
  14. int node; /* NUMA node */
  15. #ifdef CONFIG_ACPI
  16. struct acpi_device *companion; /* ACPI companion device */
  17. #endif
  18. #ifdef CONFIG_X86_64
  19. void *iommu; /* IOMMU private data */
  20. #endif
  21. #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
  22. void *fwnode; /* IRQ domain for MSI assignment */
  23. #endif
  24. #if IS_ENABLED(CONFIG_VMD)
  25. bool vmd_domain; /* True if in Intel VMD domain */
  26. #endif
  27. };
  28. extern int pci_routeirq;
  29. extern int noioapicquirk;
  30. extern int noioapicreroute;
  31. #ifdef CONFIG_PCI
  32. #ifdef CONFIG_PCI_DOMAINS
  33. static inline int pci_domain_nr(struct pci_bus *bus)
  34. {
  35. struct pci_sysdata *sd = bus->sysdata;
  36. return sd->domain;
  37. }
  38. static inline int pci_proc_domain(struct pci_bus *bus)
  39. {
  40. return pci_domain_nr(bus);
  41. }
  42. #endif
  43. #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
  44. static inline void *_pci_root_bus_fwnode(struct pci_bus *bus)
  45. {
  46. struct pci_sysdata *sd = bus->sysdata;
  47. return sd->fwnode;
  48. }
  49. #define pci_root_bus_fwnode _pci_root_bus_fwnode
  50. #endif
  51. static inline bool is_vmd(struct pci_bus *bus)
  52. {
  53. #if IS_ENABLED(CONFIG_VMD)
  54. struct pci_sysdata *sd = bus->sysdata;
  55. return sd->vmd_domain;
  56. #else
  57. return false;
  58. #endif
  59. }
  60. /* Can be used to override the logic in pci_scan_bus for skipping
  61. already-configured bus numbers - to be used for buggy BIOSes
  62. or architectures with incomplete PCI setup by the loader */
  63. extern unsigned int pcibios_assign_all_busses(void);
  64. extern int pci_legacy_init(void);
  65. # ifdef CONFIG_ACPI
  66. # define x86_default_pci_init pci_acpi_init
  67. # else
  68. # define x86_default_pci_init pci_legacy_init
  69. # endif
  70. #else
  71. # define pcibios_assign_all_busses() 0
  72. # define x86_default_pci_init NULL
  73. #endif
  74. extern unsigned long pci_mem_start;
  75. #define PCIBIOS_MIN_IO 0x1000
  76. #define PCIBIOS_MIN_MEM (pci_mem_start)
  77. #define PCIBIOS_MIN_CARDBUS_IO 0x4000
  78. extern int pcibios_enabled;
  79. void pcibios_config_init(void);
  80. void pcibios_scan_root(int bus);
  81. void pcibios_set_master(struct pci_dev *dev);
  82. struct irq_routing_table *pcibios_get_irq_routing_table(void);
  83. int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
  84. #define HAVE_PCI_MMAP
  85. #define arch_can_pci_mmap_wc() pat_enabled()
  86. #define ARCH_GENERIC_PCI_MMAP_RESOURCE
  87. #ifdef CONFIG_PCI
  88. extern void early_quirks(void);
  89. #else
  90. static inline void early_quirks(void) { }
  91. #endif
  92. extern void pci_iommu_alloc(void);
  93. #ifdef CONFIG_PCI_MSI
  94. /* implemented in arch/x86/kernel/apic/io_apic. */
  95. struct msi_desc;
  96. int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
  97. void native_teardown_msi_irq(unsigned int irq);
  98. void native_restore_msi_irqs(struct pci_dev *dev);
  99. #else
  100. #define native_setup_msi_irqs NULL
  101. #define native_teardown_msi_irq NULL
  102. #endif
  103. #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
  104. #endif /* __KERNEL__ */
  105. #ifdef CONFIG_X86_64
  106. #include <asm/pci_64.h>
  107. #endif
  108. /* generic pci stuff */
  109. #include <asm-generic/pci.h>
  110. #ifdef CONFIG_NUMA
  111. /* Returns the node based on pci bus */
  112. static inline int __pcibus_to_node(const struct pci_bus *bus)
  113. {
  114. const struct pci_sysdata *sd = bus->sysdata;
  115. return sd->node;
  116. }
  117. static inline const struct cpumask *
  118. cpumask_of_pcibus(const struct pci_bus *bus)
  119. {
  120. int node;
  121. node = __pcibus_to_node(bus);
  122. return (node == -1) ? cpu_online_mask :
  123. cpumask_of_node(node);
  124. }
  125. #endif
  126. struct pci_setup_rom {
  127. struct setup_data data;
  128. uint16_t vendor;
  129. uint16_t devid;
  130. uint64_t pcilen;
  131. unsigned long segment;
  132. unsigned long bus;
  133. unsigned long device;
  134. unsigned long function;
  135. uint8_t romdata[0];
  136. };
  137. #endif /* _ASM_X86_PCI_H */