mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/6] video: stmfb: Add device tree support
Date: Fri, 12 Jun 2015 11:53:36 +0200	[thread overview]
Message-ID: <1434102821-10555-1-git-send-email-s.hauer@pengutronix.de> (raw)

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/video/stm.c | 52 ++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 42 insertions(+), 10 deletions(-)

diff --git a/drivers/video/stm.c b/drivers/video/stm.c
index 3c90c0d..bf913f1 100644
--- a/drivers/video/stm.c
+++ b/drivers/video/stm.c
@@ -317,7 +317,7 @@ static int stmfb_activate_var(struct fb_info *fb_info)
 	size = calc_line_length(mode->xres, fb_info->bits_per_pixel) *
 		mode->yres;
 
-	if (pdata->fixed_screen) {
+	if (pdata && pdata->fixed_screen) {
 		if (pdata->fixed_screen_size < size)
 			return -ENOMEM;
 		fb_info->screen_base = pdata->fixed_screen;
@@ -497,16 +497,37 @@ static int stmfb_probe(struct device_d *hw_dev)
 		return PTR_ERR(fbi.clk);
 	clk_enable(fbi.clk);
 
+	fbi.info.bits_per_pixel = 16;
+
 	/* add runtime video info */
-	fbi.info.modes.modes = pdata->mode_list;
-	fbi.info.modes.num_modes = pdata->mode_cnt;
-	fbi.info.mode = &fbi.info.modes.modes[0];
-	fbi.info.xres = fbi.info.mode->xres;
-	fbi.info.yres = fbi.info.mode->yres;
-	if (pdata->bits_per_pixel)
-		fbi.info.bits_per_pixel = pdata->bits_per_pixel;
-	else
-		fbi.info.bits_per_pixel = 16;
+	if (pdata) {
+		fbi.info.modes.modes = pdata->mode_list;
+		fbi.info.modes.num_modes = pdata->mode_cnt;
+		fbi.info.mode = &fbi.info.modes.modes[0];
+		if (pdata->bits_per_pixel)
+			fbi.info.bits_per_pixel = pdata->bits_per_pixel;
+	} else {
+		struct display_timings *modes;
+		struct device_node *display;
+
+		if (!IS_ENABLED(CONFIG_OFDEVICE) || !hw_dev->device_node)
+			return -EINVAL;
+
+		display = of_parse_phandle(hw_dev->device_node, "display", 0);
+		if (!display) {
+			dev_err(hw_dev, "no display phandle\n");
+			return -EINVAL;
+		}
+
+		modes = of_get_display_timings(display);
+		if (IS_ERR(modes)) {
+			dev_err(hw_dev, "unable to parse display timings\n");
+			return PTR_ERR(modes);
+		}
+
+		fbi.info.modes.modes = modes->modes;
+		fbi.info.modes.num_modes = modes->num_modes;
+	}
 
 	hw_dev->info = stmfb_info;
 
@@ -519,9 +540,20 @@ static int stmfb_probe(struct device_d *hw_dev)
 	return 0;
 }
 
+static __maybe_unused struct of_device_id stmfb_compatible[] = {
+	{
+		.compatible = "fsl,imx23-lcdif",
+	}, {
+		.compatible = "fsl,imx28-lcdif",
+	}, {
+		/* sentinel */
+	}
+};
+
 static struct driver_d stmfb_driver = {
 	.name	= "stmfb",
 	.probe	= stmfb_probe,
+	.of_compatible = DRV_OF_COMPAT(stmfb_compatible),
 };
 device_platform_driver(stmfb_driver);
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2015-06-12  9:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12  9:53 Sascha Hauer [this message]
2015-06-12  9:53 ` [PATCH 2/6] video: Add backlight support Sascha Hauer
2015-06-12  9:53 ` [PATCH 3/6] video: Add PWM " Sascha Hauer
2015-06-12  9:58   ` Marc Kleine-Budde
2015-06-12  9:53 ` [PATCH 4/6] ARM: i.MX28: Add PWM clk support Sascha Hauer
2015-06-12  9:53 ` [PATCH 5/6] PWM: Allow multiple PWMs per device node Sascha Hauer
2015-06-12  9:53 ` [PATCH 6/6] PWM: Add MXS PWM support Sascha Hauer

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=1434102821-10555-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@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