From 0ee80f35a28d651d243a6d56678800f9697d14c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Mon, 15 Nov 2021 12:24:56 +0100 Subject: [PATCH] fix(plat/marvell/a3720/uart): do external reset during initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes when changing UART clock from TBG to XTAL, UART HW enters into some broken state. It does not transit characters from TX FIFO anymore and TX FIFO stays always empty. TX FIFO reset does not recover UART HW from this broken state. Experiments show that external reset can fix UART HW from this broken state. TF-A fatal error handler calls console_a3700_core_init() function to initialize UART HW. This handler may be called anytime during CPU runtime, also when kernel is running. U-Boot or Linux kernel may change UART clock to TBG to achieve higher baudrates. During initialization, console_a3700_core_init() resets UART configuration to default settings, which means that it also changes UART clock from TBG to XTAL. Do an external reset of UART via North Bridge Peripheral reset register to prevent this UART hangup. Signed-off-by: Pali Rohár Change-Id: I8990bce24d1a6fd8ccc47a2cd0a5ff932fcfcf14 --- drivers/marvell/uart/a3700_console.S | 8 ++++++++ include/drivers/marvell/uart/a3700_console.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/marvell/uart/a3700_console.S b/drivers/marvell/uart/a3700_console.S index a6caa1ef0..c7eb165e6 100644 --- a/drivers/marvell/uart/a3700_console.S +++ b/drivers/marvell/uart/a3700_console.S @@ -69,6 +69,14 @@ func console_a3700_core_init b.ne 2b 4: + /* Reset UART via North Bridge Peripheral */ + mov_imm x4, MVEBU_NB_RESET_REG + ldr w3, [x4] + bic w3, w3, #MVEBU_NB_RESET_UART_N + str w3, [x4] + orr w3, w3, #MVEBU_NB_RESET_UART_N + str w3, [x4] + /* Reset FIFO */ mov w3, #UART_CTRL_RXFIFO_RESET orr w3, w3, #UART_CTRL_TXFIFO_RESET diff --git a/include/drivers/marvell/uart/a3700_console.h b/include/drivers/marvell/uart/a3700_console.h index 12d2cdc52..ce673a138 100644 --- a/include/drivers/marvell/uart/a3700_console.h +++ b/include/drivers/marvell/uart/a3700_console.h @@ -9,6 +9,7 @@ #define A3700_CONSOLE_H #include +#include /* MVEBU UART Registers */ #define UART_RX_REG 0x00