8 #include <linux/mm.h> /* for struct page */
10 /* Can be used to override the logic in pci_scan_bus for skipping
11 already-configured bus numbers - to be used for buggy BIOSes
12 or architectures with incomplete PCI setup by the loader */
15 extern unsigned int pcibios_assign_all_busses(void);
17 #define pcibios_assign_all_busses() 0
19 #define pcibios_scan_all_fns(a, b) 0
21 extern unsigned long pci_mem_start;
22 #define PCIBIOS_MIN_IO 0x1000
23 #define PCIBIOS_MIN_MEM (pci_mem_start)
25 #define PCIBIOS_MIN_CARDBUS_IO 0x4000
27 void pcibios_config_init(void);
28 struct pci_bus * pcibios_scan_root(int bus);
29 extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value);
30 extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value);
32 void pcibios_set_master(struct pci_dev *dev);
33 void pcibios_penalize_isa_irq(int irq, int active);
34 struct irq_routing_table *pcibios_get_irq_routing_table(void);
35 int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
37 #include <linux/types.h>
38 #include <linux/slab.h>
39 #include <asm/scatterlist.h>
40 #include <linux/string.h>
43 extern void pci_iommu_alloc(void);
44 extern int iommu_setup(char *opt);
46 /* The PCI address space does equal the physical memory
47 * address space. The networking and block device layers use
48 * this boolean for bounce buffer decisions
50 * On AMD64 it mostly equals, but we set it to zero if a hardware
51 * IOMMU (gart) of sotware IOMMU (swiotlb) is available.
53 #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
55 #if defined(CONFIG_IOMMU) || defined(CONFIG_CALGARY_IOMMU)
58 * x86-64 always supports DAC, but sometimes it is useful to force
59 * devices through the IOMMU to get automatic sg list merging.
62 extern int iommu_sac_force;
63 #define pci_dac_dma_supported(pci_dev, mask) (!iommu_sac_force)
65 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
67 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
69 #define pci_unmap_addr(PTR, ADDR_NAME) \
71 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
72 (((PTR)->ADDR_NAME) = (VAL))
73 #define pci_unmap_len(PTR, LEN_NAME) \
75 #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
76 (((PTR)->LEN_NAME) = (VAL))
78 #elif defined(CONFIG_SWIOTLB)
80 #define pci_dac_dma_supported(pci_dev, mask) 1
82 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
84 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
86 #define pci_unmap_addr(PTR, ADDR_NAME) \
88 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
89 (((PTR)->ADDR_NAME) = (VAL))
90 #define pci_unmap_len(PTR, LEN_NAME) \
92 #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
93 (((PTR)->LEN_NAME) = (VAL))
98 #define pci_dac_dma_supported(pci_dev, mask) 1
100 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
101 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
102 #define pci_unmap_addr(PTR, ADDR_NAME) (0)
103 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
104 #define pci_unmap_len(PTR, LEN_NAME) (0)
105 #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
109 #include <asm-generic/pci-dma-compat.h>
111 static inline dma64_addr_t
112 pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page, unsigned long offset, int direction)
114 return ((dma64_addr_t) page_to_phys(page) +
115 (dma64_addr_t) offset);
118 static inline struct page *
119 pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
121 return virt_to_page(__va(dma_addr));
124 static inline unsigned long
125 pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr)
127 return (dma_addr & ~PAGE_MASK);
131 pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
136 pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
138 flush_write_buffers();
142 static inline void pci_dma_burst_advice(struct pci_dev *pdev,
143 enum pci_dma_burst_strategy *strat,
144 unsigned long *strategy_parameter)
146 *strat = PCI_DMA_BURST_INFINITY;
147 *strategy_parameter = ~0UL;
151 #define HAVE_PCI_MMAP
152 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
153 enum pci_mmap_state mmap_state, int write_combine);
155 static inline void pcibios_add_platform_entries(struct pci_dev *dev)
159 #endif /* __KERNEL__ */
161 /* generic pci stuff */
163 #include <asm-generic/pci.h>
166 /* On Xen we have to scan all functions since Xen hides bridges from
167 * us. If a bridge is at fn=0 and that slot has a multifunction
168 * device, we won't find the additional devices without scanning all
170 #undef pcibios_scan_all_fns
171 #define pcibios_scan_all_fns(a, b) 1
173 #endif /* __x8664_PCI_H */