Skip to contentSkip to conversation

serial: of_serial: new properties

PATCH In review Heikki Krogerus 2 participants 13 messages Mar 25, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover serial: of_serial: new properties

These add support for fifo-size and hw-flow-control properties. The idea is to try to avoid adding new types to 8250.c for UARTs that are compatible with the standard types but that have different size fifo or support 16750 compatible auto flow control.

Heikki Krogerus (3):
serial: 8250: Allow probe drivers to ignore tx_loadsz
serial: of_serial: Handle fifo-size property
serial: of_serial: Handle hw-flow-control property

 .../devicetree/bindings/tty/serial/of-serial.txt      |    2 ++
 drivers/tty/serial/8250/8250.c                        |    4 ++++
 drivers/tty/serial/of_serial.c                        |   17 ++++++++++++++---
 3 files changed, 20 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/3 serial: 8250: Allow probe drivers to ignore tx_loadsz

In most cases the tx_loadsz is the same as fifosize. This will store the fifosize in it if it was not separately delivered from the driver.

---
 drivers/tty/serial/8250/8250.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/tty/serial/8250/8250.c +4 -0
index cf6a538..19ebbdf 100644
@@ -3247,6 +3247,10 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
 		uart->tx_loadsz		= up->tx_loadsz;
 		uart->capabilities	= up->capabilities;
 
+		/* Take tx_loadsz from fifosize if it wasn't set separately */
+		if (uart->port.fifosize && !uart->tx_loadsz)
+			uart->tx_loadsz = uart->port.fifosize;
+
 		if (up->port.dev)
 			uart->port.dev = up->port.dev;
 
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/3 serial: of_serial: Handle fifo-size property

In reply to Heikki Krogerus

This will reduce the need for extra types in 8250.c just in case the fifo size differs from the standard.

---
 Documentation/devicetree/bindings/tty/serial/of-serial.txt |    1 +
 drivers/tty/serial/of_serial.c                             |    4 ++++
 2 files changed, 5 insertions(+)
Documentation/devicetree/bindings/tty/serial/of-serial.txt +1 -0
index 8f01cb1..c13f0ce 100644
@@ -33,6 +33,7 @@ Optional properties:
   RTAS and should not be registered.
 - no-loopback-test: set to indicate that the port does not implements loopback
   test mode
+- fifo-size: the fifo size of the UART.
 
 Example:
 
drivers/tty/serial/of_serial.c +4 -0
index b025d54..267711b 100644
@@ -97,6 +97,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
 	if (of_property_read_u32(np, "reg-shift", &prop) == 0)
 		port->regshift = prop;
 
+	/* Check for fifo size */
+	if (of_property_read_u32(np, "fifo-size", &prop) == 0)
+		port->fifosize = prop;
+
 	port->irq = irq_of_parse_and_map(np, 0);
 	port->iotype = UPIO_MEM;
 	if (of_property_read_u32(np, "reg-io-width", &prop) == 0) {
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 3/3 serial: of_serial: Handle hw-flow-control property

In reply to Heikki Krogerus

This will add support for hardware flow control. It is limited to be used only with 8250 driver.

---
 .../devicetree/bindings/tty/serial/of-serial.txt          |    1 +
 drivers/tty/serial/of_serial.c                            |   13 ++++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/tty/serial/of-serial.txt +1 -0
index c13f0ce..e775c93 100644
@@ -34,6 +34,7 @@ Optional properties:
 - no-loopback-test: set to indicate that the port does not implements loopback
   test mode
 - fifo-size: the fifo size of the UART.
+- hw-flow-control: support for hardware flow control
 
 Example:
 
drivers/tty/serial/of_serial.c +10 -3
index 267711b..2933112 100644
@@ -14,7 +14,6 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/serial_core.h>
-#include <linux/serial_8250.h>
 #include <linux/serial_reg.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
@@ -22,6 +21,8 @@
 #include <linux/nwpserial.h>
 #include <linux/clk.h>
 
+#include "8250/8250.h"
+
 struct of_serial_info {
 	struct clk *clk;
 	int type;
@@ -171,11 +172,17 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
 #ifdef CONFIG_SERIAL_8250
 	case PORT_8250 ... PORT_MAX_8250:
 	{
-		/* For now the of bindings don't support the extra
-		   8250 specific bits */
 		struct uart_8250_port port8250;
 		memset(&port8250, 0, sizeof(port8250));
 		port8250.port = port;
+
+		if (port.fifosize)
+			port8250.capabilities = UART_CAP_FIFO;
+
+		if (of_property_read_bool(ofdev->dev.of_node,
+					  "hw-flow-control"))
+			port8250.capabilities |= UART_CAP_AFE;
+
 		ret = serial8250_register_8250_port(&port8250);
 		break;
 	}
Signature · 1 line
1.7.10.4
#5 lore raw

Re: [PATCH 3/3] serial: of_serial: Handle hw-flow-control property

Quoted 4 lines · Heikki Krogerus

This will add support for hardware flow control. It is limited to be used only with 8250 driver.

Does this imply that we can use hardware flow control only when this flag is set in the device tree? I assumed that working flow control would be the default. Is it not?

Arnd

#6 lore raw

Re: [PATCH 3/3] serial: of_serial: Handle hw-flow-control property

Quoted 9 lines · Arnd Bergmann
Quoted 4 lines · Heikki Krogerus

This will add support for hardware flow control. It is limited to be used only with 8250 driver.

Does this imply that we can use hardware flow control only when this flag is set in the device tree? I assumed that working flow control would be the default. Is it not?

OK, the commit message is wrong. Is the patch otherwise OK?

Signature · 1 line
heikki
#7 lore raw

Re: [PATCH 3/3] serial: of_serial: Handle hw-flow-control property

Quoted 5 lines · Heikki Krogerus
Quoted 4 lines · Arnd Bergmann
Quoted 3 lines · Heikki Krogerus

This will add support for hardware flow control. It is limited to be used only with 8250 driver.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Does this imply that we can use hardware flow control only when this flag is set in the device tree? I assumed that working flow control would be the default. Is it not?

OK, the commit message is wrong. Is the patch otherwise OK?

I still find the text in the binding and the name of the property confusing, because it seems to imply that you have no hardware flow control without this. I think what you mean here is really "automatic flow control" rather than "hardware flow control".

Arnd

#8 lore raw

Re: [PATCH 3/3] serial: of_serial: Handle hw-flow-control property

Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · Heikki Krogerus
Quoted 9 lines · Arnd Bergmann
Quoted 4 lines · Heikki Krogerus

This will add support for hardware flow control. It is limited to be used only with 8250 driver.

Does this imply that we can use hardware flow control only when this flag is set in the device tree? I assumed that working flow control would be the default. Is it not?

Quoted 6 lines
Quoted 1 line

OK, the commit message is wrong. Is the patch otherwise OK?

I still find the text in the binding and the name of the property confusing, because it seems to imply that you have no hardware flow control without this. I think what you mean here is really "automatic flow control" rather than "hardware flow control".

Ah, I understand. I'll change the property name to auto-flow-control.

Signature · 1 line
heikki
#9 lore raw

Re: [PATCH 3/3] serial: of_serial: Handle hw-flow-control property

Quoted 13 lines · Heikki Krogerus
Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · Heikki Krogerus
Quoted 9 lines · Arnd Bergmann
Quoted 4 lines · Heikki Krogerus

This will add support for hardware flow control. It is limited to be used only with 8250 driver.

Does this imply that we can use hardware flow control only when this flag is set in the device tree? I assumed that working flow control would be the default. Is it not?

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

OK, the commit message is wrong. Is the patch otherwise OK?

I still find the text in the binding and the name of the property confusing, because it seems to imply that you have no hardware flow control without this. I think what you mean here is really "automatic flow control" rather than "hardware flow control".

Ah, I understand. I'll change the property name to auto-flow-control.

Ok, sounds good. I would also suggest rewording the description in the binding so that the driver is allowed to detect the presence of the automatic flow control capability even if the property is not set, because that's what the driver does.

Arnd

#10 lore raw

Re: [PATCH 3/3] serial: of_serial: Handle hw-flow-control property

Quoted 5 lines · Arnd Bergmann
Quoted 5 lines
Quoted 4 lines

I still find the text in the binding and the name of the property confusing, because it seems to imply that you have no hardware flow control without this. I think what you mean here is really "automatic flow control" rather than "hardware flow control".

Quoted 7 lines
Quoted 2 lines

Ah, I understand. I'll change the property name to auto-flow-control.

Ok, sounds good. I would also suggest rewording the description in the binding so that the driver is allowed to detect the presence of the automatic flow control capability even if the property is not set, because that's what the driver does.

OK, I'll fix the description too.

Thanks,

Signature · 1 line
heikki
#11 lore raw

PATCH v2 3/3 serial: of_serial: Handle auto-flow-control property

Automatic Flow Control capability is not tied to this property. This is only one way of detecting it. The property is limited to be used only with 8250 driver.

---
 .../devicetree/bindings/tty/serial/of-serial.txt          |    3 +++
 drivers/tty/serial/of_serial.c                            |   13 ++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/tty/serial/of-serial.txt +3 -0
index c13f0ce..1928a3e 100644
@@ -34,6 +34,9 @@ Optional properties:
 - no-loopback-test: set to indicate that the port does not implements loopback
   test mode
 - fifo-size: the fifo size of the UART.
+- auto-flow-control: one way to enable automatic flow control support. The
+  driver is allowed to detect support for the capability even without this
+  property.
 
 Example:
 
drivers/tty/serial/of_serial.c +10 -3
index 267711b..39c7ea4 100644
@@ -14,7 +14,6 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/serial_core.h>
-#include <linux/serial_8250.h>
 #include <linux/serial_reg.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
@@ -22,6 +21,8 @@
 #include <linux/nwpserial.h>
 #include <linux/clk.h>
 
+#include "8250/8250.h"
+
 struct of_serial_info {
 	struct clk *clk;
 	int type;
@@ -171,11 +172,17 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
 #ifdef CONFIG_SERIAL_8250
 	case PORT_8250 ... PORT_MAX_8250:
 	{
-		/* For now the of bindings don't support the extra
-		   8250 specific bits */
 		struct uart_8250_port port8250;
 		memset(&port8250, 0, sizeof(port8250));
 		port8250.port = port;
+
+		if (port.fifosize)
+			port8250.capabilities = UART_CAP_FIFO;
+
+		if (of_property_read_bool(ofdev->dev.of_node,
+					  "auto-flow-control"))
+			port8250.capabilities |= UART_CAP_AFE;
+
 		ret = serial8250_register_8250_port(&port8250);
 		break;
 	}
Signature · 1 line
1.7.10.4