blob: 8140e053ccd351332f33d3df8decccfdeb86074b [file] [log] [blame]
GuanXuetao10c9c102011-01-15 18:18:29 +08001/*
2 * linux/arch/unicore32/include/asm/dma-mapping.h
3 *
4 * Code specific to PKUnity SoC and UniCore ISA
5 *
6 * Copyright (C) 2001-2010 GUAN Xue-tao
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#ifndef __UNICORE_DMA_MAPPING_H__
13#define __UNICORE_DMA_MAPPING_H__
14
15#ifdef __KERNEL__
16
17#include <linux/mm_types.h>
18#include <linux/scatterlist.h>
19#include <linux/swiotlb.h>
20
GuanXuetao10c9c102011-01-15 18:18:29 +080021#include <asm/memory.h>
22#include <asm/cacheflush.h>
23
24extern struct dma_map_ops swiotlb_dma_map_ops;
25
26static inline struct dma_map_ops *get_dma_ops(struct device *dev)
27{
28 return &swiotlb_dma_map_ops;
29}
30
GuanXuetao10c9c102011-01-15 18:18:29 +080031#include <asm-generic/dma-mapping-common.h>
32
33static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
34{
35 if (dev && dev->dma_mask)
36 return addr + size - 1 <= *dev->dma_mask;
37
38 return 1;
39}
40
41static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
42{
43 return paddr;
44}
45
46static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
47{
48 return daddr;
49}
50
51static inline void dma_mark_clean(void *addr, size_t size) {}
52
GuanXuetao10c9c102011-01-15 18:18:29 +080053static inline void dma_cache_sync(struct device *dev, void *vaddr,
54 size_t size, enum dma_data_direction direction)
55{
56 unsigned long start = (unsigned long)vaddr;
57 unsigned long end = start + size;
58
59 switch (direction) {
60 case DMA_NONE:
61 BUG();
62 case DMA_FROM_DEVICE:
63 case DMA_BIDIRECTIONAL: /* writeback and invalidate */
64 __cpuc_dma_flush_range(start, end);
65 break;
66 case DMA_TO_DEVICE: /* writeback only */
67 __cpuc_dma_clean_range(start, end);
68 break;
69 }
70}
71
72#endif /* __KERNEL__ */
73#endif