diff mbox

[PATCHv3,19/41] OMAPDSS: panel-dpi: Add DT support

Message ID 1390301833-24944-20-git-send-email-tomi.valkeinen@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tomi Valkeinen Jan. 21, 2014, 10:56 a.m. UTC
Add DT support for panel-dpi.

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

Comments

Tony Lindgren April 8, 2014, 12:13 a.m. UTC | #1
Tomi,

* Tomi Valkeinen <tomi.valkeinen@ti.com> [140121 03:01]:
> Add DT support for panel-dpi.

Looks like this patch did not get merged or am I missing
something?

As you probably are aware, we have at least these boards
needing it before we can remove the omap3 legacy support:

board-am3517evm.c
board-cm-t35.c
board-devkit8000.c
board-ldp.c
board-overo.c

We could probably set the display timings based on the
compatible flag in the driver if that's an issue?

And then board-omap3pandora.c also needs support for
panel_tpo_td043mtea1_platform_data.
 
Regards,

Tony

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>  drivers/video/omap2/displays-new/panel-dpi.c | 64 +++++++++++++++++++++++++++-
>  1 file changed, 63 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/video/omap2/displays-new/panel-dpi.c b/drivers/video/omap2/displays-new/panel-dpi.c
> index 5f8f7e7c81ef..b032daf0f407 100644
> --- a/drivers/video/omap2/displays-new/panel-dpi.c
> +++ b/drivers/video/omap2/displays-new/panel-dpi.c
> @@ -13,9 +13,12 @@
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
> +#include <linux/of.h>
> +#include <linux/of_gpio.h>
>  
>  #include <video/omapdss.h>
>  #include <video/omap-panel-data.h>
> +#include <video/of_display_timing.h>
>  
>  struct panel_drv_data {
>  	struct omap_dss_device dssdev;
> @@ -70,7 +73,8 @@ static int panel_dpi_enable(struct omap_dss_device *dssdev)
>  	if (omapdss_device_is_enabled(dssdev))
>  		return 0;
>  
> -	in->ops.dpi->set_data_lines(in, ddata->data_lines);
> +	if (ddata->data_lines)
> +		in->ops.dpi->set_data_lines(in, ddata->data_lines);
>  	in->ops.dpi->set_timings(in, &ddata->videomode);
>  
>  	r = in->ops.dpi->enable(in);
> @@ -182,6 +186,52 @@ static int panel_dpi_probe_pdata(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static int panel_dpi_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 r;
> +	struct display_timing timing;
> +	struct videomode vm;
> +	int gpio;
> +
> +	gpio = of_get_gpio(node, 0);
> +	if (gpio_is_valid(gpio) || gpio == -ENOENT) {
> +		ddata->enable_gpio = gpio;
> +	} else {
> +		dev_err(&pdev->dev, "failed to parse enable gpio\n");
> +		return gpio;
> +	}
> +
> +	gpio = of_get_gpio(node, 1);
> +	if (gpio_is_valid(gpio) || gpio == -ENOENT) {
> +		ddata->backlight_gpio = gpio;
> +	} else {
> +		dev_err(&pdev->dev, "failed to parse backlight gpio\n");
> +		return gpio;
> +	}
> +
> +	r = of_get_display_timing(node, "panel-timing", &timing);
> +	if (r) {
> +		dev_err(&pdev->dev, "failed to get video timing\n");
> +		return r;
> +	}
> +
> +	videomode_from_timing(&timing, &vm);
> +	videomode_to_omap_video_timings(&vm, &ddata->videomode);
> +
> +	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 panel_dpi_probe(struct platform_device *pdev)
>  {
>  	struct panel_drv_data *ddata;
> @@ -198,6 +248,10 @@ static int panel_dpi_probe(struct platform_device *pdev)
>  		r = panel_dpi_probe_pdata(pdev);
>  		if (r)
>  			return r;
> +	} else if (pdev->dev.of_node) {
> +		r = panel_dpi_probe_of(pdev);
> +		if (r)
> +			return r;
>  	} else {
>  		return -ENODEV;
>  	}
> @@ -254,12 +308,20 @@ static int __exit panel_dpi_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static const struct of_device_id panel_dpi_of_match[] = {
> +	{ .compatible = "omapdss,panel-dpi", },
> +	{},
> +};
> +
> +MODULE_DEVICE_TABLE(of, panel_dpi_of_match);
> +
>  static struct platform_driver panel_dpi_driver = {
>  	.probe = panel_dpi_probe,
>  	.remove = __exit_p(panel_dpi_remove),
>  	.driver = {
>  		.name = "panel-dpi",
>  		.owner = THIS_MODULE,
> +		.of_match_table = panel_dpi_of_match,
>  	},
>  };
>  
> -- 
> 1.8.3.2
>
Tomi Valkeinen April 8, 2014, 5:38 a.m. UTC | #2
On 08/04/14 03:13, Tony Lindgren wrote:
> Tomi,
> 
> * Tomi Valkeinen <tomi.valkeinen@ti.com> [140121 03:01]:
>> Add DT support for panel-dpi.
> 
> Looks like this patch did not get merged or am I missing
> something?

Yes, I dropped it. None of the boards that I converted used panel-dpi.
There was so much discussions about the display bindings, so I thought
it's better to leave out all but the needed patches.

> As you probably are aware, we have at least these boards
> needing it before we can remove the omap3 legacy support:
> 
> board-am3517evm.c
> board-cm-t35.c
> board-devkit8000.c
> board-ldp.c
> board-overo.c
> 
> We could probably set the display timings based on the
> compatible flag in the driver if that's an issue?

The timings shouldn't be an issue. But there's the backlight GPIO,
currently handled by panel-dpi, which should be removed from the panel.
We should use gpio-backlight for that one.

> And then board-omap3pandora.c also needs support for
> panel_tpo_td043mtea1_platform_data.

Yep, there's still much to do for DSS DT support. Hopefully it will be
easier now that the core support is there. I'll continue working on the
remaining boards and panels. However, I don't have any of the remaining
boards, so help is of course appreciated.

 Tomi
Tony Lindgren April 8, 2014, 3:29 p.m. UTC | #3
* Tomi Valkeinen <tomi.valkeinen@ti.com> [140407 22:42]:
> On 08/04/14 03:13, Tony Lindgren wrote:
> > Tomi,
> > 
> > * Tomi Valkeinen <tomi.valkeinen@ti.com> [140121 03:01]:
> >> Add DT support for panel-dpi.
> > 
> > Looks like this patch did not get merged or am I missing
> > something?
> 
> Yes, I dropped it. None of the boards that I converted used panel-dpi.
> There was so much discussions about the display bindings, so I thought
> it's better to leave out all but the needed patches.

OK
 
> > As you probably are aware, we have at least these boards
> > needing it before we can remove the omap3 legacy support:
> > 
> > board-am3517evm.c
> > board-cm-t35.c
> > board-devkit8000.c
> > board-ldp.c
> > board-overo.c
> > 
> > We could probably set the display timings based on the
> > compatible flag in the driver if that's an issue?
> 
> The timings shouldn't be an issue. But there's the backlight GPIO,
> currently handled by panel-dpi, which should be removed from the panel.
> We should use gpio-backlight for that one.

Using gpio-backlight makes sense for sure.

FYI, in the case of the LDP there are four GPIOs to configure to
get things going:

gpio55		LCD RESET		panel-dpi?
gpio56		LCD QVGA		panel-dpi?
twl gpio7	LCD power		panel-dpi
twl gpio15	LCD backlight		gpio-backlight
 
> > And then board-omap3pandora.c also needs support for
> > panel_tpo_td043mtea1_platform_data.
> 
> Yep, there's still much to do for DSS DT support. Hopefully it will be
> easier now that the core support is there. I'll continue working on the
> remaining boards and panels. However, I don't have any of the remaining
> boards, so help is of course appreciated.

Yeah I can test at least the LDP here.

Regards,

Tony
Tony Lindgren April 18, 2014, 3:51 p.m. UTC | #4
Hi,

Just trying to summarize what has been discussed so far in
various threads regarding changes needed to this patch.

* Tomi Valkeinen <tomi.valkeinen@ti.com> [140121 03:01]:
> --- a/drivers/video/omap2/displays-new/panel-dpi.c
> +++ b/drivers/video/omap2/displays-new/panel-dpi.c
> @@ -182,6 +186,52 @@ static int panel_dpi_probe_pdata(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static int panel_dpi_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 r;
> +	struct display_timing timing;
> +	struct videomode vm;
> +	int gpio;
> +
> +	gpio = of_get_gpio(node, 0);
> +	if (gpio_is_valid(gpio) || gpio == -ENOENT) {
> +		ddata->enable_gpio = gpio;
> +	} else {
> +		dev_err(&pdev->dev, "failed to parse enable gpio\n");
> +		return gpio;
> +	}

We should set the GPIO polarity based on the OF_GPIO_ACTIVE_LOW like
gpio_backlight_probe_dt is doing. 

Then do we really want to do the dev_err for each -EPROBE_DEFER here?

> +	gpio = of_get_gpio(node, 1);
> +	if (gpio_is_valid(gpio) || gpio == -ENOENT) {
> +		ddata->backlight_gpio = gpio;
> +	} else {
> +		dev_err(&pdev->dev, "failed to parse backlight gpio\n");
> +		return gpio;
> +	}

How about let's drop the backlight_gpio as discussed since it
can be handled with gpio-backlight?

Instead, let's add the panel specific reset_gpio as suggested by
Joachim. That seems common to some dpi using panels.

Then support for the other panel specific GPIOs can then be added
as a follow-up patch when we know how we want to handle them.

Oh, and this patch needs the related binding documentation too in
Documentation/devicetree/bindings.

Regards,

Tony
diff mbox

Patch

diff --git a/drivers/video/omap2/displays-new/panel-dpi.c b/drivers/video/omap2/displays-new/panel-dpi.c
index 5f8f7e7c81ef..b032daf0f407 100644
--- a/drivers/video/omap2/displays-new/panel-dpi.c
+++ b/drivers/video/omap2/displays-new/panel-dpi.c
@@ -13,9 +13,12 @@ 
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
 
 #include <video/omapdss.h>
 #include <video/omap-panel-data.h>
+#include <video/of_display_timing.h>
 
 struct panel_drv_data {
 	struct omap_dss_device dssdev;
@@ -70,7 +73,8 @@  static int panel_dpi_enable(struct omap_dss_device *dssdev)
 	if (omapdss_device_is_enabled(dssdev))
 		return 0;
 
-	in->ops.dpi->set_data_lines(in, ddata->data_lines);
+	if (ddata->data_lines)
+		in->ops.dpi->set_data_lines(in, ddata->data_lines);
 	in->ops.dpi->set_timings(in, &ddata->videomode);
 
 	r = in->ops.dpi->enable(in);
@@ -182,6 +186,52 @@  static int panel_dpi_probe_pdata(struct platform_device *pdev)
 	return 0;
 }
 
+static int panel_dpi_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 r;
+	struct display_timing timing;
+	struct videomode vm;
+	int gpio;
+
+	gpio = of_get_gpio(node, 0);
+	if (gpio_is_valid(gpio) || gpio == -ENOENT) {
+		ddata->enable_gpio = gpio;
+	} else {
+		dev_err(&pdev->dev, "failed to parse enable gpio\n");
+		return gpio;
+	}
+
+	gpio = of_get_gpio(node, 1);
+	if (gpio_is_valid(gpio) || gpio == -ENOENT) {
+		ddata->backlight_gpio = gpio;
+	} else {
+		dev_err(&pdev->dev, "failed to parse backlight gpio\n");
+		return gpio;
+	}
+
+	r = of_get_display_timing(node, "panel-timing", &timing);
+	if (r) {
+		dev_err(&pdev->dev, "failed to get video timing\n");
+		return r;
+	}
+
+	videomode_from_timing(&timing, &vm);
+	videomode_to_omap_video_timings(&vm, &ddata->videomode);
+
+	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 panel_dpi_probe(struct platform_device *pdev)
 {
 	struct panel_drv_data *ddata;
@@ -198,6 +248,10 @@  static int panel_dpi_probe(struct platform_device *pdev)
 		r = panel_dpi_probe_pdata(pdev);
 		if (r)
 			return r;
+	} else if (pdev->dev.of_node) {
+		r = panel_dpi_probe_of(pdev);
+		if (r)
+			return r;
 	} else {
 		return -ENODEV;
 	}
@@ -254,12 +308,20 @@  static int __exit panel_dpi_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct of_device_id panel_dpi_of_match[] = {
+	{ .compatible = "omapdss,panel-dpi", },
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, panel_dpi_of_match);
+
 static struct platform_driver panel_dpi_driver = {
 	.probe = panel_dpi_probe,
 	.remove = __exit_p(panel_dpi_remove),
 	.driver = {
 		.name = "panel-dpi",
 		.owner = THIS_MODULE,
+		.of_match_table = panel_dpi_of_match,
 	},
 };