From 1897916287efb744b887a7ccaf3af39beebc2531 Mon Sep 17 00:00:00 2001 From: zwl Date: Thu, 14 Aug 2014 14:40:16 +0800 Subject: [PATCH] rk lcdc: use new interface to open and active vop iommu device --- drivers/video/rockchip/lcdc/rk3036_lcdc.c | 17 +++++------ drivers/video/rockchip/lcdc/rk312x_lcdc.c | 26 +++++++++------- drivers/video/rockchip/lcdc/rk3288_lcdc.c | 36 ++++++++++++++++++++++- drivers/video/rockchip/rk_fb.c | 24 +++++++-------- include/linux/rk_fb.h | 3 ++ 5 files changed, 72 insertions(+), 34 deletions(-) diff --git a/drivers/video/rockchip/lcdc/rk3036_lcdc.c b/drivers/video/rockchip/lcdc/rk3036_lcdc.c index 08ab74b48b7f..581adf725163 100755 --- a/drivers/video/rockchip/lcdc/rk3036_lcdc.c +++ b/drivers/video/rockchip/lcdc/rk3036_lcdc.c @@ -34,8 +34,7 @@ #include #include #if defined(CONFIG_ION_ROCKCHIP) -#include -#include +#include #endif #include "rk3036_lcdc.h" @@ -645,15 +644,16 @@ static int rk3036_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id, if ((open) && (!lcdc_dev->atv_layer_cnt)) { rk3036_lcdc_pre_init(dev_drv); rk3036_lcdc_clk_enable(lcdc_dev); - #if defined(CONFIG_ROCKCHIP_IOMMU) + #if defined(CONFIG_ROCKCHIP_IOMMU) if (dev_drv->iommu_enabled) { if (!dev_drv->mmu_dev) { dev_drv->mmu_dev = - rockchip_get_sysmmu_device_by_compatible( + rk_fb_get_sysmmu_device_by_compatible( dev_drv->mmu_dts_name); if (dev_drv->mmu_dev) { - platform_set_sysmmu(dev_drv->mmu_dev, + rk_fb_platform_set_sysmmu(dev_drv->mmu_dev, dev_drv->dev); + rockchip_iovmm_activate(dev_drv->dev); } else { dev_err(dev_drv->dev, "failed to get iommu device\n" @@ -661,9 +661,8 @@ static int rk3036_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id, return -1; } } - iovmm_activate(dev_drv->dev); } - #endif + #endif rk3036_lcdc_reg_restore(lcdc_dev); if (dev_drv->iommu_enabled) rk3036_lcdc_mmu_en(dev_drv); @@ -976,7 +975,7 @@ static int rk3036_lcdc_early_suspend(struct rk_lcdc_driver *dev_drv) lcdc_cfg_done(lcdc_dev); if (dev_drv->iommu_enabled) { if (dev_drv->mmu_dev) - iovmm_deactivate(dev_drv->dev); + rockchip_iovmm_deactivate(dev_drv->dev); } spin_unlock(&lcdc_dev->reg_lock); } else { @@ -1013,7 +1012,7 @@ static int rk3036_lcdc_early_resume(struct rk_lcdc_driver *dev_drv) lcdc_cfg_done(lcdc_dev); if (dev_drv->iommu_enabled) { if (dev_drv->mmu_dev) - iovmm_activate(dev_drv->dev); + rockchip_iovmm_activate(dev_drv->dev); } spin_unlock(&lcdc_dev->reg_lock); } diff --git a/drivers/video/rockchip/lcdc/rk312x_lcdc.c b/drivers/video/rockchip/lcdc/rk312x_lcdc.c index 401de7869511..effb23571c46 100755 --- a/drivers/video/rockchip/lcdc/rk312x_lcdc.c +++ b/drivers/video/rockchip/lcdc/rk312x_lcdc.c @@ -1031,18 +1031,17 @@ static int rk312x_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id, if (dev_drv->iommu_enabled) { if (!dev_drv->mmu_dev) { dev_drv->mmu_dev = - rockchip_get_sysmmu_device_by_compatible - (dev_drv->mmu_dts_name); - if (dev_drv->mmu_dev) - platform_set_sysmmu(dev_drv->mmu_dev, - dev_drv->dev); - else { + rk_fb_get_sysmmu_device_by_compatible(dev_drv->mmu_dts_name); + if (dev_drv->mmu_dev) { + rk_fb_platform_set_sysmmu(dev_drv->mmu_dev, + dev_drv->dev); + rockchip_iovmm_activate(dev_drv->dev); + } else { dev_err(dev_drv->dev, "failed to get rockchip iommu device\n"); return -1; } } - iovmm_activate(dev_drv->dev); } #endif rk312x_lcdc_reg_restore(lcdc_dev); @@ -1072,7 +1071,7 @@ static int rk312x_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id, #if defined(CONFIG_ROCKCHIP_IOMMU) if (dev_drv->iommu_enabled) { if (dev_drv->mmu_dev) - iovmm_deactivate(dev_drv->dev); + rockchip_iovmm_deactivate(dev_drv->dev); } #endif rk312x_lcdc_clk_disable(lcdc_dev); @@ -1341,12 +1340,12 @@ static int rk312x_lcdc_early_suspend(struct rk_lcdc_driver *dev_drv) lcdc_msk_reg(lcdc_dev, SYS_CTRL, m_LCDC_STANDBY, v_LCDC_STANDBY(1)); lcdc_cfg_done(lcdc_dev); -#if defined(CONFIG_ROCKCHIP_IOMMU) + if (dev_drv->iommu_enabled) { if (dev_drv->mmu_dev) - iovmm_deactivate(dev_drv->dev); + rockchip_iovmm_deactivate(dev_drv->dev); } -#endif + spin_unlock(&lcdc_dev->reg_lock); } else { spin_unlock(&lcdc_dev->reg_lock); @@ -1383,6 +1382,11 @@ static int rk312x_lcdc_early_resume(struct rk_lcdc_driver *dev_drv) lcdc_msk_reg(lcdc_dev, DSP_CTRL1, m_BLANK_EN, v_BLANK_EN(0)); lcdc_cfg_done(lcdc_dev); + if (dev_drv->iommu_enabled) { + if (dev_drv->mmu_dev) + rockchip_iovmm_activate(dev_drv->dev); + } + spin_unlock(&lcdc_dev->reg_lock); } diff --git a/drivers/video/rockchip/lcdc/rk3288_lcdc.c b/drivers/video/rockchip/lcdc/rk3288_lcdc.c index 0f5b6c195690..6cbcbaaa658b 100755 --- a/drivers/video/rockchip/lcdc/rk3288_lcdc.c +++ b/drivers/video/rockchip/lcdc/rk3288_lcdc.c @@ -1298,6 +1298,23 @@ static int rk3288_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id, if ((open) && (!lcdc_dev->atv_layer_cnt)) { rockchip_set_system_status(sys_status); rk3288_lcdc_pre_init(dev_drv); +#if defined(CONFIG_ROCKCHIP_IOMMU) + if (dev_drv->iommu_enabled) { + if (!dev_drv->mmu_dev) { + dev_drv->mmu_dev = + rk_fb_get_sysmmu_device_by_compatible(dev_drv->mmu_dts_name); + if (dev_drv->mmu_dev) { + rk_fb_platform_set_sysmmu(dev_drv->mmu_dev, + dev_drv->dev); + rockchip_iovmm_activate(dev_drv->dev); + } else { + dev_err(dev_drv->dev, + "failed to get rockchip iommu device\n"); + return -1; + } + } + } +#endif rk3288_lcdc_clk_enable(lcdc_dev); rk3288_lcdc_reg_restore(lcdc_dev); if (dev_drv->iommu_enabled) @@ -1325,10 +1342,16 @@ static int rk3288_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id, else dev_err(lcdc_dev->dev, "invalid win id:%d\n", win_id); - /*when all layer closed,disable clk */ + /* when all layer closed,disable clk */ if ((!open) && (!lcdc_dev->atv_layer_cnt)) { rk3288_lcdc_disable_irq(lcdc_dev); rk3288_lcdc_reg_update(dev_drv); +#if defined(CONFIG_ROCKCHIP_IOMMU) + if (dev_drv->iommu_enabled) { + if (dev_drv->mmu_dev) + rockchip_iovmm_deactivate(dev_drv->dev); + } +#endif rk3288_lcdc_clk_disable(lcdc_dev); rockchip_clear_system_status(sys_status); } @@ -2281,6 +2304,12 @@ static int rk3288_lcdc_early_suspend(struct rk_lcdc_driver *dev_drv) lcdc_msk_reg(lcdc_dev, SYS_CTRL, m_STANDBY_EN, v_STANDBY_EN(1)); lcdc_cfg_done(lcdc_dev); + + if (dev_drv->iommu_enabled) { + if (dev_drv->mmu_dev) + rockchip_iovmm_deactivate(dev_drv->dev); + } + spin_unlock(&lcdc_dev->reg_lock); } else { spin_unlock(&lcdc_dev->reg_lock); @@ -2331,6 +2360,11 @@ static int rk3288_lcdc_early_resume(struct rk_lcdc_driver *dev_drv) v_DSP_BLANK_EN(0)); lcdc_cfg_done(lcdc_dev); + if (dev_drv->iommu_enabled) { + if (dev_drv->mmu_dev) + rockchip_iovmm_activate(dev_drv->dev); + } + spin_unlock(&lcdc_dev->reg_lock); } diff --git a/drivers/video/rockchip/rk_fb.c b/drivers/video/rockchip/rk_fb.c index 42d5408ae4d3..43f35f160d5f 100755 --- a/drivers/video/rockchip/rk_fb.c +++ b/drivers/video/rockchip/rk_fb.c @@ -706,33 +706,31 @@ bool rk_fb_poll_wait_frame_complete(void) } -/**** -1,success : pointer to the device inside of platform device -2,fail : NULL -****/ +/* rk_fb_get_sysmmu_device_by_compatible() + * @compt: dts device compatible name + * return value: success: pointer to the device inside of platform device + * fail: NULL + */ struct device *rk_fb_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); + 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); + 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 @@ -743,7 +741,7 @@ void rk_fb_platform_set_sysmmu(struct device *sysmmu, struct device *dev) #else void rk_fb_platform_set_sysmmu(struct device *sysmmu, struct device *dev) { - + } #endif diff --git a/include/linux/rk_fb.h b/include/linux/rk_fb.h index a52077480bd9..e95399432a8f 100755 --- a/include/linux/rk_fb.h +++ b/include/linux/rk_fb.h @@ -641,4 +641,7 @@ extern char *get_format_string(enum data_format, char *fmt); extern int support_uboot_display(void); extern int rk_fb_calc_fps(struct rk_screen *screen, u32 pixclock); extern int rk_get_real_fps(int time); +extern struct device *rk_fb_get_sysmmu_device_by_compatible(const char *compt); +extern void rk_fb_platform_set_sysmmu(struct device *sysmmu, + struct device *dev); #endif -- 2.34.1