serial: imx: Fix x_char handling and tx flow control
The serial core expects the UART driver to transmit x_char (START/STOP chars) even if tx is stopped and before data already in the tx ring buffer if possible. Also, sending x_char must not cause additional data in the tx ring buffer to transmit if tx is stopped. Cause x_char to be transmitted before any other data is sent. Auto-stop tx if the tx ring buffer is empty or tx should be stopped. Only perform one write wakeup if tx ring buffer space is below threshold. x_char handling in DMA mode is still broken; add FIXME. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
99abf3b924
commit
5e42e9a30c
1 changed files with 16 additions and 23 deletions
|
@ -464,9 +464,19 @@ static inline void imx_transmit_buffer(struct imx_port *sport)
|
||||||
{
|
{
|
||||||
struct circ_buf *xmit = &sport->port.state->xmit;
|
struct circ_buf *xmit = &sport->port.state->xmit;
|
||||||
|
|
||||||
|
if (sport->port.x_char) {
|
||||||
|
/* Send next char */
|
||||||
|
writel(sport->port.x_char, sport->port.membase + URTX0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) {
|
||||||
|
imx_stop_tx(&sport->port);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while (!uart_circ_empty(xmit) &&
|
while (!uart_circ_empty(xmit) &&
|
||||||
!(readl(sport->port.membase + uts_reg(sport))
|
!(readl(sport->port.membase + uts_reg(sport)) & UTS_TXFULL)) {
|
||||||
& UTS_TXFULL)) {
|
|
||||||
/* send xmit->buf[xmit->tail]
|
/* send xmit->buf[xmit->tail]
|
||||||
* out the port here */
|
* out the port here */
|
||||||
writel(xmit->buf[xmit->tail], sport->port.membase + URTX0);
|
writel(xmit->buf[xmit->tail], sport->port.membase + URTX0);
|
||||||
|
@ -567,9 +577,6 @@ static void imx_start_tx(struct uart_port *port)
|
||||||
struct imx_port *sport = (struct imx_port *)port;
|
struct imx_port *sport = (struct imx_port *)port;
|
||||||
unsigned long temp;
|
unsigned long temp;
|
||||||
|
|
||||||
if (uart_circ_empty(&port->state->xmit))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (USE_IRDA(sport)) {
|
if (USE_IRDA(sport)) {
|
||||||
/* half duplex in IrDA mode; have to disable receive mode */
|
/* half duplex in IrDA mode; have to disable receive mode */
|
||||||
temp = readl(sport->port.membase + UCR4);
|
temp = readl(sport->port.membase + UCR4);
|
||||||
|
@ -604,7 +611,10 @@ static void imx_start_tx(struct uart_port *port)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sport->dma_is_enabled) {
|
if (sport->dma_is_enabled) {
|
||||||
imx_dma_tx(sport);
|
/* FIXME: port->x_char must be transmitted if != 0 */
|
||||||
|
if (!uart_circ_empty(&port->state->xmit) &&
|
||||||
|
!uart_tx_stopped(port))
|
||||||
|
imx_dma_tx(sport);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,27 +642,10 @@ static irqreturn_t imx_rtsint(int irq, void *dev_id)
|
||||||
static irqreturn_t imx_txint(int irq, void *dev_id)
|
static irqreturn_t imx_txint(int irq, void *dev_id)
|
||||||
{
|
{
|
||||||
struct imx_port *sport = dev_id;
|
struct imx_port *sport = dev_id;
|
||||||
struct circ_buf *xmit = &sport->port.state->xmit;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&sport->port.lock, flags);
|
spin_lock_irqsave(&sport->port.lock, flags);
|
||||||
if (sport->port.x_char) {
|
|
||||||
/* Send next char */
|
|
||||||
writel(sport->port.x_char, sport->port.membase + URTX0);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) {
|
|
||||||
imx_stop_tx(&sport->port);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
imx_transmit_buffer(sport);
|
imx_transmit_buffer(sport);
|
||||||
|
|
||||||
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
|
|
||||||
uart_write_wakeup(&sport->port);
|
|
||||||
|
|
||||||
out:
|
|
||||||
spin_unlock_irqrestore(&sport->port.lock, flags);
|
spin_unlock_irqrestore(&sport->port.lock, flags);
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue