Skip to contentSkip to conversation

serial: 8250_dw: Add support for IrDA SIR mode

PATCH Superseded Ed Blake 3 participants 5 messages Oct 27, 2016 – Oct 28, 2016

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ed Blake

author
#0 lore raw

PATCH 2/2 serial: 8250_dw: Add support for IrDA SIR mode

Add a set_ldisc function to enable/disable IrDA SIR mode according to the new line discipline.

---
 drivers/tty/serial/8250/8250_dw.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/tty/serial/8250/8250_dw.c +17 -0
index 459d726..7dd5369 100644
@@ -53,6 +53,8 @@
 /* Helper for fifo size calculation */
 #define DW_UART_CPR_FIFO_SIZE(a)	(((a >> 16) & 0xff) * 16)
 
+/* DesignWare specific register fields */
+#define DW_UART_MCR_SIRE		BIT(6)
 
 struct dw8250_data {
 	u8			usr_reg;
@@ -254,6 +256,20 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
 	serial8250_do_set_termios(p, termios, old);
 }
 
+static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios)
+{
+	unsigned int mcr = p->serial_in(p, UART_MCR);
+
+	if (termios->c_line == N_IRDA)
+		mcr |= DW_UART_MCR_SIRE;
+	else
+		mcr &= ~DW_UART_MCR_SIRE;
+
+	p->serial_out(p, UART_MCR, mcr);
+
+	serial8250_do_set_ldisc(p, termios);
+}
+
 /*
  * dw8250_fallback_dma_filter will prevent the UART from getting just any free
  * channel on platforms that have DMA engines, but don't have any channels
@@ -392,6 +408,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_ldisc	= dw8250_set_ldisc;
 
 	p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
 	if (!p->membase)
Signature · 1 line
1.9.1
#1 lore raw
Quoted 2 lines · Ed Blake

Add a set_ldisc function to enable/disable IrDA SIR mode according to the new line discipline.

Thanks for the patch.

Consider that not all implementations based on 8250_dw support IRDA feature. I suppose you need to read capability register bits 6 and 7, set flag and then based on the value accept or reject IRDA mode.

P.S. Use -n when prepare patches to link them if you consider them dependent.

Quoted 55 lines

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

 1 file changed, 17 insertions(+)
drivers/tty/serial/8250/8250_dw.c +0 -0
index 459d726..7dd5369 100644
@@ -53,6 +53,8 @@
  /* Helper for fifo size calculation */
  #define DW_UART_CPR_FIFO_SIZE(a)	(((a >> 16) & 0xff) * 16)

drivers/tty/serial/8250/8250_dw.c +2 -0
+/* DesignWare specific register fields */
+#define DW_UART_MCR_SIRE		BIT(6)


 struct dw8250_data {
  u8 usr_reg;

drivers/tty/serial/8250/8250_dw.c +0 -0
@@ -254,6 +256,20 @@ static void dw8250_set_termios(struct uart_port
 *p, struct ktermios *termios,
  	serial8250_do_set_termios(p, termios, old);
  }


+static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios)

drivers/tty/serial/8250/8250_dw.c +13 -0
+{
+	unsigned int mcr = p->serial_in(p, UART_MCR);
+
+	if (termios->c_line == N_IRDA)
+		mcr |= DW_UART_MCR_SIRE;
+	else
+		mcr &= ~DW_UART_MCR_SIRE;
+
+	p->serial_out(p, UART_MCR, mcr);
+
+	serial8250_do_set_ldisc(p, termios);
+}
+

 /*
  * dw8250_fallback_dma_filter will prevent the UART from getting just any free
  * channel on platforms that have DMA engines, but don't have any channels

drivers/tty/serial/8250/8250_dw.c +1 -0
@@ -392,6 +408,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_ldisc	= dw8250_set_ldisc;


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

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
author
#2 lore raw
Quoted 8 lines · Andy Shevchenko
Quoted 2 lines · Ed Blake

Add a set_ldisc function to enable/disable IrDA SIR mode according to the new line discipline.

Thanks for the patch.

Consider that not all implementations based on 8250_dw support IRDA feature. I suppose you need to read capability register bits 6 and 7, set flag and then based on the value accept or reject IRDA mode.

Thanks for the review, I'll add this for the second version.

Ed.

Quoted 58 lines

P.S. Use -n when prepare patches to link them if you consider them dependent.

Quoted 54 lines
---
  drivers/tty/serial/8250/8250_dw.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/tty/serial/8250/8250_dw.c +16 -0
index 459d726..7dd5369 100644
@@ -53,6 +53,8 @@
  /* Helper for fifo size calculation */
  #define DW_UART_CPR_FIFO_SIZE(a)	(((a >> 16) & 0xff) * 16)
 
+/* DesignWare specific register fields */
+#define DW_UART_MCR_SIRE		BIT(6)
 
  struct dw8250_data {
  	u8			usr_reg;
@@ -254,6 +256,20 @@ static void dw8250_set_termios(struct uart_port
 *p, struct ktermios *termios,
  	serial8250_do_set_termios(p, termios, old);
  }
 
+static void dw8250_set_ldisc(struct uart_port *p, struct ktermios
 *termios)
+{
+	unsigned int mcr = p->serial_in(p, UART_MCR);
+
+	if (termios->c_line == N_IRDA)
+		mcr |= DW_UART_MCR_SIRE;
+	else
+		mcr &= ~DW_UART_MCR_SIRE;
+
+	p->serial_out(p, UART_MCR, mcr);
+
+	serial8250_do_set_ldisc(p, termios);
+}
+
  /*

* dw8250_fallback_dma_filter will prevent the UART from getting just
any free
* channel on platforms that have DMA engines, but don't have any
channels

drivers/tty/serial/8250/8250_dw.c +1 -0
@@ -392,6 +408,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_ldisc	= dw8250_set_ldisc;
 
  	p->membase = devm_ioremap(dev, regs->start,

resource_size(regs));
if (!p->membase)

#3 lore raw
In reply to Andy Shevchenko

Hi Andy,

Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · Ed Blake

Add a set_ldisc function to enable/disable IrDA SIR mode according to the new line discipline.

Quoted 8 lines

Thanks for the patch.

Consider that not all implementations based on 8250_dw support IRDA feature. I suppose you need to read capability register bits 6 and 7, set flag and then based on the value accept or reject IRDA mode.

P.S. Use -n when prepare patches to link them if you consider them dependent.

These are numbered? Or do you mean that please prefer sending series of patches as threads?

% git send-email --thread...

Or something like that? I guess coverletter would be nice too.

Thanks,

Signature · 1 line
heikki
#4 lore raw
Quoted 6 lines · Heikki Krogerus

Hi Andy,

Quoted 2 lines · Andy Shevchenko

P.S. Use -n when prepare patches to link them if you consider them dependent.

Quoted 6 lines

These are numbered? Or do you mean that please prefer sending series of patches as threads?

        % git send-email --thread...

Or something like that? I guess coverletter would be nice too.

Yes, you are right. Sorry for confusion.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy