blob: dbdd2fee3806c32e7c8a48597d0b603882cd7564 [file] [log] [blame]
Wolfgang Denk83c15852006-10-24 14:21:16 +02001/*
2 * Copyright (C) 2006 Atmel Corporation
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Wolfgang Denk83c15852006-10-24 14:21:16 +02005 */
6#ifndef __ASM_AVR32_DMA_MAPPING_H
7#define __ASM_AVR32_DMA_MAPPING_H
8
9#include <asm/io.h>
Olav Morkencbc6ce02009-01-23 12:56:27 +010010#include <asm/arch/cacheflush.h>
Wolfgang Denk83c15852006-10-24 14:21:16 +020011
12enum dma_data_direction {
13 DMA_BIDIRECTIONAL = 0,
14 DMA_TO_DEVICE = 1,
15 DMA_FROM_DEVICE = 2,
16};
17extern void *dma_alloc_coherent(size_t len, unsigned long *handle);
18
19static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
20 enum dma_data_direction dir)
21{
22 extern void __bad_dma_data_direction(void);
23
24 switch (dir) {
25 case DMA_BIDIRECTIONAL:
Andreas Bießmannd1461212014-06-12 22:07:52 +020026 flush_dcache_range((unsigned long)vaddr,
27 (unsigned long)vaddr + len);
Wolfgang Denk83c15852006-10-24 14:21:16 +020028 break;
29 case DMA_TO_DEVICE:
30 dcache_clean_range(vaddr, len);
31 break;
32 case DMA_FROM_DEVICE:
Andreas Bießmannd1461212014-06-12 22:07:52 +020033 invalidate_dcache_range((unsigned long)vaddr,
34 (unsigned long)vaddr + len);
Wolfgang Denk83c15852006-10-24 14:21:16 +020035 break;
36 default:
37 /* This will cause a linker error */
38 __bad_dma_data_direction();
39 }
40
41 return virt_to_phys(vaddr);
42}
43
44static inline void dma_unmap_single(volatile void *vaddr, size_t len,
45 unsigned long paddr)
46{
47
48}
49
50#endif /* __ASM_AVR32_DMA_MAPPING_H */