pci.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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_ACPI
  15. void *acpi; /* ACPI-specific data */
  16. #endif
  17. #ifdef CONFIG_X86_64
  18. void *iommu; /* IOMMU private data */
  19. #endif
  20. };
  21. extern int pci_routeirq;
  22. extern int noioapicquirk;
  23. extern int noioapicreroute;
  24. /* scan a bus after allocating a pci_sysdata for it */
  25. extern struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops,
  26. int node);
  27. extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
  28. #ifdef CONFIG_PCI
  29. #ifdef CONFIG_PCI_DOMAINS
  30. static inline int pci_domain_nr(struct pci_bus *bus)
  31. {
  32. struct pci_sysdata *sd = bus->sysdata;
  33. return sd->domain;
  34. }
  35. static inline int pci_proc_domain(struct pci_bus *bus)
  36. {
  37. return pci_domain_nr(bus);
  38. }
  39. #endif
  40. /* Can be used to override the logic in pci_scan_bus for skipping
  41. already-configured bus numbers - to be used for buggy BIOSes
  42. or architectures with incomplete PCI setup by the loader */
  43. extern unsigned int pcibios_assign_all_busses(void);
  44. extern int pci_legacy_init(void);
  45. # ifdef CONFIG_ACPI
  46. # define x86_default_pci_init pci_acpi_init
  47. # else
  48. # define x86_default_pci_init pci_legacy_init
  49. # endif
  50. #else
  51. # define pcibios_assign_all_busses() 0
  52. # define x86_default_pci_init NULL
  53. #endif
  54. extern unsigned long pci_mem_start;
  55. #define PCIBIOS_MIN_IO 0x1000
  56. #define PCIBIOS_MIN_MEM (pci_mem_start)
  57. #define PCIBIOS_MIN_CARDBUS_IO 0x4000
  58. extern int pcibios_enabled;
  59. void pcibios_config_init(void);
  60. struct pci_bus *pcibios_scan_root(int bus);
  61. void pcibios_set_master(struct pci_dev *dev);
  62. void pcibios_penalize_isa_irq(int irq, int active);
  63. struct irq_routing_table *pcibios_get_irq_routing_table(void);
  64. int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
  65. #define HAVE_PCI_MMAP
  66. extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
  67. enum pci_mmap_state mmap_state,
  68. int write_combine);
  69. #ifdef CONFIG_PCI
  70. extern void early_quirks(void);
  71. static inline void pci_dma_burst_advice(struct pci_dev *pdev,
  72. enum pci_dma_burst_strategy *strat,
  73. unsigned long *strategy_parameter)
  74. {
  75. *strat = PCI_DMA_BURST_INFINITY;
  76. *strategy_parameter = ~0UL;
  77. }
  78. #else
  79. static inline void early_quirks(void) { }
  80. #endif
  81. extern void pci_iommu_alloc(void);
  82. #ifdef CONFIG_PCI_MSI
  83. /* implemented in arch/x86/kernel/apic/io_apic. */
  84. struct msi_desc;
  85. int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
  86. void native_teardown_msi_irq(unsigned int irq);
  87. void native_restore_msi_irqs(struct pci_dev *dev, int irq);
  88. int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,
  89. unsigned int irq_base, unsigned int irq_offset);
  90. #else
  91. #define native_setup_msi_irqs NULL
  92. #define native_teardown_msi_irq NULL
  93. #endif
  94. #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
  95. #endif /* __KERNEL__ */
  96. #ifdef CONFIG_X86_64
  97. #include <asm/pci_64.h>
  98. #endif
  99. /* implement the pci_ DMA API in terms of the generic device dma_ one */
  100. #include <asm-generic/pci-dma-compat.h>
  101. /* generic pci stuff */
  102. #include <asm-generic/pci.h>
  103. #define PCIBIOS_MAX_MEM_32 0xffffffff
  104. #ifdef CONFIG_NUMA
  105. /* Returns the node based on pci bus */
  106. static inline int __pcibus_to_node(const struct pci_bus *bus)
  107. {
  108. const struct pci_sysdata *sd = bus->sysdata;
  109. return sd->node;
  110. }
  111. static inline const struct cpumask *
  112. cpumask_of_pcibus(const struct pci_bus *bus)
  113. {
  114. int node;
  115. node = __pcibus_to_node(bus);
  116. return (node == -1) ? cpu_online_mask :
  117. cpumask_of_node(node);
  118. }
  119. #endif
  120. struct pci_setup_rom {
  121. struct setup_data data;
  122. uint16_t vendor;
  123. uint16_t devid;
  124. uint64_t pcilen;
  125. unsigned long segment;
  126. unsigned long bus;
  127. unsigned long device;
  128. unsigned long function;
  129. uint8_t romdata[0];
  130. };
  131. #endif /* _ASM_X86_PCI_H */