OMAPDSS: panel-dpi: use gpiod for enable gpio
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 24 Apr 2014 09:36:52 +0000 (12:36 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 7 May 2014 07:58:22 +0000 (10:58 +0300)
The new gpiod API supports automatic handling of active-high/active-low
with DT. To make it possible to use that when booting with DT, change
the panel-dpi's handling of the enable GPIO to use gpiod.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/video/fbdev/omap2/displays-new/panel-dpi.c

index 5f8f7e7..d379dec 100644 (file)
@@ -25,8 +25,10 @@ struct panel_drv_data {
 
        struct omap_video_timings videomode;
 
+       /* used for non-DT boot, to be removed */
        int backlight_gpio;
-       int enable_gpio;
+
+       struct gpio_desc *enable_gpio;
 };
 
 #define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
@@ -77,8 +79,8 @@ static int panel_dpi_enable(struct omap_dss_device *dssdev)
        if (r)
                return r;
 
-       if (gpio_is_valid(ddata->enable_gpio))
-               gpio_set_value_cansleep(ddata->enable_gpio, 1);
+       if (ddata->enable_gpio)
+               gpiod_set_value_cansleep(ddata->enable_gpio, 1);
 
        if (gpio_is_valid(ddata->backlight_gpio))
                gpio_set_value_cansleep(ddata->backlight_gpio, 1);
@@ -96,8 +98,8 @@ static void panel_dpi_disable(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_enabled(dssdev))
                return;
 
-       if (gpio_is_valid(ddata->enable_gpio))
-               gpio_set_value_cansleep(ddata->enable_gpio, 0);
+       if (ddata->enable_gpio)
+               gpiod_set_value_cansleep(ddata->enable_gpio, 0);
 
        if (gpio_is_valid(ddata->backlight_gpio))
                gpio_set_value_cansleep(ddata->backlight_gpio, 0);
@@ -156,6 +158,7 @@ static int panel_dpi_probe_pdata(struct platform_device *pdev)
        struct panel_drv_data *ddata = platform_get_drvdata(pdev);
        struct omap_dss_device *dssdev, *in;
        struct videomode vm;
+       int r;
 
        pdata = dev_get_platdata(&pdev->dev);
 
@@ -176,10 +179,20 @@ static int panel_dpi_probe_pdata(struct platform_device *pdev)
        dssdev = &ddata->dssdev;
        dssdev->name = pdata->name;
 
-       ddata->enable_gpio = pdata->enable_gpio;
+       r = devm_gpio_request_one(&pdev->dev, pdata->enable_gpio,
+                                       GPIOF_OUT_INIT_LOW, "panel enable");
+       if (r)
+               goto err_gpio;
+
+       ddata->enable_gpio = gpio_to_desc(pdata->enable_gpio);
+
        ddata->backlight_gpio = pdata->backlight_gpio;
 
        return 0;
+
+err_gpio:
+       omap_dss_put_device(ddata->in);
+       return r;
 }
 
 static int panel_dpi_probe(struct platform_device *pdev)
@@ -202,13 +215,6 @@ static int panel_dpi_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       if (gpio_is_valid(ddata->enable_gpio)) {
-               r = devm_gpio_request_one(&pdev->dev, ddata->enable_gpio,
-                               GPIOF_OUT_INIT_LOW, "panel enable");
-               if (r)
-                       goto err_gpio;
-       }
-
        if (gpio_is_valid(ddata->backlight_gpio)) {
                r = devm_gpio_request_one(&pdev->dev, ddata->backlight_gpio,
                                GPIOF_OUT_INIT_LOW, "panel backlight");