From 94f2de1db2d6b5cda8a83e4516cb6e37f2d5a0bf Mon Sep 17 00:00:00 2001 From: ljf Date: Thu, 7 Aug 2014 16:38:31 +0800 Subject: [PATCH] add iommu switch in dts for iep --- drivers/video/rockchip/iep/hw_iep_reg.c | 12 +++--- drivers/video/rockchip/iep/iep_drv.c | 51 ++++++++++++++----------- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/drivers/video/rockchip/iep/hw_iep_reg.c b/drivers/video/rockchip/iep/hw_iep_reg.c index 0552a3984fe7..810206eebf1d 100755 --- a/drivers/video/rockchip/iep/hw_iep_reg.c +++ b/drivers/video/rockchip/iep/hw_iep_reg.c @@ -1195,7 +1195,7 @@ void iep_config(iep_session *session, IEP_MSG *iep_msg) #if defined(CONFIG_IEP_IOMMU) INIT_LIST_HEAD(®->mem_region_list); -#endif +#endif //write config iep_config_src_size(iep_msg); @@ -1249,10 +1249,12 @@ void iep_config(iep_session *session, IEP_MSG *iep_msg) #endif #if defined(CONFIG_IEP_IOMMU) - if (0 > iep_reg_address_translate(&iep_service, reg)) { - IEP_ERR("error: translate reg address failed\n"); - kfree(reg); - return; + if (iep_service.iommu_dev) { + if (0 > iep_reg_address_translate(&iep_service, reg)) { + IEP_ERR("error: translate reg address failed\n"); + kfree(reg); + return; + } } #endif diff --git a/drivers/video/rockchip/iep/iep_drv.c b/drivers/video/rockchip/iep/iep_drv.c index d5c8d96b1025..f1d0114a201d 100755 --- a/drivers/video/rockchip/iep/iep_drv.c +++ b/drivers/video/rockchip/iep/iep_drv.c @@ -79,11 +79,13 @@ static void iep_reg_deinit(struct iep_reg *reg) #if defined(CONFIG_IEP_IOMMU) struct iep_mem_region *mem_region = NULL, *n; // release memory region attach to this registers table. - list_for_each_entry_safe(mem_region, n, ®->mem_region_list, reg_lnk) { - ion_unmap_iommu(iep_service.iommu_dev, iep_service.ion_client, mem_region->hdl); - ion_free(iep_service.ion_client, mem_region->hdl); - list_del_init(&mem_region->reg_lnk); - kfree(mem_region); + if (iep_service.iommu_dev) { + list_for_each_entry_safe(mem_region, n, ®->mem_region_list, reg_lnk) { + ion_unmap_iommu(iep_service.iommu_dev, iep_service.ion_client, mem_region->hdl); + ion_free(iep_service.ion_client, mem_region->hdl); + list_del_init(&mem_region->reg_lnk); + kfree(mem_region); + } } #endif list_del_init(®->session_link); @@ -797,7 +799,10 @@ static int iep_drv_probe(struct platform_device *pdev) int ret = 0; struct resource *res = NULL; #if defined(CONFIG_IEP_IOMMU) + u32 iommu_en = 0; struct device *mmu_dev = NULL; + struct device_node *np = pdev->dev.of_node; + of_property_read_u32(np, "iommu_enabled", &iommu_en); #endif data = (struct iep_drvdata*)devm_kzalloc(&pdev->dev, sizeof(struct iep_drvdata), GFP_KERNEL); @@ -884,24 +889,26 @@ static int iep_drv_probe(struct platform_device *pdev) #if defined(CONFIG_IEP_IOMMU) iep_service.iommu_dev = NULL; - iep_power_on(); - iep_service.ion_client = rockchip_ion_client_create("iep"); - if (IS_ERR(iep_service.ion_client)) { - IEP_ERR("failed to create ion client for vcodec"); - return PTR_ERR(iep_service.ion_client); - } else { - IEP_INFO("iep ion client create success!\n"); - } - - mmu_dev = rockchip_get_sysmmu_device_by_compatible("iommu,iep_mmu"); - - if (mmu_dev) { - platform_set_sysmmu(mmu_dev, &pdev->dev); - iovmm_activate(&pdev->dev); + if (iommu_en) { + iep_power_on(); + iep_service.ion_client = rockchip_ion_client_create("iep"); + if (IS_ERR(iep_service.ion_client)) { + IEP_ERR("failed to create ion client for vcodec"); + return PTR_ERR(iep_service.ion_client); + } else { + IEP_INFO("iep ion client create success!\n"); + } + + mmu_dev = rockchip_get_sysmmu_device_by_compatible("iommu,iep_mmu"); + + if (mmu_dev) { + platform_set_sysmmu(mmu_dev, &pdev->dev); + iovmm_activate(&pdev->dev); + } + + iep_service.iommu_dev = &pdev->dev; + iep_power_off(); } - - iep_service.iommu_dev = &pdev->dev; - iep_power_off(); #endif IEP_INFO("IEP Driver loaded succesfully\n"); -- 2.34.1