summaryrefslogtreecommitdiff
path: root/arch/arc/plat-arcfpga
diff options
context:
space:
mode:
authorVineet Gupta <vgupta@synopsys.com>2013-01-18 15:12:20 +0530
committerVineet Gupta <vgupta@synopsys.com>2013-02-15 23:15:54 +0530
commit1162b0701b14ba112d4e3fe5c27c694caf983539 (patch)
tree4255ede27a8c75378ec6c2e5cccc64fac7e41c0a /arch/arc/plat-arcfpga
parentfbd7053a7854b12b0fdc415089c59baabf25c625 (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.h45
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 @@
+/*
+ * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * vineetg: Feb 2009
+ * -For AA4 board, kernel to DMA address APIs
+ */
+
+/*
+ * kernel addresses are 0x800_000 based, while Bus addr are 0 based
+ */
+
+#ifndef __PLAT_DMA_ADDR_H
+#define __PLAT_DMA_ADDR_H
+
+#include <linux/device.h>
+
+static inline unsigned long plat_dma_addr_to_kernel(struct device *dev,
+ dma_addr_t dma_addr)
+{
+ return dma_addr + PAGE_OFFSET;
+}
+
+static inline dma_addr_t plat_kernel_addr_to_dma(struct device *dev, void *ptr)
+{
+ unsigned long addr = (unsigned long)ptr;
+ /*
+ * To Catch buggy drivers which can call DMA map API with kernel vaddr
+ * i.e. for buffers alloc via vmalloc or ioremap which are not
+ * gaurnateed to be PHY contiguous and hence unfit for DMA anyways.
+ * On ARC kernel virtual address is 0x7000_0000 to 0x7FFF_FFFF, so
+ * ideally we want to check this range here, but our implementation is
+ * better as it checks for even worse user virtual address as well.
+ */
+ if (likely(addr >= PAGE_OFFSET))
+ return addr - PAGE_OFFSET;
+
+ BUG();
+ return addr;
+}
+
+#endif