2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2008-01-31 21:15:53 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2007
|
2011-10-31 23:00:39 +00:00
|
|
|
* Stelian Pop <stelian@popies.net>
|
2008-01-31 21:15:53 +00:00
|
|
|
* Lead Tech Design <www.leadtechdesign.com>
|
|
|
|
*/
|
|
|
|
#ifndef __ASM_ARM_DMA_MAPPING_H
|
|
|
|
#define __ASM_ARM_DMA_MAPPING_H
|
|
|
|
|
2020-01-16 08:53:45 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <asm/cache.h>
|
|
|
|
#include <cpu_func.h>
|
2017-08-25 15:50:17 +00:00
|
|
|
#include <linux/dma-direction.h>
|
2020-02-14 07:40:17 +00:00
|
|
|
#include <linux/types.h>
|
2020-01-16 08:53:45 +00:00
|
|
|
#include <malloc.h>
|
2015-02-23 13:09:56 +00:00
|
|
|
|
2017-08-25 15:50:17 +00:00
|
|
|
#define dma_mapping_error(x, y) 0
|
2008-01-31 21:15:53 +00:00
|
|
|
|
2015-02-23 13:09:49 +00:00
|
|
|
static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
|
2008-01-31 21:15:53 +00:00
|
|
|
{
|
2019-01-04 09:24:14 +00:00
|
|
|
*handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, ROUND(len, ARCH_DMA_MINALIGN));
|
2008-01-31 21:15:53 +00:00
|
|
|
return (void *)*handle;
|
|
|
|
}
|
|
|
|
|
2015-02-23 13:09:56 +00:00
|
|
|
static inline void dma_free_coherent(void *addr)
|
|
|
|
{
|
|
|
|
free(addr);
|
|
|
|
}
|
|
|
|
|
2020-02-14 07:40:17 +00:00
|
|
|
static inline dma_addr_t dma_map_single(void *vaddr, size_t len,
|
|
|
|
enum dma_data_direction dir)
|
2008-01-31 21:15:53 +00:00
|
|
|
{
|
2020-01-16 08:53:45 +00:00
|
|
|
unsigned long addr = (unsigned long)vaddr;
|
|
|
|
|
|
|
|
len = ALIGN(len, ARCH_DMA_MINALIGN);
|
|
|
|
|
|
|
|
if (dir == DMA_FROM_DEVICE)
|
|
|
|
invalidate_dcache_range(addr, addr + len);
|
|
|
|
else
|
|
|
|
flush_dcache_range(addr, addr + len);
|
|
|
|
|
|
|
|
return addr;
|
2008-01-31 21:15:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 07:40:18 +00:00
|
|
|
static inline void dma_unmap_single(dma_addr_t addr, size_t len,
|
2020-01-16 08:53:45 +00:00
|
|
|
enum dma_data_direction dir)
|
2008-01-31 21:15:53 +00:00
|
|
|
{
|
2020-01-16 08:53:45 +00:00
|
|
|
len = ALIGN(len, ARCH_DMA_MINALIGN);
|
|
|
|
|
|
|
|
if (dir != DMA_TO_DEVICE)
|
|
|
|
invalidate_dcache_range(addr, addr + len);
|
2008-01-31 21:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __ASM_ARM_DMA_MAPPING_H */
|