Skip to contentSkip to conversation

serial: ns16550: small dt support improvements

RFC Applied Antony Pavlov 2 participants 5 messages Jul 23, 2013 – Jul 25, 2013

lore
Share & tools
lore
#1 lore raw

RFC 1/2 serial: ns16550: get clock-frequency from dt

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

---
 drivers/serial/serial_ns16550.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/serial/serial_ns16550.c +6 -0
index ad3125a..6a3c865 100644
@@ -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;
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

RFC 2/2 serial: ns16550: fill cdev just-in-time

In reply to Antony Pavlov
---
 drivers/serial/serial_ns16550.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/serial/serial_ns16550.c +1 -2
index 6a3c865..5899d57 100644
@@ -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;
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#3 lore raw
In reply to Antony Pavlov
Quoted 2 lines · Antony Pavlov

[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

Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw
Quoted 7 lines · On Wed, 24 Jul 2013 18:54:21 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 2 lines · Antony Pavlov

[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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox