dma-mapping.h 553 B

123456789101112131415161718192021222324
  1. #ifndef __ASM_NIOS2_DMA_MAPPING_H
  2. #define __ASM_NIOS2_DMA_MAPPING_H
  3. #include <memalign.h>
  4. #include <asm/io.h>
  5. /*
  6. * dma_alloc_coherent() return cache-line aligned allocation which is mapped
  7. * to uncached io region.
  8. */
  9. static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
  10. {
  11. unsigned long addr = (unsigned long)malloc_cache_aligned(len);
  12. if (!addr)
  13. return NULL;
  14. invalidate_dcache_range(addr, addr + len);
  15. if (handle)
  16. *handle = addr;
  17. return map_physmem(addr, len, MAP_NOCACHE);
  18. }
  19. #endif /* __ASM_NIOS2_DMA_MAPPING_H */