123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #include <common.h>
- #include <post.h>
- #if CONFIG_POST & CONFIG_SYS_POST_WATCHDOG
- #include <watchdog.h>
- #include <asm/ppc4xx-gpio.h>
- #include <asm/io.h>
- static uint watchdog_magic_read(void)
- {
- return in_be32((void *)CONFIG_SYS_WATCHDOG_FLAGS_ADDR) &
- CONFIG_SYS_WATCHDOG_MAGIC_MASK;
- }
- static void watchdog_magic_write(uint value)
- {
- out_be32((void *)CONFIG_SYS_WATCHDOG_FLAGS_ADDR, value |
- (in_be32((void *)CONFIG_SYS_WATCHDOG_FLAGS_ADDR) &
- ~CONFIG_SYS_WATCHDOG_MAGIC_MASK));
- }
- int sysmon1_post_test(int flags)
- {
- if (gpio_read_in_bit(CONFIG_SYS_GPIO_SYSMON_STATUS) == 0) {
-
- post_log("sysmon1 Abnormal voltage detected (GPIO62)\n");
- post_log("POST sysmon1 FAILED\n");
- return 1;
- } else {
- post_log("sysmon1 PASSED\n");
- }
- return 0;
- }
- int lwmon5_watchdog_post_test(int flags)
- {
-
- if (!(flags & POST_MANUAL) && sysmon1_post_test(flags)) {
-
-
- watchdog_magic_write(0);
-
- return 1;
- }
- if (watchdog_magic_read() != CONFIG_SYS_WATCHDOG_MAGIC) {
-
- int ints;
- ulong base;
- ulong time;
-
- watchdog_magic_write(CONFIG_SYS_WATCHDOG_MAGIC);
- ints = disable_interrupts ();
-
- WATCHDOG_RESET();
- out_be32((void *)CONFIG_SYS_WATCHDOG_TIME_ADDR, 0);
-
- base = post_time_ms (0);
-
- while ((time = post_time_ms (base)) < 150)
- out_be32((void *)CONFIG_SYS_WATCHDOG_TIME_ADDR, time);
- if (ints)
- enable_interrupts ();
-
- watchdog_magic_write(0);
-
- post_log("hw watchdog time : %u ms, failed ", time);
- return 2;
- } else {
-
- ulong time;
-
- time = in_be32((void *)CONFIG_SYS_WATCHDOG_TIME_ADDR);
- if (time > 90 ) {
- post_log("hw watchdog time : %u ms, passed ", time);
-
- watchdog_magic_write(0);
- return 0;
- } else {
-
- post_log("hw watchdog time : %u ms, failed ", time);
- return 2;
- }
- }
- return -1;
- }
- #endif
|