Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v4.20-rc1 134 lines 3.2 kB view raw
1/* exynos_drm_iommu.h 2 * 3 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 4 * Authoer: Inki Dae <inki.dae@samsung.com> 5 * 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. 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 17 18#ifdef CONFIG_DRM_EXYNOS_IOMMU 19 20#if defined(CONFIG_ARM_DMA_USE_IOMMU) 21#include <asm/dma-iommu.h> 22 23static 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 31static inline void 32__exynos_iommu_release_mapping(struct exynos_drm_private *priv) 33{ 34 arm_iommu_release_mapping(priv->mapping); 35} 36 37static 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 46static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, 47 struct device *dev) 48{ 49 arm_iommu_detach_device(dev); 50} 51 52#elif defined(CONFIG_IOMMU_DMA) 53#include <linux/dma-iommu.h> 54 55static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv, 56 unsigned long start, unsigned long size) 57{ 58 priv->mapping = iommu_get_domain_for_dev(priv->dma_dev); 59 return 0; 60} 61 62static inline void __exynos_iommu_release_mapping(struct exynos_drm_private *priv) 63{ 64 priv->mapping = NULL; 65} 66 67static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, 68 struct device *dev) 69{ 70 struct iommu_domain *domain = priv->mapping; 71 72 if (dev != priv->dma_dev) 73 return iommu_attach_device(domain, dev); 74 return 0; 75} 76 77static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, 78 struct device *dev) 79{ 80 struct iommu_domain *domain = priv->mapping; 81 82 if (dev != priv->dma_dev) 83 iommu_detach_device(domain, dev); 84} 85#else 86#error Unsupported architecture and IOMMU/DMA-mapping glue code 87#endif 88 89int drm_create_iommu_mapping(struct drm_device *drm_dev); 90 91void drm_release_iommu_mapping(struct drm_device *drm_dev); 92 93int drm_iommu_attach_device(struct drm_device *drm_dev, 94 struct device *subdrv_dev); 95 96void drm_iommu_detach_device(struct drm_device *dev_dev, 97 struct device *subdrv_dev); 98 99static inline bool is_drm_iommu_supported(struct drm_device *drm_dev) 100{ 101 struct exynos_drm_private *priv = drm_dev->dev_private; 102 103 return priv->mapping ? true : false; 104} 105 106#else 107 108static inline int drm_create_iommu_mapping(struct drm_device *drm_dev) 109{ 110 return 0; 111} 112 113static inline void drm_release_iommu_mapping(struct drm_device *drm_dev) 114{ 115} 116 117static inline int drm_iommu_attach_device(struct drm_device *drm_dev, 118 struct device *subdrv_dev) 119{ 120 return 0; 121} 122 123static inline void drm_iommu_detach_device(struct drm_device *drm_dev, 124 struct device *subdrv_dev) 125{ 126} 127 128static inline bool is_drm_iommu_supported(struct drm_device *drm_dev) 129{ 130 return false; 131} 132 133#endif 134#endif