Skip to content

Commit

Permalink
serial: 8250_dw: Add support for IrDA SIR mode
Browse files Browse the repository at this point in the history
Add a set_ldisc function to enable/disable IrDA SIR mode according to
the new line discipline, if IrDA SIR mode is supported by the hardware
configuration.

Signed-off-by: Ed Blake <ed.blake@imgtec.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ed Blake authored and Greg Kroah-Hartman committed Nov 16, 2016
1 parent db405a8 commit 0e0b989
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions drivers/tty/serial/8250/8250_dw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -254,6 +256,22 @@ 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)
{
struct uart_8250_port *up = up_to_u8250p(p);
unsigned int mcr = p->serial_in(p, UART_MCR);

if (up->capabilities & UART_CAP_IRDA) {
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
Expand Down Expand Up @@ -357,6 +375,9 @@ static void dw8250_setup_port(struct uart_port *p)

if (reg & DW_UART_CPR_AFCE_MODE)
up->capabilities |= UART_CAP_AFE;

if (reg & DW_UART_CPR_SIR_MODE)
up->capabilities |= UART_CAP_IRDA;
}

static int dw8250_probe(struct platform_device *pdev)
Expand Down Expand Up @@ -392,6 +413,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)
Expand Down

0 comments on commit 0e0b989

Please sign in to comment.