From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 5/6] serial: ns16550: Add clk support and make platform_data optional
Date: Tue, 23 Jul 2013 08:40:09 +0200 [thread overview]
Message-ID: <1374561610-686-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1374561610-686-1-git-send-email-s.hauer@pengutronix.de>
The clockrate was the only really needed field from platform data.
Add clk support to retrieve the clockrate and make platform data
optional.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/serial/serial_ns16550.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index dd50fc5..b010785 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -38,6 +38,7 @@
#include <errno.h>
#include <malloc.h>
#include <io.h>
+#include <linux/clk.h>
#include "serial_ns16550.h"
#include <ns16550.h>
@@ -46,6 +47,7 @@ struct ns16550_priv {
struct console_device cdev;
struct NS16550_plat plat;
int access_width;
+ struct clk *clk;
};
static inline struct ns16550_priv *to_ns16550_priv(struct console_device *cdev)
@@ -243,10 +245,8 @@ static int ns16550_probe(struct device_d *dev)
struct ns16550_priv *priv;
struct console_device *cdev;
struct NS16550_plat *plat = (struct NS16550_plat *)dev->platform_data;
+ int ret;
- /* we do expect platform specific data */
- if (plat == NULL)
- return -EINVAL;
dev->priv = dev_request_mem_region(dev, 0);
priv = xzalloc(sizeof(*priv));
@@ -254,6 +254,21 @@ static int ns16550_probe(struct device_d *dev)
cdev = &priv->cdev;
priv->plat = *plat;
+ if (!plat || !plat->clock) {
+ priv->clk = clk_get(dev, NULL);
+ if (IS_ERR(priv->clk)) {
+ ret = PTR_ERR(priv->clk);
+ goto err;
+ }
+ priv->plat.clock = clk_get_rate(priv->clk);
+ }
+
+ if (priv->plat.clock == 0) {
+ dev_err(dev, "no valid clockrate\n");
+ ret = -EINVAL;
+ goto err;
+ }
+
priv->access_width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
cdev->dev = dev;
@@ -266,6 +281,11 @@ static int ns16550_probe(struct device_d *dev)
ns16550_serial_init_port(cdev);
return console_register(cdev);
+
+err:
+ free(priv);
+
+ return ret;
}
/**
--
1.8.3.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev 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 ` Sascha Hauer [this message]
2013-07-23 6:40 ` [PATCH 6/6] serial: ns16550: Add devicetree probe 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=1374561610-686-6-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