linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: thomas.abraham@linaro.org (Thomas Abraham)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC][PATCH 4/4] lcd: platform-lcd: Add device tree support
Date: Mon, 02 Jan 2012 11:24:35 +0530	[thread overview]
Message-ID: <1325483675-21908-5-git-send-email-thomas.abraham@linaro.org> (raw)
In-Reply-To: <1325483675-21908-4-git-send-email-thomas.abraham@linaro.org>

Add device tree based initialization for Hydis hv070wsa lcd panel.

Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
---
 drivers/video/backlight/platform_lcd.c |   33 ++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c
index feb4fd0..ebdddfd 100644
--- a/drivers/video/backlight/platform_lcd.c
+++ b/drivers/video/backlight/platform_lcd.c
@@ -18,6 +18,8 @@
 #include <linux/lcd.h>
 #include <linux/slab.h>
 #include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
 
 #include <video/platform_lcd.h>
 
@@ -81,9 +83,18 @@ static struct lcd_ops platform_lcd_ops = {
 	.check_fb	= platform_lcd_match,
 };
 
+static const struct of_device_id platform_lcd_dt_match[];
+
 static inline struct plat_lcd_driver_data *platform_lcd_get_driver_data(
 			struct platform_device *pdev)
 {
+#ifdef CONFIG_OF
+	if (pdev->dev.of_node) {
+		const struct of_device_id *match;
+		match = of_match_node(platform_lcd_dt_match, pdev->dev.of_node);
+		return (struct plat_lcd_driver_data *)match->data;
+	}
+#endif
 	return (struct plat_lcd_driver_data *)
 			platform_get_device_id(pdev)->driver_data;
 }
@@ -167,6 +178,19 @@ static int lcd_hv070wsa_init(struct platform_lcd *plcd)
 	struct plat_lcd_hydis_hv070wsa_pdata *pdata = plcd->lcd_pdata;
 	int err;
 
+#ifdef CONFIG_OF
+	if (of_have_populated_dt()) {
+		plcd->lcd_pdata = devm_kzalloc(plcd->us,
+						sizeof(*pdata), GFP_KERNEL);
+		if (!plcd->lcd_pdata) {
+			dev_err(plcd->us, "mem alloc for pdata failed\n");
+			return -ENOMEM;
+		}
+		pdata = plcd->lcd_pdata;
+		pdata->gpio = of_get_gpio(plcd->us->of_node, 0);
+	}
+#endif
+
 	if (!pdata) {
 		dev_err(plcd->us, "no platform data\n");
 		return -EINVAL;
@@ -214,10 +238,19 @@ static struct platform_device_id platform_lcd_driver_ids[] = {
 };
 MODULE_DEVICE_TABLE(platform, platform_lcd_driver_ids);
 
+#ifdef CONFIG_OF
+static const struct of_device_id platform_lcd_dt_match[] = {
+	{ .compatible = "hydis,hv070wsa", .data = (void *)HV070WSA_DRV_DATA},
+	{},
+};
+MODULE_DEVICE_TABLE(of, platform_lcd_dt_match);
+#endif
+
 static struct platform_driver platform_lcd_driver = {
 	.driver		= {
 		.name	= "platform-lcd",
 		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(platform_lcd_dt_match),
 	},
 	.probe		= platform_lcd_probe,
 	.remove		= __devexit_p(platform_lcd_remove),
-- 
1.6.6.rc2

  reply	other threads:[~2012-01-02  5:54 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-02  5:54 [RFC][PATCH 0/4] lcd: platform-lcd: Add lcd panel and device tree support Thomas Abraham
2012-01-02  5:54 ` [RFC][PATCH 1/4] lcd: platform-lcd: Eliminate need for platform data Thomas Abraham
2012-01-02  5:54   ` [RFC][PATCH 2/4] lcd: platform-lcd: Add support for Hydis hv070wsa lcd panel Thomas Abraham
2012-01-02  5:54     ` [RFC][PATCH 3/4] ARM: Exynos: Remove platform data of platform-lcd driver Thomas Abraham
2012-01-02  5:54       ` Thomas Abraham [this message]
2012-01-02  7:34         ` [RFC][PATCH 4/4] lcd: platform-lcd: Add device tree support Grant Likely
2012-01-02 17:33           ` Thomas Abraham
2012-01-02  8:02     ` [RFC][PATCH 2/4] lcd: platform-lcd: Add support for Hydis hv070wsa lcd panel Kyungmin Park
2012-01-02 17:39       ` Thomas Abraham
2012-01-02 11:45     ` Mark Brown
2012-01-02 17:41       ` Thomas Abraham
2012-01-02 11:59   ` [RFC][PATCH 1/4] lcd: platform-lcd: Eliminate need for platform data Mark Brown
2012-01-02 17:51     ` Thomas Abraham
2012-01-02 18:13       ` Mark Brown
2012-01-03  8:26         ` Thomas Abraham
2012-01-02  6:48 ` [RFC][PATCH 0/4] lcd: platform-lcd: Add lcd panel and device tree support Olof Johansson
2012-01-02 17:31   ` Thomas Abraham
2012-01-02  7:34 ` Grant Likely
2012-01-03  9:06 ` Lars-Peter Clausen
2012-01-03 11:54   ` Thomas Abraham
2012-01-03 12:26     ` Lars-Peter Clausen
2012-01-03 17:07       ` Thomas Abraham
2012-01-03 18:36         ` Lars-Peter Clausen
2012-01-04  6:13           ` Thomas Abraham

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=1325483675-21908-5-git-send-email-thomas.abraham@linaro.org \
    --to=thomas.abraham@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).