[PATCH v2 3/6] nios: add dma_alloc, asm/dma.h

Marc Kleine-Budde mkl at pengutronix.de
Wed Jun 20 07:57:32 EDT 2012


This patch add dma_alloc to existing dma-mapping.h. On nios the mem is
aligned to D_ACHE_LINE_SIZE.

Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 arch/nios2/include/asm/dma-mapping.h |   10 ++++++++++
 arch/nios2/include/asm/dma.h         |    8 ++++++++
 2 files changed, 18 insertions(+)
 create mode 100644 arch/nios2/include/asm/dma.h

diff --git a/arch/nios2/include/asm/dma-mapping.h b/arch/nios2/include/asm/dma-mapping.h
index 5b70f4c..9819a97 100644
--- a/arch/nios2/include/asm/dma-mapping.h
+++ b/arch/nios2/include/asm/dma-mapping.h
@@ -1,8 +1,12 @@
 #ifndef __ASM_NIOS2_DMA_MAPPING_H
 #define __ASM_NIOS2_DMA_MAPPING_H
 
+#include <common.h>
+#include <xfuncs.h>
+
 #include <asm/cache.h>
 
+
 /* dma_alloc_coherent() return cache-line aligned allocation which is mapped
  * to uncached io region.
  *
@@ -22,4 +26,10 @@ static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
 	return (void *)(*handle | IO_REGION_BASE);
 }
 
+#define dma_alloc dma_alloc
+static inline void *dma_alloc(size_t size)
+{
+	return xmemalign(DCACHE_LINE_SIZE, ALIGN(size, DCACHE_LINE_SIZE));
+}
+
 #endif /* __ASM_NIOS2_DMA_MAPPING_H */
diff --git a/arch/nios2/include/asm/dma.h b/arch/nios2/include/asm/dma.h
new file mode 100644
index 0000000..8f709d2
--- /dev/null
+++ b/arch/nios2/include/asm/dma.h
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2012 by Marc Kleine-Budde <mkl at pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#include <asm/dma-mapping.h>
-- 
1.7.10




More information about the barebox mailing list