From e905086e6b2fc9d7e2764cf04622743ca86558f1 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 20 Jun 2018 09:11:15 +0200 Subject: MIPS: loongson64: use generic dma noncoherent ops Provide phys_to_dma/dma_to_phys helpers, everything else is generic. Signed-off-by: Christoph Hellwig Patchwork: https://patchwork.linux-mips.org/patch/19545/ Signed-off-by: Paul Burton Cc: Florian Fainelli Cc: David Daney Cc: Kevin Cernekee Cc: Jiaxun Yang Cc: Tom Bogendoerfer Cc: Huacai Chen Cc: iommu@lists.linux-foundation.org Cc: linux-mips@linux-mips.org --- arch/mips/loongson64/Kconfig | 2 -- arch/mips/loongson64/common/Makefile | 1 + arch/mips/loongson64/common/dma.c | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 arch/mips/loongson64/common/dma.c (limited to 'arch/mips/loongson64') diff --git a/arch/mips/loongson64/Kconfig b/arch/mips/loongson64/Kconfig index a785bf8da3f3..c865b4b9b775 100644 --- a/arch/mips/loongson64/Kconfig +++ b/arch/mips/loongson64/Kconfig @@ -13,7 +13,6 @@ config LEMOTE_FULOONG2E select CSRC_R4K select SYS_HAS_CPU_LOONGSON2E select DMA_NONCOHERENT - select MIPS_DMA_DEFAULT select BOOT_ELF32 select BOARD_SCACHE select HW_HAS_PCI @@ -45,7 +44,6 @@ config LEMOTE_MACH2F select CS5536 select CSRC_R4K if ! MIPS_EXTERNAL_TIMER select DMA_NONCOHERENT - select MIPS_DMA_DEFAULT select GENERIC_ISA_DMA_SUPPORT_BROKEN select HAVE_CLK select HW_HAS_PCI diff --git a/arch/mips/loongson64/common/Makefile b/arch/mips/loongson64/common/Makefile index 684624f61f5a..57ee03022941 100644 --- a/arch/mips/loongson64/common/Makefile +++ b/arch/mips/loongson64/common/Makefile @@ -6,6 +6,7 @@ obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \ bonito-irq.o mem.o machtype.o platform.o serial.o obj-$(CONFIG_PCI) += pci.o +obj-$(CONFIG_CPU_LOONGSON2) += dma.o # # Serial port support diff --git a/arch/mips/loongson64/common/dma.c b/arch/mips/loongson64/common/dma.c new file mode 100644 index 000000000000..48f04126bde2 --- /dev/null +++ b/arch/mips/loongson64/common/dma.c @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0 +#include + +dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr) +{ + return paddr | 0x80000000; +} + +phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dma_addr) +{ +#if defined(CONFIG_CPU_LOONGSON2F) && defined(CONFIG_64BIT) + if (dma_addr > 0x8fffffff) + return dma_addr; + return dma_addr & 0x0fffffff; +#else + return dma_addr & 0x7fffffff; +#endif +} -- cgit v1.2.3