Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __x8664_PCI_H |
| 2 | #define __x8664_PCI_H |
| 3 | |
| 4 | #include <linux/config.h> |
| 5 | #include <asm/io.h> |
| 6 | |
| 7 | #ifdef __KERNEL__ |
| 8 | |
| 9 | #include <linux/mm.h> /* for struct page */ |
| 10 | |
| 11 | /* Can be used to override the logic in pci_scan_bus for skipping |
| 12 | already-configured bus numbers - to be used for buggy BIOSes |
| 13 | or architectures with incomplete PCI setup by the loader */ |
| 14 | |
| 15 | #ifdef CONFIG_PCI |
| 16 | extern unsigned int pcibios_assign_all_busses(void); |
| 17 | #else |
| 18 | #define pcibios_assign_all_busses() 0 |
| 19 | #endif |
| 20 | #define pcibios_scan_all_fns(a, b) 0 |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | extern unsigned long pci_mem_start; |
Linus Torvalds | 2ba8468 | 2005-08-14 18:21:30 -0700 | [diff] [blame] | 23 | #define PCIBIOS_MIN_IO 0x1000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #define PCIBIOS_MIN_MEM (pci_mem_start) |
| 25 | |
Linus Torvalds | 2ba8468 | 2005-08-14 18:21:30 -0700 | [diff] [blame] | 26 | #define PCIBIOS_MIN_CARDBUS_IO 0x4000 |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | void pcibios_config_init(void); |
| 29 | struct pci_bus * pcibios_scan_root(int bus); |
| 30 | extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value); |
| 31 | extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value); |
| 32 | |
| 33 | void pcibios_set_master(struct pci_dev *dev); |
David Shaohua Li | c9c3e45 | 2005-04-01 00:07:31 -0500 | [diff] [blame] | 34 | void pcibios_penalize_isa_irq(int irq, int active); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | struct irq_routing_table *pcibios_get_irq_routing_table(void); |
| 36 | int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq); |
| 37 | |
| 38 | #include <linux/types.h> |
| 39 | #include <linux/slab.h> |
| 40 | #include <asm/scatterlist.h> |
| 41 | #include <linux/string.h> |
| 42 | #include <asm/page.h> |
Muli Ben-Yehuda | 17a941d | 2006-01-11 22:44:42 +0100 | [diff] [blame] | 43 | #include <linux/dma-mapping.h> /* for have_iommu */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | extern int iommu_setup(char *opt); |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | /* The PCI address space does equal the physical memory |
| 48 | * address space. The networking and block device layers use |
| 49 | * this boolean for bounce buffer decisions |
| 50 | * |
Muli Ben-Yehuda | 17a941d | 2006-01-11 22:44:42 +0100 | [diff] [blame] | 51 | * On AMD64 it mostly equals, but we set it to zero if a hardware |
| 52 | * IOMMU (gart) of sotware IOMMU (swiotlb) is available. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | */ |
Muli Ben-Yehuda | 17a941d | 2006-01-11 22:44:42 +0100 | [diff] [blame] | 54 | #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) |
| 55 | |
| 56 | #ifdef CONFIG_GART_IOMMU |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | /* |
| 59 | * x86-64 always supports DAC, but sometimes it is useful to force |
| 60 | * devices through the IOMMU to get automatic sg list merging. |
| 61 | * Optional right now. |
| 62 | */ |
| 63 | extern int iommu_sac_force; |
| 64 | #define pci_dac_dma_supported(pci_dev, mask) (!iommu_sac_force) |
| 65 | |
| 66 | #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ |
| 67 | dma_addr_t ADDR_NAME; |
| 68 | #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \ |
| 69 | __u32 LEN_NAME; |
| 70 | #define pci_unmap_addr(PTR, ADDR_NAME) \ |
| 71 | ((PTR)->ADDR_NAME) |
| 72 | #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \ |
| 73 | (((PTR)->ADDR_NAME) = (VAL)) |
| 74 | #define pci_unmap_len(PTR, LEN_NAME) \ |
| 75 | ((PTR)->LEN_NAME) |
| 76 | #define pci_unmap_len_set(PTR, LEN_NAME, VAL) \ |
| 77 | (((PTR)->LEN_NAME) = (VAL)) |
| 78 | |
| 79 | #else |
| 80 | /* No IOMMU */ |
| 81 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #define pci_dac_dma_supported(pci_dev, mask) 1 |
| 83 | |
| 84 | #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) |
| 85 | #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) |
| 86 | #define pci_unmap_addr(PTR, ADDR_NAME) (0) |
| 87 | #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0) |
| 88 | #define pci_unmap_len(PTR, LEN_NAME) (0) |
| 89 | #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) |
| 90 | |
| 91 | #endif |
| 92 | |
| 93 | #include <asm-generic/pci-dma-compat.h> |
| 94 | |
| 95 | static inline dma64_addr_t |
| 96 | pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page, unsigned long offset, int direction) |
| 97 | { |
| 98 | return ((dma64_addr_t) page_to_phys(page) + |
| 99 | (dma64_addr_t) offset); |
| 100 | } |
| 101 | |
| 102 | static inline struct page * |
| 103 | pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr) |
| 104 | { |
| 105 | return virt_to_page(__va(dma_addr)); |
| 106 | } |
| 107 | |
| 108 | static inline unsigned long |
| 109 | pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr) |
| 110 | { |
| 111 | return (dma_addr & ~PAGE_MASK); |
| 112 | } |
| 113 | |
| 114 | static inline void |
| 115 | pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction) |
| 116 | { |
| 117 | } |
| 118 | |
| 119 | static inline void |
| 120 | pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction) |
| 121 | { |
| 122 | flush_write_buffers(); |
| 123 | } |
| 124 | |
Andrew Morton | bb4a61b | 2005-06-06 23:07:46 -0700 | [diff] [blame] | 125 | #ifdef CONFIG_PCI |
David S. Miller | e24c2d9 | 2005-06-02 12:55:50 -0700 | [diff] [blame] | 126 | static inline void pci_dma_burst_advice(struct pci_dev *pdev, |
| 127 | enum pci_dma_burst_strategy *strat, |
| 128 | unsigned long *strategy_parameter) |
| 129 | { |
| 130 | *strat = PCI_DMA_BURST_INFINITY; |
| 131 | *strategy_parameter = ~0UL; |
| 132 | } |
Andrew Morton | bb4a61b | 2005-06-06 23:07:46 -0700 | [diff] [blame] | 133 | #endif |
David S. Miller | e24c2d9 | 2005-06-02 12:55:50 -0700 | [diff] [blame] | 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | #define HAVE_PCI_MMAP |
| 136 | extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, |
| 137 | enum pci_mmap_state mmap_state, int write_combine); |
| 138 | |
| 139 | static inline void pcibios_add_platform_entries(struct pci_dev *dev) |
| 140 | { |
| 141 | } |
| 142 | |
| 143 | #endif /* __KERNEL__ */ |
| 144 | |
| 145 | /* generic pci stuff */ |
| 146 | #ifdef CONFIG_PCI |
| 147 | #include <asm-generic/pci.h> |
| 148 | #endif |
| 149 | |
| 150 | #endif /* __x8664_PCI_H */ |