blob: 1dfaa2f977a6bec84f9534693e57e02afb3f8a93 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
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 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
26#include <common.h>
27#include <config.h>
28#include <rtc.h>
29#include "errors.h"
30#include "dtt.h"
31
Stefan Roesef2302d42008-08-06 14:05:38 +020032/* for LM75 DTT POST test */
33#define DTT_READ_TEMP 0x0
34#define DTT_CONFIG 0x1
35#define DTT_TEMP_HYST 0x2
36#define DTT_TEMP_SET 0x3
37
wdenkc6097192002-11-03 00:24:07 +000038#if defined(CONFIG_RTC_M48T35A)
39void rtctest(void)
40{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020041 volatile uchar *tchar = (uchar*)(CONFIG_SYS_NVRAM_BASE_ADDR + CONFIG_SYS_NVRAM_SIZE - 9);
wdenkc6097192002-11-03 00:24:07 +000042 struct rtc_time tmp;
43
44 /* set up led code for RTC tests */
45 log_stat(ERR_RTCG);
46
47 /*
48 * Do RTC battery test. The first write after power up
49 * fails if battery is low.
50 */
51 *tchar = 0xaa;
52 if ((*tchar ^ 0xaa) != 0x0) log_warn(ERR_RTCBAT);
53 *tchar = 0x55; /* Reset test address */
54
55 /*
56 * Now lets check the validity of the values in the RTC.
57 */
58 rtc_get(&tmp);
59 if ((tmp.tm_sec < 0) | (tmp.tm_sec > 59) |
60 (tmp.tm_min < 0) | (tmp.tm_min > 59) |
61 (tmp.tm_hour < 0) | (tmp.tm_hour > 23) |
62 (tmp.tm_mday < 1 ) | (tmp.tm_mday > 31) |
63 (tmp.tm_mon < 1 ) | (tmp.tm_mon > 12) |
64 (tmp.tm_year < 2000) | (tmp.tm_year > 2500) |
65 (tmp.tm_wday < 1 ) | (tmp.tm_wday > 7)) {
66 log_warn(ERR_RTCTIM);
67 rtc_reset();
68 }
69
70 /*
71 * Now lets do a check to see if the NV RAM is there.
72 */
73 *tchar = 0xaa;
74 if ((*tchar ^ 0xaa) != 0x0) log_err(ERR_RTCVAL);
75 *tchar = 0x55; /* Reset test address */
76
77} /* rtctest() */
78#endif /* CONFIG_RTC_M48T35A */
79
80
81#ifdef CONFIG_DTT_LM75
82int dtt_test(int sensor)
83{
84 short temp, trip, hyst;
85
86 /* get values */
87 temp = dtt_read(sensor, DTT_READ_TEMP) / 256;
88 trip = dtt_read(sensor, DTT_TEMP_SET) / 256;
89 hyst = dtt_read(sensor, DTT_TEMP_HYST) / 256;
90
91 /* check values */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020092 if ((hyst != (CONFIG_SYS_DTT_MAX_TEMP - CONFIG_SYS_DTT_HYSTERESIS)) ||
93 (trip != CONFIG_SYS_DTT_MAX_TEMP) ||
94 (temp < CONFIG_SYS_DTT_LOW_TEMP) || (temp > CONFIG_SYS_DTT_MAX_TEMP))
wdenkc6097192002-11-03 00:24:07 +000095 return 1;
96
97 return 0;
98} /* dtt_test() */
99#endif /* CONFIG_DTT_LM75 */
100
101/*****************************************/
102
103void post2(void)
104{
105#if defined(CONFIG_RTC_M48T35A)
106 rtctest();
107#endif /* CONFIG_RTC_M48T35A */
108
109#ifdef CONFIG_DTT_LM75
110 log_stat(ERR_TempG);
111 if(dtt_test(2) != 0) log_warn(ERR_Ttest0);
112 if(dtt_test(4) != 0) log_warn(ERR_Ttest1);
113#endif /* CONFIG_DTT_LM75 */
114} /* post2() */