summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-06-02 10:54:01 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-06-03 10:03:33 +0200
commitb4d56cdc55bc3c2a5ba31ffec162cc6f8334e0ff (patch)
tree656a9aef03a4c0701265f5cad31b4eeb7f349883
parent14c86b1a71c175556126f9612cf910697f29209f (diff)
downloadbarebox-b4d56cdc55bc3c2a5ba31ffec162cc6f8334e0ff.tar.gz
barebox-b4d56cdc55bc3c2a5ba31ffec162cc6f8334e0ff.tar.xz
sandbox: asm: implement stub DMA functions
For compile-testing drivers that use DMA operations under sandbox, we want stub implementations of these. Provide them. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/sandbox/include/asm/dma.h53
1 files changed, 52 insertions, 1 deletions
diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h
index 459536779e..5e72d8e7df 100644
--- a/arch/sandbox/include/asm/dma.h
+++ b/arch/sandbox/include/asm/dma.h
@@ -8,6 +8,57 @@
#ifndef __ASM_DMA_H
#define __ASM_DMA_H
-/* empty*/
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <driver.h>
+
+#define dma_alloc dma_alloc
+static inline void *dma_alloc(size_t size)
+{
+ return xmemalign(64, ALIGN(size, 64));
+}
+
+static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
+{
+ void *ret = xmemalign(4096, size);
+ if (dma_handle)
+ *dma_handle = (dma_addr_t)ret;
+
+ memset(ret, 0, size);
+
+ return ret;
+}
+
+static inline void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
+{
+ return dma_alloc_coherent(size, dma_handle);
+}
+
+static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,
+ size_t size)
+{
+ free(mem);
+}
+
+static inline dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
+ enum dma_data_direction dir)
+{
+ return (dma_addr_t)ptr;
+}
+
+static inline void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
+ enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
+ enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_for_device(dma_addr_t address, size_t size,
+ enum dma_data_direction dir)
+{
+}
#endif /* __ASM_DMA_H */