diff options
-rw-r--r-- | arch/mips/Kconfig | 1 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-loongson64/dma-coherence.h | 69 | ||||
-rw-r--r-- | arch/mips/loongson64/Kconfig | 2 | ||||
-rw-r--r-- | arch/mips/loongson64/common/Makefile | 1 | ||||
-rw-r--r-- | arch/mips/loongson64/common/dma.c | 18 |
5 files changed, 20 insertions, 71 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 47592cc7fa54..aa438f0a0273 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -1828,6 +1828,7 @@ config CPU_LOONGSON2 | |||
1828 | select CPU_SUPPORTS_64BIT_KERNEL | 1828 | select CPU_SUPPORTS_64BIT_KERNEL |
1829 | select CPU_SUPPORTS_HIGHMEM | 1829 | select CPU_SUPPORTS_HIGHMEM |
1830 | select CPU_SUPPORTS_HUGEPAGES | 1830 | select CPU_SUPPORTS_HUGEPAGES |
1831 | select ARCH_HAS_PHYS_TO_DMA | ||
1831 | 1832 | ||
1832 | config CPU_LOONGSON1 | 1833 | config CPU_LOONGSON1 |
1833 | bool | 1834 | bool |
diff --git a/arch/mips/include/asm/mach-loongson64/dma-coherence.h b/arch/mips/include/asm/mach-loongson64/dma-coherence.h deleted file mode 100644 index 651dd2eb3ee5..000000000000 --- a/arch/mips/include/asm/mach-loongson64/dma-coherence.h +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | /* | ||
2 | * This file is subject to the terms and conditions of the GNU General Public | ||
3 | * License. See the file "COPYING" in the main directory of this archive | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2006, 07 Ralf Baechle <ralf@linux-mips.org> | ||
7 | * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology | ||
8 | * Author: Fuxin Zhang, zhangfx@lemote.com | ||
9 | * | ||
10 | */ | ||
11 | #ifndef __ASM_MACH_LOONGSON64_DMA_COHERENCE_H | ||
12 | #define __ASM_MACH_LOONGSON64_DMA_COHERENCE_H | ||
13 | |||
14 | #ifdef CONFIG_SWIOTLB | ||
15 | #include <linux/swiotlb.h> | ||
16 | #endif | ||
17 | |||
18 | struct device; | ||
19 | |||
20 | static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, | ||
21 | size_t size) | ||
22 | { | ||
23 | return virt_to_phys(addr) | 0x80000000; | ||
24 | } | ||
25 | |||
26 | static inline dma_addr_t plat_map_dma_mem_page(struct device *dev, | ||
27 | struct page *page) | ||
28 | { | ||
29 | return page_to_phys(page) | 0x80000000; | ||
30 | } | ||
31 | |||
32 | static inline unsigned long plat_dma_addr_to_phys(struct device *dev, | ||
33 | dma_addr_t dma_addr) | ||
34 | { | ||
35 | #if defined(CONFIG_CPU_LOONGSON2F) && defined(CONFIG_64BIT) | ||
36 | return (dma_addr > 0x8fffffff) ? dma_addr : (dma_addr & 0x0fffffff); | ||
37 | #else | ||
38 | return dma_addr & 0x7fffffff; | ||
39 | #endif | ||
40 | } | ||
41 | |||
42 | static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr, | ||
43 | size_t size, enum dma_data_direction direction) | ||
44 | { | ||
45 | } | ||
46 | |||
47 | static inline int plat_dma_supported(struct device *dev, u64 mask) | ||
48 | { | ||
49 | /* | ||
50 | * we fall back to GFP_DMA when the mask isn't all 1s, | ||
51 | * so we can't guarantee allocations that must be | ||
52 | * within a tighter range than GFP_DMA.. | ||
53 | */ | ||
54 | if (mask < DMA_BIT_MASK(24)) | ||
55 | return 0; | ||
56 | |||
57 | return 1; | ||
58 | } | ||
59 | |||
60 | static inline int plat_device_is_coherent(struct device *dev) | ||
61 | { | ||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static inline void plat_post_dma_flush(struct device *dev) | ||
66 | { | ||
67 | } | ||
68 | |||
69 | #endif /* __ASM_MACH_LOONGSON64_DMA_COHERENCE_H */ | ||
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 | |||
13 | select CSRC_R4K | 13 | select CSRC_R4K |
14 | select SYS_HAS_CPU_LOONGSON2E | 14 | select SYS_HAS_CPU_LOONGSON2E |
15 | select DMA_NONCOHERENT | 15 | select DMA_NONCOHERENT |
16 | select MIPS_DMA_DEFAULT | ||
17 | select BOOT_ELF32 | 16 | select BOOT_ELF32 |
18 | select BOARD_SCACHE | 17 | select BOARD_SCACHE |
19 | select HW_HAS_PCI | 18 | select HW_HAS_PCI |
@@ -45,7 +44,6 @@ config LEMOTE_MACH2F | |||
45 | select CS5536 | 44 | select CS5536 |
46 | select CSRC_R4K if ! MIPS_EXTERNAL_TIMER | 45 | select CSRC_R4K if ! MIPS_EXTERNAL_TIMER |
47 | select DMA_NONCOHERENT | 46 | select DMA_NONCOHERENT |
48 | select MIPS_DMA_DEFAULT | ||
49 | select GENERIC_ISA_DMA_SUPPORT_BROKEN | 47 | select GENERIC_ISA_DMA_SUPPORT_BROKEN |
50 | select HAVE_CLK | 48 | select HAVE_CLK |
51 | select HW_HAS_PCI | 49 | 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 @@ | |||
6 | obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \ | 6 | obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \ |
7 | bonito-irq.o mem.o machtype.o platform.o serial.o | 7 | bonito-irq.o mem.o machtype.o platform.o serial.o |
8 | obj-$(CONFIG_PCI) += pci.o | 8 | obj-$(CONFIG_PCI) += pci.o |
9 | obj-$(CONFIG_CPU_LOONGSON2) += dma.o | ||
9 | 10 | ||
10 | # | 11 | # |
11 | # Serial port support | 12 | # 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 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | #include <linux/dma-direct.h> | ||
3 | |||
4 | dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr) | ||
5 | { | ||
6 | return paddr | 0x80000000; | ||
7 | } | ||
8 | |||
9 | phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dma_addr) | ||
10 | { | ||
11 | #if defined(CONFIG_CPU_LOONGSON2F) && defined(CONFIG_64BIT) | ||
12 | if (dma_addr > 0x8fffffff) | ||
13 | return dma_addr; | ||
14 | return dma_addr & 0x0fffffff; | ||
15 | #else | ||
16 | return dma_addr & 0x7fffffff; | ||
17 | #endif | ||
18 | } | ||