mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [RFC 0/2] serial: ns16550: small dt support improvements
@ 2013-07-23 15:28 Antony Pavlov
  2013-07-23 15:28 ` [RFC 1/2] serial: ns16550: get clock-frequency from dt Antony Pavlov
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Antony Pavlov @ 2013-07-23 15:28 UTC (permalink / raw)
  To: barebox

[RFC 1/2] serial: ns16550: get clock-frequency from dt
[RFC 2/2] serial: ns16550: fill cdev just-in-time

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC 1/2] serial: ns16550: get clock-frequency from dt
  2013-07-23 15:28 [RFC 0/2] serial: ns16550: small dt support improvements Antony Pavlov
@ 2013-07-23 15:28 ` Antony Pavlov
  2013-07-23 15:28 ` [RFC 2/2] serial: ns16550: fill cdev just-in-time Antony Pavlov
  2013-07-24 16:54 ` [RFC 0/2] serial: ns16550: small dt support improvements Sascha Hauer
  2 siblings, 0 replies; 5+ messages in thread
From: Antony Pavlov @ 2013-07-23 15:28 UTC (permalink / raw)
  To: barebox

This patch helps clk-less boards to use device
tree for clock frequency probing (taken from
linux.git/drivers/tty/serial/of_serial.c).

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 drivers/serial/serial_ns16550.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index ad3125a..6a3c865 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -277,6 +277,12 @@ static int ns16550_probe(struct device_d *dev)
 		priv->plat.clock = clk_get_rate(priv->clk);
 	}
 
+	if (priv->plat.clock == 0 && IS_ENABLED(CONFIG_OFDEVICE)) {
+		struct device_node *np = dev->device_node;
+
+		of_property_read_u32(np, "clock-frequency", &priv->plat.clock);
+	}
+
 	if (priv->plat.clock == 0) {
 		dev_err(dev, "no valid clockrate\n");
 		ret = -EINVAL;
-- 
1.8.3.1


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC 2/2] serial: ns16550: fill cdev just-in-time
  2013-07-23 15:28 [RFC 0/2] serial: ns16550: small dt support improvements Antony Pavlov
  2013-07-23 15:28 ` [RFC 1/2] serial: ns16550: get clock-frequency from dt Antony Pavlov
@ 2013-07-23 15:28 ` Antony Pavlov
  2013-07-24 16:54 ` [RFC 0/2] serial: ns16550: small dt support improvements Sascha Hauer
  2 siblings, 0 replies; 5+ messages in thread
From: Antony Pavlov @ 2013-07-23 15:28 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 drivers/serial/serial_ns16550.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 6a3c865..5899d57 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -266,8 +266,6 @@ static int ns16550_probe(struct device_d *dev)
 	else
 		ns16550_probe_dt(dev, priv);
 
-	cdev = &priv->cdev;
-
 	if (!plat || !plat->clock) {
 		priv->clk = clk_get(dev, NULL);
 		if (IS_ERR(priv->clk)) {
@@ -291,6 +289,7 @@ static int ns16550_probe(struct device_d *dev)
 
 	priv->access_width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
 
+	cdev = &priv->cdev;
 	cdev->dev = dev;
 	cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
 	cdev->tstc = ns16550_tstc;
-- 
1.8.3.1


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC 0/2] serial: ns16550: small dt support improvements
  2013-07-23 15:28 [RFC 0/2] serial: ns16550: small dt support improvements Antony Pavlov
  2013-07-23 15:28 ` [RFC 1/2] serial: ns16550: get clock-frequency from dt Antony Pavlov
  2013-07-23 15:28 ` [RFC 2/2] serial: ns16550: fill cdev just-in-time Antony Pavlov
@ 2013-07-24 16:54 ` Sascha Hauer
  2013-07-25  8:28   ` Antony Pavlov
  2 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2013-07-24 16:54 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Tue, Jul 23, 2013 at 07:28:00PM +0400, Antony Pavlov wrote:
> [RFC 1/2] serial: ns16550: get clock-frequency from dt
> [RFC 2/2] serial: ns16550: fill cdev just-in-time

Applied, thanks.

I assume the second one is only cosmetic, right?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC 0/2] serial: ns16550: small dt support improvements
  2013-07-24 16:54 ` [RFC 0/2] serial: ns16550: small dt support improvements Sascha Hauer
@ 2013-07-25  8:28   ` Antony Pavlov
  0 siblings, 0 replies; 5+ messages in thread
From: Antony Pavlov @ 2013-07-25  8:28 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Wed, 24 Jul 2013 18:54:21 +0200
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> On Tue, Jul 23, 2013 at 07:28:00PM +0400, Antony Pavlov wrote:
> > [RFC 1/2] serial: ns16550: get clock-frequency from dt
> > [RFC 2/2] serial: ns16550: fill cdev just-in-time
> 
> Applied, thanks.
> 
> I assume the second one is only cosmetic, right?

Yes, it's mostly cosmetic: the main goal of the second patch
is making code more "easy-to-understand".

As a bonus you get a tiny insignificant optimisation: if there is any error
during probe then there is no need in cdev and cdev can
be keeped unitialized (tut IMHO a smart compiler can make itself
a reposition like this :).

-- 
Best regards,
  Antony Pavlov

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-25  8:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-23 15:28 [RFC 0/2] serial: ns16550: small dt support improvements Antony Pavlov
2013-07-23 15:28 ` [RFC 1/2] serial: ns16550: get clock-frequency from dt Antony Pavlov
2013-07-23 15:28 ` [RFC 2/2] serial: ns16550: fill cdev just-in-time Antony Pavlov
2013-07-24 16:54 ` [RFC 0/2] serial: ns16550: small dt support improvements Sascha Hauer
2013-07-25  8:28   ` Antony Pavlov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox