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
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
,
19 /* ignore region specifiers */
20 gfp
&= ~(__GFP_DMA
| __GFP_HIGHMEM
);
22 if (dev
== NULL
|| (*dev
->dma_mask
< 0xffffffff))
24 ret
= (void *)__get_free_pages(gfp
, get_order(size
));
28 *dma_handle
= virt_to_phys(ret
);
33 static void dma_free(struct device
*dev
, size_t size
,
34 void *vaddr
, dma_addr_t dma_handle
,
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
,
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
,
53 struct scatterlist
*sg
;
56 for_each_sg(sgl
, sg
, nents
, i
) {
57 sg
->dma_address
= sg_phys(sg
);
63 const struct dma_map_ops h8300_dma_map_ops
= {
69 EXPORT_SYMBOL(h8300_dma_map_ops
);