diff options
Diffstat (limited to 'arch/arc')
-rw-r--r-- | arch/arc/Kconfig | 4 | ||||
-rw-r--r-- | arch/arc/include/asm/dma-mapping.h | 16 | ||||
-rw-r--r-- | arch/arc/plat-arcfpga/include/plat/dma_addr.h | 45 |
3 files changed, 20 insertions, 45 deletions
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index ac173687c05..be85ceb8b26 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -119,6 +119,10 @@ config CPU_BIG_ENDIAN help Build kernel for Big Endian Mode of ARC CPU +# If a platform can't work with 0x8000_0000 based dma_addr_t +config ARC_PLAT_NEEDS_CPU_TO_DMA + bool + config SMP bool "Symmetric Multi-Processing (Incomplete)" default n diff --git a/arch/arc/include/asm/dma-mapping.h b/arch/arc/include/asm/dma-mapping.h index 7fd150e97eb..31f77aec082 100644 --- a/arch/arc/include/asm/dma-mapping.h +++ b/arch/arc/include/asm/dma-mapping.h @@ -13,7 +13,23 @@ #include <asm-generic/dma-coherent.h> #include <asm/cacheflush.h> + +#ifndef CONFIG_ARC_PLAT_NEEDS_CPU_TO_DMA +/* + * dma_map_* API take cpu addresses, which is kernel logical address in the + * untranslated address space (0x8000_0000) based. The dma address (bus addr) + * ideally needs to be 0x0000_0000 based hence these glue routines. + * However given that intermediate bus bridges can ignore the high bit, we can + * do with these routines being no-ops. + * If a platform/device comes up which sriclty requires 0 based bus addr + * (e.g. AHB-PCI bridge on Angel4 board), then it can provide it's own versions + */ +#define plat_dma_addr_to_kernel(dev, addr) ((unsigned long)(addr)) +#define plat_kernel_addr_to_dma(dev, ptr) ((dma_addr_t)(ptr)) + +#else #include <plat/dma_addr.h> +#endif void *dma_alloc_noncoherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp); diff --git a/arch/arc/plat-arcfpga/include/plat/dma_addr.h b/arch/arc/plat-arcfpga/include/plat/dma_addr.h deleted file mode 100644 index 0e963431b72..00000000000 --- a/arch/arc/plat-arcfpga/include/plat/dma_addr.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * vineetg: Feb 2009 - * -For AA4 board, kernel to DMA address APIs - */ - -/* - * kernel addresses are 0x800_000 based, while Bus addr are 0 based - */ - -#ifndef __PLAT_DMA_ADDR_H -#define __PLAT_DMA_ADDR_H - -#include <linux/device.h> - -static inline unsigned long plat_dma_addr_to_kernel(struct device *dev, - dma_addr_t dma_addr) -{ - return dma_addr + PAGE_OFFSET; -} - -static inline dma_addr_t plat_kernel_addr_to_dma(struct device *dev, void *ptr) -{ - unsigned long addr = (unsigned long)ptr; - /* - * To Catch buggy drivers which can call DMA map API with kernel vaddr - * i.e. for buffers alloc via vmalloc or ioremap which are not - * gaurnateed to be PHY contiguous and hence unfit for DMA anyways. - * On ARC kernel virtual address is 0x7000_0000 to 0x7FFF_FFFF, so - * ideally we want to check this range here, but our implementation is - * better as it checks for even worse user virtual address as well. - */ - if (likely(addr >= PAGE_OFFSET)) - return addr - PAGE_OFFSET; - - BUG(); - return addr; -} - -#endif |