From 7c3d77c388f714d8ae4f4fc789791e2d69ecab07 Mon Sep 17 00:00:00 2001
From: xxm <xxm@rock-chips.com>
Date: Fri, 8 Aug 2014 11:36:52 +0800
Subject: [PATCH] camsys_drv: update with iommu interface related changed

---
 .../media/video/rk_camsys/camsys_internal.h   |  3 +-
 drivers/media/video/rk_camsys/camsys_marvin.c | 41 +++++++++++++++++--
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/drivers/media/video/rk_camsys/camsys_internal.h b/drivers/media/video/rk_camsys/camsys_internal.h
index 112299f3de7b..87d45670661f 100755
--- a/drivers/media/video/rk_camsys/camsys_internal.h
+++ b/drivers/media/video/rk_camsys/camsys_internal.h
@@ -48,8 +48,7 @@
 #include <linux/of_gpio.h>
 #include <linux/rockchip/cpu.h>
 #include <media/camsys_head.h>
-#include <linux/rockchip/sysmmu.h>
-#include <linux/rockchip/iovmm.h>
+#include <linux/rockchip-iovmm.h>
 
 
 
diff --git a/drivers/media/video/rk_camsys/camsys_marvin.c b/drivers/media/video/rk_camsys/camsys_marvin.c
index 77a0a23e0ae1..c05ebd6d298b 100755
--- a/drivers/media/video/rk_camsys/camsys_marvin.c
+++ b/drivers/media/video/rk_camsys/camsys_marvin.c
@@ -194,6 +194,41 @@ static int camsys_mrv_flash_trigger_cb(void *ptr,unsigned int on)
     }
     return retval;
 }
+static struct device *rockchip_get_sysmmu_device_by_compatible(const char *compt)
+{
+	struct device_node *dn = NULL;
+	struct platform_device *pd = NULL;
+	struct device *ret = NULL ;
+
+	dn = of_find_compatible_node(NULL,NULL,compt);
+	if(!dn)
+	{
+		printk("can't find device node %s \r\n",compt);
+		return NULL;
+	}
+	
+	pd = of_find_device_by_node(dn);
+	if(!pd)
+	{	
+		printk("can't find platform device in device node %s \r\n",compt);
+		return  NULL;
+	}
+	ret = &pd->dev;
+	
+	return ret;
+
+}
+#ifdef CONFIG_IOMMU_API
+static inline void platform_set_sysmmu(struct device *iommu, struct device *dev)
+{
+	dev->archdata.iommu = iommu;
+}
+#else
+static inline void platform_set_sysmmu(struct device *iommu, struct device *dev)
+{
+}
+#endif
+
 
 static int camsys_mrv_iommu_cb(void *ptr,camsys_sysctrl_t *devctl)
 {
@@ -212,7 +247,7 @@ static int camsys_mrv_iommu_cb(void *ptr,camsys_sysctrl_t *devctl)
         goto iommu_end;
     }
     
-    iommu_dev = rockchip_get_sysmmu_device_by_compatible("iommu,isp_mmu");
+    iommu_dev = rockchip_get_sysmmu_device_by_compatible(ISP_IOMMU_COMPATIBLE_NAME);
     if(!iommu_dev){
         camsys_err("get iommu device erro!\n");
         ret = -1;
@@ -247,14 +282,14 @@ static int camsys_mrv_iommu_cb(void *ptr,camsys_sysctrl_t *devctl)
     }
     if(devctl->on){
         platform_set_sysmmu(iommu_dev,dev);
-        ret = iovmm_activate(dev);
+        ret = rockchip_iovmm_activate(dev);
         
         ret = ion_map_iommu(dev,client,handle,&(iommu->linear_addr),&(iommu->len));
         
     }else{
         ion_unmap_iommu(dev,client,handle);
         platform_set_sysmmu(iommu_dev,dev);
-        iovmm_deactivate(dev);
+        rockchip_iovmm_deactivate(dev);
     }
 iommu_end:
     return ret;
-- 
2.34.1