fix(plat/marvell/a3720/uart): configure UART after TX FIFO reset
If TX FIFO is not empty, do not touch UART settings and let UART HW
transmit remaining bytes from TX FIFO. New UART settings are then set
only after TX FIFO is reset.
Signed-off-by: Pali Rohár <pali@kernel.org>
Change-Id: I2976c0a4fbb841d3a79d42ef67c06e70174afc3b
diff --git a/drivers/marvell/uart/a3700_console.S b/drivers/marvell/uart/a3700_console.S
index 2f4bf26..a6caa1e 100644
--- a/drivers/marvell/uart/a3700_console.S
+++ b/drivers/marvell/uart/a3700_console.S
@@ -44,19 +44,6 @@
cbz w1, init_fail
cbz w2, init_fail
- /* Program the baudrate */
- /* Divisor = Round(Uartclock / (16 * baudrate)) */
- lsl w2, w2, #4
- add w1, w1, w2, lsr #1
- udiv w2, w1, w2
- and w2, w2, #0x3ff /* clear all other bits to use default clock */
-
- str w2, [x0, #UART_BAUD_REG]/* set baud rate divisor */
-
- /* Set UART to default 16X scheme */
- mov w3, #0
- str w3, [x0, #UART_POSSR_REG]
-
/*
* Wait for the TX (THR and TSR) to be empty. If wait for 3ms, the TX FIFO is
* still not empty, TX FIFO will reset by all means.
@@ -94,6 +81,19 @@
cmp w3, #0
b.ne 1b
+ /* Program the baudrate */
+ /* Divisor = Round(Uartclock / (16 * baudrate)) */
+ lsl w2, w2, #4
+ add w1, w1, w2, lsr #1
+ udiv w2, w1, w2
+ and w2, w2, #0x3ff /* clear all other bits to use default clock */
+
+ str w2, [x0, #UART_BAUD_REG]/* set baud rate divisor */
+
+ /* Set UART to default 16X scheme */
+ mov w3, #0
+ str w3, [x0, #UART_POSSR_REG]
+
/* No Parity, 1 Stop */
mov w3, #0
str w3, [x0, #UART_CTRL_REG]