3 * Bill Hunter, Wave 7 Optics, williamhunter@mediaone.net
5 * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
7 * SPDX-License-Identifier: GPL-2.0+
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
22 #if defined(CONFIG_RTC_M48T35A)
25 volatile uchar *tchar = (uchar*)(CONFIG_SYS_NVRAM_BASE_ADDR + CONFIG_SYS_NVRAM_SIZE - 9);
28 /* set up led code for RTC tests */
32 * Do RTC battery test. The first write after power up
33 * fails if battery is low.
36 if ((*tchar ^ 0xaa) != 0x0) log_warn(ERR_RTCBAT);
37 *tchar = 0x55; /* Reset test address */
40 * Now lets check the validity of the values in the RTC.
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)) {
55 * Now lets do a check to see if the NV RAM is there.
58 if ((*tchar ^ 0xaa) != 0x0) log_err(ERR_RTCVAL);
59 *tchar = 0x55; /* Reset test address */
62 #endif /* CONFIG_RTC_M48T35A */
65 #ifdef CONFIG_DTT_LM75
66 int dtt_test(int sensor)
68 short temp, trip, hyst;
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;
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))
83 #endif /* CONFIG_DTT_LM75 */
85 /*****************************************/
89 #if defined(CONFIG_RTC_M48T35A)
91 #endif /* CONFIG_RTC_M48T35A */
93 #ifdef CONFIG_DTT_LM75
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 */