pci.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 <linux/numa.h>
  10. #include <asm/io.h>
  11. #include <asm/memtype.h>
  12. #include <asm/x86_init.h>
  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. struct pci_dev *vmd_dev; /* VMD Device if in Intel VMD domain */
  27. #endif
  28. };
  29. extern int pci_routeirq;
  30. extern int noioapicquirk;
  31. extern int noioapicreroute;
  32. static inline struct pci_sysdata *to_pci_sysdata(const struct pci_bus *bus)
  33. {
  34. return bus->sysdata;
  35. }
  36. #ifdef CONFIG_PCI
  37. #ifdef CONFIG_PCI_DOMAINS
  38. static inline int pci_domain_nr(struct pci_bus *bus)
  39. {
  40. return to_pci_sysdata(bus)->domain;
  41. }
  42. static inline int pci_proc_domain(struct pci_bus *bus)
  43. {
  44. return pci_domain_nr(bus);
  45. }
  46. #endif
  47. #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
  48. static inline void *_pci_root_bus_fwnode(struct pci_bus *bus)
  49. {
  50. return to_pci_sysdata(bus)->fwnode;
  51. }
  52. #define pci_root_bus_fwnode _pci_root_bus_fwnode
  53. #endif
  54. #if IS_ENABLED(CONFIG_VMD)
  55. static inline bool is_vmd(struct pci_bus *bus)
  56. {
  57. return to_pci_sysdata(bus)->vmd_dev != NULL;
  58. }
  59. #else
  60. #define is_vmd(bus) false
  61. #endif /* CONFIG_VMD */
  62. /* Can be used to override the logic in pci_scan_bus for skipping
  63. already-configured bus numbers - to be used for buggy BIOSes
  64. or architectures with incomplete PCI setup by the loader */
  65. extern unsigned int pcibios_assign_all_busses(void);
  66. extern int pci_legacy_init(void);
  67. #else
  68. static inline int pcibios_assign_all_busses(void) { return 0; }
  69. #endif
  70. extern unsigned long pci_mem_start;
  71. #define PCIBIOS_MIN_IO 0x1000
  72. #define PCIBIOS_MIN_MEM (pci_mem_start)
  73. #define PCIBIOS_MIN_CARDBUS_IO 0x4000
  74. extern int pcibios_enabled;
  75. void pcibios_scan_root(int bus);
  76. struct irq_routing_table *pcibios_get_irq_routing_table(void);
  77. int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
  78. #define HAVE_PCI_MMAP
  79. #define arch_can_pci_mmap_wc() pat_enabled()
  80. #define ARCH_GENERIC_PCI_MMAP_RESOURCE
  81. #ifdef CONFIG_PCI
  82. extern void early_quirks(void);
  83. #else
  84. static inline void early_quirks(void) { }
  85. #endif
  86. extern void pci_iommu_alloc(void);
  87. #ifdef CONFIG_NUMA
  88. /* Returns the node based on pci bus */
  89. static inline int __pcibus_to_node(const struct pci_bus *bus)
  90. {
  91. return to_pci_sysdata(bus)->node;
  92. }
  93. static inline const struct cpumask *
  94. cpumask_of_pcibus(const struct pci_bus *bus)
  95. {
  96. int node;
  97. node = __pcibus_to_node(bus);
  98. return (node == NUMA_NO_NODE) ? cpu_online_mask :
  99. cpumask_of_node(node);
  100. }
  101. #endif
  102. struct pci_setup_rom {
  103. struct setup_data data;
  104. uint16_t vendor;
  105. uint16_t devid;
  106. uint64_t pcilen;
  107. unsigned long segment;
  108. unsigned long bus;
  109. unsigned long device;
  110. unsigned long function;
  111. uint8_t romdata[];
  112. };
  113. #endif /* _ASM_X86_PCI_H */