[PATCH] bsps/zynq-uart: Make post baud change kick global
Kinsey Moore
kinsey.moore at oarcorp.com
Mon Jun 28 13:02:43 UTC 2021
The existing fix for the ZynqMP UART hardware bug only caught the vast
majority of instances where it could occur. To fully fix the data
corruption, this fix must be applied after every baud rate change. This
makes the logic reset and kick apply in any locations where the baud
rate could be changed.
---
bsps/aarch64/xilinx-zynqmp/console/console.c | 5 -----
bsps/shared/dev/serial/zynq-uart-polled.c | 6 ++++++
bsps/shared/dev/serial/zynq-uart.c | 8 ++++++++
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/bsps/aarch64/xilinx-zynqmp/console/console.c b/bsps/aarch64/xilinx-zynqmp/console/console.c
index 9886a117dc..d1948f1a0c 100644
--- a/bsps/aarch64/xilinx-zynqmp/console/console.c
+++ b/bsps/aarch64/xilinx-zynqmp/console/console.c
@@ -113,11 +113,6 @@ static void zynqmp_debug_console_early_init(char c)
zynq_uart_initialize(base);
BSP_output_char = zynqmp_debug_console_out;
- /*
- * Some ZynqMP UARTs have a hardware bug that causes TX/RX logic restarts to
- * require a kick after baud rate registers are initialized.
- */
- zynqmp_debug_console_out(0);
zynqmp_debug_console_out(c);
}
diff --git a/bsps/shared/dev/serial/zynq-uart-polled.c b/bsps/shared/dev/serial/zynq-uart-polled.c
index 74e7255ec2..95c51dea11 100644
--- a/bsps/shared/dev/serial/zynq-uart-polled.c
+++ b/bsps/shared/dev/serial/zynq-uart-polled.c
@@ -144,6 +144,12 @@ void zynq_uart_initialize(rtems_termios_device_context *base)
regs->control = ZYNQ_UART_CONTROL_RXEN
| ZYNQ_UART_CONTROL_TXEN
| ZYNQ_UART_CONTROL_RSTTO;
+
+ /*
+ * Some ZynqMP UARTs have a hardware bug that causes TX/RX logic restarts to
+ * require a kick after baud rate registers are initialized.
+ */
+ zynq_uart_write_polled(base, 0);
}
int zynq_uart_read_polled(rtems_termios_device_context *base)
diff --git a/bsps/shared/dev/serial/zynq-uart.c b/bsps/shared/dev/serial/zynq-uart.c
index cd0d0e7584..8503e31d49 100644
--- a/bsps/shared/dev/serial/zynq-uart.c
+++ b/bsps/shared/dev/serial/zynq-uart.c
@@ -214,9 +214,17 @@ static bool zynq_uart_set_attributes(
if (baud > 0) {
regs->baud_rate_gen = ZYNQ_UART_BAUD_RATE_GEN_CD(brgr);
regs->baud_rate_div = ZYNQ_UART_BAUD_RATE_DIV_BDIV(bauddiv);
+ regs->control |= ZYNQ_UART_CONTROL_RXRES
+ | ZYNQ_UART_CONTROL_TXRES;
}
regs->control |= ZYNQ_UART_CONTROL_RXEN | ZYNQ_UART_CONTROL_TXEN;
+ /*
+ * Some ZynqMP UARTs have a hardware bug that causes TX/RX logic restarts to
+ * require a kick after baud rate registers are initialized.
+ */
+ zynq_uart_write_polled(context, 0);
+
return true;
}
--
2.20.1
More information about the devel
mailing list