[rtems commit] bsps/zynq-uart: Make post baud change kick global

Joel Sherrill joel at rtems.org
Tue Jun 29 16:42:18 UTC 2021


Module:    rtems
Branch:    master
Commit:    26d61c867077e0b529f7ab301188101e7352022d
Changeset: http://git.rtems.org/rtems/commit/?id=26d61c867077e0b529f7ab301188101e7352022d

Author:    Kinsey Moore <kinsey.moore at oarcorp.com>
Date:      Wed Jun 23 11:57:18 2021 -0500

bsps/zynq-uart: Make post baud change kick global

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 9886a11..d1948f1 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 74e7255..95c51de 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 cd0d0e7..8503e31 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;
 }
 



More information about the vc mailing list