aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/include
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2009-05-14 12:23:11 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-16 07:56:47 -0400
commitd69864158e24f323e818403c6b89ad4871aea6f6 (patch)
tree2fe0ec981c9bc96b5195956defd1b5989aa694a5 /arch/sparc/include
parent797a75686528e9f6f9bfee2a719a00b47868c999 (diff)
sparc: remove dma-mapping_{32|64}.h
This modifies SPARC32 to use struct dma_map ops. It means that we can remove dma-mapping_{32|64}.h. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Tested-by: Robert Reif <reif@earthlink.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/include')
-rw-r--r--arch/sparc/include/asm/dma-mapping.h148
-rw-r--r--arch/sparc/include/asm/dma-mapping_32.h42
-rw-r--r--arch/sparc/include/asm/dma-mapping_64.h121
3 files changed, 132 insertions, 179 deletions
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 8c911ea9ee5f..204e4bf64438 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -1,33 +1,134 @@
1#ifndef ___ASM_SPARC_DMA_MAPPING_H 1#ifndef ___ASM_SPARC_DMA_MAPPING_H
2#define ___ASM_SPARC_DMA_MAPPING_H 2#define ___ASM_SPARC_DMA_MAPPING_H
3#if defined(__sparc__) && defined(__arch64__) 3
4#include <asm/dma-mapping_64.h> 4#include <linux/scatterlist.h>
5#else 5#include <linux/mm.h>
6#include <asm/dma-mapping_32.h>
7#endif
8 6
9#define DMA_ERROR_CODE (~(dma_addr_t)0x0) 7#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
10 8
11extern int dma_supported(struct device *dev, u64 mask); 9extern int dma_supported(struct device *dev, u64 mask);
12extern int dma_set_mask(struct device *dev, u64 dma_mask); 10extern int dma_set_mask(struct device *dev, u64 dma_mask);
13 11
14static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) 12#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
13#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
14#define dma_is_consistent(d, h) (1)
15
16struct dma_ops {
17 void *(*alloc_coherent)(struct device *dev, size_t size,
18 dma_addr_t *dma_handle, gfp_t flag);
19 void (*free_coherent)(struct device *dev, size_t size,
20 void *cpu_addr, dma_addr_t dma_handle);
21 dma_addr_t (*map_page)(struct device *dev, struct page *page,
22 unsigned long offset, size_t size,
23 enum dma_data_direction direction);
24 void (*unmap_page)(struct device *dev, dma_addr_t dma_addr,
25 size_t size,
26 enum dma_data_direction direction);
27 int (*map_sg)(struct device *dev, struct scatterlist *sg, int nents,
28 enum dma_data_direction direction);
29 void (*unmap_sg)(struct device *dev, struct scatterlist *sg,
30 int nhwentries,
31 enum dma_data_direction direction);
32 void (*sync_single_for_cpu)(struct device *dev,
33 dma_addr_t dma_handle, size_t size,
34 enum dma_data_direction direction);
35 void (*sync_single_for_device)(struct device *dev,
36 dma_addr_t dma_handle, size_t size,
37 enum dma_data_direction direction);
38 void (*sync_sg_for_cpu)(struct device *dev, struct scatterlist *sg,
39 int nelems,
40 enum dma_data_direction direction);
41 void (*sync_sg_for_device)(struct device *dev,
42 struct scatterlist *sg, int nents,
43 enum dma_data_direction dir);
44};
45extern const struct dma_ops *dma_ops;
46
47static inline void *dma_alloc_coherent(struct device *dev, size_t size,
48 dma_addr_t *dma_handle, gfp_t flag)
15{ 49{
16 return (dma_addr == DMA_ERROR_CODE); 50 return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
17} 51}
18 52
19static inline int dma_get_cache_alignment(void) 53static inline void dma_free_coherent(struct device *dev, size_t size,
54 void *cpu_addr, dma_addr_t dma_handle)
20{ 55{
21 /* 56 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
22 * no easy way to get cache size on all processors, so return
23 * the maximum possible, to be safe
24 */
25 return (1 << INTERNODE_CACHE_SHIFT);
26} 57}
27 58
28#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 59static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
29#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 60 size_t size,
30#define dma_is_consistent(d, h) (1) 61 enum dma_data_direction direction)
62{
63 return dma_ops->map_page(dev, virt_to_page(cpu_addr),
64 (unsigned long)cpu_addr & ~PAGE_MASK, size,
65 direction);
66}
67
68static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
69 size_t size,
70 enum dma_data_direction direction)
71{
72 dma_ops->unmap_page(dev, dma_addr, size, direction);
73}
74
75static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
76 unsigned long offset, size_t size,
77 enum dma_data_direction direction)
78{
79 return dma_ops->map_page(dev, page, offset, size, direction);
80}
81
82static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
83 size_t size,
84 enum dma_data_direction direction)
85{
86 dma_ops->unmap_page(dev, dma_address, size, direction);
87}
88
89static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
90 int nents, enum dma_data_direction direction)
91{
92 return dma_ops->map_sg(dev, sg, nents, direction);
93}
94
95static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
96 int nents, enum dma_data_direction direction)
97{
98 dma_ops->unmap_sg(dev, sg, nents, direction);
99}
100
101static inline void dma_sync_single_for_cpu(struct device *dev,
102 dma_addr_t dma_handle, size_t size,
103 enum dma_data_direction direction)
104{
105 dma_ops->sync_single_for_cpu(dev, dma_handle, size, direction);
106}
107
108static inline void dma_sync_single_for_device(struct device *dev,
109 dma_addr_t dma_handle,
110 size_t size,
111 enum dma_data_direction direction)
112{
113 if (dma_ops->sync_single_for_device)
114 dma_ops->sync_single_for_device(dev, dma_handle, size,
115 direction);
116}
117
118static inline void dma_sync_sg_for_cpu(struct device *dev,
119 struct scatterlist *sg, int nelems,
120 enum dma_data_direction direction)
121{
122 dma_ops->sync_sg_for_cpu(dev, sg, nelems, direction);
123}
124
125static inline void dma_sync_sg_for_device(struct device *dev,
126 struct scatterlist *sg, int nelems,
127 enum dma_data_direction direction)
128{
129 if (dma_ops->sync_sg_for_device)
130 dma_ops->sync_sg_for_device(dev, sg, nelems, direction);
131}
31 132
32static inline void dma_sync_single_range_for_cpu(struct device *dev, 133static inline void dma_sync_single_range_for_cpu(struct device *dev,
33 dma_addr_t dma_handle, 134 dma_addr_t dma_handle,
@@ -47,4 +148,19 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
47 dma_sync_single_for_device(dev, dma_handle+offset, size, dir); 148 dma_sync_single_for_device(dev, dma_handle+offset, size, dir);
48} 149}
49 150
151
152static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
153{
154 return (dma_addr == DMA_ERROR_CODE);
155}
156
157static inline int dma_get_cache_alignment(void)
158{
159 /*
160 * no easy way to get cache size on all processors, so return
161 * the maximum possible, to be safe
162 */
163 return (1 << INTERNODE_CACHE_SHIFT);
164}
165
50#endif 166#endif
diff --git a/arch/sparc/include/asm/dma-mapping_32.h b/arch/sparc/include/asm/dma-mapping_32.h
deleted file mode 100644
index 7f09c85103a5..000000000000
--- a/arch/sparc/include/asm/dma-mapping_32.h
+++ /dev/null
@@ -1,42 +0,0 @@
1#ifndef _ASM_SPARC_DMA_MAPPING_H
2#define _ASM_SPARC_DMA_MAPPING_H
3
4#include <linux/types.h>
5
6struct device;
7struct scatterlist;
8struct page;
9
10extern void *dma_alloc_coherent(struct device *dev, size_t size,
11 dma_addr_t *dma_handle, gfp_t flag);
12extern void dma_free_coherent(struct device *dev, size_t size,
13 void *cpu_addr, dma_addr_t dma_handle);
14extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
15 size_t size,
16 enum dma_data_direction direction);
17extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
18 size_t size,
19 enum dma_data_direction direction);
20extern dma_addr_t dma_map_page(struct device *dev, struct page *page,
21 unsigned long offset, size_t size,
22 enum dma_data_direction direction);
23extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
24 size_t size, enum dma_data_direction direction);
25extern int dma_map_sg(struct device *dev, struct scatterlist *sg,
26 int nents, enum dma_data_direction direction);
27extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
28 int nents, enum dma_data_direction direction);
29extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
30 size_t size,
31 enum dma_data_direction direction);
32extern void dma_sync_single_for_device(struct device *dev,
33 dma_addr_t dma_handle,
34 size_t size,
35 enum dma_data_direction direction);
36extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
37 int nelems, enum dma_data_direction direction);
38extern void dma_sync_sg_for_device(struct device *dev,
39 struct scatterlist *sg, int nelems,
40 enum dma_data_direction direction);
41
42#endif /* _ASM_SPARC_DMA_MAPPING_H */
diff --git a/arch/sparc/include/asm/dma-mapping_64.h b/arch/sparc/include/asm/dma-mapping_64.h
deleted file mode 100644
index 579757e00a25..000000000000
--- a/arch/sparc/include/asm/dma-mapping_64.h
+++ /dev/null
@@ -1,121 +0,0 @@
1#ifndef _ASM_SPARC64_DMA_MAPPING_H
2#define _ASM_SPARC64_DMA_MAPPING_H
3
4#include <linux/scatterlist.h>
5#include <linux/mm.h>
6
7struct dma_ops {
8 void *(*alloc_coherent)(struct device *dev, size_t size,
9 dma_addr_t *dma_handle, gfp_t flag);
10 void (*free_coherent)(struct device *dev, size_t size,
11 void *cpu_addr, dma_addr_t dma_handle);
12 dma_addr_t (*map_page)(struct device *dev, struct page *page,
13 unsigned long offset, size_t size,
14 enum dma_data_direction direction);
15 void (*unmap_page)(struct device *dev, dma_addr_t dma_addr,
16 size_t size,
17 enum dma_data_direction direction);
18 int (*map_sg)(struct device *dev, struct scatterlist *sg, int nents,
19 enum dma_data_direction direction);
20 void (*unmap_sg)(struct device *dev, struct scatterlist *sg,
21 int nhwentries,
22 enum dma_data_direction direction);
23 void (*sync_single_for_cpu)(struct device *dev,
24 dma_addr_t dma_handle, size_t size,
25 enum dma_data_direction direction);
26 void (*sync_single_for_device)(struct device *dev,
27 dma_addr_t dma_handle, size_t size,
28 enum dma_data_direction direction);
29 void (*sync_sg_for_cpu)(struct device *dev, struct scatterlist *sg,
30 int nelems,
31 enum dma_data_direction direction);
32 void (*sync_sg_for_device)(struct device *dev,
33 struct scatterlist *sg, int nents,
34 enum dma_data_direction dir);
35};
36extern const struct dma_ops *dma_ops;
37
38static inline void *dma_alloc_coherent(struct device *dev, size_t size,
39 dma_addr_t *dma_handle, gfp_t flag)
40{
41 return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
42}
43
44static inline void dma_free_coherent(struct device *dev, size_t size,
45 void *cpu_addr, dma_addr_t dma_handle)
46{
47 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
48}
49
50static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
51 size_t size,
52 enum dma_data_direction direction)
53{
54 return dma_ops->map_page(dev, virt_to_page(cpu_addr),
55 (unsigned long)cpu_addr & ~PAGE_MASK, size,
56 direction);
57}
58
59static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
60 size_t size,
61 enum dma_data_direction direction)
62{
63 dma_ops->unmap_page(dev, dma_addr, size, direction);
64}
65
66static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
67 unsigned long offset, size_t size,
68 enum dma_data_direction direction)
69{
70 return dma_ops->map_page(dev, page, offset, size, direction);
71}
72
73static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
74 size_t size,
75 enum dma_data_direction direction)
76{
77 dma_ops->unmap_page(dev, dma_address, size, direction);
78}
79
80static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
81 int nents, enum dma_data_direction direction)
82{
83 return dma_ops->map_sg(dev, sg, nents, direction);
84}
85
86static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
87 int nents, enum dma_data_direction direction)
88{
89 dma_ops->unmap_sg(dev, sg, nents, direction);
90}
91
92static inline void dma_sync_single_for_cpu(struct device *dev,
93 dma_addr_t dma_handle, size_t size,
94 enum dma_data_direction direction)
95{
96 dma_ops->sync_single_for_cpu(dev, dma_handle, size, direction);
97}
98
99static inline void dma_sync_single_for_device(struct device *dev,
100 dma_addr_t dma_handle,
101 size_t size,
102 enum dma_data_direction direction)
103{
104 /* No flushing needed to sync cpu writes to the device. */
105}
106
107static inline void dma_sync_sg_for_cpu(struct device *dev,
108 struct scatterlist *sg, int nelems,
109 enum dma_data_direction direction)
110{
111 dma_ops->sync_sg_for_cpu(dev, sg, nelems, direction);
112}
113
114static inline void dma_sync_sg_for_device(struct device *dev,
115 struct scatterlist *sg, int nelems,
116 enum dma_data_direction direction)
117{
118 /* No flushing needed to sync cpu writes to the device. */
119}
120
121#endif /* _ASM_SPARC64_DMA_MAPPING_H */