Commit 570d2910 authored by Jon Medhurst's avatar Jon Medhurst Committed by Greg Kroah-Hartman

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: default avatarJon Medhurst <tixy@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b60f2f66
...@@ -1529,7 +1529,7 @@ static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h) ...@@ -1529,7 +1529,7 @@ static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h)
static int pl011_startup(struct uart_port *port) static int pl011_startup(struct uart_port *port)
{ {
struct uart_amba_port *uap = (struct uart_amba_port *)port; struct uart_amba_port *uap = (struct uart_amba_port *)port;
unsigned int cr; unsigned int cr, lcr_h, fbrd, ibrd;
int retval; int retval;
retval = pl011_hwinit(port); retval = pl011_hwinit(port);
...@@ -1548,10 +1548,16 @@ static int pl011_startup(struct uart_port *port) ...@@ -1548,10 +1548,16 @@ static int pl011_startup(struct uart_port *port)
writew(uap->vendor->ifls, uap->port.membase + UART011_IFLS); writew(uap->vendor->ifls, uap->port.membase + UART011_IFLS);
/* /*
* Provoke TX FIFO interrupt into asserting. * Provoke TX FIFO interrupt into asserting. Taking care to preserve
* baud rate and data format specified by FBRD, IBRD and LCRH as the
* UART may already be in use as a console.
*/ */
spin_lock_irq(&uap->port.lock); spin_lock_irq(&uap->port.lock);
fbrd = readw(uap->port.membase + UART011_FBRD);
ibrd = readw(uap->port.membase + UART011_IBRD);
lcr_h = readw(uap->port.membase + uap->lcrh_rx);
cr = UART01x_CR_UARTEN | UART011_CR_TXE | UART011_CR_LBE; cr = UART01x_CR_UARTEN | UART011_CR_TXE | UART011_CR_LBE;
writew(cr, uap->port.membase + UART011_CR); writew(cr, uap->port.membase + UART011_CR);
writew(0, uap->port.membase + UART011_FBRD); writew(0, uap->port.membase + UART011_FBRD);
...@@ -1561,6 +1567,10 @@ static int pl011_startup(struct uart_port *port) ...@@ -1561,6 +1567,10 @@ static int pl011_startup(struct uart_port *port)
while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY) while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY)
barrier(); barrier();
writew(fbrd, uap->port.membase + UART011_FBRD);
writew(ibrd, uap->port.membase + UART011_IBRD);
pl011_write_lcr_h(uap, lcr_h);
/* restore RTS and DTR */ /* restore RTS and DTR */
cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR); cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR);
cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE; cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment