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.
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
;
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",
48 return PTR_ERR(mapping
);
51 ret
= arm_iommu_attach_device(dev
, mapping
);
53 pr_warn("Failed to attached device %s to IOMMU_mapping\n",
55 arm_iommu_release_mapping(mapping
);
64 static inline bool exynos_is_iommu_available(struct device
*dev
)
69 static inline int exynos_configure_iommu(struct device
*dev
,
70 unsigned int base
, unsigned int size
)
75 static inline void exynos_unconfigure_iommu(struct device
*dev
) { }
79 #endif /* S5P_MFC_IOMMU_H_ */