aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/amba-pl011.c
diff options
context:
space:
mode:
authorJon Medhurst <tixy@linaro.org>2013-12-10 05:19:00 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-17 12:35:38 -0500
commit570d291048aecc02271884f6a5f50ad555f271a5 (patch)
tree9d9e47b193b44c5550cbdd24b93a687d3a8b6d56 /drivers/tty/serial/amba-pl011.c
parentb60f2f66a58c43e8c928336ec72f64e72f1237ea (diff)
serial: amba-pl011: preseserve hardware settings during initialisation
During initialisation, a UART may already be in use for a console, so take care to preserve things like baud rate and data format to avoid corrupting console output. Signed-off-by: Jon Medhurst <tixy@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/amba-pl011.c')
-rw-r--r--drivers/tty/serial/amba-pl011.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 844bfba9d0ab..182a922e1942 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1529,7 +1529,7 @@ static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h)
1529static int pl011_startup(struct uart_port *port) 1529static int pl011_startup(struct uart_port *port)
1530{ 1530{
1531 struct uart_amba_port *uap = (struct uart_amba_port *)port; 1531 struct uart_amba_port *uap = (struct uart_amba_port *)port;
1532 unsigned int cr; 1532 unsigned int cr, lcr_h, fbrd, ibrd;
1533 int retval; 1533 int retval;
1534 1534
1535 retval = pl011_hwinit(port); 1535 retval = pl011_hwinit(port);
@@ -1548,10 +1548,16 @@ static int pl011_startup(struct uart_port *port)
1548 writew(uap->vendor->ifls, uap->port.membase + UART011_IFLS); 1548 writew(uap->vendor->ifls, uap->port.membase + UART011_IFLS);
1549 1549
1550 /* 1550 /*
1551 * Provoke TX FIFO interrupt into asserting. 1551 * Provoke TX FIFO interrupt into asserting. Taking care to preserve
1552 * baud rate and data format specified by FBRD, IBRD and LCRH as the
1553 * UART may already be in use as a console.
1552 */ 1554 */
1553 spin_lock_irq(&uap->port.lock); 1555 spin_lock_irq(&uap->port.lock);
1554 1556
1557 fbrd = readw(uap->port.membase + UART011_FBRD);
1558 ibrd = readw(uap->port.membase + UART011_IBRD);
1559 lcr_h = readw(uap->port.membase + uap->lcrh_rx);
1560
1555 cr = UART01x_CR_UARTEN | UART011_CR_TXE | UART011_CR_LBE; 1561 cr = UART01x_CR_UARTEN | UART011_CR_TXE | UART011_CR_LBE;
1556 writew(cr, uap->port.membase + UART011_CR); 1562 writew(cr, uap->port.membase + UART011_CR);
1557 writew(0, uap->port.membase + UART011_FBRD); 1563 writew(0, uap->port.membase + UART011_FBRD);
@@ -1561,6 +1567,10 @@ static int pl011_startup(struct uart_port *port)
1561 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY) 1567 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY)
1562 barrier(); 1568 barrier();
1563 1569
1570 writew(fbrd, uap->port.membase + UART011_FBRD);
1571 writew(ibrd, uap->port.membase + UART011_IBRD);
1572 pl011_write_lcr_h(uap, lcr_h);
1573
1564 /* restore RTS and DTR */ 1574 /* restore RTS and DTR */
1565 cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR); 1575 cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR);
1566 cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE; 1576 cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE;