summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-03-08 09:37:49 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-03-08 19:28:50 -0800
commit427005489fdbbfa43fdf237b2ddcb5d38ac0c6e8 (patch)
tree1407293aedce1c75efaa21f249c1a09aa74a834f
parent31369c44c22dc307d6c52845432099266bcc2945 (diff)
downloadchrome-ec-427005489fdbbfa43fdf237b2ddcb5d38ac0c6e8.tar.gz
Allow repeated waitms commands without resetting
At present issuing several 'waitms 1000' commands immediately after each other trips the watchdog. Add a watchdog reload to avoid this. Also document the behaviour in the command help. BUG=b:72542719 BRANCH=none TEST=manually on grunt, pasting these three lines in: waitms 1000 waitms 1000 waitms 1000 and see that it does not reset now. Change-Id: I453708299e4e26c1bbdb5fc406f26e916e7389af Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/955927 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Martin Roth <martinroth@chromium.org>
-rw-r--r--common/timer.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/common/timer.c b/common/timer.c
index da3feff404..d88a34164e 100644
--- a/common/timer.c
+++ b/common/timer.c
@@ -13,6 +13,7 @@
#include "util.h"
#include "task.h"
#include "timer.h"
+#include "watchdog.h"
#define TIMER_SYSJUMP_TAG 0x4d54 /* "TM" */
@@ -265,13 +266,25 @@ static int command_wait(int argc, char **argv)
if (*e)
return EC_ERROR_PARAM1;
+ /*
+ * Waiting for too long (e.g. 3s) will cause the EC to reset due to a
+ * watchdog timeout. This is intended behaviour and is in fact used by
+ * a FAFT test to check that the watchdog timer is working.
+ */
udelay(i * 1000);
+ /*
+ * Reload the watchdog so that issuing multiple small waitms commands
+ * quickly one after the other will not cause a reset.
+ */
+ watchdog_reload();
+
return EC_SUCCESS;
}
+/* Typically a large delay (e.g. 3s) will cause a reset */
DECLARE_CONSOLE_COMMAND(waitms, command_wait,
"msec",
- "Busy-wait for msec");
+ "Busy-wait for msec (large delays will reset)");
#endif
#ifdef CONFIG_CMD_FORCETIME