devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org,
	devicetree-discuss@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org
Cc: Archit Taneja <archit@ti.com>, Andy Gross <andy.gross@ti.com>,
	Tony Lindgren <tony@atomide.com>,
	Benoit Cousson <b-cousson@ti.com>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [RFC 06/14] OMAPDSS: Taal: Add DT support
Date: Wed, 27 Mar 2013 10:45:13 +0200	[thread overview]
Message-ID: <1364373921-7599-7-git-send-email-tomi.valkeinen@ti.com> (raw)
In-Reply-To: <1364373921-7599-1-git-send-email-tomi.valkeinen@ti.com>

Add DT support to Taal panel driver.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/video/omap2/displays/panel-taal.c |   89 +++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)

diff --git a/drivers/video/omap2/displays/panel-taal.c b/drivers/video/omap2/displays/panel-taal.c
index 01de2a9..f8771da 100644
--- a/drivers/video/omap2/displays/panel-taal.c
+++ b/drivers/video/omap2/displays/panel-taal.c
@@ -32,6 +32,8 @@
 #include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 
 #include <video/omapdss.h>
 #include <video/omap-panel-nokia-dsi.h>
@@ -788,6 +790,81 @@ static int taal_probe_pdata(struct platform_device *pdev)
 	return 0;
 }
 
+static int taal_probe_of(struct platform_device *pdev)
+{
+	struct device_node *node = pdev->dev.of_node;
+	struct taal_data *td = dev_get_drvdata(&pdev->dev);
+	struct property *prop;
+	struct device_node *src_node;
+	u32 lane_arr[10];
+	int gpio, len, num_pins;
+	int r, i;
+
+	src_node = of_parse_phandle(node, "video-source", 0);
+	if (!src_node) {
+		dev_err(&pdev->dev, "failed to parse video source\n");
+		return -ENODEV;
+	}
+
+	td->src = omap_dss_find_output_by_node(src_node);
+	if (!td->src) {
+		dev_err(&pdev->dev, "failed to find video source\n");
+		return -ENODEV;
+	}
+
+	gpio = of_get_gpio(node, 0);
+
+	if (gpio_is_valid(gpio)) {
+		td->reset_gpio = gpio;
+	} else {
+		dev_err(&pdev->dev, "failed to parse reset gpio\n");
+		return gpio;
+	}
+
+	if (of_gpio_count(node) > 1) {
+		gpio = of_get_gpio(node, 1);
+
+		if (gpio_is_valid(gpio)) {
+			td->ext_te_gpio = gpio;
+		} else if (gpio == -ENOENT) {
+			td->ext_te_gpio = -1;
+		} else {
+			dev_err(&pdev->dev, "failed to parse TE gpio\n");
+			return gpio;
+		}
+	} else {
+		td->ext_te_gpio = -1;
+	}
+
+	prop = of_find_property(node, "lanes", &len);
+	if (prop == NULL) {
+		dev_err(&pdev->dev, "failed to find lane data\n");
+		return -EINVAL;
+	}
+
+	num_pins = len / sizeof(u32);
+
+	if (num_pins < 4 || num_pins % 2 != 0
+			|| num_pins > ARRAY_SIZE(lane_arr)) {
+		dev_err(&pdev->dev, "bad number of lanes\n");
+		return -EINVAL;
+	}
+
+	r = of_property_read_u32_array(node, "lanes", lane_arr, num_pins);
+	if (r) {
+		dev_err(&pdev->dev, "failed to read lane data\n");
+		return r;
+	}
+
+	td->pin_config.num_pins = num_pins;
+	for (i = 0; i < num_pins; ++i)
+		td->pin_config.pins[i] = (int)lane_arr[i];
+
+	td->dssdev.name = node->name;
+
+	return 0;
+}
+
 static int taal_probe(struct platform_device *pdev)
 {
 	const struct nokia_dsi_panel_data *pdata = dev_get_platdata(&pdev->dev);
@@ -813,6 +890,12 @@ static int taal_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "failed to read platform data\n");
 			return r;
 		}
+	} else if (pdev->dev.of_node) {
+		r = taal_probe_of(pdev);
+		if (r) {
+			dev_err(&pdev->dev, "failed to parse OF data\n");
+			return r;
+		}
 	} else {
 		return -ENODEV;
 	}
@@ -1576,12 +1659,18 @@ static struct omap_dss_driver taal_driver = {
 	.memory_read	= taal_memory_read,
 };
 
+static const struct of_device_id taal_of_match[] = {
+	{ .compatible = "tpo,taal", },
+	{},
+};
+
 static struct platform_driver taal_platform_driver = {
 	.probe	= taal_probe,
 	.remove	= __exit_p(taal_remove),
 	.driver	= {
 		.name	= "taal",
 		.owner	= THIS_MODULE,
+		.of_match_table = taal_of_match,
 	},
 };
 
-- 
1.7.10.4


  parent reply	other threads:[~2013-03-27  8:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-27  8:45 [RFC 00/14] Add DT support to OMAPDSS Tomi Valkeinen
2013-03-27  8:45 ` [RFC 01/14] ARM: OMAP: remove DSS DT hack Tomi Valkeinen
2013-03-27  8:45 ` [RFC 02/14] ARM: OMAP2+: add omapdss_init_of() Tomi Valkeinen
2013-03-27  9:28   ` Benoit Cousson
2013-03-27 10:09     ` Tomi Valkeinen
2013-03-27  8:45 ` [RFC 03/14] OMAPDSS: Add DT support to DSS, DISPC, DPI Tomi Valkeinen
2013-03-27  8:45 ` [RFC 04/14] OMAPDSS: Add DT support to DSI Tomi Valkeinen
2013-03-27  8:45 ` [RFC 05/14] OMAPDSS: Add DT support to HDMI Tomi Valkeinen
2013-03-27  8:45 ` Tomi Valkeinen [this message]
2013-03-27  8:45 ` [RFC 07/14] OMAPDSS: TFP410: Add DT support Tomi Valkeinen
2013-03-27  8:45 ` [RFC 11/14] ARM: omap4-panda.dts: add display information Tomi Valkeinen
2013-03-27  8:45 ` [RFC 12/14] ARM: omap4-sdp.dts: " Tomi Valkeinen
     [not found] ` <1364373921-7599-1-git-send-email-tomi.valkeinen-l0cyMroinI0@public.gmane.org>
2013-03-27  8:45   ` [RFC 08/14] OMAPDSS: panel-generic-dpi: add DT support Tomi Valkeinen
2013-03-27  8:45   ` [RFC 09/14] ARM: omap3.dtsi: add omapdss information Tomi Valkeinen
2013-03-27  8:45   ` [RFC 10/14] ARM: omap4.dtsi: " Tomi Valkeinen
2013-03-27  8:45   ` [RFC 13/14] ARM: omap3-tobi.dts: add lcd (TEST) Tomi Valkeinen
2013-03-27  8:45   ` [RFC 14/14] ARM: omap3-beagle.dts: add TFP410 Tomi Valkeinen
2013-03-27  9:30 ` [RFC 00/14] Add DT support to OMAPDSS Benoit Cousson
2013-03-27 10:15   ` Tomi Valkeinen
2013-03-27  9:41 ` Benoit Cousson
     [not found]   ` <5152BEB7.4060804-l0cyMroinI0@public.gmane.org>
2013-03-27 10:39     ` Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1364373921-7599-7-git-send-email-tomi.valkeinen@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=andy.gross@ti.com \
    --cc=archit@ti.com \
    --cc=b-cousson@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=santosh.shilimkar@ti.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).