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