mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 6/6] serial: ns16550: Add devicetree probe support
Date: Tue, 23 Jul 2013 08:40:10 +0200	[thread overview]
Message-ID: <1374561610-686-7-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1374561610-686-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/serial/serial_ns16550.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index b010785..ad3125a 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -231,6 +231,16 @@ static int ns16550_tstc(struct console_device *cdev)
 	return ((ns16550_read(cdev, lsr) & LSR_DR) != 0);
 }
 
+static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
+{
+	struct device_node *np = dev->device_node;
+
+	if (!IS_ENABLED(CONFIG_OFDEVICE))
+		return;
+
+	of_property_read_u32(np, "reg-shift", &priv->plat.shift);
+}
+
 /**
  * @brief Probe entry point -called on the first match for device
  *
@@ -251,8 +261,12 @@ static int ns16550_probe(struct device_d *dev)
 
 	priv = xzalloc(sizeof(*priv));
 
+	if (plat)
+		priv->plat = *plat;
+	else
+		ns16550_probe_dt(dev, priv);
+
 	cdev = &priv->cdev;
-	priv->plat = *plat;
 
 	if (!plat || !plat->clock) {
 		priv->clk = clk_get(dev, NULL);
@@ -288,11 +302,20 @@ err:
 	return ret;
 }
 
+static struct of_device_id ns16550_serial_dt_ids[] = {
+	{
+		.compatible = "ns16550a",
+	}, {
+		/* sentinel */
+	},
+};
+
 /**
  * @brief Driver registration structure
  */
 static struct driver_d ns16550_serial_driver = {
 	.name = "ns16550_serial",
 	.probe = ns16550_probe,
+	.of_compatible = DRV_OF_COMPAT(ns16550_serial_dt_ids),
 };
 console_platform_driver(ns16550_serial_driver);
-- 
1.8.3.2


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

      parent reply	other threads:[~2013-07-23  6:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23  6:40 [PATCH] serial: ns16550: Add devicetree support Sascha Hauer
2013-07-23  6:40 ` [PATCH 1/6] clk: provide static inline wrappers Sascha Hauer
2013-07-23  6:40 ` [PATCH 2/6] serial: ns16550: reorder functions to avoid forward declaration Sascha Hauer
2013-07-23  6:40 ` [PATCH 3/6] serial: ns16550: introduce private struct Sascha Hauer
2013-07-23  6:40 ` [PATCH 4/6] serial: ns16550: remove f_caps from platform_data Sascha Hauer
2013-07-23  6:40 ` [PATCH 5/6] serial: ns16550: Add clk support and make platform_data optional Sascha Hauer
2013-07-23  6:40 ` Sascha Hauer [this message]

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=1374561610-686-7-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