blob: 24e80939a9cb06a97dae5c5236e5777a4ab53fab [file] [log] [blame]
Igor Lisitsin95bcd382007-03-28 19:06:19 +04001/*
2 * (C) Copyright 2007
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Sergei Poselenov3190dbe2007-07-05 08:17:37 +02005 * Author: Igor Lisitsin <igor@emcraft.com>
6 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02007 * SPDX-License-Identifier: GPL-2.0+
Igor Lisitsin95bcd382007-03-28 19:06:19 +04008 */
9
10#include <common.h>
11
12/*
13 * Watchdog test
14 *
15 * The test verifies the watchdog timer operation.
16 * On the first iteration, the test routine disables interrupts and
17 * makes a 10-second delay. If the system does not reboot during this delay,
18 * the watchdog timer is not operational and the test fails. If the system
19 * reboots, on the second iteration the test routine reports a success.
20 */
21
Igor Lisitsin95bcd382007-03-28 19:06:19 +040022#include <post.h>
Igor Lisitsin95bcd382007-03-28 19:06:19 +040023
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020024#if CONFIG_POST & CONFIG_SYS_POST_WATCHDOG
Igor Lisitsin95bcd382007-03-28 19:06:19 +040025
Sergei Poselenov3190dbe2007-07-05 08:17:37 +020026#include <watchdog.h>
27
Igor Lisitsin95bcd382007-03-28 19:06:19 +040028int watchdog_post_test (int flags)
29{
30 if (flags & POST_REBOOT) {
31 /* Test passed */
Igor Lisitsin95bcd382007-03-28 19:06:19 +040032 return 0;
Sergei Poselenov3190dbe2007-07-05 08:17:37 +020033 }
34 else {
Igor Lisitsin95bcd382007-03-28 19:06:19 +040035 /* 10-second delay */
36 int ints = disable_interrupts ();
37 ulong base = post_time_ms (0);
38
39 while (post_time_ms (base) < 10000)
40 ;
41 if (ints)
42 enable_interrupts ();
43
44 /*
45 * If we have reached this point, the watchdog timer
46 * does not work
47 */
48 return -1;
49 }
50}
51
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020052#endif /* CONFIG_POST & CONFIG_SYS_POST_WATCHDOG */