From: yxj Date: Fri, 23 Mar 2012 12:41:56 +0000 (+0800) Subject: rk30 fb: add lcd en io init X-Git-Tag: firefly_0821_release~9595^2~21 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=37b60c9cb0c26020d3d8c1c81cb06b77047cdd58;p=firefly-linux-kernel-4.4.55.git rk30 fb: add lcd en io init fix a fb memory alloc bug in rk_fb.c add clk set in rk30 lcdc driver --- diff --git a/arch/arm/mach-rk30/board-rk30-sdk.c b/arch/arm/mach-rk30/board-rk30-sdk.c index e7684991f4d6..f82d4d9e8082 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk.c +++ b/arch/arm/mach-rk30/board-rk30-sdk.c @@ -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 diff --git a/drivers/video/rockchip/chips/rk30_lcdc.c b/drivers/video/rockchip/chips/rk30_lcdc.c index 1e1a4811a0d3..98b6db5a85ac 100644 --- a/drivers/video/rockchip/chips/rk30_lcdc.c +++ b/drivers/video/rockchip/chips/rk30_lcdc.c @@ -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"); } diff --git a/drivers/video/rockchip/rk_fb.c b/drivers/video/rockchip/rk_fb.c index d8d933122a24..27668fbab83a 100644 --- a/drivers/video/rockchip/rk_fb.c +++ b/drivers/video/rockchip/rk_fb.c @@ -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; }