Skip to content

Commit

Permalink
serial: altera: don't enable any irq if the device doesn't feature an…
Browse files Browse the repository at this point in the history
… irq

If the irq line of an altera UART device isn't used to report interrupts
for this device the driver better ensures that this device doesn't pull
this line to active state and so disturb the whatever might be connected
to this line.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Uwe Kleine-König authored and Greg Kroah-Hartman committed Feb 28, 2018
1 parent 0e25496 commit 2ea6ad8
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions drivers/tty/serial/altera_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ static unsigned int altera_uart_get_mctrl(struct uart_port *port)
return sigs;
}

static void altera_uart_update_ctrl_reg(struct altera_uart *pp)
{
unsigned short imr = pp->imr;

/*
* If the device doesn't have an irq, ensure that the irq bits are
* masked out to keep the irq line inactive.
*/
if (!pp->port.irq)
imr &= ALTERA_UART_CONTROL_TRBK_MSK | ALTERA_UART_CONTROL_RTS_MSK;

altera_uart_writel(&pp->port, imr, ALTERA_UART_CONTROL_REG);
}

static void altera_uart_set_mctrl(struct uart_port *port, unsigned int sigs)
{
struct altera_uart *pp = container_of(port, struct altera_uart, port);
Expand All @@ -118,31 +132,31 @@ static void altera_uart_set_mctrl(struct uart_port *port, unsigned int sigs)
pp->imr |= ALTERA_UART_CONTROL_RTS_MSK;
else
pp->imr &= ~ALTERA_UART_CONTROL_RTS_MSK;
altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG);
altera_uart_update_ctrl_reg(pp);
}

static void altera_uart_start_tx(struct uart_port *port)
{
struct altera_uart *pp = container_of(port, struct altera_uart, port);

pp->imr |= ALTERA_UART_CONTROL_TRDY_MSK;
altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG);
altera_uart_update_ctrl_reg(pp);
}

static void altera_uart_stop_tx(struct uart_port *port)
{
struct altera_uart *pp = container_of(port, struct altera_uart, port);

pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK;
altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG);
altera_uart_update_ctrl_reg(pp);
}

static void altera_uart_stop_rx(struct uart_port *port)
{
struct altera_uart *pp = container_of(port, struct altera_uart, port);

pp->imr &= ~ALTERA_UART_CONTROL_RRDY_MSK;
altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG);
altera_uart_update_ctrl_reg(pp);
}

static void altera_uart_break_ctl(struct uart_port *port, int break_state)
Expand All @@ -155,7 +169,7 @@ static void altera_uart_break_ctl(struct uart_port *port, int break_state)
pp->imr |= ALTERA_UART_CONTROL_TRBK_MSK;
else
pp->imr &= ~ALTERA_UART_CONTROL_TRBK_MSK;
altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG);
altera_uart_update_ctrl_reg(pp);
spin_unlock_irqrestore(&port->lock, flags);
}

Expand Down Expand Up @@ -262,7 +276,7 @@ static void altera_uart_tx_chars(struct altera_uart *pp)

if (xmit->head == xmit->tail) {
pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK;
altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG);
altera_uart_update_ctrl_reg(pp);
}
}

Expand Down Expand Up @@ -327,7 +341,7 @@ static int altera_uart_startup(struct uart_port *port)

/* Enable RX interrupts now */
pp->imr = ALTERA_UART_CONTROL_RRDY_MSK;
altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG);
altera_uart_update_ctrl_reg(pp);

spin_unlock_irqrestore(&port->lock, flags);

Expand All @@ -343,7 +357,7 @@ static void altera_uart_shutdown(struct uart_port *port)

/* Disable all interrupts now */
pp->imr = 0;
altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG);
altera_uart_update_ctrl_reg(pp);

spin_unlock_irqrestore(&port->lock, flags);

Expand Down

0 comments on commit 2ea6ad8

Please sign in to comment.