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; |
Mitchel Humpherys | 5c704e0 | 2015-12-21 15:06:34 -0800 | [diff] [blame^] | 36 | struct notifier_block notifier; |
Mitchel Humpherys | 0e43f0a | 2015-10-08 15:03:09 -0700 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | #ifdef CONFIG_IOMMU_IO_PGTABLE_FAST |
| 40 | int fast_smmu_attach_device(struct device *dev, |
| 41 | struct dma_iommu_mapping *mapping); |
| 42 | void fast_smmu_detach_device(struct device *dev, |
| 43 | struct dma_iommu_mapping *mapping); |
| 44 | #else |
| 45 | static inline int fast_smmu_attach_device(struct device *dev, |
| 46 | struct dma_iommu_mapping *mapping) |
| 47 | { |
| 48 | return -ENODEV; |
| 49 | } |
| 50 | |
| 51 | static inline void fast_smmu_detach_device(struct device *dev, |
| 52 | struct dma_iommu_mapping *mapping) |
| 53 | { |
| 54 | } |
| 55 | #endif |
| 56 | |
| 57 | #endif /* __LINUX_DMA_MAPPING_FAST_H */ |