serial: stm32: fix incorrect characters on console
[ Upstream commitf264c6f6ae] Incorrect characters are observed on console during boot. This issue occurs when init/main.c is modifying termios settings to open /dev/console on the rootfs. This patch adds a waiting loop in set_termios to wait for TX shift register empty (and TX FIFO if any) before stopping serial port. Fixes:48a6092fb4("serial: stm32-usart: Add STM32 USART Driver") Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com> Link: https://lore.kernel.org/r/20210304162308.8984-4-erwan.leray@foss.st.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
a44d6acfa7
commit
5ca0d5b2c8
1 changed files with 11 additions and 1 deletions
|
|
@ -736,8 +736,9 @@ static void stm32_usart_set_termios(struct uart_port *port,
|
|||
unsigned int baud, bits;
|
||||
u32 usartdiv, mantissa, fraction, oversampling;
|
||||
tcflag_t cflag = termios->c_cflag;
|
||||
u32 cr1, cr2, cr3;
|
||||
u32 cr1, cr2, cr3, isr;
|
||||
unsigned long flags;
|
||||
int ret;
|
||||
|
||||
if (!stm32_port->hw_flow_control)
|
||||
cflag &= ~CRTSCTS;
|
||||
|
|
@ -746,6 +747,15 @@ static void stm32_usart_set_termios(struct uart_port *port,
|
|||
|
||||
spin_lock_irqsave(&port->lock, flags);
|
||||
|
||||
ret = readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr,
|
||||
isr,
|
||||
(isr & USART_SR_TC),
|
||||
10, 100000);
|
||||
|
||||
/* Send the TC error message only when ISR_TC is not set. */
|
||||
if (ret)
|
||||
dev_err(port->dev, "Transmission is not complete\n");
|
||||
|
||||
/* Stop serial port and reset value */
|
||||
writel_relaxed(0, port->membase + ofs->cr1);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue