public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] ns16550: Add WATCHDOG_RESET to putc for short watchdog timeout boards
@ 2010-10-07  7:01 Stefan Roese
  2010-10-07 10:17 ` Wolfgang Denk
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Roese @ 2010-10-07  7:01 UTC (permalink / raw)
  To: u-boot

This is needed for board with a very short watchdog timeout, like the
lwmon5 with a 100ms timeout. Without this patch this board resets in the
commands with long outputs, like "printenv" or "fdt print".

Note that the image size is not increased with this patch when
CONFIG_HW_WATCHDOG or CONFIG_WATCHDOG are not defined since the compiler
optimizes this additional code away.

Signed-off-by: Stefan Roese <sr@denx.de>
---
v2:
- Move declaration and assignment of "count" out of loop
  as pointed out by Wolfgang (thanks).

 drivers/serial/ns16550.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 7e833fd..5dc18f4 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -5,6 +5,7 @@
  */
 
 #include <config.h>
+#include <common.h>
 #include <ns16550.h>
 #include <watchdog.h>
 #include <linux/types.h>
@@ -68,7 +69,13 @@ void NS16550_reinit (NS16550_t com_port, int baud_divisor)
 
 void NS16550_putc (NS16550_t com_port, char c)
 {
-	while ((serial_in(&com_port->lsr) & UART_LSR_THRE) == 0);
+	int count = 0;
+
+	while ((serial_in(&com_port->lsr) & UART_LSR_THRE) == 0) {
+		/* reset watchdog from time to time */
+		if ((count++ % (256 << 10)) == 0)
+			WATCHDOG_RESET();
+	}
 	serial_out(c, &com_port->thr);
 }
 
-- 
1.7.3.1

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

end of thread, other threads:[~2010-10-07 13:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-07  7:01 [U-Boot] [PATCH v2] ns16550: Add WATCHDOG_RESET to putc for short watchdog timeout boards Stefan Roese
2010-10-07 10:17 ` Wolfgang Denk
2010-10-07 11:27   ` Stefan Roese
2010-10-07 12:23     ` Wolfgang Denk
2010-10-07 12:45       ` Reinhard Meyer
2010-10-07 13:18       ` Stefan Roese

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