From 282ecb879bdb75db42a3a869847e82a2d1c6b4d7 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 30 Jul 2013 10:36:29 +0300 Subject: [PATCH 18/23] OMAPDSS: connector-dvi: Add DT support Signed-off-by: Tomi Valkeinen --- drivers/video/omap2/displays-new/connector-dvi.c | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/video/omap2/displays-new/connector-dvi.c b/drivers/video/omap2/displays-new/connector-dvi.c index bc5f8ce..c6e04ed 100644 --- a/drivers/video/omap2/displays-new/connector-dvi.c +++ b/drivers/video/omap2/displays-new/connector-dvi.c @@ -274,6 +274,42 @@ static int dvic_probe_pdata(struct platform_device *pdev) return 0; } +static int dvic_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; + struct device_node *src_node; + struct device_node *adapter_node; + struct i2c_adapter *adapter; + + src_node = of_parse_phandle(node, "video-source", 0); + if (!src_node) { + dev_err(&pdev->dev, "failed to parse video source\n"); + return -ENODEV; + } + + in = omap_dss_find_output_by_node(src_node); + if (in == NULL) { + dev_err(&pdev->dev, "failed to find video source\n"); + return -EPROBE_DEFER; + } + ddata->in = in; + + 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 dvic_probe(struct platform_device *pdev) { struct panel_drv_data *ddata; @@ -290,6 +326,10 @@ static int dvic_probe(struct platform_device *pdev) r = dvic_probe_pdata(pdev); if (r) return r; + } else if (pdev->dev.of_node) { + r = dvic_probe_of(pdev); + if (r) + return r; } else { return -ENODEV; } @@ -335,12 +375,20 @@ static int __exit dvic_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id dvic_of_match[] = { + { .compatible = "ti,dvi_connector", }, + {}, +}; + +MODULE_DEVICE_TABLE(of, dvic_of_match); + static struct platform_driver dvi_connector_driver = { .probe = dvic_probe, .remove = __exit_p(dvic_remove), .driver = { .name = "connector-dvi", .owner = THIS_MODULE, + .of_match_table = dvic_of_match, }, }; -- 1.8.4.rc3