2010-04-17 15:34:40 +00:00
|
|
|
#ifndef __ASM_NIOS2_DMA_MAPPING_H
|
|
|
|
#define __ASM_NIOS2_DMA_MAPPING_H
|
|
|
|
|
2015-10-18 12:03:53 +00:00
|
|
|
#include <memalign.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dma_alloc_coherent() return cache-line aligned allocation which is mapped
|
2010-04-17 15:34:40 +00:00
|
|
|
* to uncached io region.
|
|
|
|
*/
|
|
|
|
static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
|
|
|
|
{
|
2015-10-18 12:03:53 +00:00
|
|
|
unsigned long addr = (unsigned long)malloc_cache_aligned(len);
|
|
|
|
|
2010-04-17 15:34:40 +00:00
|
|
|
if (!addr)
|
2015-10-18 12:03:53 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
invalidate_dcache_range(addr, addr + len);
|
|
|
|
if (handle)
|
|
|
|
*handle = addr;
|
2010-04-17 15:34:40 +00:00
|
|
|
|
2015-11-14 03:34:09 +00:00
|
|
|
return map_physmem(addr, len, MAP_NOCACHE);
|
2015-10-18 12:03:53 +00:00
|
|
|
}
|
2010-04-17 15:34:40 +00:00
|
|
|
#endif /* __ASM_NIOS2_DMA_MAPPING_H */
|