ARM: dts: UniPhier: add UART and USB pinmux nodes
[linux-2.6/btrfs-unstable.git] / arch / h8300 / kernel / dma.c
blobeeb13d3f2424dc4354fca2dc4048db7dc1b82486
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file COPYING in the main directory of this archive
4 * for more details.
5 */
7 #include <linux/dma-mapping.h>
8 #include <linux/kernel.h>
9 #include <linux/scatterlist.h>
10 #include <linux/module.h>
11 #include <asm/pgalloc.h>
13 static void *dma_alloc(struct device *dev, size_t size,
14 dma_addr_t *dma_handle, gfp_t gfp,
15 struct dma_attrs *attrs)
17 void *ret;
19 /* ignore region specifiers */
20 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
22 if (dev == NULL || (*dev->dma_mask < 0xffffffff))
23 gfp |= GFP_DMA;
24 ret = (void *)__get_free_pages(gfp, get_order(size));
26 if (ret != NULL) {
27 memset(ret, 0, size);
28 *dma_handle = virt_to_phys(ret);
30 return ret;
33 static void dma_free(struct device *dev, size_t size,
34 void *vaddr, dma_addr_t dma_handle,
35 struct dma_attrs *attrs)
38 free_pages((unsigned long)vaddr, get_order(size));
41 static dma_addr_t map_page(struct device *dev, struct page *page,
42 unsigned long offset, size_t size,
43 enum dma_data_direction direction,
44 struct dma_attrs *attrs)
46 return page_to_phys(page) + offset;
49 static int map_sg(struct device *dev, struct scatterlist *sgl,
50 int nents, enum dma_data_direction direction,
51 struct dma_attrs *attrs)
53 struct scatterlist *sg;
54 int i;
56 for_each_sg(sgl, sg, nents, i) {
57 sg->dma_address = sg_phys(sg);
60 return nents;
63 struct dma_map_ops h8300_dma_map_ops = {
64 .alloc = dma_alloc,
65 .free = dma_free,
66 .map_page = map_page,
67 .map_sg = map_sg,
69 EXPORT_SYMBOL(h8300_dma_map_ops);