Wolfgang Denk | 83c1585 | 2006-10-24 14:21:16 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 Atmel Corporation |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Wolfgang Denk | 83c1585 | 2006-10-24 14:21:16 +0200 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __ASM_AVR32_DMA_MAPPING_H |
| 7 | #define __ASM_AVR32_DMA_MAPPING_H |
| 8 | |
| 9 | #include <asm/io.h> |
Olav Morken | cbc6ce0 | 2009-01-23 12:56:27 +0100 | [diff] [blame] | 10 | #include <asm/arch/cacheflush.h> |
Wolfgang Denk | 83c1585 | 2006-10-24 14:21:16 +0200 | [diff] [blame] | 11 | |
| 12 | enum dma_data_direction { |
| 13 | DMA_BIDIRECTIONAL = 0, |
| 14 | DMA_TO_DEVICE = 1, |
| 15 | DMA_FROM_DEVICE = 2, |
| 16 | }; |
| 17 | extern void *dma_alloc_coherent(size_t len, unsigned long *handle); |
| 18 | |
| 19 | static 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: |
| 26 | dcache_flush_range(vaddr, len); |
| 27 | break; |
| 28 | case DMA_TO_DEVICE: |
| 29 | dcache_clean_range(vaddr, len); |
| 30 | break; |
| 31 | case DMA_FROM_DEVICE: |
| 32 | dcache_invalidate_range(vaddr, len); |
| 33 | break; |
| 34 | default: |
| 35 | /* This will cause a linker error */ |
| 36 | __bad_dma_data_direction(); |
| 37 | } |
| 38 | |
| 39 | return virt_to_phys(vaddr); |
| 40 | } |
| 41 | |
| 42 | static inline void dma_unmap_single(volatile void *vaddr, size_t len, |
| 43 | unsigned long paddr) |
| 44 | { |
| 45 | |
| 46 | } |
| 47 | |
| 48 | #endif /* __ASM_AVR32_DMA_MAPPING_H */ |