summaryrefslogtreecommitdiffstats
path: root/arch/arm/cpu
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2021-03-03 17:12:47 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-03-04 12:11:22 +0100
commit3f975f810bd34c56cfafd88d1d4e6eb669e74561 (patch)
tree4ee73d2980ee39d9c6bed962f04ddd4f7eb63430 /arch/arm/cpu
parent598217bad38f62aa1691742839cfe856ba2a99e2 (diff)
downloadbarebox-3f975f810bd34c56cfafd88d1d4e6eb669e74561.tar.gz
barebox-3f975f810bd34c56cfafd88d1d4e6eb669e74561.tar.xz
dma: move dma_map/unmap_single from ARM to common code
There's nothing ARM specific about these functions. Move them to a common location, so other arches can use them as well. This also fixes a bug on ARM MMU=n configurations: Previously these two functions these functions only respected dma-ranges translation when compiled with MMU support. DMA address translation is applicable regardless of CPU use of MMU though. Now, dma-ranges should be respected unconditionally. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/cpu')
-rw-r--r--arch/arm/cpu/mmu-common.c41
1 files changed, 1 insertions, 40 deletions
diff --git a/arch/arm/cpu/mmu-common.c b/arch/arm/cpu/mmu-common.c
index 287622b203..5cc5138cfa 100644
--- a/arch/arm/cpu/mmu-common.c
+++ b/arch/arm/cpu/mmu-common.c
@@ -10,27 +10,6 @@
#include <memory.h>
#include "mmu.h"
-
-static inline dma_addr_t cpu_to_dma(struct device_d *dev, unsigned long cpu_addr)
-{
- dma_addr_t dma_addr = cpu_addr;
-
- if (dev)
- dma_addr -= dev->dma_offset;
-
- return dma_addr;
-}
-
-static inline unsigned long dma_to_cpu(struct device_d *dev, dma_addr_t addr)
-{
- unsigned long cpu_addr = addr;
-
- if (dev)
- cpu_addr += dev->dma_offset;
-
- return cpu_addr;
-}
-
void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
enum dma_data_direction dir)
{
@@ -41,24 +20,6 @@ void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
dma_inv_range((void *)address, size);
}
-dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
- enum dma_data_direction dir)
-{
- unsigned long addr = (unsigned long)ptr;
-
- dma_sync_single_for_device(addr, size, dir);
-
- return cpu_to_dma(dev, addr);
-}
-
-void dma_unmap_single(struct device_d *dev, dma_addr_t dma_addr, size_t size,
- enum dma_data_direction dir)
-{
- unsigned long addr = dma_to_cpu(dev, dma_addr);
-
- dma_sync_single_for_cpu(addr, size, dir);
-}
-
void *dma_alloc_map(size_t size, dma_addr_t *dma_handle, unsigned flags)
{
void *ret;
@@ -108,4 +69,4 @@ static int mmu_init(void)
return 0;
}
-mmu_initcall(mmu_init); \ No newline at end of file
+mmu_initcall(mmu_init);