[PATCH] arm/zynq: Wait for the UART TX FIFO to empty on reset.

Chris Johns chrisj at rtems.org
Thu Nov 24 22:55:23 UTC 2016


---
 c/src/lib/libbsp/arm/xilinx-zynq/console/zynq-uart.c | 13 +++++++++++++
 c/src/lib/libbsp/arm/xilinx-zynq/include/zynq-uart.h |  5 +++++
 c/src/lib/libbsp/arm/xilinx-zynq/startup/bspreset.c  |  6 ++++++
 3 files changed, 24 insertions(+)

diff --git a/c/src/lib/libbsp/arm/xilinx-zynq/console/zynq-uart.c b/c/src/lib/libbsp/arm/xilinx-zynq/console/zynq-uart.c
index aa96eba..f9a1cf9 100644
--- a/c/src/lib/libbsp/arm/xilinx-zynq/console/zynq-uart.c
+++ b/c/src/lib/libbsp/arm/xilinx-zynq/console/zynq-uart.c
@@ -226,3 +226,16 @@ const console_fns zynq_uart_fns = {
   .deviceSetAttributes = zynq_uart_set_attribues,
   .deviceOutputUsesInterrupts = false
 };
+
+void zynq_uart_reset_tx_flush(int minor)
+{
+  volatile zynq_uart *regs = zynq_uart_get_regs(minor);
+  int                 c = 4;
+
+  while (c-- > 0)
+    zynq_uart_write_polled(minor, '\r');
+
+  while ((regs->channel_sts & ZYNQ_UART_CHANNEL_STS_TEMPTY) == 0) {
+    /* Wait */
+  }
+}
diff --git a/c/src/lib/libbsp/arm/xilinx-zynq/include/zynq-uart.h b/c/src/lib/libbsp/arm/xilinx-zynq/include/zynq-uart.h
index bb0ff56..07c883a 100644
--- a/c/src/lib/libbsp/arm/xilinx-zynq/include/zynq-uart.h
+++ b/c/src/lib/libbsp/arm/xilinx-zynq/include/zynq-uart.h
@@ -35,6 +35,11 @@ extern "C" {
 
 extern const console_fns zynq_uart_fns;
 
+/**
+  * Flush TX FIFO and wait until it is empty. Used in bsp_reset.
+  */
+void zynq_uart_reset_tx_flush(int minor);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/c/src/lib/libbsp/arm/xilinx-zynq/startup/bspreset.c b/c/src/lib/libbsp/arm/xilinx-zynq/startup/bspreset.c
index 8d70baa..f86d1f3 100644
--- a/c/src/lib/libbsp/arm/xilinx-zynq/startup/bspreset.c
+++ b/c/src/lib/libbsp/arm/xilinx-zynq/startup/bspreset.c
@@ -12,13 +12,19 @@
  * http://www.rtems.org/license/LICENSE.
  */
 
+#include <bsp.h>
 #include <bsp/bootcard.h>
+#include <bsp/zynq-uart.h>
 
 void bsp_reset(void)
 {
   volatile uint32_t *slcr_unlock = (volatile uint32_t *) 0xf8000008;
   volatile uint32_t *pss_rst_ctrl = (volatile uint32_t *) 0xf8000200;
 
+  if (Console_Port_Tbl != NULL) {
+    zynq_uart_reset_tx_flush((int) Console_Port_Minor);
+  }
+
   while (true) {
     *slcr_unlock = 0xdf0d;
     *pss_rst_ctrl = 0x1;
-- 
2.9.0



More information about the devel mailing list