post2.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. * 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. #include <common.h>
  26. #include <config.h>
  27. #include <rtc.h>
  28. #include "errors.h"
  29. #include "dtt.h"
  30. /* for LM75 DTT POST test */
  31. #define DTT_READ_TEMP 0x0
  32. #define DTT_CONFIG 0x1
  33. #define DTT_TEMP_HYST 0x2
  34. #define DTT_TEMP_SET 0x3
  35. #if defined(CONFIG_RTC_M48T35A)
  36. void rtctest(void)
  37. {
  38. volatile uchar *tchar = (uchar*)(CFG_NVRAM_BASE_ADDR + CFG_NVRAM_SIZE - 9);
  39. struct rtc_time tmp;
  40. /* set up led code for RTC tests */
  41. log_stat(ERR_RTCG);
  42. /*
  43. * Do RTC battery test. The first write after power up
  44. * fails if battery is low.
  45. */
  46. *tchar = 0xaa;
  47. if ((*tchar ^ 0xaa) != 0x0) log_warn(ERR_RTCBAT);
  48. *tchar = 0x55; /* Reset test address */
  49. /*
  50. * Now lets check the validity of the values in the RTC.
  51. */
  52. rtc_get(&tmp);
  53. if ((tmp.tm_sec < 0) | (tmp.tm_sec > 59) |
  54. (tmp.tm_min < 0) | (tmp.tm_min > 59) |
  55. (tmp.tm_hour < 0) | (tmp.tm_hour > 23) |
  56. (tmp.tm_mday < 1 ) | (tmp.tm_mday > 31) |
  57. (tmp.tm_mon < 1 ) | (tmp.tm_mon > 12) |
  58. (tmp.tm_year < 2000) | (tmp.tm_year > 2500) |
  59. (tmp.tm_wday < 1 ) | (tmp.tm_wday > 7)) {
  60. log_warn(ERR_RTCTIM);
  61. rtc_reset();
  62. }
  63. /*
  64. * Now lets do a check to see if the NV RAM is there.
  65. */
  66. *tchar = 0xaa;
  67. if ((*tchar ^ 0xaa) != 0x0) log_err(ERR_RTCVAL);
  68. *tchar = 0x55; /* Reset test address */
  69. } /* rtctest() */
  70. #endif /* CONFIG_RTC_M48T35A */
  71. #ifdef CONFIG_DTT_LM75
  72. int dtt_test(int sensor)
  73. {
  74. short temp, trip, hyst;
  75. /* get values */
  76. temp = dtt_read(sensor, DTT_READ_TEMP) / 256;
  77. trip = dtt_read(sensor, DTT_TEMP_SET) / 256;
  78. hyst = dtt_read(sensor, DTT_TEMP_HYST) / 256;
  79. /* check values */
  80. if ((hyst != (CFG_DTT_MAX_TEMP - CFG_DTT_HYSTERESIS)) ||
  81. (trip != CFG_DTT_MAX_TEMP) ||
  82. (temp < CFG_DTT_LOW_TEMP) || (temp > CFG_DTT_MAX_TEMP))
  83. return 1;
  84. return 0;
  85. } /* dtt_test() */
  86. #endif /* CONFIG_DTT_LM75 */
  87. /*****************************************/
  88. void post2(void)
  89. {
  90. #if defined(CONFIG_RTC_M48T35A)
  91. rtctest();
  92. #endif /* CONFIG_RTC_M48T35A */
  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() */