5 #include <linux/config.h>
6 #include <linux/dma-mapping.h>
8 #include <asm/hardware.h> /* for PCIBIOS_MIN_* */
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)
19 #define pcidev_is_sa1111(dev) (0)
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
38 #define PCI_DMA_BUS_IS_PHYS (0)
41 pci_alloc_consistent(struct pci_dev
*hwdev
, size_t size
, dma_addr_t
*handle
)
45 if (hwdev
== NULL
|| pcidev_is_sa1111(hwdev
) ||
46 hwdev
->dma_mask
!= 0xffffffff)
49 return consistent_alloc(gfp
, size
, handle
, 0);
53 pci_free_consistent(struct pci_dev
*hwdev
, size_t size
, void *vaddr
,
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
);
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
);
76 return dma_unmap_single(hwdev
? &hwdev
->dev
: NULL
, handle
, size
, dir
);
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
);
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
);
96 return dma_unmap_sg(hwdev
? &hwdev
->dev
: NULL
, sg
, nents
, dir
);
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
);
107 return dma_sync_single(hwdev
? &hwdev
->dev
: NULL
, handle
, size
, dir
);
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
);
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
)
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
);
152 * Whether pci_unmap_{single,page} is a nop depends upon the
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))
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)
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__ */