summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/include/mach
diff options
context:
space:
mode:
authorHiroshi DOYU <hdoyu@nvidia.com>2012-07-10 09:32:42 +0300
committerRohan Somvanshi <rsomvanshi@nvidia.com>2012-07-16 02:27:31 -0700
commit0f76524e9a3a88797b9b2e9f0f1dad33f64ffac6 (patch)
treeb05d57ff4d2a35d4bfa2e13b7666a2f34da1d58c /arch/arm/mach-tegra/include/mach
parentb8b0b4c42fc77d94b8deadaa46f795784f3bbb5e (diff)
ARM: tegra: iovmm: Replace IOVMM backend with IOMMU
Replace IOVMM backend functions with the standard IOMMU API ones. Instead of modifying the actual C-files in drivers, MACROs in iovmm.h does the all work. Change-Id: I27dc893555ca1495588852261e3ba1e3e5619764 Signed-off-by: Hiroshi DOYU <hdoyu@nvidia.com> Reviewed-on: http://git-master/r/114460 Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com> Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/include/mach')
-rw-r--r--arch/arm/mach-tegra/include/mach/iovmm.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/include/mach/iovmm.h b/arch/arm/mach-tegra/include/mach/iovmm.h
index ff94e4751a75..e1e360be9010 100644
--- a/arch/arm/mach-tegra/include/mach/iovmm.h
+++ b/arch/arm/mach-tegra/include/mach/iovmm.h
@@ -68,6 +68,8 @@ struct tegra_iovmm_domain {
struct iovmm_share_group;
+#if !defined(CONFIG_IOMMU_API)
+
struct tegra_iovmm_client {
const char *name;
unsigned long flags;
@@ -90,6 +92,25 @@ struct tegra_iovmm_area {
struct tegra_iovmm_area_ops *ops;
};
+#else /* CONFIG_IOMMU_API */
+
+/*
+ * To replace IOVMM with IOMMU backend
+ */
+
+struct tegra_iovmm_client {
+ struct device *dev;
+};
+
+struct tegra_iovmm_area {
+ dma_addr_t iovm_start;
+ size_t iovm_length;
+ pgprot_t pgprot;
+ struct device *dev;
+};
+
+#endif /* CONFIG_IOMMU_API */
+
struct tegra_iovmm_device_ops {
/* maps a VMA using the page residency functions provided by the VMA */
int (*map)(struct tegra_iovmm_domain *domain,
@@ -326,5 +347,37 @@ static inline void tegra_iovmm_resume(void)
{
}
+#ifdef CONFIG_IOMMU_API
+/*
+ * Replace tegra_iovmm_*() with tegra_iommu_*() helpers
+ */
+#include <linux/dma-mapping.h>
+#include <linux/dma-direction.h>
+
+#include <asm/dma-iommu.h>
+
+#define tegra_iovmm_alloc_client(d, s, m) tegra_iommu_alloc_client(d)
+#define tegra_iovmm_free_client(c) tegra_iommu_free_client(c)
+
+#define tegra_iovmm_create_vm(c, o, s, a, p, i) \
+ tegra_iommu_create_vm((c)->dev, i, s, p)
+#define tegra_iovmm_free_vm(v) tegra_iommu_free_vm(v)
+
+#define tegra_iovmm_get_vm_size(c) arm_iommu_iova_avail((c)->dev)
+#define tegra_iovmm_get_max_free(c) arm_iommu_iova_max_free((c)->dev)
+
+#define tegra_iovmm_vm_insert_pfn(a, v, n) \
+ dma_map_page_at((a)->dev, pfn_to_page(n), v, 0, PAGE_SIZE, DMA_NONE);
+
+struct tegra_iovmm_area *tegra_iommu_create_vm(struct device *dev,
+ dma_addr_t req, size_t size, pgprot_t prot);
+
+void tegra_iommu_free_vm(struct tegra_iovmm_area *area);
+
+struct tegra_iovmm_client *tegra_iommu_alloc_client(struct device *dev);
+
+void tegra_iommu_free_client(struct tegra_iovmm_client *client);
+
+#endif /* CONFIG_IOMMU_API */
#endif /* CONFIG_TEGRA_IOVMM */
#endif /* _MACH_TEGRA_IOVMM_H_*/