pci.h 3.5 KB

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