diff options
author | Lucas Stach <dev@lynxeye.de> | 2015-03-05 22:50:01 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-06 07:52:02 +0100 |
commit | 381f034ed607042fa171673b6c4d0150745842e8 (patch) | |
tree | d019a16eb1dde42943f07d32828e520a2715154d /arch/arm/include | |
parent | a0c4e2203fdde7b2636eab3f1406ea66f0e0da19 (diff) | |
download | barebox-381f034ed607042fa171673b6c4d0150745842e8.tar.gz barebox-381f034ed607042fa171673b6c4d0150745842e8.tar.xz |
ARM: move DMA alloc functions to dma.h
This better separates the DMA from the MMU functionality.
Also move all drivers that only depends on asm/mmu.h for the alloc
functions over to the common header.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/include')
-rw-r--r-- | arch/arm/include/asm/dma.h | 25 | ||||
-rw-r--r-- | arch/arm/include/asm/mmu.h | 26 |
2 files changed, 24 insertions, 27 deletions
diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h index cb9cd1b4ea..48a9c6e67b 100644 --- a/arch/arm/include/asm/dma.h +++ b/arch/arm/include/asm/dma.h @@ -5,4 +5,27 @@ * */ -#include <asm/mmu.h> +#include <common.h> + +#define dma_alloc dma_alloc +static inline void *dma_alloc(size_t size) +{ + return xmemalign(64, ALIGN(size, 64)); +} + +#ifndef CONFIG_MMU +static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle) +{ + void *ret = xmemalign(4096, size); + if (dma_handle) + *dma_handle = (dma_addr_t)ret; + + return ret; +} + +static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle, + size_t size) +{ + free(mem); +} +#endif diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h index d0a644b88f..01c20bd0dd 100644 --- a/arch/arm/include/asm/mmu.h +++ b/arch/arm/include/asm/mmu.h @@ -11,8 +11,6 @@ #define PMD_SECT_DEF_UNCACHED (PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT) #define PMD_SECT_DEF_CACHED (PMD_SECT_WB | PMD_SECT_DEF_UNCACHED) -#define DMA_ADDRESS_BROKEN NULL - struct arm_memory; static inline void mmu_enable(void) @@ -28,16 +26,7 @@ static inline void setup_dma_coherent(unsigned long offset) { } -#define dma_alloc dma_alloc -static inline void *dma_alloc(size_t size) -{ - return xmemalign(64, ALIGN(size, 64)); -} - #ifdef CONFIG_MMU -void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle); -void dma_free_coherent(void *mem, dma_addr_t dma_handle, size_t size); - void dma_clean_range(unsigned long, unsigned long); void dma_flush_range(unsigned long, unsigned long); void dma_inv_range(unsigned long, unsigned long); @@ -47,21 +36,6 @@ uint32_t mmu_get_pte_cached_flags(void); uint32_t mmu_get_pte_uncached_flags(void); #else -static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle) -{ - void *ret = xmemalign(4096, size); - if (dma_handle) - *dma_handle = (dma_addr_t)ret; - - return ret; -} - -static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle, - size_t size) -{ - free(mem); -} - static inline void dma_clean_range(unsigned long s, unsigned long e) { } |