From d78f2d3e8fd34d3095f12391e0b0473ce6bfccb7 Mon Sep 17 00:00:00 2001 From: yxj Date: Tue, 25 Jun 2013 09:17:13 +0800 Subject: [PATCH] mfd:rk616:support power down in suspend,add config to enable/disable debug message --- drivers/mfd/Kconfig | 6 +++ drivers/mfd/rk616-core.c | 19 +++++--- drivers/mfd/rk616-vif.c | 45 ++++++++++++------- .../video/rockchip/transmitter/rk616_lvds.c | 34 +++----------- include/linux/mfd/rk616.h | 7 +++ 5 files changed, 62 insertions(+), 49 deletions(-) mode change 100644 => 100755 drivers/mfd/rk616-core.c mode change 100644 => 100755 drivers/mfd/rk616-vif.c mode change 100644 => 100755 drivers/video/rockchip/transmitter/rk616_lvds.c mode change 100644 => 100755 include/linux/mfd/rk616.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 5f515c44e69e..1ad97adbcdb0 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -852,6 +852,12 @@ config MFD_RK616 if you say yes here you get support for the RK616, with func as HDMI、LCD、LVDS、CODEC、MIPI. +config RK616_DEBUG + bool "RK616(JettaB) debug enable" + depends on MFD_RK616 + help + if you say y here ,it will enable rk616 debug function + endif # MFD_SUPPORT menu "Multimedia Capabilities Port drivers" diff --git a/drivers/mfd/rk616-core.c b/drivers/mfd/rk616-core.c old mode 100644 new mode 100755 index 40b8d0214410..97d1b662e8f5 --- a/drivers/mfd/rk616-core.c +++ b/drivers/mfd/rk616-core.c @@ -1,4 +1,3 @@ - #include #include #include @@ -129,7 +128,6 @@ static ssize_t rk616_reg_write (struct file *file, const char __user *buf, size_ if (copy_from_user(kbuf, buf, count)) return -EFAULT; sscanf(kbuf, "%x%x", ®,&val); - dev_dbg(rk616->dev,"%s:reg:0x%04x val:0x%08x\n",__func__,reg,val); rk616->write_dev(rk616,reg,&val); return count; } @@ -244,7 +242,7 @@ static int rk616_pll_wait_lock(struct mfd_rk616 *rk616,int id) ret = rk616->read_dev(rk616,CRU_PLL0_CON1 + offset,&val); if (val&PLL0_LOCK) { - dev_info(rk616->dev,"PLL%d locked\n",id); + rk616_dbg(rk616->dev,"PLL%d locked\n",id); break; } msleep(1); @@ -252,7 +250,7 @@ static int rk616_pll_wait_lock(struct mfd_rk616 *rk616,int id) } if (delay == 0) { - printk(KERN_ALERT "rk616 wait PLL%d lock time out!\n",id); + dev_err(rk616->dev,"rk616 wait PLL%d lock time out!\n",id); } return 0; @@ -385,7 +383,17 @@ static int rk616_clk_common_init(struct mfd_rk616 *rk616) return 0; } +static int rk616_core_suspend(struct device *dev, pm_message_t state) +{ + return 0; +} +static int rk616_core_resume(struct device* dev) +{ + struct mfd_rk616 *rk616 = dev_get_drvdata(dev); + rk616_clk_common_init(rk616); + return 0; +} static int rk616_i2c_probe(struct i2c_client *client,const struct i2c_device_id *id) { int ret; @@ -456,7 +464,6 @@ static int rk616_i2c_probe(struct i2c_client *client,const struct i2c_device_id ret = mfd_add_devices(rk616->dev, -1, rk616_devs, ARRAY_SIZE(rk616_devs), NULL, rk616->irq_base); - dev_info(&client->dev,"rk616 core probe success!\n"); return 0; } @@ -483,6 +490,8 @@ static struct i2c_driver rk616_i2c_driver = { .driver = { .name = "rk616", .owner = THIS_MODULE, + .suspend = &rk616_core_suspend, + .resume = &rk616_core_resume, }, .probe = &rk616_i2c_probe, .remove = &rk616_i2c_remove, diff --git a/drivers/mfd/rk616-vif.c b/drivers/mfd/rk616-vif.c old mode 100644 new mode 100755 index 31016d8a4999..83e5d09eec1f --- a/drivers/mfd/rk616-vif.c +++ b/drivers/mfd/rk616-vif.c @@ -1,10 +1,10 @@ #include #include -#include #include #include + extern int rk616_pll_set_rate(struct mfd_rk616 *rk616,int id,u32 cfg_val,u32 frac); extern int rk616_pll_pwr_down(struct mfd_rk616 *rk616,int id); @@ -44,7 +44,7 @@ extern int rk616_pll_pwr_down(struct mfd_rk616 *rk616,int id); } - dev_info(rk616->dev,"rk616 vif%d disable\n",id); + rk616_dbg(rk616->dev,"rk616 vif%d disable\n",id); return 0; } @@ -76,7 +76,7 @@ int rk616_vif_enable(struct mfd_rk616 *rk616,int id) ret = rk616->write_dev(rk616,VIF0_REG0 + offset,&val); - dev_info(rk616->dev,"rk616 vif%d enable\n",id); + rk616_dbg(rk616->dev,"rk616 vif%d enable\n",id); return 0; @@ -97,7 +97,7 @@ static int rk616_vif_bypass(struct mfd_rk616 *rk616,int id) ret = rk616->write_dev(rk616,CRU_CLKSEL2_CON,&val); - dev_info(rk616->dev,"rk616 vif%d bypass\n",id); + rk616_dbg(rk616->dev,"rk616 vif%d bypass\n",id); return 0; } @@ -237,7 +237,7 @@ static int rk616_scaler_disable(struct mfd_rk616 *rk616) val &= (~SCL_EN); //disable scaler val |= (SCL_EN<<16); ret = rk616->write_dev(rk616,SCL_REG0,&val); - dev_info(rk616->dev,"rk616 scaler disable\n"); + rk616_dbg(rk616->dev,"rk616 scaler disable\n"); return 0; } @@ -417,7 +417,7 @@ int rk616_scaler_cfg(struct mfd_rk616 *rk616,rk_screen *screen) rk616->write_dev(rk616,SCL_REG8,&scl_reg8_value); rk616->write_dev(rk616,SCL_REG0,&scl_reg0_value); - dev_info(rk616->dev,"rk616 scaler enable\n"); + rk616_dbg(rk616->dev,"rk616 scaler enable\n"); #endif return 0; @@ -629,13 +629,13 @@ int rk616_set_router(struct mfd_rk616 *rk616,rk_screen *screen,bool enable) { ret = rk616_dual_input_cfg(rk616,screen,enable); - dev_info(rk616->dev,"rk616 use dual input for dual display!\n"); + rk616_dbg(rk616->dev,"rk616 use dual input for dual display!\n"); } else if((pdata->lcd0_func == INPUT) && (pdata->lcd1_func == UNUSED)) { ret = rk616_lcd0_input_lcd1_unused_cfg(rk616,screen,enable); - dev_info(rk616->dev, + rk616_dbg(rk616->dev, "rk616 use lcd0 as input and lvds/rgb " "port as output for dual display\n"); } @@ -643,14 +643,14 @@ int rk616_set_router(struct mfd_rk616 *rk616,rk_screen *screen,bool enable) { ret = rk616_lcd0_input_lcd1_output_cfg(rk616,screen,enable); - dev_info(rk616->dev, + rk616_dbg(rk616->dev, "rk616 use lcd0 as input and lcd1 as " "output for dual display\n"); } else if((pdata->lcd0_func == UNUSED) && (pdata->lcd1_func == INPUT)) { ret = rk616_lcd0_unused_lcd1_input_cfg(rk616,screen,enable); - dev_info(rk616->dev, + rk616_dbg(rk616->dev, "rk616 use lcd1 as input and lvds/rgb as " "output for dual display\n"); } @@ -692,6 +692,22 @@ static int rk616_router_cfg(struct mfd_rk616 *rk616) } +static int rk616_dither_cfg(struct mfd_rk616 *rk616,rk_screen *screen,bool enable) +{ + u32 val = 0; + int ret = 0; + val = FRC_DCLK_INV | (FRC_DCLK_INV << 16); + if((screen->face != OUT_P888) && enable) //enable frc dither if the screen is not 24bit + val |= FRC_DITHER_EN | (FRC_DITHER_EN << 16); + //val |= (FRC_DITHER_EN << 16); + else + val |= (FRC_DITHER_EN << 16); + ret = rk616->write_dev(rk616,FRC_REG,&val); + + return 0; + +} + int rk616_display_router_cfg(struct mfd_rk616 *rk616,rk_screen *screen,bool enable) { int ret; @@ -702,13 +718,12 @@ int rk616_display_router_cfg(struct mfd_rk616 *rk616,rk_screen *screen,bool enab ret = rk616_router_cfg(rk616); ret = rk616_vif_cfg(rk616,hdmi_screen,0); ret = rk616_vif_cfg(rk616,hdmi_screen,1); - ret = rk616_scaler_cfg(rk616,screen); - + ret = rk616_scaler_cfg(rk616,screen); + ret = rk616_dither_cfg(rk616,screen,enable); return 0; } - int rk616_set_vif(struct mfd_rk616 *rk616,rk_screen *screen,bool connect) { struct rk616_platform_data *pdata; @@ -736,12 +751,12 @@ int rk616_set_vif(struct mfd_rk616 *rk616,rk_screen *screen,bool connect) { rk616_dual_input_cfg(rk616,screen,connect); - dev_info(rk616->dev,"rk616 use dual input for dual display!\n"); + rk616_dbg(rk616->dev,"rk616 use dual input for dual display!\n"); } else if((pdata->lcd0_func == INPUT) && (pdata->lcd1_func == UNUSED)) { rk616_lcd0_input_lcd1_unused_cfg(rk616,screen,connect); - dev_info(rk616->dev,"rk616 use lcd0 input for hdmi display!\n"); + rk616_dbg(rk616->dev,"rk616 use lcd0 input for hdmi display!\n"); } rk616_router_cfg(rk616); rk616_vif_cfg(rk616,screen,0); diff --git a/drivers/video/rockchip/transmitter/rk616_lvds.c b/drivers/video/rockchip/transmitter/rk616_lvds.c old mode 100644 new mode 100755 index 79f8743bd508..904283d74047 --- a/drivers/video/rockchip/transmitter/rk616_lvds.c +++ b/drivers/video/rockchip/transmitter/rk616_lvds.c @@ -4,6 +4,7 @@ #include #include "rk616_lvds.h" + struct rk616_lvds *g_lvds; @@ -46,7 +47,7 @@ static int rk616_lvds_cfg(struct mfd_rk616 *rk616,rk_screen *screen) (LVDS_HBP_ODD_MASK); ret = rk616->write_dev(rk616,CRU_LVDS_CON0,&val); - dev_info(rk616->dev,"rk616 use dual lvds channel.......\n"); + rk616_dbg(rk616->dev,"rk616 use dual lvds channel.......\n"); } else //single lvds channel { @@ -59,7 +60,7 @@ static int rk616_lvds_cfg(struct mfd_rk616 *rk616,rk_screen *screen) (LVDS_OUT_FORMAT_MASK) | (LVDS_DCLK_INV << 16); ret = rk616->write_dev(rk616,CRU_LVDS_CON0,&val); - dev_info(rk616->dev,"rk616 use single lvds channel.......\n"); + rk616_dbg(rk616->dev,"rk616 use single lvds channel.......\n"); } @@ -75,7 +76,7 @@ static int rk616_lvds_cfg(struct mfd_rk616 *rk616,rk_screen *screen) val &= ~(LVDS_OUT_EN); val |= (LVDS_OUT_EN << 16); ret = rk616->write_dev(rk616,CRU_IO_CON0,&val); - dev_info(rk616->dev,"rk616 use RGB output.....\n"); + rk616_dbg(rk616->dev,"rk616 use RGB output.....\n"); } } @@ -85,25 +86,6 @@ static int rk616_lvds_cfg(struct mfd_rk616 *rk616,rk_screen *screen) } -static int rk616_dither_cfg(struct mfd_rk616 *rk616,rk_screen *screen,bool enable) -{ - u32 val = 0; - int ret = 0; - val = FRC_DCLK_INV | (FRC_DCLK_INV << 16); - if((screen->face != OUT_P888) && enable) //enable frc dither if the screen is not 24bit - val |= FRC_DITHER_EN | (FRC_DITHER_EN << 16); - //val |= (FRC_DITHER_EN << 16); - else - val |= (FRC_DITHER_EN << 16); - ret = rk616->write_dev(rk616,FRC_REG,&val); - - return 0; - -} - - - - int rk616_scaler_set_param(rk_screen *screen,bool enable )//enable:0 bypass 1: scale { int ret; @@ -113,10 +95,7 @@ int rk616_scaler_set_param(rk_screen *screen,bool enable )//enable:0 bypass 1: s printk(KERN_ERR "%s:mfd rk616 is null!\n",__func__); return -1; } - ret = rk616_display_router_cfg(rk616,screen,enable); - - ret = rk616_dither_cfg(rk616,screen,enable); ret = rk616_lvds_cfg(rk616,screen); return ret; } @@ -126,10 +105,7 @@ static int rk616_lvds_init_cfg(struct mfd_rk616 *rk616,rk_screen *screen) { int ret ; ret = rk616_display_router_cfg(rk616,screen,0); - - ret = rk616_dither_cfg(rk616,screen,0); ret = rk616_lvds_cfg(rk616,screen); - return ret; } @@ -156,7 +132,7 @@ static void rk616_lvds_late_resume(struct early_suspend *h) { struct rk616_lvds *lvds = container_of(h, struct rk616_lvds,early_suspend); struct mfd_rk616 *rk616 = lvds->rk616; - rk616_lvds_cfg(rk616,lvds->screen); + rk616_lvds_init_cfg(rk616,lvds->screen); } #endif diff --git a/include/linux/mfd/rk616.h b/include/linux/mfd/rk616.h old mode 100644 new mode 100755 index e97057b7ce2d..8803d1bd5d8e --- a/include/linux/mfd/rk616.h +++ b/include/linux/mfd/rk616.h @@ -7,6 +7,13 @@ #include #include +#if defined(CONFIG_RK616_DEBUG) +#define rk616_dbg(dev, format, arg...) \ + dev_info(dev , format , ## arg) +#else +#define rk616_dbg(dev, format, arg...) do{}while(0) +#endif + #define VIF0_REG0 0x0000 #define VIF0_DDR_CLK_EN (1<<3) #define VIF0_DDR_PHASEN_EN (1<<2) //negative edge first en -- 2.34.1