From ab1fe18841252b49e9c4b61ac499c0e7ddbee2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Tue, 16 Feb 2021 11:49:11 +0100 Subject: [PATCH 1/3] marvell: uart: a3720: Fix comments in console_a3700_core_init() function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The delay loop executes 3 instructions. These 3 instructions are executed in 2 processor ticks and 30000 iterations on a 600 MHz CPU should yield approximately 100 us. This means we are waiting 2 ms, not 20 ms, for TX FIFO to be empty. Signed-off-by: Pali Rohár Change-Id: I2cccad405bcc73cd6d1062adc0205c405c16c15f --- drivers/marvell/uart/a3700_console.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/marvell/uart/a3700_console.S b/drivers/marvell/uart/a3700_console.S index 58dad7aa5..7bef7a142 100644 --- a/drivers/marvell/uart/a3700_console.S +++ b/drivers/marvell/uart/a3700_console.S @@ -60,10 +60,10 @@ func console_a3700_core_init str w3, [x0, #UART_POSSR_REG] /* - * Wait for the TX (THR and TSR) to be empty. If wait for 20ms, the TX FIFO is + * Wait for the TX (THR and TSR) to be empty. If wait for 2ms, the TX FIFO is * still not empty, TX FIFO will reset by all means. */ - mov w1, #20 /* max time out 20ms */ + mov w1, #20 /* max time out 20 * 100 us */ 2: /* Check whether TX (THR and TSR) is empty */ ldr w3, [x0, #UART_STATUS_REG] @@ -72,13 +72,13 @@ func console_a3700_core_init b.ne 4f /* Delay */ - mov w2, #30000 + mov w2, #30000 /* 30000 cycles of below 3 instructions on 600 MHz CPU ~~ 100 us */ 3: sub w2, w2, #1 cmp w2, #0 b.ne 3b - /* Check whether 10ms is waited */ + /* Check whether wait timeout expired */ sub w1, w1, #1 cmp w1, #0 b.ne 2b From 98641515a40f7a72b32073128db9ca99f2785dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Tue, 16 Feb 2021 11:55:02 +0100 Subject: [PATCH 2/3] marvell: uart: a3720: Update delay code to be compatible with 1200 MHz CPU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Console initialization function needs to wait at least minimal specified time. The fastest Armada 3720 CPU is 1200 MHz so increase loop delay to wait at least for 100 us on 1200 MHz variant too. The slowest Armada 3720 CPU is 600 MHz and in this case delay loop would take just 2 times more, which is not a problem. Signed-off-by: Pali Rohár Change-Id: I1f0b4aabd0e08b7696feec631419f7f7c7ec17d2 --- drivers/marvell/uart/a3700_console.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/marvell/uart/a3700_console.S b/drivers/marvell/uart/a3700_console.S index 7bef7a142..9e74c33bb 100644 --- a/drivers/marvell/uart/a3700_console.S +++ b/drivers/marvell/uart/a3700_console.S @@ -72,7 +72,7 @@ func console_a3700_core_init b.ne 4f /* Delay */ - mov w2, #30000 /* 30000 cycles of below 3 instructions on 600 MHz CPU ~~ 100 us */ + mov w2, #60000 /* 60000 cycles of below 3 instructions on 1200 MHz CPU ~~ 100 us */ 3: sub w2, w2, #1 cmp w2, #0 From 0d06b058a5bef1971ef7ebe7b9616b03fa7ecec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Tue, 16 Feb 2021 11:56:24 +0100 Subject: [PATCH 3/3] marvell: uart: a3720: Increase TX FIFO EMPTY timeout from 2ms to 3ms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TX FIFO has space for 32 characters. With default UART baudrate 115200 it takes more than 2ms to transmit all 32 characters, so wait at least 3ms before flushing TX FIFO. If WTMI firmware transmitted something via UART before TF-A was booted, some characters may still wait in TX FIFO when TF-A is initializing UART driver. So wait at least 3ms to ensure that HW has enough time to transmit all characters waiting in TX FIFO. This fixes an issue where sometimes characters transmitted on UART by our custom WTMI image are lost. Signed-off-by: Pali Rohár Change-Id: I8ea4ea58e4ba3e0c0d7f47e679171b9b94442f19 --- drivers/marvell/uart/a3700_console.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/marvell/uart/a3700_console.S b/drivers/marvell/uart/a3700_console.S index 9e74c33bb..b37732189 100644 --- a/drivers/marvell/uart/a3700_console.S +++ b/drivers/marvell/uart/a3700_console.S @@ -60,10 +60,10 @@ func console_a3700_core_init str w3, [x0, #UART_POSSR_REG] /* - * Wait for the TX (THR and TSR) to be empty. If wait for 2ms, the TX FIFO is + * 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. */ - mov w1, #20 /* max time out 20 * 100 us */ + mov w1, #30 /* max time out 30 * 100 us */ 2: /* Check whether TX (THR and TSR) is empty */ ldr w3, [x0, #UART_STATUS_REG]