summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2020-07-10 01:12:07 +0900
committerMasahiro Yamada <yamada.masahiro@socionext.com>2020-07-11 21:30:21 +0900
commit26f7a7deab33e9fb46abec50a5209878fc3b53dc (patch)
tree9f5d4c37130966a32a703156368c44720bc2e7c5 /drivers
parent70434ab9de795b205608067d9a5e067f30ad3629 (diff)
serial: uniphier: flush transmitter before changing hardware settings
Ensure the transmitter is empty when chaining the baudrate or any hardware settings. If a character is remaining in the transmitter, the console will be garbled. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/serial/serial_uniphier.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index 2ffab004bd..aaf8657ee1 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -43,6 +43,10 @@ static int uniphier_serial_setbrg(struct udevice *dev, int baudrate)
divisor = DIV_ROUND_CLOSEST(priv->uartclk, mode_x_div * baudrate);
+ /* flush the trasmitter before changing hw setting */
+ while (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_TEMT))
+ ;
+
writel(divisor, priv->membase + UNIPHIER_UART_DLR);
return 0;
@@ -132,6 +136,10 @@ static int uniphier_serial_probe(struct udevice *dev)
priv->uartclk = clk_data->clk_rate;
+ /* flush the trasmitter empty before changing hw setting */
+ while (!(readl(priv->membase + UNIPHIER_UART_LSR) & UART_LSR_TEMT))
+ ;
+
tmp = readl(priv->membase + UNIPHIER_UART_LCR_MCR);
tmp &= ~UNIPHIER_UART_LCR_MASK;
tmp |= FIELD_PREP(UNIPHIER_UART_LCR_MASK, UART_LCR_WLEN8);