Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

video: mxsfb: add simple device tree probe

Add a simple device tree probe support for mxsfb driver. Before
a common binding for struct fb_videomode is available, the driver will
keep using struct mxsfb_platform_data. That said, platform code will
use auxdata to attach mxsfb_platform_data for device tree boot.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>

Shawn Guo 73fc610f ce4409b5

+66 -13
+19
Documentation/devicetree/bindings/fb/mxsfb.txt
··· 1 + * Freescale MXS LCD Interface (LCDIF) 2 + 3 + Required properties: 4 + - compatible: Should be "fsl,<chip>-lcdif". Supported chips include 5 + imx23 and imx28. 6 + - reg: Address and length of the register set for lcdif 7 + - interrupts: Should contain lcdif interrupts 8 + 9 + Optional properties: 10 + - panel-enable-gpios : Should specify the gpio for panel enable 11 + 12 + Examples: 13 + 14 + lcdif@80030000 { 15 + compatible = "fsl,imx28-lcdif"; 16 + reg = <0x80030000 2000>; 17 + interrupts = <38 86>; 18 + panel-enable-gpios = <&gpio3 30 0>; 19 + };
+47 -13
drivers/video/mxsfb.c
··· 41 41 42 42 #include <linux/module.h> 43 43 #include <linux/kernel.h> 44 + #include <linux/of_device.h> 45 + #include <linux/of_gpio.h> 44 46 #include <linux/platform_device.h> 45 47 #include <linux/clk.h> 46 48 #include <linux/dma-mapping.h> ··· 752 750 } 753 751 } 754 752 753 + static struct platform_device_id mxsfb_devtype[] = { 754 + { 755 + .name = "imx23-fb", 756 + .driver_data = MXSFB_V3, 757 + }, { 758 + .name = "imx28-fb", 759 + .driver_data = MXSFB_V4, 760 + }, { 761 + /* sentinel */ 762 + } 763 + }; 764 + MODULE_DEVICE_TABLE(platform, mxsfb_devtype); 765 + 766 + static const struct of_device_id mxsfb_dt_ids[] = { 767 + { .compatible = "fsl,imx23-lcdif", .data = &mxsfb_devtype[0], }, 768 + { .compatible = "fsl,imx28-lcdif", .data = &mxsfb_devtype[1], }, 769 + { /* sentinel */ } 770 + }; 771 + MODULE_DEVICE_TABLE(of, mxsfb_dt_ids); 772 + 755 773 static int __devinit mxsfb_probe(struct platform_device *pdev) 756 774 { 775 + const struct of_device_id *of_id = 776 + of_match_device(mxsfb_dt_ids, &pdev->dev); 757 777 struct mxsfb_platform_data *pdata = pdev->dev.platform_data; 758 778 struct resource *res; 759 779 struct mxsfb_info *host; 760 780 struct fb_info *fb_info; 761 781 struct fb_modelist *modelist; 762 782 struct pinctrl *pinctrl; 783 + int panel_enable; 784 + enum of_gpio_flags flags; 763 785 int i, ret; 786 + 787 + if (of_id) 788 + pdev->id_entry = of_id->data; 764 789 765 790 if (!pdata) { 766 791 dev_err(&pdev->dev, "No platformdata. Giving up\n"); ··· 834 805 if (IS_ERR(host->clk)) { 835 806 ret = PTR_ERR(host->clk); 836 807 goto error_getclock; 808 + } 809 + 810 + panel_enable = of_get_named_gpio_flags(pdev->dev.of_node, 811 + "panel-enable-gpios", 0, &flags); 812 + if (gpio_is_valid(panel_enable)) { 813 + unsigned long f = GPIOF_OUT_INIT_HIGH; 814 + if (flags == OF_GPIO_ACTIVE_LOW) 815 + f = GPIOF_OUT_INIT_LOW; 816 + ret = devm_gpio_request_one(&pdev->dev, panel_enable, 817 + f, "panel-enable"); 818 + if (ret) { 819 + dev_err(&pdev->dev, 820 + "failed to request gpio %d: %d\n", 821 + panel_enable, ret); 822 + goto error_panel_enable; 823 + } 837 824 } 838 825 839 826 fb_info->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); ··· 899 854 error_init_fb: 900 855 kfree(fb_info->pseudo_palette); 901 856 error_pseudo_pallette: 857 + error_panel_enable: 902 858 clk_put(host->clk); 903 859 error_getclock: 904 860 error_getpin: ··· 947 901 writel(CTRL_RUN, host->base + LCDC_CTRL + REG_CLR); 948 902 } 949 903 950 - static struct platform_device_id mxsfb_devtype[] = { 951 - { 952 - .name = "imx23-fb", 953 - .driver_data = MXSFB_V3, 954 - }, { 955 - .name = "imx28-fb", 956 - .driver_data = MXSFB_V4, 957 - }, { 958 - /* sentinel */ 959 - } 960 - }; 961 - MODULE_DEVICE_TABLE(platform, mxsfb_devtype); 962 - 963 904 static struct platform_driver mxsfb_driver = { 964 905 .probe = mxsfb_probe, 965 906 .remove = __devexit_p(mxsfb_remove), ··· 954 921 .id_table = mxsfb_devtype, 955 922 .driver = { 956 923 .name = DRIVER_NAME, 924 + .of_match_table = mxsfb_dt_ids, 957 925 }, 958 926 }; 959 927