/* Rx DMA timeout in ms, which is used to calculate Rx ring buffer size */
#define DMA_RX_TIMEOUT (10)
-@@ -254,6 +261,9 @@ struct lpuart_port {
+@@ -252,6 +259,9 @@ struct lpuart_port {
unsigned int txfifo_size;
unsigned int rxfifo_size;
bool lpuart_dma_tx_use;
bool lpuart_dma_rx_use;
struct dma_chan *dma_tx_chan;
-@@ -279,33 +289,45 @@ struct lpuart_soc_data {
+@@ -276,33 +286,45 @@ struct lpuart_soc_data {
enum lpuart_type devtype;
char iotype;
u8 reg_off;
};
static const struct of_device_id lpuart_dt_ids[] = {
-@@ -320,6 +342,7 @@ MODULE_DEVICE_TABLE(of, lpuart_dt_ids);
+@@ -317,6 +339,7 @@ MODULE_DEVICE_TABLE(of, lpuart_dt_ids);
/* Forward declare this for the dma callbacks*/
static void lpuart_dma_tx_complete(void *arg);
static inline bool is_layerscape_lpuart(struct lpuart_port *sport)
{
-@@ -1011,19 +1034,15 @@ static irqreturn_t lpuart32_int(int irq,
+@@ -1008,19 +1031,15 @@ static irqreturn_t lpuart32_int(int irq,
if ((sts & UARTSTAT_TDRE) && !sport->lpuart_dma_tx_use)
lpuart32_txint(sport);
if (lpuart_is_32(sport)) {
unsigned long sr = lpuart32_read(&sport->port, UARTSTAT);
-@@ -1075,8 +1094,21 @@ static void lpuart_copy_rx_to_tty(struct
+@@ -1072,8 +1091,21 @@ static void lpuart_copy_rx_to_tty(struct
writeb(cr2, sport->port.membase + UARTCR2);
}
}
spin_lock_irqsave(&sport->port.lock, flags);
-@@ -1139,7 +1171,33 @@ static void lpuart_copy_rx_to_tty(struct
+@@ -1136,7 +1168,33 @@ static void lpuart_copy_rx_to_tty(struct
spin_unlock_irqrestore(&sport->port.lock, flags);
tty_flip_buffer_push(port);
}
static void lpuart_dma_rx_complete(void *arg)
-@@ -1147,6 +1205,8 @@ static void lpuart_dma_rx_complete(void
+@@ -1144,6 +1202,8 @@ static void lpuart_dma_rx_complete(void
struct lpuart_port *sport = arg;
lpuart_copy_rx_to_tty(sport);
}
static void lpuart_timer_func(struct timer_list *t)
-@@ -1154,13 +1214,78 @@ static void lpuart_timer_func(struct tim
+@@ -1151,13 +1211,78 @@ static void lpuart_timer_func(struct tim
struct lpuart_port *sport = from_timer(sport, t, lpuart_timer);
lpuart_copy_rx_to_tty(sport);
int bits, baud;
struct tty_port *port = &sport->port.state->port;
struct tty_struct *tty = port->tty;
-@@ -1180,6 +1305,18 @@ static inline int lpuart_start_rx_dma(st
+@@ -1177,6 +1302,18 @@ static inline int lpuart_start_rx_dma(st
sport->rx_dma_rng_buf_len = (1 << (fls(sport->rx_dma_rng_buf_len) - 1));
if (sport->rx_dma_rng_buf_len < 16)
sport->rx_dma_rng_buf_len = 16;
ring->buf = kzalloc(sport->rx_dma_rng_buf_len, GFP_ATOMIC);
if (!ring->buf)
-@@ -1205,32 +1342,7 @@ static inline int lpuart_start_rx_dma(st
+@@ -1202,32 +1339,7 @@ static inline int lpuart_start_rx_dma(st
return ret;
}
}
static void lpuart_dma_rx_free(struct uart_port *port)
-@@ -1416,8 +1528,10 @@ static void lpuart_setup_watermark(struc
+@@ -1413,8 +1525,10 @@ static void lpuart_setup_watermark(struc
writeb(UARTSFIFO_RXUF, sport->port.membase + UARTSFIFO);
}
/* Restore cr2 */
writeb(cr2_saved, sport->port.membase + UARTCR2);
-@@ -1438,6 +1552,7 @@ static void lpuart32_setup_watermark(str
+@@ -1435,6 +1549,7 @@ static void lpuart32_setup_watermark(str
{
unsigned long val, ctrl;
unsigned long ctrl_saved;
ctrl = lpuart32_read(&sport->port, UARTCTRL);
ctrl_saved = ctrl;
-@@ -1449,12 +1564,26 @@ static void lpuart32_setup_watermark(str
+@@ -1446,12 +1561,26 @@ static void lpuart32_setup_watermark(str
val = lpuart32_read(&sport->port, UARTFIFO);
val |= UARTFIFO_TXFE | UARTFIFO_RXFE;
val |= UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH;
/* Restore cr2 */
lpuart32_write(&sport->port, ctrl_saved, UARTCTRL);
}
-@@ -1466,17 +1595,29 @@ static void lpuart32_setup_watermark_ena
+@@ -1463,17 +1592,29 @@ static void lpuart32_setup_watermark_ena
lpuart32_setup_watermark(sport);
temp = lpuart32_read(&sport->port, UARTCTRL);
static void lpuart_tx_dma_startup(struct lpuart_port *sport)
{
u32 uartbaud;
-@@ -1540,19 +1681,23 @@ static int lpuart_startup(struct uart_po
+@@ -1537,19 +1678,23 @@ static int lpuart_startup(struct uart_po
return 0;
}
if (!sport->lpuart_dma_tx_use)
temp |= UARTCTRL_TIE;
lpuart32_write(&sport->port, temp, UARTCTRL);
-@@ -1596,12 +1741,12 @@ static int lpuart32_startup(struct uart_
+@@ -1593,12 +1738,12 @@ static int lpuart32_startup(struct uart_
spin_lock_irqsave(&sport->port.lock, flags);
lpuart32_configure(sport);
spin_unlock_irqrestore(&sport->port.lock, flags);
-@@ -1611,7 +1756,7 @@ static int lpuart32_startup(struct uart_
+@@ -1608,7 +1753,7 @@ static int lpuart32_startup(struct uart_
static void lpuart_dma_shutdown(struct lpuart_port *sport)
{
if (sport->lpuart_dma_rx_use) {
lpuart_dma_rx_free(&sport->port);
}
-@@ -1652,11 +1797,22 @@ static void lpuart32_shutdown(struct uar
+@@ -1649,11 +1794,22 @@ static void lpuart32_shutdown(struct uar
spin_lock_irqsave(&port->lock, flags);
spin_unlock_irqrestore(&port->lock, flags);
-@@ -1753,10 +1909,10 @@ lpuart_set_termios(struct uart_port *por
+@@ -1750,10 +1906,10 @@ lpuart_set_termios(struct uart_port *por
* baud rate and restart Rx DMA path.
*
* Since timer function acqures sport->port.lock, need to stop before
lpuart_dma_rx_free(&sport->port);
}
-@@ -1968,10 +2124,10 @@ lpuart32_set_termios(struct uart_port *p
+@@ -1965,10 +2121,10 @@ lpuart32_set_termios(struct uart_port *p
* baud rate and restart Rx DMA path.
*
* Since timer function acqures sport->port.lock, need to stop before
lpuart_dma_rx_free(&sport->port);
}
-@@ -2483,6 +2639,10 @@ static int lpuart_probe(struct platform_
+@@ -2480,6 +2636,10 @@ static int lpuart_probe(struct platform_
sport->port.dev = &pdev->dev;
sport->port.type = PORT_LPUART;
sport->devtype = sdata->devtype;
ret = platform_get_irq(pdev, 0);
if (ret < 0)
return ret;
-@@ -2645,7 +2805,7 @@ static int lpuart_suspend(struct device
+@@ -2630,7 +2790,7 @@ static int lpuart_suspend(struct device
* Rx DMA path before suspend and start Rx DMA path on resume.
*/
if (irq_wake) {