[MIPS] Random fixes for sb1250
[linux-2.6/verdex.git] / include / asm-sparc64 / dma-mapping.h
bloba8d39f23d43b7755023541770b35e3fa1e2c88b2
1 #ifndef _ASM_SPARC64_DMA_MAPPING_H
2 #define _ASM_SPARC64_DMA_MAPPING_H
4 #include <linux/config.h>
6 #ifdef CONFIG_PCI
8 /* we implement the API below in terms of the existing PCI one,
9 * so include it */
10 #include <linux/pci.h>
11 /* need struct page definitions */
12 #include <linux/mm.h>
14 static inline int
15 dma_supported(struct device *dev, u64 mask)
17 BUG_ON(dev->bus != &pci_bus_type);
19 return pci_dma_supported(to_pci_dev(dev), mask);
22 static inline int
23 dma_set_mask(struct device *dev, u64 dma_mask)
25 BUG_ON(dev->bus != &pci_bus_type);
27 return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
30 static inline void *
31 dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
32 gfp_t flag)
34 BUG_ON(dev->bus != &pci_bus_type);
36 return pci_iommu_ops->alloc_consistent(to_pci_dev(dev), size, dma_handle, flag);
39 static inline void
40 dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
41 dma_addr_t dma_handle)
43 BUG_ON(dev->bus != &pci_bus_type);
45 pci_free_consistent(to_pci_dev(dev), size, cpu_addr, dma_handle);
48 static inline dma_addr_t
49 dma_map_single(struct device *dev, void *cpu_addr, size_t size,
50 enum dma_data_direction direction)
52 BUG_ON(dev->bus != &pci_bus_type);
54 return pci_map_single(to_pci_dev(dev), cpu_addr, size, (int)direction);
57 static inline void
58 dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
59 enum dma_data_direction direction)
61 BUG_ON(dev->bus != &pci_bus_type);
63 pci_unmap_single(to_pci_dev(dev), dma_addr, size, (int)direction);
66 static inline dma_addr_t
67 dma_map_page(struct device *dev, struct page *page,
68 unsigned long offset, size_t size,
69 enum dma_data_direction direction)
71 BUG_ON(dev->bus != &pci_bus_type);
73 return pci_map_page(to_pci_dev(dev), page, offset, size, (int)direction);
76 static inline void
77 dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
78 enum dma_data_direction direction)
80 BUG_ON(dev->bus != &pci_bus_type);
82 pci_unmap_page(to_pci_dev(dev), dma_address, size, (int)direction);
85 static inline int
86 dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
87 enum dma_data_direction direction)
89 BUG_ON(dev->bus != &pci_bus_type);
91 return pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
94 static inline void
95 dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
96 enum dma_data_direction direction)
98 BUG_ON(dev->bus != &pci_bus_type);
100 pci_unmap_sg(to_pci_dev(dev), sg, nhwentries, (int)direction);
103 static inline void
104 dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
105 enum dma_data_direction direction)
107 BUG_ON(dev->bus != &pci_bus_type);
109 pci_dma_sync_single_for_cpu(to_pci_dev(dev), dma_handle,
110 size, (int)direction);
113 static inline void
114 dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
115 enum dma_data_direction direction)
117 BUG_ON(dev->bus != &pci_bus_type);
119 pci_dma_sync_single_for_device(to_pci_dev(dev), dma_handle,
120 size, (int)direction);
123 static inline void
124 dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
125 enum dma_data_direction direction)
127 BUG_ON(dev->bus != &pci_bus_type);
129 pci_dma_sync_sg_for_cpu(to_pci_dev(dev), sg, nelems, (int)direction);
132 static inline void
133 dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
134 enum dma_data_direction direction)
136 BUG_ON(dev->bus != &pci_bus_type);
138 pci_dma_sync_sg_for_device(to_pci_dev(dev), sg, nelems, (int)direction);
141 static inline int
142 dma_mapping_error(dma_addr_t dma_addr)
144 return pci_dma_mapping_error(dma_addr);
147 #else
149 struct device;
151 static inline void *dma_alloc_coherent(struct device *dev, size_t size,
152 dma_addr_t *dma_handle, gfp_t flag)
154 BUG();
155 return NULL;
158 static inline void dma_free_coherent(struct device *dev, size_t size,
159 void *vaddr, dma_addr_t dma_handle)
161 BUG();
164 #endif /* PCI */
166 #endif /* _ASM_SPARC64_DMA_MAPPING_H */