Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 1 | /* exynos_drm_iommu.h |
| 2 | * |
| 3 | * Copyright (c) 2012 Samsung Electronics Co., Ltd. |
| 4 | * Authoer: Inki Dae <inki.dae@samsung.com> |
| 5 | * |
Inki Dae | d81aecb | 2012-12-18 02:30:17 +0900 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2 of the License, or (at your |
| 9 | * option) any later version. |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #ifndef _EXYNOS_DRM_IOMMU_H_ |
| 13 | #define _EXYNOS_DRM_IOMMU_H_ |
| 14 | |
| 15 | #define EXYNOS_DEV_ADDR_START 0x20000000 |
| 16 | #define EXYNOS_DEV_ADDR_SIZE 0x40000000 |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 17 | |
| 18 | #ifdef CONFIG_DRM_EXYNOS_IOMMU |
| 19 | |
Marek Szyprowski | 17879a4 | 2016-06-17 09:54:26 +0200 | [diff] [blame^] | 20 | #if defined(CONFIG_ARM_DMA_USE_IOMMU) |
| 21 | #include <asm/dma-iommu.h> |
| 22 | |
| 23 | static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv, |
| 24 | unsigned long start, unsigned long size) |
| 25 | { |
| 26 | priv->mapping = arm_iommu_create_mapping(&platform_bus_type, start, |
| 27 | size); |
| 28 | return IS_ERR(priv->mapping); |
| 29 | } |
| 30 | |
| 31 | static inline void |
| 32 | __exynos_iommu_release_mapping(struct exynos_drm_private *priv) |
| 33 | { |
| 34 | arm_iommu_release_mapping(priv->mapping); |
| 35 | } |
| 36 | |
| 37 | static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, |
| 38 | struct device *dev) |
| 39 | { |
| 40 | if (dev->archdata.mapping) |
| 41 | arm_iommu_detach_device(dev); |
| 42 | |
| 43 | return arm_iommu_attach_device(dev, priv->mapping); |
| 44 | } |
| 45 | |
| 46 | static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, |
| 47 | struct device *dev) |
| 48 | { |
| 49 | arm_iommu_detach_device(dev); |
| 50 | } |
| 51 | |
| 52 | #else |
| 53 | #error Unsupported architecture and IOMMU/DMA-mapping glue code |
| 54 | #endif |
| 55 | |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 56 | int drm_create_iommu_mapping(struct drm_device *drm_dev); |
| 57 | |
| 58 | void drm_release_iommu_mapping(struct drm_device *drm_dev); |
| 59 | |
| 60 | int drm_iommu_attach_device(struct drm_device *drm_dev, |
| 61 | struct device *subdrv_dev); |
| 62 | |
| 63 | void drm_iommu_detach_device(struct drm_device *dev_dev, |
| 64 | struct device *subdrv_dev); |
| 65 | |
| 66 | static inline bool is_drm_iommu_supported(struct drm_device *drm_dev) |
| 67 | { |
Marek Szyprowski | f43c359 | 2016-02-29 17:50:53 +0900 | [diff] [blame] | 68 | struct exynos_drm_private *priv = drm_dev->dev_private; |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 69 | |
Marek Szyprowski | f43c359 | 2016-02-29 17:50:53 +0900 | [diff] [blame] | 70 | return priv->mapping ? true : false; |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | #else |
| 74 | |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 75 | static inline int drm_create_iommu_mapping(struct drm_device *drm_dev) |
| 76 | { |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | static inline void drm_release_iommu_mapping(struct drm_device *drm_dev) |
| 81 | { |
| 82 | } |
| 83 | |
| 84 | static inline int drm_iommu_attach_device(struct drm_device *drm_dev, |
| 85 | struct device *subdrv_dev) |
| 86 | { |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | static inline void drm_iommu_detach_device(struct drm_device *drm_dev, |
| 91 | struct device *subdrv_dev) |
| 92 | { |
| 93 | } |
| 94 | |
| 95 | static inline bool is_drm_iommu_supported(struct drm_device *drm_dev) |
| 96 | { |
| 97 | return false; |
| 98 | } |
| 99 | |
Inki Dae | 0519f9a | 2012-10-20 07:53:42 -0700 | [diff] [blame] | 100 | #endif |
| 101 | #endif |