From 13d6cd1020359e17b988f187708fd2664669604c Mon Sep 17 00:00:00 2001 From: Fugang Duan Date: Mon, 5 Mar 2018 18:45:51 +0800 Subject: MLK-17738 tty: serial: lpuart: restore console setting after power lost i.MX7ULP enter VLLS mode that lpuart module power off and registers all lost no matter the port is wakeup source. For console port, console baud rate setting lost and print messy log when enable the console port as wakeup source. To avoid the issue happen, user should not enable uart port as wakeup source in VLLS mode, or restore console setting. The patch is to add one fixup to restore console port register setting for i.MX7ULP platform. Reviewed-by: Gao Pan Signed-off-by: Fugang Duan --- drivers/tty/serial/fsl_lpuart.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'drivers/tty') diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 904f5f2b406b..3cf799c8e46d 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -2703,6 +2703,37 @@ static int lpuart_suspend(struct device *dev) return 0; } +static void lpuart_console_fixup(struct lpuart_port *sport) +{ + struct tty_port *port = &sport->port.state->port; + struct uart_port *uport = &sport->port; + struct device_node *np = sport->port.dev->of_node; + struct ktermios termios; + + if (!lpuart_is_32(sport) || !np) + return; + + /* i.MX7ULP enter VLLS mode that lpuart module power off and registers + * all lost no matter the port is wakeup source. + * For console port, console baud rate setting lost and print messy + * log when enable the console port as wakeup source. To avoid the + * issue happen, user should not enable uart port as wakeup source + * in VLLS mode, or restore console setting here. + */ + if (of_device_is_compatible(np, "fsl,imx7ulp-lpuart") && + lpuart_uport_is_active(sport) && console_suspend_enabled && + uart_console(&sport->port)) { + + mutex_lock(&port->mutex); + memset(&termios, 0, sizeof(struct ktermios)); + termios.c_cflag = uport->cons->cflag; + if (port->tty && termios.c_cflag == 0) + termios = port->tty->termios; + uport->ops->set_termios(uport, &termios, NULL); + mutex_unlock(&port->mutex); + } +} + static inline void lpuart32_resume_init(struct lpuart_port *sport) { unsigned long temp; @@ -2842,6 +2873,7 @@ static int lpuart_resume(struct device *dev) pm_runtime_enable(sport->port.dev); } + lpuart_console_fixup(sport); uart_resume_port(&lpuart_reg, &sport->port); return 0; -- cgit v1.2.3