video: rockchip: vop iommu state depend on dts and delete CONFIG_ROCKCHIP_IOMMU
authorHuang Jiachai <hjc@rock-chips.com>
Thu, 14 Jan 2016 06:27:57 +0000 (14:27 +0800)
committerHuang Jiachai <hjc@rock-chips.com>
Mon, 25 Jan 2016 12:40:47 +0000 (20:40 +0800)
Change-Id: I4de26882995313ed11c81b2162e29bc771e117de
Signed-off-by: Huang Jiachai <hjc@rock-chips.com>
drivers/video/rockchip/lcdc/rk3036_lcdc.c
drivers/video/rockchip/lcdc/rk312x_lcdc.c
drivers/video/rockchip/lcdc/rk322x_lcdc.c
drivers/video/rockchip/lcdc/rk3288_lcdc.c
drivers/video/rockchip/lcdc/rk3368_lcdc.c
drivers/video/rockchip/rk_fb.c

index c01520c4161906990f7cab595b9a874c198a814a..dbaf15bfafe4c72448ba72d43f2e2296315629a2 100755 (executable)
@@ -728,7 +728,6 @@ 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 (dev_drv->iommu_enabled) {
                        if (!dev_drv->mmu_dev) {
                                dev_drv->mmu_dev =
@@ -745,7 +744,6 @@ static int rk3036_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id,
                                }
                        }
                }
-       #endif
                rk3036_lcdc_reg_restore(lcdc_dev);
                /*if (dev_drv->iommu_enabled)
                        rk3036_lcdc_mmu_en(dev_drv);*/
@@ -767,12 +765,10 @@ static int rk3036_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id,
        if ((!open) && (!lcdc_dev->atv_layer_cnt)) {
                rk3036_lcdc_disable_irq(lcdc_dev);
                rk3036_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
                rk3036_lcdc_clk_disable(lcdc_dev);
        }
 */
@@ -1156,7 +1152,6 @@ static int rk3036_lcdc_cfg_done(struct rk_lcdc_driver *dev_drv)
 
        spin_lock(&lcdc_dev->reg_lock);
        if (lcdc_dev->clk_on) {
-               #if defined(CONFIG_ROCKCHIP_IOMMU)
                if (dev_drv->iommu_enabled) {
                        if (!lcdc_dev->iommu_status && dev_drv->mmu_dev) {
                                lcdc_dev->iommu_status = 1;
@@ -1174,7 +1169,6 @@ static int rk3036_lcdc_cfg_done(struct rk_lcdc_driver *dev_drv)
                                rk3036_lcdc_mmu_en(dev_drv);
                        }
                }
-               #endif
                lcdc_msk_reg(lcdc_dev, SYS_CTRL, m_LCDC_STANDBY,
                             v_LCDC_STANDBY(lcdc_dev->standby));
                for (i = 0; i < ARRAY_SIZE(lcdc_win); i++) {
@@ -1551,14 +1545,10 @@ static int rk3036_lcdc_parse_dt(struct lcdc_device *lcdc_dev)
        struct device_node *np = lcdc_dev->dev->of_node;
        int val;
 
-#if defined(CONFIG_ROCKCHIP_IOMMU)
        if (of_property_read_u32(np, "rockchip,iommu-enabled", &val))
                lcdc_dev->driver.iommu_enabled = 0;
        else
                lcdc_dev->driver.iommu_enabled = val;
-#else
-       lcdc_dev->driver.iommu_enabled = 0;
-#endif
        if (of_property_read_u32(np, "rockchip,fb-win-map", &val))
                lcdc_dev->driver.fb_win_map = FB_DEFAULT_ORDER;
        else
index c1721b3c48175f48c9479d1eafe1bc15d6cd2da0..0a1dc7f0a65e8f91e6d13c8c77d69a3435917b99 100755 (executable)
@@ -635,14 +635,12 @@ static int rk312x_lcdc_mmu_en(struct rk_lcdc_driver *dev_drv)
                lcdc_msk_reg(lcdc_dev, AXI_BUS_CTRL, mask, val);
        }
        /*spin_unlock(&lcdc_dev->reg_lock);*/
-       #if defined(CONFIG_ROCKCHIP_IOMMU)
        if (dev_drv->iommu_enabled) {
                if (!lcdc_dev->iommu_status && dev_drv->mmu_dev) {
                        lcdc_dev->iommu_status = 1;
                        rockchip_iovmm_activate(dev_drv->dev);
                }
        }
-       #endif
 
        return 0;
 }
@@ -1488,7 +1486,6 @@ static int rk312x_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id,
                rockchip_set_system_status(SYS_STATUS_LCDC0);
                rk312x_lcdc_pre_init(dev_drv);
                rk312x_lcdc_clk_enable(lcdc_dev);
-#if defined(CONFIG_ROCKCHIP_IOMMU)
                if (dev_drv->iommu_enabled) {
                        if (!dev_drv->mmu_dev) {
                                dev_drv->mmu_dev =
@@ -1505,7 +1502,6 @@ static int rk312x_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id,
                        /*if (dev_drv->mmu_dev)
                                rockchip_iovmm_activate(dev_drv->dev);*/
                }
-#endif
                rk312x_lcdc_reg_restore(lcdc_dev);
                /*if (dev_drv->iommu_enabled)
                        rk312x_lcdc_mmu_en(dev_drv);*/
@@ -1533,12 +1529,10 @@ static int rk312x_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id,
 /*     if ((!open) && (!lcdc_dev->atv_layer_cnt)) {
                rk312x_lcdc_disable_irq(lcdc_dev);
                rk312x_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
                rk312x_lcdc_clk_disable(lcdc_dev);
                rockchip_clear_system_status(SYS_STATUS_LCDC0);
        }*/
@@ -2618,14 +2612,10 @@ static int rk312x_lcdc_parse_dt(struct lcdc_device *lcdc_dev)
        const struct rk_lcdc_drvdata *lcdc_drvdata;
        int val;
 
-#if defined(CONFIG_ROCKCHIP_IOMMU)
        if (of_property_read_u32(np, "rockchip,iommu-enabled", &val))
                lcdc_dev->driver.iommu_enabled = 0;
        else
                lcdc_dev->driver.iommu_enabled = val;
-#else
-       lcdc_dev->driver.iommu_enabled = 0;
-#endif
 
        if (of_property_read_u32(np, "rockchip,fb-win-map", &val))
                lcdc_dev->driver.fb_win_map = FB_DEFAULT_ORDER;
index 0ec00873161163c274a5e707ad7b1aeb065fe339..1694c9158435cc8efa45b97ebaeaf28626a10313 100644 (file)
@@ -1164,7 +1164,6 @@ static int __maybe_unused vop_mmu_en(struct rk_lcdc_driver *dev_drv)
                pr_info("%s,clk_on = %d\n", __func__, vop_dev->clk_on);
                return 0;
        }
-#if defined(CONFIG_ROCKCHIP_IOMMU)
        if (dev_drv->iommu_enabled) {
                if (!vop_dev->iommu_status && dev_drv->mmu_dev) {
                        if (likely(vop_dev->clk_on)) {
@@ -1178,7 +1177,6 @@ static int __maybe_unused vop_mmu_en(struct rk_lcdc_driver *dev_drv)
                        rockchip_iovmm_activate(dev_drv->dev);
                }
        }
-#endif
        return 0;
 }
 
@@ -1644,7 +1642,6 @@ static int vop_open(struct rk_lcdc_driver *dev_drv, int win_id,
                vop_pre_init(dev_drv);
                vop_clk_enable(vop_dev);
                vop_enable_irq(dev_drv);
-#if defined(CONFIG_ROCKCHIP_IOMMU)
                if (dev_drv->iommu_enabled) {
                        if (!dev_drv->mmu_dev) {
                                dev_drv->mmu_dev =
@@ -1660,7 +1657,6 @@ static int vop_open(struct rk_lcdc_driver *dev_drv, int win_id,
                                }
                        }
                }
-#endif
                if ((support_uboot_display() && (vop_dev->prop == PRMRY)))
                        vop_set_dclk(dev_drv, 0);
                else
@@ -3540,14 +3536,10 @@ static int vop_parse_dt(struct vop_device *vop_dev)
                dev_drv->bcsh.cos_hue = (val >> 8) & 0xff;
        }
 
-#if defined(CONFIG_ROCKCHIP_IOMMU)
        if (of_property_read_u32(np, "rockchip,iommu-enabled", &val))
                dev_drv->iommu_enabled = 0;
        else
                dev_drv->iommu_enabled = val;
-#else
-       dev_drv->iommu_enabled = 0;
-#endif
        return 0;
 }
 
index a90c8cb00416c6eeda2181499a7e7c58aff3e2e7..5e44b961d66bc305ccde1fa8a9b6012e7e39a15e 100755 (executable)
@@ -1085,7 +1085,6 @@ static int rk3288_lcdc_mmu_en(struct rk_lcdc_driver *dev_drv)
                pr_info("%s,clk_on = %d\n", __func__, lcdc_dev->clk_on);
                return 0;
        }
-#if defined(CONFIG_ROCKCHIP_IOMMU)
        if (dev_drv->iommu_enabled) {
                if (!lcdc_dev->iommu_status && dev_drv->mmu_dev) {
 
@@ -1103,7 +1102,6 @@ static int rk3288_lcdc_mmu_en(struct rk_lcdc_driver *dev_drv)
                        rockchip_iovmm_activate(dev_drv->dev);
                }
        }
-#endif
        return 0;
 }
 
@@ -1572,7 +1570,6 @@ static int rk3288_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id,
                rk3288_lcdc_pre_init(dev_drv);
                rk3288_lcdc_clk_enable(lcdc_dev);
                rk3288_lcdc_enable_irq(dev_drv);
-#if defined(CONFIG_ROCKCHIP_IOMMU)
                if (dev_drv->iommu_enabled) {
                        if (!dev_drv->mmu_dev) {
                                dev_drv->mmu_dev =
@@ -1587,7 +1584,6 @@ static int rk3288_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id,
                                }
                        }
                }
-#endif
                rk3288_lcdc_reg_restore(lcdc_dev);
                /*if (dev_drv->iommu_enabled)
                   rk3368_lcdc_mmu_en(dev_drv); */
@@ -1619,14 +1615,12 @@ static int rk3288_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id,
        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);
                                lcdc_dev->iommu_status = 0;
                        }
                }
-#endif
                rk3288_lcdc_clk_disable(lcdc_dev);
                rockchip_clear_system_status(sys_status);
        }
@@ -4062,14 +4056,10 @@ static int rk3288_lcdc_parse_dt(struct lcdc_device *lcdc_dev)
                dev_drv->bcsh.cos_hue = (val >> 8) & 0xff;
        }
 
-#if defined(CONFIG_ROCKCHIP_IOMMU)
        if (of_property_read_u32(np, "rockchip,iommu-enabled", &val))
                dev_drv->iommu_enabled = 0;
        else
                dev_drv->iommu_enabled = val;
-#else
-       dev_drv->iommu_enabled = 0;
-#endif
        return 0;
 }
 
index 63f9a7afe72626f02a89c61eeb19b101e6737ca4..e504618bd5152f6702400c1381a205ddb33b1b7b 100644 (file)
@@ -1555,7 +1555,6 @@ static int __maybe_unused rk3368_lcdc_mmu_en(struct rk_lcdc_driver *dev_drv)
                pr_info("%s,clk_on = %d\n", __func__, lcdc_dev->clk_on);
                return 0;
        }
-#if defined(CONFIG_RK_IOMMU)
        if (dev_drv->iommu_enabled) {
                if (!lcdc_dev->iommu_status && dev_drv->mmu_dev) {
                        if (likely(lcdc_dev->clk_on)) {
@@ -1572,7 +1571,6 @@ static int __maybe_unused rk3368_lcdc_mmu_en(struct rk_lcdc_driver *dev_drv)
                        rockchip_iovmm_activate(dev_drv->dev);
                }
        }
-#endif
        return 0;
 }
 
@@ -2257,7 +2255,6 @@ static int rk3368_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id,
                rk3368_lcdc_pre_init(dev_drv);
                rk3368_lcdc_clk_enable(lcdc_dev);
                rk3368_lcdc_enable_irq(dev_drv);
-#if defined(CONFIG_RK_IOMMU)
                if (dev_drv->iommu_enabled) {
                        if (!dev_drv->mmu_dev) {
                                dev_drv->mmu_dev =
@@ -2275,7 +2272,6 @@ static int rk3368_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id,
                        /*if (dev_drv->mmu_dev)
                           rockchip_iovmm_activate(dev_drv->dev); */
                }
-#endif
                rk3368_lcdc_reg_restore(lcdc_dev);
                /*if (dev_drv->iommu_enabled)
                   rk3368_lcdc_mmu_en(dev_drv); */
@@ -2304,12 +2300,10 @@ static int rk3368_lcdc_open(struct rk_lcdc_driver *dev_drv, int win_id,
        /*if ((!open) && (!lcdc_dev->atv_layer_cnt)) {
           rk3368_lcdc_disable_irq(lcdc_dev);
           rk3368_lcdc_reg_update(dev_drv);
-          #if defined(CONFIG_RK_IOMMU)
           if (dev_drv->iommu_enabled) {
           if (dev_drv->mmu_dev)
           rockchip_iovmm_deactivate(dev_drv->dev);
           }
-          #endif
           rk3368_lcdc_clk_disable(lcdc_dev);
           #ifndef CONFIG_RK_FPGA
           rockchip_clear_system_status(sys_status);
@@ -4895,14 +4889,10 @@ static int rk3368_lcdc_parse_dt(struct lcdc_device *lcdc_dev)
                dev_drv->bcsh.cos_hue = (val >> 8) & 0xff;
        }
 
-#if defined(CONFIG_RK_IOMMU)
        if (of_property_read_u32(np, "rockchip,iommu-enabled", &val))
                dev_drv->iommu_enabled = 0;
        else
                dev_drv->iommu_enabled = val;
-#else
-       dev_drv->iommu_enabled = 0;
-#endif
        return 0;
 }
 
index 35aa8be4486de63ec72be6ef72466fa94856e4d4..a267229b203834aa0c7827a229a1b4351fef761b 100644 (file)
@@ -1205,7 +1205,6 @@ static void win_copy_by_rga(struct rk_lcdc_win *dst_win,
        Rga_Request.clip.ymin = 0;
        Rga_Request.clip.ymax = dst_win->area[0].yact - 1;
        Rga_Request.scale_mode = 0;
-#if defined(CONFIG_RK_IOMMU)
        if (iommu_en) {
                Rga_Request.mmu_info.mmu_en = 1;
                Rga_Request.mmu_info.mmu_flag = 1;
@@ -1213,10 +1212,6 @@ static void win_copy_by_rga(struct rk_lcdc_win *dst_win,
                Rga_Request.mmu_info.mmu_en = 0;
                Rga_Request.mmu_info.mmu_flag = 0;
        }
-#else
-       Rga_Request.mmu_info.mmu_en = 0;
-       Rga_Request.mmu_info.mmu_flag = 0;
-#endif
 
        ret = rga_ioctl_kernel(&Rga_Request);
 }
@@ -1464,7 +1459,6 @@ static int rk_fb_copy_from_loader(struct fb_info *info)
        return 0;
 }
 #endif
-#ifdef CONFIG_RK_IOMMU
 static int g_last_addr[5][4];
 static int g_now_config_addr[5][4];
 static int g_last_state[5][4];
@@ -1514,7 +1508,6 @@ int rk_fb_sysmmu_fault_handler(struct device *dev,
 
        return 0;
 }
-#endif
 
 void rk_fb_free_dma_buf(struct rk_lcdc_driver *dev_drv,
                        struct rk_fb_reg_win_data *reg_win_data)
@@ -1526,7 +1519,6 @@ void rk_fb_free_dma_buf(struct rk_lcdc_driver *dev_drv,
        for (i = 0; i < reg_win_data->area_num; i++) {
                area_data = &reg_win_data->reg_area_data[i];
                index_buf = area_data->index_buf;
-#if defined(CONFIG_RK_IOMMU)
                if (dev_drv->iommu_enabled) {
                        if (area_data->ion_handle != NULL &&
                            !IS_YUV_FMT(area_data->data_format))
@@ -1534,7 +1526,6 @@ void rk_fb_free_dma_buf(struct rk_lcdc_driver *dev_drv,
                                                area_data->ion_handle);
                        freed_addr[freed_index++] = area_data->smem_start;
                }
-#endif
                if (area_data->ion_handle != NULL)
                        ion_free(rk_fb->ion_client, area_data->ion_handle);
 
@@ -1662,22 +1653,18 @@ static void rk_fb_update_win(struct rk_lcdc_driver *dev_drv,
                                win->area[i].y_vir_stride =
                                    reg_win_data->reg_area_data[i].y_vir_stride;
                                win->area[i].state = 1;
-#if defined(CONFIG_RK_IOMMU)
                                if (dev_drv->iommu_enabled) {
                                        g_now_config_addr[win->id][i] =
                                                win->area[i].smem_start +
                                                win->area[i].y_offset;
                                        g_now_config_state[win->id][i] = 1;
                                }
-#endif
                        } else {
                                win->area[i].state = 0;
-#if defined(CONFIG_RK_IOMMU)
                                if (dev_drv->iommu_enabled) {
                                        g_now_config_addr[win->id][i] = 0;
                                        g_now_config_state[win->id][i] = 0;
                                }
-#endif
                        }
                }
        }
@@ -1852,14 +1839,12 @@ static void rk_fb_update_reg(struct rk_lcdc_driver *dev_drv,
                        win->state = 0;
                        for (j = 0; j < 4; j++)
                                win->area[j].state = 0;
-#if defined(CONFIG_RK_IOMMU)
                        if (dev_drv->iommu_enabled) {
                                for (j = 0; j < 4; j++) {
                                        g_now_config_addr[i][j] = 0;
                                        g_now_config_state[i][j] = 0;
                                }
                        }
-#endif
                }
        }
        dev_drv->ops->ovl_mgr(dev_drv, 0, 1);
@@ -1885,14 +1870,12 @@ static void rk_fb_update_reg(struct rk_lcdc_driver *dev_drv,
 #endif
 
        if (dev_drv->front_regs) {
-#if defined(CONFIG_RK_IOMMU)
                if (dev_drv->iommu_enabled) {
                        if (dev_drv->ops->mmu_en)
                                dev_drv->ops->mmu_en(dev_drv);
                        freed_index = 0;
                        g_last_timeout = timeout;
                }
-#endif
 
                mutex_lock(&dev_drv->front_lock);
 
@@ -1904,10 +1887,8 @@ static void rk_fb_update_reg(struct rk_lcdc_driver *dev_drv,
 
                mutex_unlock(&dev_drv->front_lock);
 
-#if defined(CONFIG_RK_IOMMU)
                if (dev_drv->iommu_enabled)
                        freed_addr[freed_index] = 0xfefefefe;
-#endif
        }
 
        mutex_lock(&dev_drv->front_lock);
@@ -2110,10 +2091,6 @@ static int rk_fb_set_win_buffer(struct fb_info *info,
                                        break;
                                }
                                reg_win_data->reg_area_data[i].ion_handle = hdl;
-#ifndef CONFIG_RK_IOMMU
-                               ret = ion_phys(rk_fb->ion_client, hdl, &phy_addr,
-                                              &len);
-#else
                                if (dev_drv->iommu_enabled)
                                        ret = ion_map_iommu(dev_drv->dev,
                                                            rk_fb->ion_client,
@@ -2123,7 +2100,6 @@ static int rk_fb_set_win_buffer(struct fb_info *info,
                                else
                                        ret = ion_phys(rk_fb->ion_client, hdl,
                                                       &phy_addr, &len);
-#endif
                                if (ret < 0) {
                                        dev_err(fbi->dev, "ion map to get phy addr failed\n");
                                        ion_free(rk_fb->ion_client, hdl);
@@ -2589,11 +2565,9 @@ int rk_get_real_fps(int before)
 EXPORT_SYMBOL(rk_get_real_fps);
 
 #endif
-#ifdef CONFIG_RK_IOMMU
 #define ION_MAX 10
 static struct ion_handle *ion_hanle[ION_MAX];
 static struct ion_handle *ion_hwc[1];
-#endif
 static int rk_fb_ioctl(struct fb_info *info, unsigned int cmd,
                       unsigned long arg)
 {
@@ -2621,11 +2595,8 @@ static int rk_fb_ioctl(struct fb_info *info, unsigned int cmd,
 
                if (copy_from_user(hwc_phy, argp, 4))
                        return -EFAULT;
-#ifdef CONFIG_RK_IOMMU
                if (!dev_drv->iommu_enabled) {
-#endif
                        fix->smem_start = hwc_phy[0];
-#ifdef CONFIG_RK_IOMMU
                } else {
                        int usr_fd;
                        struct ion_handle *hdl;
@@ -2663,7 +2634,6 @@ static int rk_fb_ioctl(struct fb_info *info, unsigned int cmd,
                        fix->smem_start = phy_addr;
                        ion_hwc[0] = hdl;
                }
-#endif
                break;
        }
        case RK_FBIOSET_YUV_ADDR:
@@ -2672,12 +2642,9 @@ static int rk_fb_ioctl(struct fb_info *info, unsigned int cmd,
 
                        if (copy_from_user(yuv_phy, argp, 8))
                                return -EFAULT;
-                       #ifdef CONFIG_RK_IOMMU
                        if (!dev_drv->iommu_enabled || !strcmp(info->fix.id, "fb0")) {
-                       #endif
                                fix->smem_start = yuv_phy[0];
                                fix->mmio_start = yuv_phy[1];
-                       #ifdef CONFIG_RK_IOMMU
                        } else {
                                int usr_fd, offset, tmp;
                                struct ion_handle *hdl;
@@ -2729,7 +2696,6 @@ static int rk_fb_ioctl(struct fb_info *info, unsigned int cmd,
                                        ion_hanle[tmp] = ion_hanle[tmp - 1];
                                ion_hanle[0] = 0;
                        }
-                       #endif
                        break;
                }
        case RK_FBIOSET_ENABLE:
@@ -3729,16 +3695,12 @@ static int rk_fb_alloc_buffer_by_ion(struct fb_info *fbi,
        win->area[0].ion_hdl = handle;
        if (dev_drv->prop == PRMRY)
                fbi->screen_base = ion_map_kernel(rk_fb->ion_client, handle);
-#ifdef CONFIG_RK_IOMMU
        if (dev_drv->iommu_enabled && dev_drv->mmu_dev)
                ret = ion_map_iommu(dev_drv->dev, rk_fb->ion_client, handle,
                                    (unsigned long *)&phy_addr,
                                    (unsigned long *)&len);
        else
                ret = ion_phys(rk_fb->ion_client, handle, &phy_addr, &len);
-#else
-       ret = ion_phys(rk_fb->ion_client, handle, &phy_addr, &len);
-#endif
        if (ret < 0) {
                dev_err(fbi->dev, "ion map to get phy addr failed\n");
                goto err_share_dma_buf;
@@ -3817,8 +3779,7 @@ static int rk_fb_alloc_buffer(struct fb_info *fbi)
                                                       fb_par->ion_hdl);
                                dev_drv->win[win_id]->area[0].ion_hdl =
                                        fb_par->ion_hdl;
-#ifdef CONFIG_RK_IOMMU
-                               if (dev_drv->mmu_dev)
+                               if (dev_drv->iommu_enabled && dev_drv->mmu_dev)
                                        ret = ion_map_iommu(dev_drv->dev,
                                                            rk_fb->ion_client,
                                                            fb_par->ion_hdl,
@@ -3828,7 +3789,6 @@ static int rk_fb_alloc_buffer(struct fb_info *fbi)
                                        ret = ion_phys(rk_fb->ion_client,
                                                       fb_par->ion_hdl,
                                                       &phy_addr, &len);
-#endif
                                if (ret < 0) {
                                        dev_err(fbi->dev, "ion map to get phy addr failed\n");
                                        return -ENOMEM;
@@ -4145,13 +4105,11 @@ int rk_fb_register(struct rk_lcdc_driver *dev_drv,
 
                main_fbi->fbops->fb_open(main_fbi, 1);
                main_fbi->var.pixclock = dev_drv->pixclock;
-#if defined(CONFIG_RK_IOMMU)
                if (dev_drv->iommu_enabled) {
                        if (dev_drv->mmu_dev)
                                rockchip_iovmm_set_fault_handler(dev_drv->dev,
                                                rk_fb_sysmmu_fault_handler);
                }
-#endif
 
                rk_fb_alloc_buffer(main_fbi);   /* only alloc memory for main fb */
                dev_drv->uboot_logo = support_uboot_display();
@@ -4308,16 +4266,13 @@ int rk_fb_register(struct rk_lcdc_driver *dev_drv,
 #endif
        } else {
                struct fb_info *extend_fbi = rk_fb->fb[rk_fb->num_fb >> 1];
-
                extend_fbi->var.pixclock = rk_fb->fb[0]->var.pixclock;
                extend_fbi->fbops->fb_open(extend_fbi, 1);
-#if defined(CONFIG_RK_IOMMU)
                if (dev_drv->iommu_enabled) {
                        if (dev_drv->mmu_dev)
                                rockchip_iovmm_set_fault_handler(dev_drv->dev,
                                                                 rk_fb_sysmmu_fault_handler);
                }
-#endif
                rk_fb_alloc_buffer(extend_fbi);
        }
 #endif