intersil.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

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 <linux/rtc.h>
  14. #include <asm/system.h>
  15. #include <asm/rtc.h>
  16. #include <asm/intersil.h>
  17. /* bits to set for start/run of the intersil */
  18. #define STOP_VAL (INTERSIL_STOP | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE)
  19. #define START_VAL (INTERSIL_RUN | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE)
  20. /* does this need to be implemented? */
  21. unsigned long sun3_gettimeoffset(void)
  22.   return 1;
  23. }
  24. void sun3_gettod (int *yearp, int *monp, int *dayp,
  25.                    int *hourp, int *minp, int *secp)
  26. {
  27. unsigned char wday;
  28. volatile struct intersil_dt* todintersil;
  29. unsigned long flags;
  30.         todintersil = (struct intersil_dt *) &intersil_clock->counter;
  31. save_and_cli(flags);
  32. intersil_clock->cmd_reg = STOP_VAL;
  33. *secp  = todintersil->csec;
  34.         *hourp = todintersil->hour;
  35.         *minp  = todintersil->minute;
  36.         *secp  = todintersil->second; 
  37.         *monp  = todintersil->month;
  38.         *dayp  = todintersil->day;
  39.         *yearp = todintersil->year+68; /* The base year for sun3 is 1968 */
  40. wday = todintersil->weekday;
  41. intersil_clock->cmd_reg = START_VAL;
  42. restore_flags(flags);
  43. }
  44. /* get/set hwclock */
  45. int sun3_hwclk(int set, struct rtc_time *t)
  46. {
  47. volatile struct intersil_dt *todintersil;
  48. unsigned long flags;
  49.         todintersil = (struct intersil_dt *) &intersil_clock->counter;
  50. save_and_cli(flags);
  51. intersil_clock->cmd_reg = STOP_VAL;
  52. /* set or read the clock */
  53. if(set) {
  54. todintersil->csec = 0;
  55. todintersil->hour = t->tm_hour;
  56. todintersil->minute = t->tm_min;
  57. todintersil->second = t->tm_sec;
  58. todintersil->month = t->tm_mon;
  59. todintersil->day = t->tm_mday;
  60. todintersil->year = t->tm_year - 68;
  61. todintersil->weekday = t->tm_wday;
  62. } else {
  63. /* read clock */
  64. t->tm_sec = todintersil->csec;
  65. t->tm_hour = todintersil->hour;
  66. t->tm_min = todintersil->minute;
  67. t->tm_sec = todintersil->second;
  68. t->tm_mon = todintersil->month;
  69. t->tm_mday = todintersil->day;
  70. t->tm_year = todintersil->year + 68;
  71. t->tm_wday = todintersil->weekday;
  72. }
  73. intersil_clock->cmd_reg = START_VAL;
  74. restore_flags(flags);
  75. return 0;
  76. }