OMAPDSS: encoder-tfp410: Add DT support
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 30 Jul 2013 07:35:30 +0000 (10:35 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 19 Mar 2014 09:03:09 +0000 (11:03 +0200)
Add DT support for encoder-tfp410.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Archit Taneja <archit@ti.com>
drivers/video/omap2/displays-new/encoder-tfp410.c

index 4a291e756be944cfc0dcb647312d520891bca4e0..b4e9a42a79e61cc58d9dc0abd50811e0db694d48 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/of_gpio.h>
 
 #include <video/omapdss.h>
 #include <video/omap-panel-data.h>
@@ -82,7 +83,8 @@ static int tfp410_enable(struct omap_dss_device *dssdev)
                return 0;
 
        in->ops.dpi->set_timings(in, &ddata->timings);
-       in->ops.dpi->set_data_lines(in, ddata->data_lines);
+       if (ddata->data_lines)
+               in->ops.dpi->set_data_lines(in, ddata->data_lines);
 
        r = in->ops.dpi->enable(in);
        if (r)
@@ -179,6 +181,33 @@ static int tfp410_probe_pdata(struct platform_device *pdev)
        return 0;
 }
 
+static int tfp410_probe_of(struct platform_device *pdev)
+{
+       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
+       struct device_node *node = pdev->dev.of_node;
+       struct omap_dss_device *in;
+       int gpio;
+
+       gpio = of_get_named_gpio(node, "powerdown-gpios", 0);
+
+       if (gpio_is_valid(gpio) || gpio == -ENOENT) {
+               ddata->pd_gpio = gpio;
+       } else {
+               dev_err(&pdev->dev, "failed to parse PD gpio\n");
+               return gpio;
+       }
+
+       in = omapdss_of_find_source_for_first_ep(node);
+       if (IS_ERR(in)) {
+               dev_err(&pdev->dev, "failed to find video source\n");
+               return PTR_ERR(in);
+       }
+
+       ddata->in = in;
+
+       return 0;
+}
+
 static int tfp410_probe(struct platform_device *pdev)
 {
        struct panel_drv_data *ddata;
@@ -195,6 +224,10 @@ static int tfp410_probe(struct platform_device *pdev)
                r = tfp410_probe_pdata(pdev);
                if (r)
                        return r;
+       } else if (pdev->dev.of_node) {
+               r = tfp410_probe_of(pdev);
+               if (r)
+                       return r;
        } else {
                return -ENODEV;
        }
@@ -251,12 +284,20 @@ static int __exit tfp410_remove(struct platform_device *pdev)
        return 0;
 }
 
+static const struct of_device_id tfp410_of_match[] = {
+       { .compatible = "omapdss,ti,tfp410", },
+       {},
+};
+
+MODULE_DEVICE_TABLE(of, tfp410_of_match);
+
 static struct platform_driver tfp410_driver = {
        .probe  = tfp410_probe,
        .remove = __exit_p(tfp410_remove),
        .driver = {
                .name   = "tfp410",
                .owner  = THIS_MODULE,
+               .of_match_table = tfp410_of_match,
        },
 };