Commit 00661dd8 authored by Ben Dooks's avatar Ben Dooks Committed by Greg Kroah-Hartman

ARM: meson: serial: don't reset port on uart startup

When the uart startup entry is called, do not reset the port as this
could cause issues with anything left in the FIFO from a previous operation
such as a console write. Move the hardware reset to probe time and simply
clear the errors before enabling the port.

This fixes the issue where the console could become corrupted as there
where characters left in the output or output fifo when a user process
such as systemd would open/close the uart to transmit characters.

For example, you get:
    [    3.252263] systemd[1]: Dete

instead of:
    [    3.338801] systemd[1]: Detected architecture arm.
Signed-off-by: default avatarBen Dooks <ben.dooks@codethink.co.uk>
Tested-by: default avatarCarlo Caione <carlo@endlessm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1bc1f17b
...@@ -241,10 +241,9 @@ static const char *meson_uart_type(struct uart_port *port) ...@@ -241,10 +241,9 @@ static const char *meson_uart_type(struct uart_port *port)
return (port->type == PORT_MESON) ? "meson_uart" : NULL; return (port->type == PORT_MESON) ? "meson_uart" : NULL;
} }
static int meson_uart_startup(struct uart_port *port) static void meson_uart_reset(struct uart_port *port)
{ {
u32 val; u32 val;
int ret = 0;
val = readl(port->membase + AML_UART_CONTROL); val = readl(port->membase + AML_UART_CONTROL);
val |= (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLR_ERR); val |= (AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLR_ERR);
...@@ -252,6 +251,18 @@ static int meson_uart_startup(struct uart_port *port) ...@@ -252,6 +251,18 @@ static int meson_uart_startup(struct uart_port *port)
val &= ~(AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLR_ERR); val &= ~(AML_UART_RX_RST | AML_UART_TX_RST | AML_UART_CLR_ERR);
writel(val, port->membase + AML_UART_CONTROL); writel(val, port->membase + AML_UART_CONTROL);
}
static int meson_uart_startup(struct uart_port *port)
{
u32 val;
int ret = 0;
val = readl(port->membase + AML_UART_CONTROL);
val |= AML_UART_CLR_ERR;
writel(val, port->membase + AML_UART_CONTROL);
val &= ~AML_UART_CLR_ERR;
writel(val, port->membase + AML_UART_CONTROL);
val |= (AML_UART_RX_EN | AML_UART_TX_EN); val |= (AML_UART_RX_EN | AML_UART_TX_EN);
writel(val, port->membase + AML_UART_CONTROL); writel(val, port->membase + AML_UART_CONTROL);
...@@ -581,6 +592,12 @@ static int meson_uart_probe(struct platform_device *pdev) ...@@ -581,6 +592,12 @@ static int meson_uart_probe(struct platform_device *pdev)
meson_ports[pdev->id] = port; meson_ports[pdev->id] = port;
platform_set_drvdata(pdev, port); platform_set_drvdata(pdev, port);
/* reset port before registering (and possibly registering console) */
if (meson_uart_request_port(port) >= 0) {
meson_uart_reset(port);
meson_uart_release_port(port);
}
ret = uart_add_one_port(&meson_uart_driver, port); ret = uart_add_one_port(&meson_uart_driver, port);
if (ret) if (ret)
meson_ports[pdev->id] = NULL; meson_ports[pdev->id] = NULL;
......
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