rk616:add lvds suspend support
authoryxj <yxj@rock-chips.com>
Thu, 2 May 2013 03:33:05 +0000 (11:33 +0800)
committeryxj <yxj@rock-chips.com>
Fri, 3 May 2013 01:18:28 +0000 (09:18 +0800)
drivers/video/display/transmitter/rk616_vif.c
drivers/video/display/transmitter/rk616_vif.h [new file with mode: 0644]

index 1101646fd812cfe1c865eed55ab1db1117f13936..6eb96ab315affabe571d457dfca85a6beda2537c 100644 (file)
@@ -2,10 +2,10 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
-#include <linux/mfd/rk616.h>
 #include <linux/rk_fb.h>
+#include "rk616_vif.h"
 
-struct mfd_rk616 *g_rk616;
+struct rk616_vif *g_vif;
 extern int rk616_pll_set_rate(struct mfd_rk616 *rk616,int id,u32 cfg_val,u32 frac);
 
 /*rk616 video interface config*/
@@ -663,27 +663,70 @@ static int rk616_display_router_cfg(struct mfd_rk616 *rk616,rk_screen *screen,bo
 int rk610_lcd_scaler_set_param(rk_screen *screen,bool enable )//enable:0 bypass 1: scale
 {
        int ret;
-       struct mfd_rk616 *rk616 = g_rk616;
+       struct mfd_rk616 *rk616 = g_vif->rk616;
        if(!rk616)
        {
                printk(KERN_ERR "%s:mfd rk616 is null!\n",__func__);
                return -1;
        }
+       g_vif->screen = screen;
        ret = rk616_display_router_cfg(rk616,screen,enable);
        return ret;
 }
 
+
+#if    defined(CONFIG_HAS_EARLYSUSPEND)
+static void rk616_vif_early_suspend(struct early_suspend *h)
+{
+       struct rk616_vif *vif = container_of(h, struct rk616_vif,early_suspend);
+       struct mfd_rk616 *rk616 = vif->rk616;
+       u32 val = 0;
+       int ret = 0;
+
+       val &= ~(LVDS_CH1_PWR_EN | LVDS_CH0_PWR_EN | LVDS_CBG_PWR_EN);
+       val |= LVDS_PLL_PWR_DN |(LVDS_CH1_PWR_EN << 16) | (LVDS_CH0_PWR_EN << 16) |
+               (LVDS_CBG_PWR_EN << 16) | (LVDS_PLL_PWR_DN << 16);
+       ret = rk616->write_dev(rk616,CRU_LVDS_CON0,&val);
+       
+}
+
+static void rk616_vif_late_resume(struct early_suspend *h)
+{
+       struct rk616_vif *vif = container_of(h, struct rk616_vif,early_suspend);
+       struct mfd_rk616 *rk616 = vif->rk616;
+       rk616_lvds_cfg(rk616,vif->screen);
+}
+
+#endif
+
 static int rk616_vif_probe(struct platform_device *pdev)
 {
+       struct rk616_vif *vif = NULL; 
+       struct mfd_rk616 *rk616 = NULL;
 
-       struct mfd_rk616 *rk616 = dev_get_drvdata(pdev->dev.parent);
+       vif = kzalloc(sizeof(struct rk616_vif),GFP_KERNEL);
+       if(!vif)
+       {
+               printk(KERN_ALERT "alloc for struct rk616_vif fail\n");
+               return  -ENOMEM;
+       }
+
+       rk616 = dev_get_drvdata(pdev->dev.parent);
        if(!rk616)
        {
                dev_err(&pdev->dev,"null mfd device rk616!\n");
                return -ENODEV;
        }
        else
-               g_rk616 = rk616;
+               g_vif = vif;
+               vif->rk616 = rk616;
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+       vif->early_suspend.suspend = rk616_vif_early_suspend;
+       vif->early_suspend.resume = rk616_vif_late_resume;
+       vif->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1;
+       register_early_suspend(&vif->early_suspend);
+#endif
        
 
        dev_info(&pdev->dev,"rk616 vif probe success!\n");
diff --git a/drivers/video/display/transmitter/rk616_vif.h b/drivers/video/display/transmitter/rk616_vif.h
new file mode 100644 (file)
index 0000000..0f2a1bb
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __RK616_VIF_H__
+#define __RK616_VIF_H__
+#include<linux/mfd/rk616.h>
+#include<linux/earlysuspend.h>
+#include<linux/rk_screen.h>
+
+
+struct rk616_vif {
+       struct mfd_rk616 *rk616;
+       rk_screen *screen;
+#ifdef CONFIG_HAS_EARLYSUSPEND
+       struct early_suspend early_suspend;
+#endif 
+};
+
+#endif