pci.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #ifndef __x8664_PCI_H
  2. #define __x8664_PCI_H
  3. #include <linux/config.h>
  4. #include <asm/io.h>
  5. #ifdef __KERNEL__
  6. #include <linux/mm.h> /* for struct page */
  7. /* Can be used to override the logic in pci_scan_bus for skipping
  8. already-configured bus numbers - to be used for buggy BIOSes
  9. or architectures with incomplete PCI setup by the loader */
  10. #ifdef CONFIG_PCI
  11. extern unsigned int pcibios_assign_all_busses(void);
  12. #else
  13. #define pcibios_assign_all_busses() 0
  14. #endif
  15. #define pcibios_scan_all_fns(a, b) 0
  16. extern int no_iommu, force_iommu;
  17. extern unsigned long pci_mem_start;
  18. #define PCIBIOS_MIN_IO 0x1000
  19. #define PCIBIOS_MIN_MEM (pci_mem_start)
  20. #define PCIBIOS_MIN_CARDBUS_IO 0x4000
  21. void pcibios_config_init(void);
  22. struct pci_bus * pcibios_scan_root(int bus);
  23. extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value);
  24. extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value);
  25. void pcibios_set_master(struct pci_dev *dev);
  26. void pcibios_penalize_isa_irq(int irq, int active);
  27. struct irq_routing_table *pcibios_get_irq_routing_table(void);
  28. int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
  29. #include <linux/types.h>
  30. #include <linux/slab.h>
  31. #include <asm/scatterlist.h>
  32. #include <linux/string.h>
  33. #include <asm/page.h>
  34. extern int iommu_setup(char *opt);
  35. #ifdef CONFIG_GART_IOMMU
  36. /* The PCI address space does equal the physical memory
  37. * address space. The networking and block device layers use
  38. * this boolean for bounce buffer decisions
  39. *
  40. * On AMD64 it mostly equals, but we set it to zero to tell some subsystems
  41. * that an IOMMU is available.
  42. */
  43. #define PCI_DMA_BUS_IS_PHYS (no_iommu ? 1 : 0)
  44. /*
  45. * x86-64 always supports DAC, but sometimes it is useful to force
  46. * devices through the IOMMU to get automatic sg list merging.
  47. * Optional right now.
  48. */
  49. extern int iommu_sac_force;
  50. #define pci_dac_dma_supported(pci_dev, mask) (!iommu_sac_force)
  51. #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
  52. dma_addr_t ADDR_NAME;
  53. #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
  54. __u32 LEN_NAME;
  55. #define pci_unmap_addr(PTR, ADDR_NAME) \
  56. ((PTR)->ADDR_NAME)
  57. #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
  58. (((PTR)->ADDR_NAME) = (VAL))
  59. #define pci_unmap_len(PTR, LEN_NAME) \
  60. ((PTR)->LEN_NAME)
  61. #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
  62. (((PTR)->LEN_NAME) = (VAL))
  63. #else
  64. /* No IOMMU */
  65. #define PCI_DMA_BUS_IS_PHYS 1
  66. #define pci_dac_dma_supported(pci_dev, mask) 1
  67. #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
  68. #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
  69. #define pci_unmap_addr(PTR, ADDR_NAME) (0)
  70. #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
  71. #define pci_unmap_len(PTR, LEN_NAME) (0)
  72. #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
  73. #endif
  74. #include <asm-generic/pci-dma-compat.h>
  75. static inline dma64_addr_t
  76. pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page, unsigned long offset, int direction)
  77. {
  78. return ((dma64_addr_t) page_to_phys(page) +
  79. (dma64_addr_t) offset);
  80. }
  81. static inline struct page *
  82. pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
  83. {
  84. return virt_to_page(__va(dma_addr));
  85. }
  86. static inline unsigned long
  87. pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr)
  88. {
  89. return (dma_addr & ~PAGE_MASK);
  90. }
  91. static inline void
  92. pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
  93. {
  94. }
  95. static inline void
  96. pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
  97. {
  98. flush_write_buffers();
  99. }
  100. #ifdef CONFIG_PCI
  101. static inline void pci_dma_burst_advice(struct pci_dev *pdev,
  102. enum pci_dma_burst_strategy *strat,
  103. unsigned long *strategy_parameter)
  104. {
  105. *strat = PCI_DMA_BURST_INFINITY;
  106. *strategy_parameter = ~0UL;
  107. }
  108. #endif
  109. #define HAVE_PCI_MMAP
  110. extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
  111. enum pci_mmap_state mmap_state, int write_combine);
  112. static inline void pcibios_add_platform_entries(struct pci_dev *dev)
  113. {
  114. }
  115. #endif /* __KERNEL__ */
  116. /* generic pci stuff */
  117. #ifdef CONFIG_PCI
  118. #include <asm-generic/pci.h>
  119. #endif
  120. #endif /* __x8664_PCI_H */