Mitchel Humpherys | 0e43f0a | 2015-10-08 15:03:09 -0700 | [diff] [blame^] | 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef __LINUX_DMA_MAPPING_FAST_H |
| 14 | #define __LINUX_DMA_MAPPING_FAST_H |
| 15 | |
| 16 | #include <linux/iommu.h> |
| 17 | #include <linux/io-pgtable-fast.h> |
| 18 | |
| 19 | struct dma_fast_smmu_mapping { |
| 20 | struct device *dev; |
| 21 | struct iommu_domain *domain; |
| 22 | dma_addr_t base; |
| 23 | size_t size; |
| 24 | size_t num_4k_pages; |
| 25 | |
| 26 | unsigned int bitmap_size; |
| 27 | unsigned long *bitmap; |
| 28 | unsigned long next_start; |
| 29 | unsigned long upcoming_stale_bit; |
| 30 | bool have_stale_tlbs; |
| 31 | |
| 32 | dma_addr_t pgtbl_dma_handle; |
| 33 | av8l_fast_iopte *pgtbl_pmds; |
| 34 | |
| 35 | spinlock_t lock; |
| 36 | }; |
| 37 | |
| 38 | #ifdef CONFIG_IOMMU_IO_PGTABLE_FAST |
| 39 | int fast_smmu_attach_device(struct device *dev, |
| 40 | struct dma_iommu_mapping *mapping); |
| 41 | void fast_smmu_detach_device(struct device *dev, |
| 42 | struct dma_iommu_mapping *mapping); |
| 43 | #else |
| 44 | static inline int fast_smmu_attach_device(struct device *dev, |
| 45 | struct dma_iommu_mapping *mapping) |
| 46 | { |
| 47 | return -ENODEV; |
| 48 | } |
| 49 | |
| 50 | static inline void fast_smmu_detach_device(struct device *dev, |
| 51 | struct dma_iommu_mapping *mapping) |
| 52 | { |
| 53 | } |
| 54 | #endif |
| 55 | |
| 56 | #endif /* __LINUX_DMA_MAPPING_FAST_H */ |