]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/w7o/post2.c
f16f9a191c1eb6c327dc0537960fb9b1a9220e7e
[karo-tx-uboot.git] / board / w7o / post2.c
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  *
7  * SPDX-License-Identifier:     GPL-2.0+ 
8  */
9
10 #include <common.h>
11 #include <config.h>
12 #include <rtc.h>
13 #include "errors.h"
14 #include "dtt.h"
15
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
22 #if defined(CONFIG_RTC_M48T35A)
23 void rtctest(void)
24 {
25     volatile uchar *tchar = (uchar*)(CONFIG_SYS_NVRAM_BASE_ADDR + CONFIG_SYS_NVRAM_SIZE - 9);
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 */
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))
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() */