[RFC 07/14] OMAPDSS: TFP410: Add DT support

Tomi Valkeinen tomi.valkeinen at ti.com
Wed Mar 27 19:45:14 EST 2013


In the DT data we model the TFP410 chip and the DVI connector. For the
moment we have only 1 driver to handle those both.

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

diff --git a/drivers/video/omap2/displays/panel-tfp410.c b/drivers/video/omap2/displays/panel-tfp410.c
index a225ea1..a087489c 100644
--- a/drivers/video/omap2/displays/panel-tfp410.c
+++ b/drivers/video/omap2/displays/panel-tfp410.c
@@ -24,6 +24,8 @@
 #include <linux/gpio.h>
 #include <linux/platform_device.h>
 #include <drm/drm_edid.h>
+#include <linux/of_gpio.h>
+#include <linux/of_i2c.h>
 
 #include <video/omap-panel-tfp410.h>
 
@@ -112,6 +114,63 @@ static int tfp410_probe_pdata(struct platform_device *pdev)
 	return 0;
 }
 
+static int tfp410_probe_of(struct platform_device *pdev)
+{
+	struct device_node *node = pdev->dev.of_node;
+	struct panel_drv_data *ddata = dev_get_drvdata(&pdev->dev);
+	struct device_node *adapter_node;
+	struct i2c_adapter *adapter;
+	int r, gpio, datalines;
+
+	ddata->name = node->name;
+
+	node = of_parse_phandle(node, "video-source", 0);
+	if (!node) {
+		dev_err(&pdev->dev, "failed to parse video source\n");
+		return -ENODEV;
+	}
+
+	gpio = of_get_gpio(node, 0);
+
+	if (gpio_is_valid(gpio)) {
+		r = devm_gpio_request_one(&pdev->dev, gpio,
+				GPIOF_OUT_INIT_LOW, "tfp410 pd");
+		if (r) {
+			dev_err(&pdev->dev, "Failed to request PD GPIO %d\n",
+					gpio);
+			return r;
+		}
+
+		ddata->pd_gpio = gpio;
+	} else if (gpio == -ENOENT) {
+		ddata->pd_gpio = -1;
+	} else {
+		dev_err(&pdev->dev, "failed to parse PD gpio\n");
+		return gpio;
+	}
+
+	r = of_property_read_u32(node, "data-lines", &datalines);
+	if (r) {
+		dev_err(&pdev->dev, "failed to parse datalines");
+		return r;
+	}
+
+	ddata->data_lines = datalines;
+
+	adapter_node = of_parse_phandle(node, "i2c-bus", 0);
+	if (adapter_node) {
+		adapter = of_find_i2c_adapter_by_node(adapter_node);
+		if (adapter == NULL) {
+			dev_err(&pdev->dev, "failed to parse i2c-bus\n");
+			return -EINVAL;
+		}
+
+		ddata->i2c_adapter = adapter;
+	}
+
+	return 0;
+}
+
 static int tfp410_probe(struct platform_device *pdev)
 {
 	struct tfp410_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -131,6 +190,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;
 	}
@@ -380,12 +443,20 @@ static struct omap_dss_driver tfp410_driver = {
 	.detect		= tfp410_detect,
 };
 
+static const struct of_device_id tfp410_of_match[] = {
+	{
+		.compatible = "ti,dvi_connector",
+	},
+	{},
+};
+
 static struct platform_driver tfp410_platform_driver = {
 	.probe	= tfp410_probe,
 	.remove	= __exit_p(tfp410_remove),
 	.driver	= {
 		.name	= "tfp410",
 		.owner	= THIS_MODULE,
+		.of_match_table = tfp410_of_match,
 	},
 };
 
-- 
1.7.10.4



More information about the devicetree-discuss mailing list