]>
Commit | Line | Data |
---|---|---|
c609719b WD |
1 | /* |
2 | * (C) Copyright 2001 | |
3 | * Bill Hunter, Wave 7 Optics, williamhunter@mediaone.net | |
4 | * and | |
5 | * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com. | |
6 | * | |
3765b3e7 | 7 | * SPDX-License-Identifier: GPL-2.0+ |
c609719b WD |
8 | */ |
9 | ||
10 | #include <common.h> | |
11 | #include <config.h> | |
12 | #include <rtc.h> | |
13 | #include "errors.h" | |
14 | #include "dtt.h" | |
15 | ||
f2302d44 SR |
16 | /* for LM75 DTT POST test */ |
17 | #define DTT_READ_TEMP 0x0 | |
18 | #define DTT_CONFIG 0x1 | |
19 | #define DTT_TEMP_HYST 0x2 | |
20 | #define DTT_TEMP_SET 0x3 | |
21 | ||
c609719b WD |
22 | #if defined(CONFIG_RTC_M48T35A) |
23 | void rtctest(void) | |
24 | { | |
6d0f6bcf | 25 | volatile uchar *tchar = (uchar*)(CONFIG_SYS_NVRAM_BASE_ADDR + CONFIG_SYS_NVRAM_SIZE - 9); |
c609719b WD |
26 | struct rtc_time tmp; |
27 | ||
28 | /* set up led code for RTC tests */ | |
29 | log_stat(ERR_RTCG); | |
30 | ||
31 | /* | |
32 | * Do RTC battery test. The first write after power up | |
33 | * fails if battery is low. | |
34 | */ | |
35 | *tchar = 0xaa; | |
36 | if ((*tchar ^ 0xaa) != 0x0) log_warn(ERR_RTCBAT); | |
37 | *tchar = 0x55; /* Reset test address */ | |
38 | ||
39 | /* | |
40 | * Now lets check the validity of the values in the RTC. | |
41 | */ | |
42 | rtc_get(&tmp); | |
43 | if ((tmp.tm_sec < 0) | (tmp.tm_sec > 59) | | |
44 | (tmp.tm_min < 0) | (tmp.tm_min > 59) | | |
45 | (tmp.tm_hour < 0) | (tmp.tm_hour > 23) | | |
46 | (tmp.tm_mday < 1 ) | (tmp.tm_mday > 31) | | |
47 | (tmp.tm_mon < 1 ) | (tmp.tm_mon > 12) | | |
48 | (tmp.tm_year < 2000) | (tmp.tm_year > 2500) | | |
49 | (tmp.tm_wday < 1 ) | (tmp.tm_wday > 7)) { | |
50 | log_warn(ERR_RTCTIM); | |
51 | rtc_reset(); | |
52 | } | |
53 | ||
54 | /* | |
55 | * Now lets do a check to see if the NV RAM is there. | |
56 | */ | |
57 | *tchar = 0xaa; | |
58 | if ((*tchar ^ 0xaa) != 0x0) log_err(ERR_RTCVAL); | |
59 | *tchar = 0x55; /* Reset test address */ | |
60 | ||
61 | } /* rtctest() */ | |
62 | #endif /* CONFIG_RTC_M48T35A */ | |
63 | ||
64 | ||
65 | #ifdef CONFIG_DTT_LM75 | |
66 | int dtt_test(int sensor) | |
67 | { | |
68 | short temp, trip, hyst; | |
69 | ||
70 | /* get values */ | |
71 | temp = dtt_read(sensor, DTT_READ_TEMP) / 256; | |
72 | trip = dtt_read(sensor, DTT_TEMP_SET) / 256; | |
73 | hyst = dtt_read(sensor, DTT_TEMP_HYST) / 256; | |
74 | ||
75 | /* check values */ | |
6d0f6bcf JCPV |
76 | if ((hyst != (CONFIG_SYS_DTT_MAX_TEMP - CONFIG_SYS_DTT_HYSTERESIS)) || |
77 | (trip != CONFIG_SYS_DTT_MAX_TEMP) || | |
78 | (temp < CONFIG_SYS_DTT_LOW_TEMP) || (temp > CONFIG_SYS_DTT_MAX_TEMP)) | |
c609719b WD |
79 | return 1; |
80 | ||
81 | return 0; | |
82 | } /* dtt_test() */ | |
83 | #endif /* CONFIG_DTT_LM75 */ | |
84 | ||
85 | /*****************************************/ | |
86 | ||
87 | void post2(void) | |
88 | { | |
89 | #if defined(CONFIG_RTC_M48T35A) | |
90 | rtctest(); | |
91 | #endif /* CONFIG_RTC_M48T35A */ | |
92 | ||
93 | #ifdef CONFIG_DTT_LM75 | |
94 | log_stat(ERR_TempG); | |
95 | if(dtt_test(2) != 0) log_warn(ERR_Ttest0); | |
96 | if(dtt_test(4) != 0) log_warn(ERR_Ttest1); | |
97 | #endif /* CONFIG_DTT_LM75 */ | |
98 | } /* post2() */ |