Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: merge dma-mapping.h

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

+92 -170
+92 -34
include/asm-ppc/dma-mapping.h include/asm-powerpc/dma-mapping.h
··· 1 1 /* 2 - * This is based on both include/asm-sh/dma-mapping.h and 3 - * include/asm-ppc/pci.h 2 + * Copyright (C) 2004 IBM 3 + * 4 + * Implements the generic device dma API for powerpc. 5 + * the pci and vio busses 4 6 */ 5 - #ifndef __ASM_PPC_DMA_MAPPING_H 6 - #define __ASM_PPC_DMA_MAPPING_H 7 + #ifndef _ASM_DMA_MAPPING_H 8 + #define _ASM_DMA_MAPPING_H 7 9 8 10 #include <linux/config.h> 11 + #include <linux/types.h> 12 + #include <linux/cache.h> 9 13 /* need struct page definitions */ 10 14 #include <linux/mm.h> 11 15 #include <asm/scatterlist.h> 12 16 #include <asm/io.h> 17 + #include <asm/bug.h> 18 + 19 + #define DMA_ERROR_CODE (~(dma_addr_t)0x0) 13 20 14 21 #ifdef CONFIG_NOT_COHERENT_CACHE 15 22 /* ··· 43 36 #define __dma_sync_page(pg, off, sz, rw) do { } while (0) 44 37 45 38 #endif /* ! CONFIG_NOT_COHERENT_CACHE */ 39 + 40 + #ifdef CONFIG_PPC64 41 + 42 + extern int dma_supported(struct device *dev, u64 mask); 43 + extern int dma_set_mask(struct device *dev, u64 dma_mask); 44 + extern void *dma_alloc_coherent(struct device *dev, size_t size, 45 + dma_addr_t *dma_handle, gfp_t flag); 46 + extern void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, 47 + dma_addr_t dma_handle); 48 + extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, 49 + size_t size, enum dma_data_direction direction); 50 + extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, 51 + size_t size, enum dma_data_direction direction); 52 + extern dma_addr_t dma_map_page(struct device *dev, struct page *page, 53 + unsigned long offset, size_t size, 54 + enum dma_data_direction direction); 55 + extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address, 56 + size_t size, enum dma_data_direction direction); 57 + extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 58 + enum dma_data_direction direction); 59 + extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg, 60 + int nhwentries, enum dma_data_direction direction); 61 + 62 + #else /* CONFIG_PPC64 */ 46 63 47 64 #define dma_supported(dev, mask) (1) 48 65 ··· 165 134 /* We don't do anything here. */ 166 135 #define dma_unmap_sg(dev, sg, nents, dir) do { } while (0) 167 136 168 - static inline void 169 - dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, 170 - size_t size, 171 - enum dma_data_direction direction) 137 + #endif /* CONFIG_PPC64 */ 138 + 139 + static inline void dma_sync_single_for_cpu(struct device *dev, 140 + dma_addr_t dma_handle, size_t size, 141 + enum dma_data_direction direction) 172 142 { 173 143 BUG_ON(direction == DMA_NONE); 174 - 175 144 __dma_sync(bus_to_virt(dma_handle), size, direction); 176 145 } 177 146 178 - static inline void 179 - dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, 180 - size_t size, 181 - enum dma_data_direction direction) 147 + static inline void dma_sync_single_for_device(struct device *dev, 148 + dma_addr_t dma_handle, size_t size, 149 + enum dma_data_direction direction) 182 150 { 183 151 BUG_ON(direction == DMA_NONE); 184 - 185 152 __dma_sync(bus_to_virt(dma_handle), size, direction); 186 153 } 187 154 188 - static inline void 189 - dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents, 190 - enum dma_data_direction direction) 155 + static inline void dma_sync_sg_for_cpu(struct device *dev, 156 + struct scatterlist *sg, int nents, 157 + enum dma_data_direction direction) 191 158 { 192 159 int i; 193 160 ··· 195 166 __dma_sync_page(sg->page, sg->offset, sg->length, direction); 196 167 } 197 168 198 - static inline void 199 - dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents, 200 - enum dma_data_direction direction) 169 + static inline void dma_sync_sg_for_device(struct device *dev, 170 + struct scatterlist *sg, int nents, 171 + enum dma_data_direction direction) 201 172 { 202 173 int i; 203 174 ··· 205 176 206 177 for (i = 0; i < nents; i++, sg++) 207 178 __dma_sync_page(sg->page, sg->offset, sg->length, direction); 179 + } 180 + 181 + static inline int dma_mapping_error(dma_addr_t dma_addr) 182 + { 183 + #ifdef CONFIG_PPC64 184 + return (dma_addr == DMA_ERROR_CODE); 185 + #else 186 + return 0; 187 + #endif 208 188 } 209 189 210 190 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) ··· 226 188 227 189 static inline int dma_get_cache_alignment(void) 228 190 { 191 + #ifdef CONFIG_PPC64 192 + /* no easy way to get cache size on all processors, so return 193 + * the maximum possible, to be safe */ 194 + return (1 << L1_CACHE_SHIFT_MAX); 195 + #else 229 196 /* 230 197 * Each processor family will define its own L1_CACHE_SHIFT, 231 198 * L1_CACHE_BYTES wraps to this, so this is always safe. 232 199 */ 233 200 return L1_CACHE_BYTES; 201 + #endif 234 202 } 235 203 236 - static inline void 237 - dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, 238 - unsigned long offset, size_t size, 239 - enum dma_data_direction direction) 204 + static inline void dma_sync_single_range_for_cpu(struct device *dev, 205 + dma_addr_t dma_handle, unsigned long offset, size_t size, 206 + enum dma_data_direction direction) 240 207 { 241 208 /* just sync everything for now */ 242 209 dma_sync_single_for_cpu(dev, dma_handle, offset + size, direction); 243 210 } 244 211 245 - static inline void 246 - dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle, 247 - unsigned long offset, size_t size, 248 - enum dma_data_direction direction) 212 + static inline void dma_sync_single_range_for_device(struct device *dev, 213 + dma_addr_t dma_handle, unsigned long offset, size_t size, 214 + enum dma_data_direction direction) 249 215 { 250 216 /* just sync everything for now */ 251 217 dma_sync_single_for_device(dev, dma_handle, offset + size, direction); 252 218 } 253 219 254 220 static inline void dma_cache_sync(void *vaddr, size_t size, 255 - enum dma_data_direction direction) 221 + enum dma_data_direction direction) 256 222 { 223 + BUG_ON(direction == DMA_NONE); 257 224 __dma_sync(vaddr, size, (int)direction); 258 225 } 259 226 260 - static inline int dma_mapping_error(dma_addr_t dma_addr) 261 - { 262 - return 0; 263 - } 227 + /* 228 + * DMA operations are abstracted for G5 vs. i/pSeries, PCI vs. VIO 229 + */ 230 + struct dma_mapping_ops { 231 + void * (*alloc_coherent)(struct device *dev, size_t size, 232 + dma_addr_t *dma_handle, gfp_t flag); 233 + void (*free_coherent)(struct device *dev, size_t size, 234 + void *vaddr, dma_addr_t dma_handle); 235 + dma_addr_t (*map_single)(struct device *dev, void *ptr, 236 + size_t size, enum dma_data_direction direction); 237 + void (*unmap_single)(struct device *dev, dma_addr_t dma_addr, 238 + size_t size, enum dma_data_direction direction); 239 + int (*map_sg)(struct device *dev, struct scatterlist *sg, 240 + int nents, enum dma_data_direction direction); 241 + void (*unmap_sg)(struct device *dev, struct scatterlist *sg, 242 + int nents, enum dma_data_direction direction); 243 + int (*dma_supported)(struct device *dev, u64 mask); 244 + int (*dac_dma_supported)(struct device *dev, u64 mask); 245 + }; 264 246 265 - #endif /* __ASM_PPC_DMA_MAPPING_H */ 247 + #endif /* _ASM_DMA_MAPPING_H */
-136
include/asm-ppc64/dma-mapping.h
··· 1 - /* Copyright (C) 2004 IBM 2 - * 3 - * Implements the generic device dma API for ppc64. Handles 4 - * the pci and vio busses 5 - */ 6 - 7 - #ifndef _ASM_DMA_MAPPING_H 8 - #define _ASM_DMA_MAPPING_H 9 - 10 - #include <linux/types.h> 11 - #include <linux/cache.h> 12 - /* need struct page definitions */ 13 - #include <linux/mm.h> 14 - #include <asm/scatterlist.h> 15 - #include <asm/bug.h> 16 - 17 - #define DMA_ERROR_CODE (~(dma_addr_t)0x0) 18 - 19 - extern int dma_supported(struct device *dev, u64 mask); 20 - extern int dma_set_mask(struct device *dev, u64 dma_mask); 21 - extern void *dma_alloc_coherent(struct device *dev, size_t size, 22 - dma_addr_t *dma_handle, gfp_t flag); 23 - extern void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, 24 - dma_addr_t dma_handle); 25 - extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, 26 - size_t size, enum dma_data_direction direction); 27 - extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, 28 - size_t size, enum dma_data_direction direction); 29 - extern dma_addr_t dma_map_page(struct device *dev, struct page *page, 30 - unsigned long offset, size_t size, 31 - enum dma_data_direction direction); 32 - extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address, 33 - size_t size, enum dma_data_direction direction); 34 - extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 35 - enum dma_data_direction direction); 36 - extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg, 37 - int nhwentries, enum dma_data_direction direction); 38 - 39 - static inline void 40 - dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size, 41 - enum dma_data_direction direction) 42 - { 43 - BUG_ON(direction == DMA_NONE); 44 - /* nothing to do */ 45 - } 46 - 47 - static inline void 48 - dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size, 49 - enum dma_data_direction direction) 50 - { 51 - BUG_ON(direction == DMA_NONE); 52 - /* nothing to do */ 53 - } 54 - 55 - static inline void 56 - dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, 57 - enum dma_data_direction direction) 58 - { 59 - BUG_ON(direction == DMA_NONE); 60 - /* nothing to do */ 61 - } 62 - 63 - static inline void 64 - dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems, 65 - enum dma_data_direction direction) 66 - { 67 - BUG_ON(direction == DMA_NONE); 68 - /* nothing to do */ 69 - } 70 - 71 - static inline int dma_mapping_error(dma_addr_t dma_addr) 72 - { 73 - return (dma_addr == DMA_ERROR_CODE); 74 - } 75 - 76 - /* Now for the API extensions over the pci_ one */ 77 - 78 - #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 79 - #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 80 - #define dma_is_consistent(d) (1) 81 - 82 - static inline int 83 - dma_get_cache_alignment(void) 84 - { 85 - /* no easy way to get cache size on all processors, so return 86 - * the maximum possible, to be safe */ 87 - return (1 << L1_CACHE_SHIFT_MAX); 88 - } 89 - 90 - static inline void 91 - dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, 92 - unsigned long offset, size_t size, 93 - enum dma_data_direction direction) 94 - { 95 - BUG_ON(direction == DMA_NONE); 96 - /* nothing to do */ 97 - } 98 - 99 - static inline void 100 - dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle, 101 - unsigned long offset, size_t size, 102 - enum dma_data_direction direction) 103 - { 104 - BUG_ON(direction == DMA_NONE); 105 - /* nothing to do */ 106 - } 107 - 108 - static inline void 109 - dma_cache_sync(void *vaddr, size_t size, 110 - enum dma_data_direction direction) 111 - { 112 - BUG_ON(direction == DMA_NONE); 113 - /* nothing to do */ 114 - } 115 - 116 - /* 117 - * DMA operations are abstracted for G5 vs. i/pSeries, PCI vs. VIO 118 - */ 119 - struct dma_mapping_ops { 120 - void * (*alloc_coherent)(struct device *dev, size_t size, 121 - dma_addr_t *dma_handle, gfp_t flag); 122 - void (*free_coherent)(struct device *dev, size_t size, 123 - void *vaddr, dma_addr_t dma_handle); 124 - dma_addr_t (*map_single)(struct device *dev, void *ptr, 125 - size_t size, enum dma_data_direction direction); 126 - void (*unmap_single)(struct device *dev, dma_addr_t dma_addr, 127 - size_t size, enum dma_data_direction direction); 128 - int (*map_sg)(struct device *dev, struct scatterlist *sg, 129 - int nents, enum dma_data_direction direction); 130 - void (*unmap_sg)(struct device *dev, struct scatterlist *sg, 131 - int nents, enum dma_data_direction direction); 132 - int (*dma_supported)(struct device *dev, u64 mask); 133 - int (*dac_dma_supported)(struct device *dev, u64 mask); 134 - }; 135 - 136 - #endif /* _ASM_DMA_MAPPING_H */