OMAPDSS: acx565akm: Add DT support
authorSebastian Reichel <sre@debian.org>
Fri, 13 Dec 2013 18:17:28 +0000 (19:17 +0100)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 19 Mar 2014 09:03:11 +0000 (11:03 +0200)
Add DT support for panel-sony-acx565akm

Signed-off-by: Sebastian Reichel <sre@debian.org>
[tomi.valkeinen@ti.com: some modifications]
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Archit Taneja <archit@ti.com>
drivers/video/omap2/displays-new/panel-sony-acx565akm.c

index 8e97d06921ffdfff11a20ce6916666d8c1672351..906220c20186716e0ea321cfde63061d00ce1a12 100644 (file)
@@ -30,6 +30,8 @@
 #include <linux/backlight.h>
 #include <linux/fb.h>
 #include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
 
 #include <video/omapdss.h>
 #include <video/omap-panel-data.h>
@@ -547,7 +549,9 @@ static int acx565akm_panel_power_on(struct omap_dss_device *dssdev)
        dev_dbg(&ddata->spi->dev, "%s\n", __func__);
 
        in->ops.sdi->set_timings(in, &ddata->videomode);
-       in->ops.sdi->set_datapairs(in, ddata->datapairs);
+
+       if (ddata->datapairs > 0)
+               in->ops.sdi->set_datapairs(in, ddata->datapairs);
 
        r = in->ops.sdi->enable(in);
        if (r) {
@@ -726,6 +730,22 @@ static int acx565akm_probe_pdata(struct spi_device *spi)
        return 0;
 }
 
+static int acx565akm_probe_of(struct spi_device *spi)
+{
+       struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
+       struct device_node *np = spi->dev.of_node;
+
+       ddata->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0);
+
+       ddata->in = omapdss_of_find_source_for_first_ep(np);
+       if (IS_ERR(ddata->in)) {
+               dev_err(&spi->dev, "failed to find video source\n");
+               return PTR_ERR(ddata->in);
+       }
+
+       return 0;
+}
+
 static int acx565akm_probe(struct spi_device *spi)
 {
        struct panel_drv_data *ddata;
@@ -753,7 +773,12 @@ static int acx565akm_probe(struct spi_device *spi)
                r = acx565akm_probe_pdata(spi);
                if (r)
                        return r;
+       } else if (spi->dev.of_node) {
+               r = acx565akm_probe_of(spi);
+               if (r)
+                       return r;
        } else {
+               dev_err(&spi->dev, "platform data missing!\n");
                return -ENODEV;
        }
 
@@ -864,10 +889,16 @@ static int acx565akm_remove(struct spi_device *spi)
        return 0;
 }
 
+static const struct of_device_id acx565akm_of_match[] = {
+       { .compatible = "omapdss,sony,acx565akm", },
+       {},
+};
+
 static struct spi_driver acx565akm_driver = {
        .driver = {
                .name   = "acx565akm",
                .owner  = THIS_MODULE,
+               .of_match_table = acx565akm_of_match,
        },
        .probe  = acx565akm_probe,
        .remove = acx565akm_remove,