aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorStefan Agner <stefan@agner.ch>2014-07-02 12:02:57 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-10 19:03:59 -0400
commited9891bf093638fad29f89c10b536550d29b129d (patch)
tree60c0c56e9c3b936351ac3befb15fc025275e4389 /drivers/tty
parent90abef91c5974d3d4845d64fd75a319fb20f6e6b (diff)
serial: fsl_lpuart: calculate DMA burst
The DMA burst size must match the transmit FIFO depth in order to make sure all character are transmitted. This patch calculates DMA burst size by using FIFO depth rather than use the hardcoded 16 bytes. This is required since some UARTs (e.g. UART2 on Vybrid) have a FIFO depth of 8 bytes. Signed-off-by: Stefan Agner <stefan@agner.ch> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/fsl_lpuart.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 5fde6da6ba20..acd3617677e8 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -117,8 +117,6 @@
117#define UARTSFIFO_TXOF 0x02 117#define UARTSFIFO_TXOF 0x02
118#define UARTSFIFO_RXUF 0x01 118#define UARTSFIFO_RXUF 0x01
119 119
120#define DMA_MAXBURST 16
121#define DMA_MAXBURST_MASK (DMA_MAXBURST - 1)
122#define FSL_UART_RX_DMA_BUFFER_SIZE 64 120#define FSL_UART_RX_DMA_BUFFER_SIZE 64
123 121
124#define DRIVER_NAME "fsl-lpuart" 122#define DRIVER_NAME "fsl-lpuart"
@@ -236,7 +234,7 @@ static int lpuart_dma_tx(struct lpuart_port *sport, unsigned long count)
236 234
237 dma_sync_single_for_device(sport->port.dev, sport->dma_tx_buf_bus, 235 dma_sync_single_for_device(sport->port.dev, sport->dma_tx_buf_bus,
238 UART_XMIT_SIZE, DMA_TO_DEVICE); 236 UART_XMIT_SIZE, DMA_TO_DEVICE);
239 sport->dma_tx_bytes = count & ~(DMA_MAXBURST_MASK); 237 sport->dma_tx_bytes = count & ~(sport->txfifo_size - 1);
240 tx_bus_addr = sport->dma_tx_buf_bus + xmit->tail; 238 tx_bus_addr = sport->dma_tx_buf_bus + xmit->tail;
241 sport->dma_tx_desc = dmaengine_prep_slave_single(sport->dma_tx_chan, 239 sport->dma_tx_desc = dmaengine_prep_slave_single(sport->dma_tx_chan,
242 tx_bus_addr, sport->dma_tx_bytes, 240 tx_bus_addr, sport->dma_tx_bytes,
@@ -265,7 +263,7 @@ static void lpuart_prepare_tx(struct lpuart_port *sport)
265 if (!count) 263 if (!count)
266 return; 264 return;
267 265
268 if (count < DMA_MAXBURST) 266 if (count < sport->txfifo_size)
269 writeb(readb(sport->port.membase + UARTCR5) & ~UARTCR5_TDMAS, 267 writeb(readb(sport->port.membase + UARTCR5) & ~UARTCR5_TDMAS,
270 sport->port.membase + UARTCR5); 268 sport->port.membase + UARTCR5);
271 else { 269 else {
@@ -595,15 +593,7 @@ static void lpuart_setup_watermark(struct lpuart_port *sport)
595 UARTCR2_RIE | UARTCR2_RE); 593 UARTCR2_RIE | UARTCR2_RE);
596 writeb(cr2, sport->port.membase + UARTCR2); 594 writeb(cr2, sport->port.membase + UARTCR2);
597 595
598 /* determine FIFO size and enable FIFO mode */
599 val = readb(sport->port.membase + UARTPFIFO); 596 val = readb(sport->port.membase + UARTPFIFO);
600
601 sport->txfifo_size = 0x1 << (((val >> UARTPFIFO_TXSIZE_OFF) &
602 UARTPFIFO_FIFOSIZE_MASK) + 1);
603
604 sport->rxfifo_size = 0x1 << (((val >> UARTPFIFO_RXSIZE_OFF) &
605 UARTPFIFO_FIFOSIZE_MASK) + 1);
606
607 writeb(val | UARTPFIFO_TXFE | UARTPFIFO_RXFE, 597 writeb(val | UARTPFIFO_TXFE | UARTPFIFO_RXFE,
608 sport->port.membase + UARTPFIFO); 598 sport->port.membase + UARTPFIFO);
609 599
@@ -648,7 +638,7 @@ static int lpuart_dma_tx_request(struct uart_port *port)
648 dma_buf = sport->port.state->xmit.buf; 638 dma_buf = sport->port.state->xmit.buf;
649 dma_tx_sconfig.dst_addr = sport->port.mapbase + UARTDR; 639 dma_tx_sconfig.dst_addr = sport->port.mapbase + UARTDR;
650 dma_tx_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; 640 dma_tx_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
651 dma_tx_sconfig.dst_maxburst = DMA_MAXBURST; 641 dma_tx_sconfig.dst_maxburst = sport->txfifo_size;
652 dma_tx_sconfig.direction = DMA_MEM_TO_DEV; 642 dma_tx_sconfig.direction = DMA_MEM_TO_DEV;
653 ret = dmaengine_slave_config(tx_chan, &dma_tx_sconfig); 643 ret = dmaengine_slave_config(tx_chan, &dma_tx_sconfig);
654 644
@@ -761,7 +751,16 @@ static int lpuart_startup(struct uart_port *port)
761 unsigned long flags; 751 unsigned long flags;
762 unsigned char temp; 752 unsigned char temp;
763 753
764 /*whether use dma support by dma request results*/ 754 /* determine FIFO size and enable FIFO mode */
755 temp = readb(sport->port.membase + UARTPFIFO);
756
757 sport->txfifo_size = 0x1 << (((temp >> UARTPFIFO_TXSIZE_OFF) &
758 UARTPFIFO_FIFOSIZE_MASK) + 1);
759
760 sport->rxfifo_size = 0x1 << (((temp >> UARTPFIFO_RXSIZE_OFF) &
761 UARTPFIFO_FIFOSIZE_MASK) + 1);
762
763 /* Whether use dma support by dma request results */
765 if (lpuart_dma_tx_request(port) || lpuart_dma_rx_request(port)) { 764 if (lpuart_dma_tx_request(port) || lpuart_dma_rx_request(port)) {
766 sport->lpuart_dma_use = false; 765 sport->lpuart_dma_use = false;
767 } else { 766 } else {