aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2005-11-18 09:40:46 -0500
committerStephen Rothwell <sfr@canb.auug.org.au>2005-11-18 09:48:52 -0500
commit78b09735a2f42f32c4611d92ea51755e1faae385 (patch)
tree7123a78093d45454aff1350e95457b129383366d
parent78baa2f8ad53968ff82ad9827b7793b3f46cba0e (diff)
powerpc: merge dma-mapping.h
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
-rw-r--r--include/asm-powerpc/dma-mapping.h (renamed from include/asm-ppc/dma-mapping.h)128
-rw-r--r--include/asm-ppc64/dma-mapping.h136
2 files changed, 93 insertions, 171 deletions
diff --git a/include/asm-ppc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h
index 798602620e87..59a80163f75f 100644
--- a/include/asm-ppc/dma-mapping.h
+++ b/include/asm-powerpc/dma-mapping.h
@@ -1,15 +1,22 @@
1/* 1/*
2 * This is based on both include/asm-sh/dma-mapping.h and 2 * Copyright (C) 2004 IBM
3 * include/asm-ppc/pci.h 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 7#ifndef _ASM_DMA_MAPPING_H
6#define __ASM_PPC_DMA_MAPPING_H 8#define _ASM_DMA_MAPPING_H
7 9
8#include <linux/config.h> 10#include <linux/config.h>
11#include <linux/types.h>
12#include <linux/cache.h>
9/* need struct page definitions */ 13/* need struct page definitions */
10#include <linux/mm.h> 14#include <linux/mm.h>
11#include <asm/scatterlist.h> 15#include <asm/scatterlist.h>
12#include <asm/io.h> 16#include <asm/io.h>
17#include <asm/bug.h>
18
19#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
13 20
14#ifdef CONFIG_NOT_COHERENT_CACHE 21#ifdef CONFIG_NOT_COHERENT_CACHE
15/* 22/*
@@ -37,6 +44,30 @@ extern void __dma_sync_page(struct page *page, unsigned long offset,
37 44
38#endif /* ! CONFIG_NOT_COHERENT_CACHE */ 45#endif /* ! CONFIG_NOT_COHERENT_CACHE */
39 46
47#ifdef CONFIG_PPC64
48
49extern int dma_supported(struct device *dev, u64 mask);
50extern int dma_set_mask(struct device *dev, u64 dma_mask);
51extern void *dma_alloc_coherent(struct device *dev, size_t size,
52 dma_addr_t *dma_handle, gfp_t flag);
53extern void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
54 dma_addr_t dma_handle);
55extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
56 size_t size, enum dma_data_direction direction);
57extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
58 size_t size, enum dma_data_direction direction);
59extern dma_addr_t dma_map_page(struct device *dev, struct page *page,
60 unsigned long offset, size_t size,
61 enum dma_data_direction direction);
62extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
63 size_t size, enum dma_data_direction direction);
64extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
65 enum dma_data_direction direction);
66extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
67 int nhwentries, enum dma_data_direction direction);
68
69#else /* CONFIG_PPC64 */
70
40#define dma_supported(dev, mask) (1) 71#define dma_supported(dev, mask) (1)
41 72
42static inline int dma_set_mask(struct device *dev, u64 dma_mask) 73static inline int dma_set_mask(struct device *dev, u64 dma_mask)
@@ -134,29 +165,27 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
134/* We don't do anything here. */ 165/* We don't do anything here. */
135#define dma_unmap_sg(dev, sg, nents, dir) do { } while (0) 166#define dma_unmap_sg(dev, sg, nents, dir) do { } while (0)
136 167
137static inline void 168#endif /* CONFIG_PPC64 */
138dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, 169
139 size_t size, 170static inline void dma_sync_single_for_cpu(struct device *dev,
140 enum dma_data_direction direction) 171 dma_addr_t dma_handle, size_t size,
172 enum dma_data_direction direction)
141{ 173{
142 BUG_ON(direction == DMA_NONE); 174 BUG_ON(direction == DMA_NONE);
143
144 __dma_sync(bus_to_virt(dma_handle), size, direction); 175 __dma_sync(bus_to_virt(dma_handle), size, direction);
145} 176}
146 177
147static inline void 178static inline void dma_sync_single_for_device(struct device *dev,
148dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, 179 dma_addr_t dma_handle, size_t size,
149 size_t size, 180 enum dma_data_direction direction)
150 enum dma_data_direction direction)
151{ 181{
152 BUG_ON(direction == DMA_NONE); 182 BUG_ON(direction == DMA_NONE);
153
154 __dma_sync(bus_to_virt(dma_handle), size, direction); 183 __dma_sync(bus_to_virt(dma_handle), size, direction);
155} 184}
156 185
157static inline void 186static inline void dma_sync_sg_for_cpu(struct device *dev,
158dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents, 187 struct scatterlist *sg, int nents,
159 enum dma_data_direction direction) 188 enum dma_data_direction direction)
160{ 189{
161 int i; 190 int i;
162 191
@@ -166,9 +195,9 @@ dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents,
166 __dma_sync_page(sg->page, sg->offset, sg->length, direction); 195 __dma_sync_page(sg->page, sg->offset, sg->length, direction);
167} 196}
168 197
169static inline void 198static inline void dma_sync_sg_for_device(struct device *dev,
170dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents, 199 struct scatterlist *sg, int nents,
171 enum dma_data_direction direction) 200 enum dma_data_direction direction)
172{ 201{
173 int i; 202 int i;
174 203
@@ -178,6 +207,15 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents,
178 __dma_sync_page(sg->page, sg->offset, sg->length, direction); 207 __dma_sync_page(sg->page, sg->offset, sg->length, direction);
179} 208}
180 209
210static inline int dma_mapping_error(dma_addr_t dma_addr)
211{
212#ifdef CONFIG_PPC64
213 return (dma_addr == DMA_ERROR_CODE);
214#else
215 return 0;
216#endif
217}
218
181#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 219#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
182#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 220#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
183#ifdef CONFIG_NOT_COHERENT_CACHE 221#ifdef CONFIG_NOT_COHERENT_CACHE
@@ -188,40 +226,60 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents,
188 226
189static inline int dma_get_cache_alignment(void) 227static inline int dma_get_cache_alignment(void)
190{ 228{
229#ifdef CONFIG_PPC64
230 /* no easy way to get cache size on all processors, so return
231 * the maximum possible, to be safe */
232 return (1 << L1_CACHE_SHIFT_MAX);
233#else
191 /* 234 /*
192 * Each processor family will define its own L1_CACHE_SHIFT, 235 * Each processor family will define its own L1_CACHE_SHIFT,
193 * L1_CACHE_BYTES wraps to this, so this is always safe. 236 * L1_CACHE_BYTES wraps to this, so this is always safe.
194 */ 237 */
195 return L1_CACHE_BYTES; 238 return L1_CACHE_BYTES;
239#endif
196} 240}
197 241
198static inline void 242static inline void dma_sync_single_range_for_cpu(struct device *dev,
199dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, 243 dma_addr_t dma_handle, unsigned long offset, size_t size,
200 unsigned long offset, size_t size, 244 enum dma_data_direction direction)
201 enum dma_data_direction direction)
202{ 245{
203 /* just sync everything for now */ 246 /* just sync everything for now */
204 dma_sync_single_for_cpu(dev, dma_handle, offset + size, direction); 247 dma_sync_single_for_cpu(dev, dma_handle, offset + size, direction);
205} 248}
206 249
207static inline void 250static inline void dma_sync_single_range_for_device(struct device *dev,
208dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle, 251 dma_addr_t dma_handle, unsigned long offset, size_t size,
209 unsigned long offset, size_t size, 252 enum dma_data_direction direction)
210 enum dma_data_direction direction)
211{ 253{
212 /* just sync everything for now */ 254 /* just sync everything for now */
213 dma_sync_single_for_device(dev, dma_handle, offset + size, direction); 255 dma_sync_single_for_device(dev, dma_handle, offset + size, direction);