From 9e5485791b805e3235ba5fb53d140881dbbe79be Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Wed, 13 Mar 2013 13:37:11 +0800 Subject: video: mxsfb: use devm_* managed functions Use devm_* managed functions to make code a little cleaner. Signed-off-by: Shawn Guo --- drivers/video/mxsfb.c | 50 ++++++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) (limited to 'drivers/video') diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c index 45169cbaba6..69fb3f1d1e1 100644 --- a/drivers/video/mxsfb.c +++ b/drivers/video/mxsfb.c @@ -802,23 +802,19 @@ static int mxsfb_probe(struct platform_device *pdev) return -ENODEV; } - if (!request_mem_region(res->start, resource_size(res), pdev->name)) - return -EBUSY; - fb_info = framebuffer_alloc(sizeof(struct mxsfb_info), &pdev->dev); if (!fb_info) { dev_err(&pdev->dev, "Failed to allocate fbdev\n"); - ret = -ENOMEM; - goto error_alloc_info; + return -ENOMEM; } host = to_imxfb_host(fb_info); - host->base = ioremap(res->start, resource_size(res)); - if (!host->base) { + host->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(host->base)) { dev_err(&pdev->dev, "ioremap failed\n"); - ret = -ENOMEM; - goto error_ioremap; + ret = PTR_ERR(host->base); + goto fb_release; } host->pdev = pdev; @@ -829,13 +825,13 @@ static int mxsfb_probe(struct platform_device *pdev) pinctrl = devm_pinctrl_get_select_default(&pdev->dev); if (IS_ERR(pinctrl)) { ret = PTR_ERR(pinctrl); - goto error_getpin; + goto fb_release; } - host->clk = clk_get(&host->pdev->dev, NULL); + host->clk = devm_clk_get(&host->pdev->dev, NULL); if (IS_ERR(host->clk)) { ret = PTR_ERR(host->clk); - goto error_getclock; + goto fb_release; } panel_enable = of_get_named_gpio_flags(pdev->dev.of_node, @@ -850,14 +846,15 @@ static int mxsfb_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to request gpio %d: %d\n", panel_enable, ret); - goto error_panel_enable; + goto fb_release; } } - fb_info->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); + fb_info->pseudo_palette = devm_kzalloc(&pdev->dev, sizeof(u32) * 16, + GFP_KERNEL); if (!fb_info->pseudo_palette) { ret = -ENOMEM; - goto error_pseudo_pallette; + goto fb_release; } INIT_LIST_HEAD(&fb_info->modelist); @@ -866,7 +863,7 @@ static int mxsfb_probe(struct platform_device *pdev) ret = mxsfb_init_fbinfo(host); if (ret != 0) - goto error_init_fb; + goto fb_release; for (i = 0; i < pdata->mode_count; i++) fb_add_videomode(&pdata->mode_list[i], &fb_info->modelist); @@ -883,7 +880,7 @@ static int mxsfb_probe(struct platform_device *pdev) ret = register_framebuffer(fb_info); if (ret != 0) { dev_err(&pdev->dev,"Failed to register framebuffer\n"); - goto error_register; + goto fb_destroy; } if (!host->enabled) { @@ -896,22 +893,12 @@ static int mxsfb_probe(struct platform_device *pdev) return 0; -error_register: +fb_destroy: if (host->enabled) clk_disable_unprepare(host->clk); fb_destroy_modelist(&fb_info->modelist); -error_init_fb: - kfree(fb_info->pseudo_palette); -error_pseudo_pallette: -error_panel_enable: - clk_put(host->clk); -error_getclock: -error_getpin: - iounmap(host->base); -error_ioremap: +fb_release: framebuffer_release(fb_info); -error_alloc_info: - release_mem_region(res->start, resource_size(res)); return ret; } @@ -920,19 +907,14 @@ static int mxsfb_remove(struct platform_device *pdev) { struct fb_info *fb_info = platform_get_drvdata(pdev); struct mxsfb_info *host = to_imxfb_host(fb_info); - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (host->enabled) mxsfb_disable_controller(fb_info); unregister_framebuffer(fb_info); - kfree(fb_info->pseudo_palette); mxsfb_free_videomem(host); - iounmap(host->base); - clk_put(host->clk); framebuffer_release(fb_info); - release_mem_region(res->start, resource_size(res)); platform_set_drvdata(pdev, NULL); -- cgit v1.2.3-70-g09d2 From 4aa02c7cbb6816913554dc18ff750a70a4ace796 Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Wed, 13 Mar 2013 14:03:12 +0800 Subject: video: mxsfb: remove fb_phys/fb_size from platform_data There is no in-tree users of mxsfb_platform_data fb_phys/fb_size. With CMA support in the kernel, there is no real need for platform to reserve memory and pass address and size into driver via platform_data. So let's remove fb_phys/fb_size from mxsfb_platform_data to ease full device tree adoption. Signed-off-by: Shawn Guo --- drivers/video/mxsfb.c | 39 +++++++-------------------------------- include/linux/mxsfb.h | 9 --------- 2 files changed, 7 insertions(+), 41 deletions(-) (limited to 'drivers/video') diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c index 69fb3f1d1e1..9e8740bade3 100644 --- a/drivers/video/mxsfb.c +++ b/drivers/video/mxsfb.c @@ -168,7 +168,6 @@ struct mxsfb_info { unsigned ld_intf_width; unsigned dotclk_delay; const struct mxsfb_devdata *devdata; - int mapped; u32 sync; }; @@ -686,7 +685,7 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host) struct mxsfb_platform_data *pdata = host->pdev->dev.platform_data; dma_addr_t fb_phys; void *fb_virt; - unsigned fb_size = pdata->fb_size; + unsigned fb_size; fb_info->fbops = &mxsfb_ops; fb_info->flags = FBINFO_FLAG_DEFAULT | FBINFO_READS_FAST; @@ -706,30 +705,12 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host) host->ld_intf_width = pdata->ld_intf_width; /* Memory allocation for framebuffer */ - if (pdata->fb_phys) { - if (!fb_size) - return -EINVAL; - - fb_phys = pdata->fb_phys; + fb_size = SZ_2M; + fb_virt = alloc_pages_exact(fb_size, GFP_DMA); + if (!fb_virt) + return -ENOMEM; - if (!request_mem_region(fb_phys, fb_size, host->pdev->name)) - return -ENOMEM; - - fb_virt = ioremap(fb_phys, fb_size); - if (!fb_virt) { - release_mem_region(fb_phys, fb_size); - return -ENOMEM; - } - host->mapped = 1; - } else { - if (!fb_size) - fb_size = SZ_2M; /* default */ - fb_virt = alloc_pages_exact(fb_size, GFP_DMA); - if (!fb_virt) - return -ENOMEM; - - fb_phys = virt_to_phys(fb_virt); - } + fb_phys = virt_to_phys(fb_virt); fb_info->fix.smem_start = fb_phys; fb_info->screen_base = fb_virt; @@ -745,13 +726,7 @@ static void mxsfb_free_videomem(struct mxsfb_info *host) { struct fb_info *fb_info = &host->fb_info; - if (host->mapped) { - iounmap(fb_info->screen_base); - release_mem_region(fb_info->fix.smem_start, - fb_info->screen_size); - } else { - free_pages_exact(fb_info->screen_base, fb_info->fix.smem_len); - } + free_pages_exact(fb_info->screen_base, fb_info->fix.smem_len); } static struct platform_device_id mxsfb_devtype[] = { diff --git a/include/linux/mxsfb.h b/include/linux/mxsfb.h index f80af867434..93696404ee5 100644 --- a/include/linux/mxsfb.h +++ b/include/linux/mxsfb.h @@ -35,15 +35,6 @@ struct mxsfb_platform_data { unsigned dotclk_delay; /* refer manual HW_LCDIF_VDCTRL4 register */ unsigned ld_intf_width; /* refer STMLCDIF_* macros */ - - unsigned fb_size; /* Size of the video memory. If zero a - * default will be used - */ - unsigned long fb_phys; /* physical address for the video memory. If - * zero the framebuffer memory will be dynamically - * allocated. If specified,fb_size must also be specified. - * fb_phys must be unused by Linux. - */ u32 sync; /* sync mask, contains MXSFB specifics not * carried in fb_info->var.sync */ -- cgit v1.2.3-70-g09d2 From 36f3e99649baa77b2d22e385b2ea09e8f308c905 Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Wed, 13 Mar 2013 14:28:19 +0800 Subject: video: mxsfb: remove dotclk_delay from platform_data There is no in-tree mxsfb users using mxsfb_platform_data dotclk_delay. Let's remove it from mxsfb_platform_data to ease full device tree adoption of mxsfb driver. If later we have platform/board need to configure this parameter, we can add it into device tree bindings. Signed-off-by: Shawn Guo --- drivers/video/mxsfb.c | 1 - include/linux/mxsfb.h | 1 - 2 files changed, 2 deletions(-) (limited to 'drivers/video') diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c index 9e8740bade3..a89901c7f5e 100644 --- a/drivers/video/mxsfb.c +++ b/drivers/video/mxsfb.c @@ -701,7 +701,6 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host) var->accel_flags = 0; var->vmode = FB_VMODE_NONINTERLACED; - host->dotclk_delay = pdata->dotclk_delay; host->ld_intf_width = pdata->ld_intf_width; /* Memory allocation for framebuffer */ diff --git a/include/linux/mxsfb.h b/include/linux/mxsfb.h index 93696404ee5..b78465cdb26 100644 --- a/include/linux/mxsfb.h +++ b/include/linux/mxsfb.h @@ -33,7 +33,6 @@ struct mxsfb_platform_data { unsigned default_bpp; - unsigned dotclk_delay; /* refer manual HW_LCDIF_VDCTRL4 register */ unsigned ld_intf_width; /* refer STMLCDIF_* macros */ u32 sync; /* sync mask, contains MXSFB specifics not * carried in fb_info->var.sync -- cgit v1.2.3-70-g09d2 From 669406534b4abb827d1bdc39bb5e2d5255818ae2 Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Thu, 14 Mar 2013 10:57:34 +0800 Subject: video: mxsfb: get display timings from device tree Use videomode helpers to get display timings and configurations from device tree when platform_data is absent. Signed-off-by: Shawn Guo --- Documentation/devicetree/bindings/fb/mxsfb.txt | 34 +++++++ drivers/video/Kconfig | 2 + drivers/video/mxsfb.c | 122 ++++++++++++++++++++++--- 3 files changed, 146 insertions(+), 12 deletions(-) (limited to 'drivers/video') diff --git a/Documentation/devicetree/bindings/fb/mxsfb.txt b/Documentation/devicetree/bindings/fb/mxsfb.txt index b41e5e52a67..7ba3b766351 100644 --- a/Documentation/devicetree/bindings/fb/mxsfb.txt +++ b/Documentation/devicetree/bindings/fb/mxsfb.txt @@ -5,10 +5,20 @@ Required properties: imx23 and imx28. - reg: Address and length of the register set for lcdif - interrupts: Should contain lcdif interrupts +- display : phandle to display node (see below for details) Optional properties: - panel-enable-gpios : Should specify the gpio for panel enable +* display node + +Required properties: +- bits-per-pixel : <16> for RGB565, <32> for RGB888/666. +- bus-width : number of data lines. Could be <8>, <16>, <18> or <24>. + +Required sub-node: +- display-timings : Refer to binding doc display-timing.txt for details. + Examples: lcdif@80030000 { @@ -16,4 +26,28 @@ lcdif@80030000 { reg = <0x80030000 2000>; interrupts = <38 86>; panel-enable-gpios = <&gpio3 30 0>; + + display: display { + bits-per-pixel = <32>; + bus-width = <24>; + + display-timings { + native-mode = <&timing0>; + timing0: timing0 { + clock-frequency = <33500000>; + hactive = <800>; + vactive = <480>; + hfront-porch = <164>; + hback-porch = <89>; + hsync-len = <10>; + vback-porch = <23>; + vfront-porch = <10>; + vsync-len = <10>; + hsync-active = <0>; + vsync-active = <0>; + de-active = <1>; + pixelclk-active = <0>; + }; + }; + }; }; diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 4c1546f71d5..e7718fdad1e 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -2437,6 +2437,8 @@ config FB_MXS select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT + select FB_MODE_HELPERS + select OF_VIDEOMODE help Framebuffer support for the MXS SoC. diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c index a89901c7f5e..e5ceba54d22 100644 --- a/drivers/video/mxsfb.c +++ b/drivers/video/mxsfb.c @@ -43,12 +43,14 @@ #include #include #include +#include