Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: ath25: use generic dma noncoherent ops

Provide phys_to_dma/dma_to_phys helpers only if PCI support is
enabled, everything else is generic.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Patchwork: https://patchwork.linux-mips.org/patch/19547/
Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: David Daney <david.daney@cavium.com>
Cc: Kevin Cernekee <cernekee@gmail.com>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Tom Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Huacai Chen <chenhc@lemote.com>
Cc: iommu@lists.linux-foundation.org
Cc: linux-mips@linux-mips.org

authored by

Christoph Hellwig and committed by
Paul Burton
d1f2564a 03df8229

+25 -72
-1
arch/mips/Kconfig
··· 182 182 select DMA_NONCOHERENT 183 183 select IRQ_MIPS_CPU 184 184 select IRQ_DOMAIN 185 - select MIPS_DMA_DEFAULT 186 185 select SYS_HAS_CPU_MIPS32_R1 187 186 select SYS_SUPPORTS_BIG_ENDIAN 188 187 select SYS_SUPPORTS_32BIT_KERNEL
+1
arch/mips/ath25/Kconfig
··· 12 12 config PCI_AR2315 13 13 bool "Atheros AR2315 PCI controller support" 14 14 depends on SOC_AR2315 15 + select ARCH_HAS_PHYS_TO_DMA 15 16 select HW_HAS_PCI 16 17 select PCI 17 18 default y
-71
arch/mips/include/asm/mach-ath25/dma-coherence.h
··· 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 Ralf Baechle <ralf@linux-mips.org> 7 - * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org> 8 - * 9 - */ 10 - #ifndef __ASM_MACH_ATH25_DMA_COHERENCE_H 11 - #define __ASM_MACH_ATH25_DMA_COHERENCE_H 12 - 13 - #include <linux/device.h> 14 - 15 - /* 16 - * We need some arbitrary non-zero value to be programmed to the BAR1 register 17 - * of PCI host controller to enable DMA. The same value should be used as the 18 - * offset to calculate the physical address of DMA buffer for PCI devices. 19 - */ 20 - #define AR2315_PCI_HOST_SDRAM_BASEADDR 0x20000000 21 - 22 - static inline dma_addr_t ath25_dev_offset(struct device *dev) 23 - { 24 - #ifdef CONFIG_PCI 25 - extern struct bus_type pci_bus_type; 26 - 27 - if (dev && dev->bus == &pci_bus_type) 28 - return AR2315_PCI_HOST_SDRAM_BASEADDR; 29 - #endif 30 - return 0; 31 - } 32 - 33 - static inline dma_addr_t 34 - plat_map_dma_mem(struct device *dev, void *addr, size_t size) 35 - { 36 - return virt_to_phys(addr) + ath25_dev_offset(dev); 37 - } 38 - 39 - static inline dma_addr_t 40 - plat_map_dma_mem_page(struct device *dev, struct page *page) 41 - { 42 - return page_to_phys(page) + ath25_dev_offset(dev); 43 - } 44 - 45 - static inline unsigned long 46 - plat_dma_addr_to_phys(struct device *dev, dma_addr_t dma_addr) 47 - { 48 - return dma_addr - ath25_dev_offset(dev); 49 - } 50 - 51 - static inline void 52 - plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr, size_t size, 53 - enum dma_data_direction direction) 54 - { 55 - } 56 - 57 - static inline int plat_dma_supported(struct device *dev, u64 mask) 58 - { 59 - return 1; 60 - } 61 - 62 - static inline int plat_device_is_coherent(struct device *dev) 63 - { 64 - return 0; 65 - } 66 - 67 - static inline void plat_post_dma_flush(struct device *dev) 68 - { 69 - } 70 - 71 - #endif /* __ASM_MACH_ATH25_DMA_COHERENCE_H */
+24
arch/mips/pci/pci-ar2315.c
··· 149 149 #define AR2315_PCI_HOST_SLOT 3 150 150 #define AR2315_PCI_HOST_DEVID ((0xff18 << 16) | PCI_VENDOR_ID_ATHEROS) 151 151 152 + /* 153 + * We need some arbitrary non-zero value to be programmed to the BAR1 register 154 + * of PCI host controller to enable DMA. The same value should be used as the 155 + * offset to calculate the physical address of DMA buffer for PCI devices. 156 + */ 157 + #define AR2315_PCI_HOST_SDRAM_BASEADDR 0x20000000 158 + 152 159 /* ??? access BAR */ 153 160 #define AR2315_PCI_HOST_MBAR0 0x10000000 154 161 /* RAM access BAR */ ··· 173 166 struct resource mem_res; 174 167 struct resource io_res; 175 168 }; 169 + 170 + static inline dma_addr_t ar2315_dev_offset(struct device *dev) 171 + { 172 + if (dev && dev_is_pci(dev)) 173 + return AR2315_PCI_HOST_SDRAM_BASEADDR; 174 + return 0; 175 + } 176 + 177 + dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr) 178 + { 179 + return paddr + ar2315_dev_offset(dev); 180 + } 181 + 182 + phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dma_addr) 183 + { 184 + return dma_addr - ar2315_dev_offset(dev); 185 + } 176 186 177 187 static inline struct ar2315_pci_ctrl *ar2315_pci_bus_to_apc(struct pci_bus *bus) 178 188 {