MLK_12886-2 video: mxsfb: handle the assert gpio in driver to support deferred probe
authorFancy Fang <chen.fang@nxp.com>
Mon, 6 Jun 2016 06:07:54 +0000 (14:07 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:52:04 +0000 (14:52 -0500)
The assert gpio comes from 'gpio_spi' module, so the framebuffer
depends on the 'gpio_spi' driver loading. And in the case that
the framebuffer driver is loaded earlier than the 'gpio_spi'
driver, the gpio asserting will fail. So handle this gpio in
the framebuffer driver and add deferred probed support.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
arch/arm/boot/dts/imx7d-sdb.dts
drivers/video/fbdev/mxsfb.c

index e9160e2..33519bf 100644 (file)
 &lcdif {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_lcdif>;
-       pinctrl-assert-gpios = <&gpio_spi 7 GPIO_ACTIVE_LOW>;
+       enable-gpio = <&gpio_spi 7 GPIO_ACTIVE_LOW>;
        display = <&display0>;
        status = "okay";
 
index 3aedf53..febae3e 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/of_device.h>
+#include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/interrupt.h>
@@ -1375,11 +1376,23 @@ static int mxsfb_probe(struct platform_device *pdev)
        struct fb_info *fb_info;
        struct pinctrl *pinctrl;
        int irq = platform_get_irq(pdev, 0);
-       int ret;
+       int gpio, ret;
 
        if (of_id)
                pdev->id_entry = of_id->data;
 
+       gpio = of_get_named_gpio(pdev->dev.of_node, "enable-gpio", 0);
+       if (gpio == -EPROBE_DEFER)
+               return -EPROBE_DEFER;
+
+       if (gpio_is_valid(gpio)) {
+               ret = devm_gpio_request_one(&pdev->dev, gpio, GPIOF_OUT_INIT_LOW, "lcd_pwr_en");
+               if (ret) {
+                       dev_err(&pdev->dev, "faild to request gpio %d, ret = %d\n", gpio, ret);
+                       return ret;
+               }
+       }
+
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!res) {
                dev_err(&pdev->dev, "Cannot get memory IO resource\n");