public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 1/4] ns16550: Add function to drain serial output
@ 2012-03-09 20:32 Simon Glass
  2012-03-09 20:32 ` [U-Boot] [PATCH v2 2/4] Enable printf() console if pre-console putc() is available Simon Glass
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Simon Glass @ 2012-03-09 20:32 UTC (permalink / raw)
  To: u-boot

Sometimes we want to be sure that the output FIFO has fully drained (e.g.
because we are about to reset or the port or reset the board). Add a
function for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Add function to drain the ns16550's FIFO

 drivers/serial/ns16550.c |   11 +++++++++++
 include/ns16550.h        |    3 +++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 0c23955..a082112 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -6,6 +6,7 @@
 
 #include <config.h>
 #include <ns16550.h>
+#include <common.h>
 #include <watchdog.h>
 #include <linux/types.h>
 #include <asm/io.h>
@@ -115,4 +116,14 @@ int NS16550_tstc(NS16550_t com_port)
 	return (serial_in(&com_port->lsr) & UART_LSR_DR) != 0;
 }
 
+/* Wait for the UART's output buffer and holding register to drain */
+void NS16550_drain(NS16550_t regs)
+{
+	u32 mask = UART_LSR_TEMT | UART_LSR_THRE;
+
+	/* Wait for the UART to finish sending */
+	while ((serial_in(&regs->lsr) & mask) != mask)
+		udelay(100);
+}
+
 #endif /* CONFIG_NS16550_MIN_FUNCTIONS */
diff --git a/include/ns16550.h b/include/ns16550.h
index e9d2eda..16b3828 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -166,4 +166,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor);
 void NS16550_putc(NS16550_t com_port, char c);
 char NS16550_getc(NS16550_t com_port);
 int NS16550_tstc(NS16550_t com_port);
+
+/* Wait for the UART's output buffer and holding register to drain */
+void NS16550_drain(NS16550_t regs);
 void NS16550_reinit(NS16550_t com_port, int baud_divisor);
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2012-03-11  2:06 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-09 20:32 [U-Boot] [PATCH v2 1/4] ns16550: Add function to drain serial output Simon Glass
2012-03-09 20:32 ` [U-Boot] [PATCH v2 2/4] Enable printf() console if pre-console putc() is available Simon Glass
2012-03-09 20:32 ` [U-Boot] [PATCH v2 3/4] tegra: Implement pre-console putc() for fdt warning Simon Glass
2012-03-10  8:16   ` Wolfgang Denk
2012-03-10 19:22     ` Simon Glass
2012-03-10 20:08       ` Wolfgang Denk
2012-03-10 21:25         ` Simon Glass
2012-03-10 22:49           ` Wolfgang Denk
2012-03-11  0:48             ` Simon Glass
2012-03-09 20:32 ` [U-Boot] [PATCH v2 4/4] tegra: Enable pre-console putc() for Tegra boards Simon Glass
2012-03-09 20:59 ` [U-Boot] [PATCH v2 1/4] ns16550: Add function to drain serial output Tom Warren
2012-03-10  8:20   ` Wolfgang Denk
2012-03-09 21:00 ` Stephen Warren
2012-03-09 21:08   ` Simon Glass
2012-03-09 21:23     ` Tom Warren
2012-03-09 21:29       ` Simon Glass
2012-03-09 21:40         ` Stephen Warren
2012-03-10  8:19 ` Wolfgang Denk
2012-03-10 19:27   ` Simon Glass
2012-03-10 20:24     ` Wolfgang Denk
2012-03-11  0:52       ` Simon Glass
2012-03-11  2:06 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox