rk30 fb: add lcd en io init
authoryxj <yxj@I7-CH.(none)>
Fri, 23 Mar 2012 12:41:56 +0000 (20:41 +0800)
committeryxj <yxj@I7-CH.(none)>
Fri, 23 Mar 2012 12:54:47 +0000 (20:54 +0800)
fix a fb memory alloc bug in rk_fb.c
add clk set in rk30 lcdc driver

arch/arm/mach-rk30/board-rk30-sdk.c
drivers/video/rockchip/chips/rk30_lcdc.c
drivers/video/rockchip/rk_fb.c

index e7684991f4d673402fc0c63f757f6bb81f81be0b..f82d4d9e80823c510454a72c0db4eb397e45601a 100755 (executable)
@@ -590,6 +590,33 @@ struct cm3217_platform_data cm3217_info = {
 #endif
 
 #ifdef CONFIG_FB_ROCKCHIP
+
+#define LCD_EN_MUX_NAME    GPIO4C7_SMCDATA7_TRACEDATA7_NAME
+#define LCD_EN_PIN         RK30_PIN4_PC7
+#define LCD_EN_VALUE       GPIO_HIGH
+
+static int rk_fb_io_init(void)
+{
+       int ret = 0;
+       rk30_mux_api_set(LCD_EN_MUX_NAME, GPIO4C_GPIO4C7);
+       ret = gpio_request(LCD_EN_PIN, NULL);
+       if (ret != 0)
+       {
+               gpio_free(LCD_EN_PIN);
+               printk(KERN_ERR "request lcd en pin fail!\n");
+               return -1;
+       }
+       else
+       {
+               gpio_direction_output(LCD_EN_PIN, 1);
+               gpio_set_value(LCD_EN_PIN, LCD_EN_VALUE);
+       }
+       return 0;
+}
+static struct rk29lcd_info rk_fb_info = {
+       .io_init   = rk_fb_io_init,
+};
+
 static struct resource resource_fb[] = {
        [0] = {
                .name  = "fb0 buf",
@@ -616,6 +643,9 @@ static struct platform_device device_fb = {
        .id             = -1,
        .num_resources  = ARRAY_SIZE(resource_fb),
        .resource       = resource_fb,
+       .dev            = {
+               .platform_data  = &rk_fb_info,
+       }
 };
 #endif
 
index 1e1a4811a0d3ff1a078e412e78aeadb3c99ed129..98b6db5a85ac95248ae757bc556d26ea9d58c06d 100644 (file)
@@ -175,7 +175,7 @@ void rk30_load_screen(struct rk30_lcdc_device*lcdc_dev, bool initscreen)
 
  
 
-  //  ret = clk_set_rate(lcdc_dev->dclk, screen->pixclock);
+    ret = clk_set_rate(lcdc_dev->dclk, screen->pixclock);
     if(ret)
     {
         printk(KERN_ERR ">>>>>> set lcdc dclk failed\n");
@@ -183,11 +183,10 @@ void rk30_load_screen(struct rk30_lcdc_device*lcdc_dev, bool initscreen)
     lcdc_dev->driver->pixclock = lcdc_dev->pixclock = div_u64(1000000000000llu, clk_get_rate(lcdc_dev->dclk));
     if(initscreen)
     {
-        //ret = clk_set_parent(lcdc_dev->aclk, lcdc_dev->aclk_parent);
         if(screen->lcdc_aclk){
            aclk_rate = screen->lcdc_aclk;
         }
-       // ret = clk_set_rate(lcdc_dev->aclk, aclk_rate);
+        ret = clk_set_rate(lcdc_dev->aclk, aclk_rate);
         if(ret){
             printk(KERN_ERR ">>>>>> set lcdc aclk failed\n");
         }
index d8d933122a2444ee4f10b11ce5619f3452f38c87..27668fbab83a510ade24b045b0f72e2cc586e926 100644 (file)
@@ -519,8 +519,8 @@ static int request_fb_buffer(struct fb_info *fbi,int fb_id)
             }
             fbi->fix.mmio_start = res->start;
             fbi->fix.mmio_len = res->end - res->start + 1;
-            break;
         #endif
+           break;
         case 2:
             res = platform_get_resource_byname(g_fb_pdev, IORESOURCE_MEM, "fb2 buf");
             if (res == NULL)
@@ -645,17 +645,21 @@ int rk_fb_unregister(struct rk_lcdc_device_driver *fb_device_driver)
 static int __devinit rk_fb_probe (struct platform_device *pdev)
 {
        struct rk_fb_inf *fb_inf        = NULL;
+       struct rk29lcd_info *lcd_info = NULL;
        int ret = 0;
        g_fb_pdev=pdev;
-    /* Malloc rk29fb_inf and set it to pdev for drvdata */
-    fb_inf = kmalloc(sizeof(struct rk_fb_inf), GFP_KERNEL);
-    if(!fb_inf)
-    {
-        dev_err(&pdev->dev, ">>fb inf kmalloc fail!");
-        ret = -ENOMEM;
-    }
-    memset(fb_inf, 0, sizeof(struct rk_fb_inf));
+       lcd_info =  pdev->dev.platform_data;
+    /* Malloc rk_fb_inf and set it to pdev for drvdata */
+       fb_inf = kmalloc(sizeof(struct rk_fb_inf), GFP_KERNEL);
+       if(!fb_inf)
+       {
+               dev_err(&pdev->dev, ">>fb inf kmalloc fail!");
+               ret = -ENOMEM;
+       }
+       memset(fb_inf, 0, sizeof(struct rk_fb_inf));
        platform_set_drvdata(pdev, fb_inf);
+       if(lcd_info->io_init)
+               lcd_info->io_init();
        printk("rk fb probe ok!\n");
     return 0;
 }