Input: xpad - add support for Xbox1 PDP Camo series gamepad
[linux/fpc-iii.git] / drivers / media / platform / s5p-mfc / s5p_mfc_iommu.h
blob6962132ae8fa745b4bef0068ff27b4e7e301c7b6
1 /*
2 * Copyright (C) 2015 Samsung Electronics Co.Ltd
3 * Authors: Marek Szyprowski <m.szyprowski@samsung.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
11 #ifndef S5P_MFC_IOMMU_H_
12 #define S5P_MFC_IOMMU_H_
14 #define S5P_MFC_IOMMU_DMA_BASE 0x20000000lu
15 #define S5P_MFC_IOMMU_DMA_SIZE SZ_256M
17 #if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU)
19 #include <asm/dma-iommu.h>
21 static inline bool exynos_is_iommu_available(struct device *dev)
23 return dev->archdata.iommu != NULL;
26 static inline void exynos_unconfigure_iommu(struct device *dev)
28 struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
30 arm_iommu_detach_device(dev);
31 arm_iommu_release_mapping(mapping);
34 static inline int exynos_configure_iommu(struct device *dev,
35 unsigned int base, unsigned int size)
37 struct dma_iommu_mapping *mapping = NULL;
38 int ret;
40 /* Disable the default mapping created by device core */
41 if (to_dma_iommu_mapping(dev))
42 exynos_unconfigure_iommu(dev);
44 mapping = arm_iommu_create_mapping(dev->bus, base, size);
45 if (IS_ERR(mapping)) {
46 pr_warn("Failed to create IOMMU mapping for device %s\n",
47 dev_name(dev));
48 return PTR_ERR(mapping);
51 ret = arm_iommu_attach_device(dev, mapping);
52 if (ret) {
53 pr_warn("Failed to attached device %s to IOMMU_mapping\n",
54 dev_name(dev));
55 arm_iommu_release_mapping(mapping);
56 return ret;
59 return 0;
62 #else
64 static inline bool exynos_is_iommu_available(struct device *dev)
66 return false;
69 static inline int exynos_configure_iommu(struct device *dev,
70 unsigned int base, unsigned int size)
72 return -ENOSYS;
75 static inline void exynos_unconfigure_iommu(struct device *dev) { }
77 #endif
79 #endif /* S5P_MFC_IOMMU_H_ */