genrtc.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * A glue layer that provides RTC read/write to drivers/char/genrtc.c driver
  3. * based on MIPS internal RTC routines. It does take care locking
  4. * issues so that we are SMP/Preemption safe.
  5. *
  6. * Copyright (C) 2004 MontaVista Software Inc.
  7. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
  8. *
  9. * Please read the COPYING file for all license details.
  10. */
  11. #include <linux/spinlock.h>
  12. #include <asm/rtc.h>
  13. #include <asm/time.h>
  14. static spinlock_t mips_rtc_lock = SPIN_LOCK_UNLOCKED;
  15. unsigned int get_rtc_time(struct rtc_time *time)
  16. {
  17. unsigned long nowtime;
  18. spin_lock(&mips_rtc_lock);
  19. nowtime = rtc_get_time();
  20. to_tm(nowtime, time);
  21. time->tm_year -= 1900;
  22. spin_unlock(&mips_rtc_lock);
  23. return RTC_24H;
  24. }
  25. int set_rtc_time(struct rtc_time *time)
  26. {
  27. unsigned long nowtime;
  28. int ret;
  29. spin_lock(&mips_rtc_lock);
  30. nowtime = mktime(time->tm_year+1900, time->tm_mon+1,
  31. time->tm_mday, time->tm_hour, time->tm_min,
  32. time->tm_sec);
  33. ret = rtc_set_time(nowtime);
  34. spin_unlock(&mips_rtc_lock);
  35. return ret;
  36. }
  37. unsigned int get_rtc_ss(void)
  38. {
  39. struct rtc_time h;
  40. get_rtc_time(&h);
  41. return h.tm_sec;
  42. }
  43. int get_rtc_pll(struct rtc_pll_info *pll)
  44. {
  45. return -EINVAL;
  46. }
  47. int set_rtc_pll(struct rtc_pll_info *pll)
  48. {
  49. return -EINVAL;
  50. }