Skip to contentSkip to conversation

serial: 8250_dw: Allow hardware flow control to be used

PATCH Superseded Jason Uy 3 participants 4 messages Dec 6, 2016 – Jan 11, 2017

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jason Uy

author
#0 lore raw

cover serial: 8250_dw: Allow hardware flow control to be used

This patchset contains changes to allow AUTOCTS to be set for the Synopsys DW UART driver. There is currently no way to set AUTOCTS unless the platform adds a quirk entry and sets the termios callback function.

There was a discussion about a similar proposed patch change. It was mentioned in the discussion that the reason set_termios hook was not set by default is because someone might be using a certain type of clock that can't handle rate rounding and ended up using improper clock frequency for some baud rates. See discussion thread here.

https://groups.google.com/forum/#!topic/fa.linux.kernel/oWrFOsw3rpQ

The current dw8250_set_termios is set such that it always call the standard serial8250_do_set_termios. So if there are clock frequency issues, this will be resolved in serial8250_do_set_termios.

This patchset has been tested on Cygnus VOIP board bcm911360_entphn board.

This patchset is based on v4.9-rc1

repo: https://github.com/Broadcom/cygnus-linux.git

branch: cygnus-tty-v1

Jason Uy (1):
serial: 8250_dw: Allow hardware flow control to be used

 drivers/tty/serial/8250/8250_dw.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/1 serial: 8250_dw: Allow hardware flow control to be used

In the most common use case, the Synopsys DW UART driver does not set the set_termios callback function. This prevents UPSTAT_AUTOCTS from being set when the UART flag CRTSCTS is set. As a result, the driver will use software flow control as opposed to hardware flow control.

To fix the problem, the set_termios callback function is set to the DW specific function. The logic to set UPSTAT_AUTOCTS is moved so that any clock error will not affect setting the hardware flow control.

---
 drivers/tty/serial/8250/8250_dw.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250_dw.c +2 -3
index 459d726..18f1f8b 100644
@@ -246,11 +246,11 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
 	if (!ret)
 		p->uartclk = rate;
 
+out:
 	p->status &= ~UPSTAT_AUTOCTS;
 	if (termios->c_cflag & CRTSCTS)
 		p->status |= UPSTAT_AUTOCTS;
 
-out:
 	serial8250_do_set_termios(p, termios, old);
 }
 
@@ -308,13 +308,11 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
 			p->serial_in = dw8250_serial_in32;
 			data->uart_16550_compatible = true;
 		}
-		p->set_termios = dw8250_set_termios;
 	}
 
 	/* Platforms with iDMA */
 	if (platform_get_resource_byname(to_platform_device(p->dev),
 					 IORESOURCE_MEM, "lpss_priv")) {
-		p->set_termios = dw8250_set_termios;
 		data->dma.rx_param = p->dev->parent;
 		data->dma.tx_param = p->dev->parent;
 		data->dma.fn = dw8250_idma_filter;
@@ -392,6 +390,7 @@ static int dw8250_probe(struct platform_device *pdev)
 	p->iotype	= UPIO_MEM;
 	p->serial_in	= dw8250_serial_in;
 	p->serial_out	= dw8250_serial_out;
+	p->set_termios	= dw8250_set_termios;
 
 	p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
 	if (!p->membase)
Signature · 1 line
1.9.1
#2 lore raw
Quoted 11 lines · Jason Uy

In the most common use case, the Synopsys DW UART driver does not set the set_termios callback function.  This prevents UPSTAT_AUTOCTS from being set when the UART flag CRTSCTS is set.  As a result, the driver will use software flow control as opposed to hardware flow control.

To fix the problem, the set_termios callback function is set to the DW specific function.  The logic to set UPSTAT_AUTOCTS is moved so that any clock error will not affect setting the hardware flow control.

It should not affect Intel HW since we are using clock for it (see drivers/mfd/intel-lpss-pci.c, drivers/acpi/acpi_lpss.c).

Thus, I'm okay with the change.

Quoted 52 lines

---
 drivers/tty/serial/8250/8250_dw.c | 5 ++---

 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250_dw.c +0 -0
index 459d726..18f1f8b 100644
@@ -246,11 +246,11 @@ static void dw8250_set_termios(struct uart_port
 *p, struct ktermios *termios,
  	if (!ret)
  		p->uartclk = rate;


+out:
  p->status &= ~UPSTAT_AUTOCTS;
  if (termios->c_cflag & CRTSCTS) p->status |= UPSTAT_AUTOCTS;
-out:
  serial8250_do_set_termios(p, termios, old); }

drivers/tty/serial/8250/8250_dw.c +0 -1
@@ -308,13 +308,11 @@ static void dw8250_quirks(struct uart_port *p,
 struct dw8250_data *data)
  			p->serial_in = dw8250_serial_in32;
  			data->uart_16550_compatible = true;
  		}
-		p->set_termios = dw8250_set_termios;
  	}


  /* Platforms with iDMA */
  if (platform_get_resource_byname(to_platform_device(p->dev), IORESOURCE_MEM, "lpss_priv")) {

drivers/tty/serial/8250/8250_dw.c +0 -1
-		p->set_termios = dw8250_set_termios;

  data->dma.rx_param = p->dev->parent; data->dma.tx_param = p->dev->parent; data->dma.fn = dw8250_idma_filter;

drivers/tty/serial/8250/8250_dw.c +1 -0
@@ -392,6 +390,7 @@ static int dw8250_probe(struct platform_device
 *pdev)
  	p->iotype	= UPIO_MEM;
  	p->serial_in	= dw8250_serial_in;
  	p->serial_out	= dw8250_serial_out;
+	p->set_termios	= dw8250_set_termios;


  p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
  if (!p->membase)

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#3 lore raw
In reply to Jason Uy
Quoted 11 lines · Jason Uy

In the most common use case, the Synopsys DW UART driver does not set the set_termios callback function. This prevents UPSTAT_AUTOCTS from being set when the UART flag CRTSCTS is set. As a result, the driver will use software flow control as opposed to hardware flow control.

To fix the problem, the set_termios callback function is set to the DW specific function. The logic to set UPSTAT_AUTOCTS is moved so that any clock error will not affect setting the hardware flow control.

Quoted 6 lines
---
 drivers/tty/serial/8250/8250_dw.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

This patch doesn't apply at all to the latest kernel tree. Can you please refresh it and resend?

thanks,

greg k-h