blob: da8ef8e8f842733751a33985879e07057e6af523 [file] [log] [blame]
Mikael Starvik59c61132005-07-27 11:44:40 -07001/* DMA mapping. Nothing tricky here, just virt_to_phys */
2
Linus Torvalds1da177e2005-04-16 15:20:36 -07003#ifndef _ASM_CRIS_DMA_MAPPING_H
4#define _ASM_CRIS_DMA_MAPPING_H
5
Mikael Starvik59c61132005-07-27 11:44:40 -07006#include <linux/mm.h>
7#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Mikael Starvik59c61132005-07-27 11:44:40 -07009#include <asm/cache.h>
10#include <asm/io.h>
11#include <asm/scatterlist.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Mikael Starvik59c61132005-07-27 11:44:40 -070013#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
14#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
Mikael Starvik59c61132005-07-27 11:44:40 -070016#ifdef CONFIG_PCI
Dmitry Baryshkov8fa8b9f2008-07-20 15:00:32 +040017#include <asm-generic/dma-coherent.h>
18
Mikael Starvik59c61132005-07-27 11:44:40 -070019void *dma_alloc_coherent(struct device *dev, size_t size,
Al Viro43b7eae2005-10-21 03:21:13 -040020 dma_addr_t *dma_handle, gfp_t flag);
Mikael Starvik59c61132005-07-27 11:44:40 -070021
22void dma_free_coherent(struct device *dev, size_t size,
23 void *vaddr, dma_addr_t dma_handle);
24#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070025static inline void *
26dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
Al Viro43b7eae2005-10-21 03:21:13 -040027 gfp_t flag)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028{
Mikael Starvik59c61132005-07-27 11:44:40 -070029 BUG();
30 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031}
32
33static inline void
34dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
Mikael Starvik59c61132005-07-27 11:44:40 -070035 dma_addr_t dma_handle)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036{
Mikael Starvik59c61132005-07-27 11:44:40 -070037 BUG();
Linus Torvalds1da177e2005-04-16 15:20:36 -070038}
Mikael Starvik59c61132005-07-27 11:44:40 -070039#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070040static inline dma_addr_t
Mikael Starvik59c61132005-07-27 11:44:40 -070041dma_map_single(struct device *dev, void *ptr, size_t size,
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 enum dma_data_direction direction)
43{
Mikael Starvik59c61132005-07-27 11:44:40 -070044 BUG_ON(direction == DMA_NONE);
45 return virt_to_phys(ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046}
47
48static inline void
49dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
50 enum dma_data_direction direction)
51{
Mikael Starvik59c61132005-07-27 11:44:40 -070052 BUG_ON(direction == DMA_NONE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053}
54
55static inline int
56dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
57 enum dma_data_direction direction)
58{
Mikael Starvik59c61132005-07-27 11:44:40 -070059 printk("Map sg\n");
60 return nents;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061}
62
Mikael Starvik59c61132005-07-27 11:44:40 -070063static inline dma_addr_t
64dma_map_page(struct device *dev, struct page *page, unsigned long offset,
65 size_t size, enum dma_data_direction direction)
66{
67 BUG_ON(direction == DMA_NONE);
68 return page_to_phys(page) + offset;
69}
70
71static inline void
72dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
73 enum dma_data_direction direction)
74{
75 BUG_ON(direction == DMA_NONE);
76}
77
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079static inline void
80dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
81 enum dma_data_direction direction)
82{
Mikael Starvik59c61132005-07-27 11:44:40 -070083 BUG_ON(direction == DMA_NONE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084}
85
86static inline void
Mikael Starvik59c61132005-07-27 11:44:40 -070087dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
88 enum dma_data_direction direction)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089{
Linus Torvalds1da177e2005-04-16 15:20:36 -070090}
91
92static inline void
Mikael Starvik59c61132005-07-27 11:44:40 -070093dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
94 enum dma_data_direction direction)
Linus Torvalds1da177e2005-04-16 15:20:36 -070095{
Linus Torvalds1da177e2005-04-16 15:20:36 -070096}
97
Mikael Starvik59c61132005-07-27 11:44:40 -070098static inline void
99dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
100 unsigned long offset, size_t size,
101 enum dma_data_direction direction)
102{
103}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Mikael Starvik59c61132005-07-27 11:44:40 -0700105static inline void
106dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
107 unsigned long offset, size_t size,
108 enum dma_data_direction direction)
109{
110}
111
112static inline void
113dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
114 enum dma_data_direction direction)
115{
116}
117
118static inline void
119dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
120 enum dma_data_direction direction)
121{
122}
123
124static inline int
FUJITA Tomonori8d8bb392008-07-25 19:44:49 -0700125dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
Mikael Starvik59c61132005-07-27 11:44:40 -0700126{
127 return 0;
128}
129
130static inline int
131dma_supported(struct device *dev, u64 mask)
132{
133 /*
134 * we fall back to GFP_DMA when the mask isn't all 1s,
135 * so we can't guarantee allocations that must be
136 * within a tighter range than GFP_DMA..
137 */
138 if(mask < 0x00ffffff)
139 return 0;
140
141 return 1;
142}
143
144static inline int
145dma_set_mask(struct device *dev, u64 mask)
146{
147 if(!dev->dma_mask || !dma_supported(dev, mask))
148 return -EIO;
149
150 *dev->dma_mask = mask;
151
152 return 0;
153}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
155static inline int
156dma_get_cache_alignment(void)
157{
Ravikiran G Thirumalai1fd73c62006-01-08 01:01:28 -0800158 return (1 << INTERNODE_CACHE_SHIFT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159}
160
Ralf Baechlef67637e2006-12-06 20:38:54 -0800161#define dma_is_consistent(d, h) (1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163static inline void
Ralf Baechled3fa72e2006-12-06 20:38:56 -0800164dma_cache_sync(struct device *dev, void *vaddr, size_t size,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 enum dma_data_direction direction)
166{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167}
168
Mikael Starvik59c61132005-07-27 11:44:40 -0700169
170#endif