Skip to contentSkip to conversation

ns16550: Add WATCHDOG_RESET to putc for short watchdog timeout boards

PATCH Superseded Stefan Roese 2 participants 2 messages Sep 29, 2010 – Oct 6, 2010

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ns16550: Add WATCHDOG_RESET to putc for short watchdog timeout boards

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.

---
 drivers/serial/ns16550.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/serial/ns16550.c +8 -1
index 7e833fd..25fa521 100644
@@ -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);
+	while ((serial_in(&com_port->lsr) & UART_LSR_THRE) == 0) {
+		int count = 0;
+
+		/* reset watchdog from time to time */
+		if ((count++ % (256 << 10)) == 0)
+			WATCHDOG_RESET();
+	}
 	serial_out(c, &com_port->thr);
 }
 
Signature · 1 line
1.7.3
#1 lore raw

PATCH 1/1 ns16550: Add WATCHDOG_RESET to putc for short watchdog timeout boards

Dear Stefan Roese,

Quoted 27 lines · In message <[email protected]> you wrote:

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.

---
 drivers/serial/ns16550.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/serial/ns16550.c +1 -0
index 7e833fd..25fa521 100644
@@ -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)
 

drivers/serial/ns16550.c void NS16550_reinit (NS16550_t com_port, int baud_divisor) · line 78

Quoted 10 lines
drivers/serial/ns16550.c +7 -1
 void NS16550_putc (NS16550_t com_port, char c)
 {
-	while ((serial_in(&com_port->lsr) & UART_LSR_THRE) == 0);
+	while ((serial_in(&com_port->lsr) & UART_LSR_THRE) == 0) {
+		int count = 0;
+
+		/* reset watchdog from time to time */
+		if ((count++ % (256 << 10)) == 0)
+			WATCHDOG_RESET();
+	}

This code makes no sense to me. You initialize the variable in the same loop, so it will never bi different from 0 when you test it.

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Severe culture shock results when experts from another protocol suite
[...] try to read OSI documents. The term "osified" is used to  refer
to  such  documents. [...] Any relationship to the word "ossified" is
purely intentional.                                - Marshall T. Rose