From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY2l6-00006p-GZ for barebox@lists.infradead.org; Mon, 11 May 2020 07:21:55 +0000 From: Ahmad Fatoum Date: Mon, 11 May 2020 09:21:29 +0200 Message-Id: <20200511072140.29610-13-a.fatoum@pengutronix.de> In-Reply-To: <20200511072140.29610-1-a.fatoum@pengutronix.de> References: <20200511072140.29610-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 12/23] sandbox: asm: implement stub DMA functions To: barebox@lists.infradead.org Cc: Ahmad Fatoum For compile-testing drivers that use DMA operations under sandbox, we want stub implementations of these. Provide them. Signed-off-by: Ahmad Fatoum --- arch/sandbox/include/asm/dma.h | 53 +++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h index 459536779e0a..5e72d8e7df2d 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 +#include +#include + +#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 */ -- 2.26.2 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox