OMAPDSS: LS037V7DW01: handle gpios in panel driver
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 3 Apr 2013 08:39:19 +0000 (11:39 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 3 Apr 2013 12:19:47 +0000 (15:19 +0300)
Move the GPIO handling from board file's platform callbacks to the panel
driver, which gets the gpios via platform data.

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

index eb6bd81..e6d9c9b 100644 (file)
 #include <linux/fb.h>
 #include <linux/err.h>
 #include <linux/slab.h>
+#include <linux/gpio.h>
 
 #include <video/omapdss.h>
-
-struct sharp_data {
-};
+#include <video/omap-panel-data.h>
 
 static struct omap_video_timings sharp_ls_timings = {
        .x_res = 480,
@@ -50,31 +49,67 @@ static struct omap_video_timings sharp_ls_timings = {
        .sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES,
 };
 
+static inline struct panel_sharp_ls037v7dw01_data
+*get_panel_data(const struct omap_dss_device *dssdev)
+{
+       return (struct panel_sharp_ls037v7dw01_data *) dssdev->data;
+}
 
 static int sharp_ls_panel_probe(struct omap_dss_device *dssdev)
 {
-       struct sharp_data *sd;
+       struct panel_sharp_ls037v7dw01_data *pd = get_panel_data(dssdev);
+       int r;
+
+       if (!pd)
+               return -EINVAL;
 
        dssdev->panel.timings = sharp_ls_timings;
 
-       sd = kzalloc(sizeof(*sd), GFP_KERNEL);
-       if (!sd)
-               return -ENOMEM;
+       if (gpio_is_valid(pd->mo_gpio)) {
+               r = devm_gpio_request_one(&dssdev->dev, pd->mo_gpio,
+                               GPIOF_OUT_INIT_LOW, "lcd MO");
+               if (r)
+                       return r;
+       }
+
+       if (gpio_is_valid(pd->lr_gpio)) {
+               r = devm_gpio_request_one(&dssdev->dev, pd->lr_gpio,
+                               GPIOF_OUT_INIT_HIGH, "lcd LR");
+               if (r)
+                       return r;
+       }
 
-       dev_set_drvdata(&dssdev->dev, sd);
+       if (gpio_is_valid(pd->ud_gpio)) {
+               r = devm_gpio_request_one(&dssdev->dev, pd->ud_gpio,
+                               GPIOF_OUT_INIT_HIGH, "lcd UD");
+               if (r)
+                       return r;
+       }
+
+       if (gpio_is_valid(pd->resb_gpio)) {
+               r = devm_gpio_request_one(&dssdev->dev, pd->resb_gpio,
+                               GPIOF_OUT_INIT_LOW, "lcd RESB");
+               if (r)
+                       return r;
+       }
+
+       if (gpio_is_valid(pd->ini_gpio)) {
+               r = devm_gpio_request_one(&dssdev->dev, pd->ini_gpio,
+                               GPIOF_OUT_INIT_LOW, "lcd INI");
+               if (r)
+                       return r;
+       }
 
        return 0;
 }
 
 static void __exit sharp_ls_panel_remove(struct omap_dss_device *dssdev)
 {
-       struct sharp_data *sd = dev_get_drvdata(&dssdev->dev);
-
-       kfree(sd);
 }
 
 static int sharp_ls_power_on(struct omap_dss_device *dssdev)
 {
+       struct panel_sharp_ls037v7dw01_data *pd = get_panel_data(dssdev);
        int r = 0;
 
        if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
@@ -96,6 +131,12 @@ static int sharp_ls_power_on(struct omap_dss_device *dssdev)
                        goto err1;
        }
 
+       if (gpio_is_valid(pd->resb_gpio))
+               gpio_set_value_cansleep(pd->resb_gpio, 1);
+
+       if (gpio_is_valid(pd->ini_gpio))
+               gpio_set_value_cansleep(pd->ini_gpio, 1);
+
        return 0;
 err1:
        omapdss_dpi_display_disable(dssdev);
@@ -105,9 +146,17 @@ err0:
 
 static void sharp_ls_power_off(struct omap_dss_device *dssdev)
 {
+       struct panel_sharp_ls037v7dw01_data *pd = get_panel_data(dssdev);
+
        if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
                return;
 
+       if (gpio_is_valid(pd->ini_gpio))
+               gpio_set_value_cansleep(pd->ini_gpio, 0);
+
+       if (gpio_is_valid(pd->resb_gpio))
+               gpio_set_value_cansleep(pd->resb_gpio, 0);
+
        if (dssdev->platform_disable)
                dssdev->platform_disable(dssdev);