David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 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 | * |
| 8 | * |
| 9 | * Similar to mach-generic/dma-coherence.h except |
| 10 | * plat_device_is_coherent hard coded to return 1. |
| 11 | * |
| 12 | */ |
| 13 | #ifndef __ASM_MACH_CAVIUM_OCTEON_DMA_COHERENCE_H |
| 14 | #define __ASM_MACH_CAVIUM_OCTEON_DMA_COHERENCE_H |
| 15 | |
David Daney | 368b062 | 2013-06-20 16:10:50 +0200 | [diff] [blame] | 16 | #include <linux/bug.h> |
| 17 | |
David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 18 | struct device; |
| 19 | |
David Daney | b93b2ab | 2010-10-01 13:27:34 -0700 | [diff] [blame] | 20 | extern void octeon_pci_dma_init(void); |
David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 21 | |
| 22 | static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, |
| 23 | size_t size) |
| 24 | { |
David Daney | b93b2ab | 2010-10-01 13:27:34 -0700 | [diff] [blame] | 25 | BUG(); |
David Daney | 368b062 | 2013-06-20 16:10:50 +0200 | [diff] [blame] | 26 | return 0; |
David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | static inline dma_addr_t plat_map_dma_mem_page(struct device *dev, |
| 30 | struct page *page) |
| 31 | { |
David Daney | 48e1fd5 | 2010-10-01 13:27:32 -0700 | [diff] [blame] | 32 | BUG(); |
David Daney | 368b062 | 2013-06-20 16:10:50 +0200 | [diff] [blame] | 33 | return 0; |
David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 34 | } |
| 35 | |
Kevin Cernekee | 3807ef3f6 | 2009-04-23 17:25:12 -0700 | [diff] [blame] | 36 | static inline unsigned long plat_dma_addr_to_phys(struct device *dev, |
| 37 | dma_addr_t dma_addr) |
David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 38 | { |
David Daney | b93b2ab | 2010-10-01 13:27:34 -0700 | [diff] [blame] | 39 | BUG(); |
David Daney | 368b062 | 2013-06-20 16:10:50 +0200 | [diff] [blame] | 40 | return 0; |
David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 41 | } |
| 42 | |
Kevin Cernekee | d3f634b | 2009-04-23 17:03:43 -0700 | [diff] [blame] | 43 | static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr, |
| 44 | size_t size, enum dma_data_direction direction) |
David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 45 | { |
David Daney | b93b2ab | 2010-10-01 13:27:34 -0700 | [diff] [blame] | 46 | BUG(); |
David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | static inline int plat_dma_supported(struct device *dev, u64 mask) |
| 50 | { |
David Daney | b93b2ab | 2010-10-01 13:27:34 -0700 | [diff] [blame] | 51 | BUG(); |
David Daney | 368b062 | 2013-06-20 16:10:50 +0200 | [diff] [blame] | 52 | return 0; |
David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 53 | } |
| 54 | |
David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 55 | static inline int plat_device_is_coherent(struct device *dev) |
| 56 | { |
| 57 | return 1; |
| 58 | } |
| 59 | |
Ralf Baechle | 0acbfc6 | 2015-03-27 15:10:30 +0100 | [diff] [blame] | 60 | static inline void plat_post_dma_flush(struct device *dev) |
| 61 | { |
| 62 | } |
| 63 | |
Christoph Hellwig | ea8c64a | 2018-01-10 16:21:13 +0100 | [diff] [blame] | 64 | static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) |
| 65 | { |
| 66 | if (!dev->dma_mask) |
| 67 | return false; |
| 68 | |
| 69 | return addr + size - 1 <= *dev->dma_mask; |
| 70 | } |
| 71 | |
Christoph Hellwig | b6e0547 | 2018-03-19 11:38:24 +0100 | [diff] [blame] | 72 | dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr); |
| 73 | phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr); |
David Daney | b93b2ab | 2010-10-01 13:27:34 -0700 | [diff] [blame] | 74 | |
| 75 | struct dma_map_ops; |
Bart Van Assche | 5299709 | 2017-01-20 13:04:01 -0800 | [diff] [blame] | 76 | extern const struct dma_map_ops *octeon_pci_dma_map_ops; |
David Daney | b93b2ab | 2010-10-01 13:27:34 -0700 | [diff] [blame] | 77 | extern char *octeon_swiotlb; |
| 78 | |
David Daney | 5b3b168 | 2009-01-08 16:46:40 -0800 | [diff] [blame] | 79 | #endif /* __ASM_MACH_CAVIUM_OCTEON_DMA_COHERENCE_H */ |