/********do basic init*********/
static int rk3288_lcdc_pre_init(struct rk_lcdc_driver *dev_drv)
{
- int v,i;
+ int v;
u32 mask,val;
struct lcdc_device *lcdc_dev = container_of(dev_drv,
struct
return 0;
}
-static int rk3288_lcdc_set_dsp_cabc(struct rk_lcdc_driver *dev_drv,int mode)
+static struct lcdc_cabc_mode cabc_mode[5] = {
+/* pixel_num, stage_up, stage_down */
+ {5, 2, 2}, /*mode 1*/
+ {10, 2, 2}, /*mode 2*/
+ {15, 2, 2}, /*mode 3*/
+ {20, 2, 2}, /*mode 4*/
+ {20, 128, 0}, /*mode 5*/
+};
+
+static int rk3288_lcdc_set_dsp_cabc(struct rk_lcdc_driver *dev_drv, int mode)
{
struct lcdc_device *lcdc_dev =
container_of(dev_drv, struct lcdc_device, driver);
struct rk_screen *screen = dev_drv->cur_screen;
- int total_pixel,calc_pixel,stage_up,stage_down;
- u32 mask=0, val=0;
-
- u32 cabc_mode[5][3]={
- /*num ,up, down*/
- {2, 10, 10}, /*mode 1*/
- {4, 10, 10}, /*mode 2*/
- {6, 10, 10}, /*mode 3*/
- {8, 10, 10}, /*mode 4*/
- {10, 10, 10}, /*mode 5*/
- };
- /*iomux connect to vop or pwm*/
- if(mode == 0){
- DBG(3,"close cabc\n");
+ int total_pixel, calc_pixel, stage_up, stage_down;
+ u32 mask = 0, val = 0;
+
+ dev_drv->cabc_mode = mode;
+
+ /* iomux connect to vop or pwm */
+ if (mode == 0) { /* select rk pwm */
+ DBG(3, "close cabc and select rk pwm\n");
val = 0x30001;
- writel_relaxed(val, RK_GRF_VIRT + RK3288_GRF_GPIO7A_IOMUX);/*pwm sel*/
- lcdc_set_bit(lcdc_dev, SYS_CTRL, 0<<23);/*disable auto gating*/
- mask = m_CABC_EN;
- val = v_CABC_EN(0);
- lcdc_set_bit(lcdc_dev, SYS_CTRL, m_AUTO_GATING_EN);
- /*lcdc_msk_reg(lcdc_dev, CABC_CTRL0, mask, val);*/
+ writel_relaxed(val, RK_GRF_VIRT + RK3288_GRF_GPIO7A_IOMUX);
+ spin_lock(&lcdc_dev->reg_lock);
+ if(lcdc_dev->clk_on) {
+ lcdc_msk_reg(lcdc_dev, CABC_CTRL0, m_CABC_EN, v_CABC_EN(0));
+ lcdc_cfg_done(lcdc_dev);
+ }
+ spin_unlock(&lcdc_dev->reg_lock);
+ return 0;
+ } else if (mode == 99) { /* select vop pwm */
+ DBG(3, "close cabc and select vop pwm\n");
+ val = (dev_drv->id == 0) ? 0x30002 : 0x30003;
+ writel_relaxed(val, RK_GRF_VIRT + RK3288_GRF_GPIO7A_IOMUX);
+ spin_lock(&lcdc_dev->reg_lock);
+ if(lcdc_dev->clk_on) {
+ lcdc_msk_reg(lcdc_dev, CABC_CTRL0, m_CABC_EN, v_CABC_EN(0));
+ lcdc_cfg_done(lcdc_dev);
+ }
+ spin_unlock(&lcdc_dev->reg_lock);
return 0;
+ } else {
+ val = (dev_drv->id == 0) ? 0x30002 : 0x30003;
+ writel_relaxed(val, RK_GRF_VIRT + RK3288_GRF_GPIO7A_IOMUX);
}
+
total_pixel = screen->mode.xres * screen->mode.yres;
- calc_pixel = total_pixel * (100 - cabc_mode[mode-1][0])/100;
- stage_up = cabc_mode[mode-1][1];
- stage_down = cabc_mode[mode-1][2];
+ calc_pixel = total_pixel * (100 - cabc_mode[mode - 1].pixel_num) / 100;
+ stage_up = cabc_mode[mode - 1].stage_up;
+ stage_down = cabc_mode[mode - 1].stage_down;
spin_lock(&lcdc_dev->reg_lock);
- if(lcdc_dev->clk_on){
- lcdc_msk_reg(lcdc_dev, CABC_CTRL0, mask, val);
+ if(lcdc_dev->clk_on) {
mask = m_CABC_TOTAL_NUM | m_CABC_STAGE_DOWN;
val = v_CABC_TOTAL_NUM(total_pixel) | v_CABC_STAGE_DOWN(stage_down);
lcdc_msk_reg(lcdc_dev, CABC_CTRL1, mask, val);
lcdc_cfg_done(lcdc_dev);
}
spin_unlock(&lcdc_dev->reg_lock);
- val = 0x30003;
- writel_relaxed(val, RK_GRF_VIRT + RK3288_GRF_GPIO7A_IOMUX);/*pwm sel*/
+
return 0;
}
/*
else
lcdc_dev->prop = val;
+ if (of_property_read_u32(np, "rockchip,cabc_mode", &val))
+ lcdc_dev->driver.cabc_mode = 0; /* default set close cabc */
+ else
+ lcdc_dev->driver.cabc_mode = val;
+
if (of_property_read_u32(np, "rockchip,pwr18", &val))
lcdc_dev->pwr18 = false; /*default set it as 3.xv power supply */
else