chromium: add drm drivers files based on
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / rockchip / rockchip_drm_iommu.h
1 /*
2  * Copyright (C) ROCKCHIP, Inc.
3  * Author:yzq<yzq@rock-chips.com>
4  *
5  * based on exynos_drm_iommu.h
6  *
7  * This software is licensed under the terms of the GNU General Public
8  * License version 2, as published by the Free Software Foundation, and
9  * may be copied, distributed, and modified under those terms.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  */
16 #ifndef _ROCKCHIP_DRM_IOMMU_H_
17 #define _ROCKCHIP_DRM_IOMMU_H_
18
19 #define ROCKCHIP_DEV_ADDR_START 0x20000000
20 #define ROCKCHIP_DEV_ADDR_SIZE  0x40000000
21 #define ROCKCHIP_DEV_ADDR_ORDER 0x0
22
23 #ifdef CONFIG_DRM_ROCKCHIP_IOMMU
24
25 int drm_create_iommu_mapping(struct drm_device *drm_dev);
26
27 void drm_release_iommu_mapping(struct drm_device *drm_dev);
28
29 int drm_iommu_attach_device(struct drm_device *drm_dev,
30                                 struct device *subdrv_dev);
31
32 void drm_iommu_detach_device(struct drm_device *dev_dev,
33                                 struct device *subdrv_dev);
34
35 static inline bool is_drm_iommu_supported(struct drm_device *drm_dev)
36 {
37 #ifdef CONFIG_ARM_DMA_USE_IOMMU
38         struct device *dev = drm_dev->dev;
39
40         return dev->archdata.mapping ? true : false;
41 #else
42         return false;
43 #endif
44 }
45
46 #else
47
48 struct dma_iommu_mapping;
49 static inline int drm_create_iommu_mapping(struct drm_device *drm_dev)
50 {
51         return 0;
52 }
53
54 static inline void drm_release_iommu_mapping(struct drm_device *drm_dev)
55 {
56 }
57
58 static inline int drm_iommu_attach_device(struct drm_device *drm_dev,
59                                                 struct device *subdrv_dev)
60 {
61         return 0;
62 }
63
64 static inline void drm_iommu_detach_device(struct drm_device *drm_dev,
65                                                 struct device *subdrv_dev)
66 {
67 }
68
69 static inline bool is_drm_iommu_supported(struct drm_device *drm_dev)
70 {
71         return false;
72 }
73
74 #endif
75 #endif