diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2013-01-18 04:42:20 -0500 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2013-02-15 12:45:54 -0500 |
commit | 1162b0701b14ba112d4e3fe5c27c694caf983539 (patch) | |
tree | 4255ede27a8c75378ec6c2e5cccc64fac7e41c0a /arch/arc/plat-arcfpga | |
parent | fbd7053a7854b12b0fdc415089c59baabf25c625 (diff) |
ARC: I/O and DMA Mappings
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'arch/arc/plat-arcfpga')
-rw-r--r-- | arch/arc/plat-arcfpga/include/plat/dma_addr.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/arch/arc/plat-arcfpga/include/plat/dma_addr.h b/arch/arc/plat-arcfpga/include/plat/dma_addr.h new file mode 100644 index 000000000000..0e963431b729 --- /dev/null +++ b/arch/arc/plat-arcfpga/include/plat/dma_addr.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * vineetg: Feb 2009 | ||
9 | * -For AA4 board, kernel to DMA address APIs | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * kernel addresses are 0x800_000 based, while Bus addr are 0 based | ||
14 | */ | ||
15 | |||
16 | #ifndef __PLAT_DMA_ADDR_H | ||
17 | #define __PLAT_DMA_ADDR_H | ||
18 | |||
19 | #include <linux/device.h> | ||
20 | |||
21 | static inline unsigned long plat_dma_addr_to_kernel(struct device *dev, | ||
22 | dma_addr_t dma_addr) | ||
23 | { | ||
24 | return dma_addr + PAGE_OFFSET; | ||
25 | } | ||
26 | |||
27 | static inline dma_addr_t plat_kernel_addr_to_dma(struct device *dev, void *ptr) | ||
28 | { | ||
29 | unsigned long addr = (unsigned long)ptr; | ||
30 | /* | ||
31 | * To Catch buggy drivers which can call DMA map API with kernel vaddr | ||
32 | * i.e. for buffers alloc via vmalloc or ioremap which are not | ||
33 | * gaurnateed to be PHY contiguous and hence unfit for DMA anyways. | ||
34 | * On ARC kernel virtual address is 0x7000_0000 to 0x7FFF_FFFF, so | ||
35 | * ideally we want to check this range here, but our implementation is | ||
36 | * better as it checks for even worse user virtual address as well. | ||
37 | */ | ||
38 | if (likely(addr >= PAGE_OFFSET)) | ||
39 | return addr - PAGE_OFFSET; | ||
40 | |||
41 | BUG(); | ||
42 | return addr; | ||
43 | } | ||
44 | |||
45 | #endif | ||