intersil.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:2k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  * arch/m68k/sun3/intersil.c
  3.  *
  4.  * basic routines for accessing the intersil clock within the sun3 machines
  5.  *
  6.  * started 11/12/1999 Sam Creasey
  7.  *
  8.  * This file is subject to the terms and conditions of the GNU General Public
  9.  * License.  See the file COPYING in the main directory of this archive
  10.  * for more details.
  11.  */
  12. #include <linux/kernel.h>
  13. #include <asm/system.h>
  14. #include <asm/rtc.h>
  15. #include <asm/intersil.h>
  16. /* bits to set for start/run of the intersil */
  17. #define STOP_VAL (INTERSIL_STOP | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE)
  18. #define START_VAL (INTERSIL_RUN | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE)
  19. /* does this need to be implemented? */
  20. unsigned long sun3_gettimeoffset(void)
  21.   return 1;
  22. }
  23. void sun3_gettod (int *yearp, int *monp, int *dayp,
  24.                    int *hourp, int *minp, int *secp)
  25. {
  26. unsigned char wday;
  27. volatile struct intersil_dt* todintersil;
  28. unsigned long flags;
  29.         todintersil = (struct intersil_dt *) &intersil_clock->counter;
  30. save_and_cli(flags);
  31. intersil_clock->cmd_reg = STOP_VAL;
  32. *secp  = todintersil->csec;
  33.         *hourp = todintersil->hour;
  34.         *minp  = todintersil->minute;
  35.         *secp  = todintersil->second; 
  36.         *monp  = todintersil->month;
  37.         *dayp  = todintersil->day;
  38.         *yearp = todintersil->year+68; /* The base year for sun3 is 1968 */
  39. wday = todintersil->weekday;
  40. intersil_clock->cmd_reg = START_VAL;
  41. restore_flags(flags);
  42. }
  43. /* get/set hwclock */
  44. int sun3_hwclk(int set, struct hwclk_time *t)
  45. {
  46. volatile struct intersil_dt *todintersil;
  47. unsigned long flags;
  48.         todintersil = (struct intersil_dt *) &intersil_clock->counter;
  49. save_and_cli(flags);
  50. intersil_clock->cmd_reg = STOP_VAL;
  51. /* set or read the clock */
  52. if(set) {
  53. todintersil->csec = 0;
  54. todintersil->hour = t->hour;
  55. todintersil->minute = t->min;
  56. todintersil->second = t->sec;
  57. todintersil->month = t->mon;
  58. todintersil->day = t->day;
  59. todintersil->year = t->year - 68;
  60. todintersil->weekday = t->wday;
  61. } else {
  62. /* read clock */
  63. t->sec = todintersil->csec;
  64. t->hour = todintersil->hour;
  65. t->min = todintersil->minute;
  66. t->sec = todintersil->second;
  67. t->mon = todintersil->month;
  68. t->day = todintersil->day;
  69. t->year = todintersil->year + 68;
  70. t->wday = todintersil->weekday;
  71. }
  72. intersil_clock->cmd_reg = START_VAL;
  73. restore_flags(flags);
  74. return 0;
  75. }