Merge with Linux 2.5.59.
[linux-2.6/linux-mips.git] / include / asm-arm / pci.h
blob7c690a057a206c02ef93fa23c49bc50d5374797e
1 #ifndef ASMARM_PCI_H
2 #define ASMARM_PCI_H
4 #ifdef __KERNEL__
5 #include <linux/config.h>
6 #include <linux/dma-mapping.h>
8 #include <asm/hardware.h> /* for PCIBIOS_MIN_* */
10 #ifdef CONFIG_SA1111
12 * Keep the SA1111 DMA-mapping tricks until the USB layer gets
13 * properly converted to the new DMA-mapping API, at which time
14 * most of this file can die.
16 #define SA1111_FAKE_PCIDEV ((struct pci_dev *) 1111)
17 #define pcidev_is_sa1111(dev) (dev == SA1111_FAKE_PCIDEV)
18 #else
19 #define pcidev_is_sa1111(dev) (0)
20 #endif
23 static inline void pcibios_set_master(struct pci_dev *dev)
25 /* No special bus mastering setup handling */
28 static inline void pcibios_penalize_isa_irq(int irq)
30 /* We don't do dynamic PCI IRQ allocation */
34 * The PCI address space does equal the physical memory address space.
35 * The networking and block device layers use this boolean for bounce
36 * buffer decisions.
38 #define PCI_DMA_BUS_IS_PHYS (0)
40 static inline void *
41 pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *handle)
43 int gfp = GFP_ATOMIC;
45 if (hwdev == NULL || pcidev_is_sa1111(hwdev) ||
46 hwdev->dma_mask != 0xffffffff)
47 gfp |= GFP_DMA;
49 return consistent_alloc(gfp, size, handle, 0);
52 static inline void
53 pci_free_consistent(struct pci_dev *hwdev, size_t size, void *vaddr,
54 dma_addr_t handle)
56 dma_free_coherent(hwdev ? &hwdev->dev : NULL, size, vaddr, handle);
59 static inline dma_addr_t
60 pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int dir)
62 if (pcidev_is_sa1111(hwdev))
63 return sa1111_map_single(ptr, size, dir);
65 return dma_map_single(hwdev ? &hwdev->dev : NULL, ptr, size, dir);
68 static inline void
69 pci_unmap_single(struct pci_dev *hwdev, dma_addr_t handle, size_t size, int dir)
71 if (pcidev_is_sa1111(hwdev)) {
72 sa1111_unmap_single(handle, size, dir);
73 return;
76 return dma_unmap_single(hwdev ? &hwdev->dev : NULL, handle, size, dir);
79 static inline int
80 pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int dir)
82 if (pcidev_is_sa1111(hwdev))
83 return sa1111_map_sg(sg, nents, dir);
85 return dma_map_sg(hwdev ? &hwdev->dev : NULL, sg, nents, dir);
88 static inline void
89 pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int dir)
91 if (pcidev_is_sa1111(hwdev)) {
92 sa1111_unmap_sg(sg, nents, dir);
93 return;
96 return dma_unmap_sg(hwdev ? &hwdev->dev : NULL, sg, nents, dir);
99 static inline void
100 pci_dma_sync_single(struct pci_dev *hwdev, dma_addr_t handle, size_t size, int dir)
102 if (pcidev_is_sa1111(hwdev)) {
103 sa1111_dma_sync_single(handle, size, dir);
104 return;
107 return dma_sync_single(hwdev ? &hwdev->dev : NULL, handle, size, dir);
110 static inline void
111 pci_dma_sync_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nelems, int dir)
113 if (pcidev_is_sa1111(hwdev)) {
114 sa1111_dma_sync_sg(sg, nelems, dir);
115 return;
118 return dma_sync_sg(hwdev ? &hwdev->dev : NULL, sg, nelems, dir);
121 static inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
123 return 1;
127 * We don't support DAC DMA cycles.
129 #define pci_dac_dma_supported(pci_dev, mask) (0)
132 * Return the index of the PCI controller for device PDEV.
134 #define pci_controller_num(PDEV) (0)
137 #if defined(CONFIG_SA1111) && !defined(CONFIG_PCI)
139 * SA-1111 needs these prototypes even when !defined(CONFIG_PCI)
141 * kmem_cache style wrapper around pci_alloc_consistent()
143 struct pci_pool *pci_pool_create (const char *name, struct pci_dev *dev,
144 size_t size, size_t align, size_t allocation);
145 void pci_pool_destroy (struct pci_pool *pool);
147 void *pci_pool_alloc (struct pci_pool *pool, int flags, dma_addr_t *handle);
148 void pci_pool_free (struct pci_pool *pool, void *vaddr, dma_addr_t addr);
149 #endif
152 * Whether pci_unmap_{single,page} is a nop depends upon the
153 * configuration.
155 #if defined(CONFIG_PCI) || defined(CONFIG_SA1111)
156 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME;
157 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME;
158 #define pci_unmap_addr(PTR, ADDR_NAME) ((PTR)->ADDR_NAME)
159 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) (((PTR)->ADDR_NAME) = (VAL))
160 #define pci_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME)
161 #define pci_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL))
162 #else
163 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
164 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
165 #define pci_unmap_addr(PTR, ADDR_NAME) (0)
166 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
167 #define pci_unmap_len(PTR, LEN_NAME) (0)
168 #define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
169 #endif
171 #define HAVE_PCI_MMAP
172 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
173 enum pci_mmap_state mmap_state, int write_combine);
175 #endif /* __KERNEL__ */
177 #endif