添加了牛皮藓,主要方便不知情的人联系我。有洁癖者自己去除代码,在
[ddnasgpl.git] / diag / diag_rtc.c
blob4c24d521e8c6c1c838a907829a9e59b3c85124f1
2 #include <common.h>
4 #include "diag.h"
6 int rtc_test(void)
8 int hour1, minute1, second1;
9 int hour2, minute2, second2;
10 int ret_val = 0;
12 printf("\tRTC test ");
14 diag_get_rtc_time(&hour1, &minute1, &second1);
16 /* FIXME: Observation says RTC requires additional udelay(1) to
17 * read proper value
19 udelay(1000000);
21 /* Set a time that changes all the digits after a second */
22 diag_set_rtc_time(9, 59, 59);
24 /* Wait for 1 second */
25 /* Observation says RTC takes additional one second when new time is set */
26 udelay(2000000);
28 diag_get_rtc_time(&hour2, &minute2, &second2);
30 if(hour2 != 10 ||
31 minute2 != 0 ||
32 second2 > 1)
34 /* Second should be 0 or max 1 (if error in udealy), not > 1 */
36 printf("FAILED\n");
37 printf("\t\tGot: hour %02d minute %02d second %02d\n", hour2, minute2, second2);
38 printf("\t\tExpected: hour 10 minute 00 second 00\n");
39 ret_val = 1;
41 else
43 printf("\t\t\t\t\t PASSED\n");
46 /* As incrementing a second here will require complex calculation,
47 * we will ignore that passed second */
48 diag_set_rtc_time(hour1, minute1, second1);
50 return ret_val;