aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Medhurst <tixy@linaro.org>2013-12-10 05:18:59 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-17 12:35:37 -0500
commitb60f2f66a58c43e8c928336ec72f64e72f1237ea (patch)
treea6ef0fef17f1d717be86e06be34820a11653c30e
parentfe43390702a1b5741fdf217063b05c7612b38303 (diff)
serial: amba-pl011: factor out code for writing LCR_H register
The code to cope with a split tx/rx LCR_H register is non-trivial so put it into it's own function to avoid duplication. Signed-off-by: Jon Medhurst <tixy@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/amba-pl011.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index a576a5bc2d15..844bfba9d0ab 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1511,6 +1511,21 @@ static int pl011_hwinit(struct uart_port *port)
1511 return retval; 1511 return retval;
1512} 1512}
1513 1513
1514static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h)
1515{
1516 writew(lcr_h, uap->port.membase + uap->lcrh_rx);
1517 if (uap->lcrh_rx != uap->lcrh_tx) {
1518 int i;
1519 /*
1520 * Wait 10 PCLKs before writing LCRH_TX register,
1521 * to get this delay write read only register 10 times
1522 */
1523 for (i = 0; i < 10; ++i)
1524 writew(0xff, uap->port.membase + UART011_MIS);
1525 writew(lcr_h, uap->port.membase + uap->lcrh_tx);
1526 }
1527}
1528
1514static int pl011_startup(struct uart_port *port) 1529static int pl011_startup(struct uart_port *port)
1515{ 1530{
1516 struct uart_amba_port *uap = (struct uart_amba_port *)port; 1531 struct uart_amba_port *uap = (struct uart_amba_port *)port;
@@ -1541,17 +1556,7 @@ static int pl011_startup(struct uart_port *port)
1541 writew(cr, uap->port.membase + UART011_CR); 1556 writew(cr, uap->port.membase + UART011_CR);
1542 writew(0, uap->port.membase + UART011_FBRD); 1557 writew(0, uap->port.membase + UART011_FBRD);
1543 writew(1, uap->port.membase + UART011_IBRD); 1558 writew(1, uap->port.membase + UART011_IBRD);
1544 writew(0, uap->port.membase + uap->lcrh_rx); 1559 pl011_write_lcr_h(uap, 0);
1545 if (uap->lcrh_tx != uap->lcrh_rx) {
1546 int i;
1547 /*
1548 * Wait 10 PCLKs before writing LCRH_TX register,
1549 * to get this delay write read only register 10 times
1550 */
1551 for (i = 0; i < 10; ++i)
1552 writew(0xff, uap->port.membase + UART011_MIS);
1553 writew(0, uap->port.membase + uap->lcrh_tx);
1554 }
1555 writew(0, uap->port.membase + UART01x_DR); 1560 writew(0, uap->port.membase + UART01x_DR);
1556 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY) 1561 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY)
1557 barrier(); 1562 barrier();
@@ -1801,17 +1806,7 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
1801 * UART011_FBRD & UART011_IBRD. 1806 * UART011_FBRD & UART011_IBRD.
1802 * ----------^----------^----------^----------^----- 1807 * ----------^----------^----------^----------^-----
1803 */ 1808 */
1804 writew(lcr_h, port->membase + uap->lcrh_rx); 1809 pl011_write_lcr_h(uap, lcr_h);
1805 if (uap->lcrh_rx != uap->lcrh_tx) {
1806 int i;
1807 /*
1808 * Wait 10 PCLKs before writing LCRH_TX register,
1809 * to get this delay write read only register 10 times
1810 */
1811 for (i = 0; i < 10; ++i)
1812 writew(0xff, uap->port.membase + UART011_MIS);
1813 writew(lcr_h, port->membase + uap->lcrh_tx);
1814 }
1815 writew(old_cr, port->membase + UART011_CR); 1810 writew(old_cr, port->membase + UART011_CR);
1816 1811
1817 spin_unlock_irqrestore(&port->lock, flags); 1812 spin_unlock_irqrestore(&port->lock, flags);