time.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * linux/arch/cris/kernel/time.c
  3. *
  4. * Copyright (C) 1991, 1992, 1995 Linus Torvalds
  5. * Copyright (C) 1999, 2000, 2001 Axis Communications AB
  6. *
  7. * 1994-07-02 Alan Modra
  8. * fixed set_rtc_mmss, fixed time.year for >= 2000, new mktime
  9. * 1995-03-26 Markus Kuhn
  10. * fixed 500 ms bug at call to set_rtc_mmss, fixed DS12887
  11. * precision CMOS clock update
  12. * 1996-05-03 Ingo Molnar
  13. * fixed time warps in do_[slow|fast]_gettimeoffset()
  14. * 1997-09-10 Updated NTP code according to technical memorandum Jan '96
  15. * "A Kernel Model for Precision Timekeeping" by Dave Mills
  16. *
  17. * Linux/CRIS specific code:
  18. *
  19. * Authors: Bjorn Wesen
  20. * Johan Adolfsson
  21. *
  22. */
  23. #include <linux/errno.h>
  24. #include <linux/module.h>
  25. #include <linux/param.h>
  26. #include <linux/jiffies.h>
  27. #include <linux/bcd.h>
  28. #include <linux/timex.h>
  29. #include <linux/init.h>
  30. #include <linux/profile.h>
  31. #include <linux/sched.h> /* just for sched_clock() - funny that */
  32. #define D(x)
  33. #define TICK_SIZE tick
  34. extern unsigned long loops_per_jiffy; /* init/main.c */
  35. unsigned long loops_per_usec;
  36. #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
  37. extern unsigned long do_slow_gettimeoffset(void);
  38. static unsigned long (*do_gettimeoffset)(void) = do_slow_gettimeoffset;
  39. u32 arch_gettimeoffset(void)
  40. {
  41. return do_gettimeoffset() * 1000;
  42. }
  43. #endif
  44. int set_rtc_mmss(unsigned long nowtime)
  45. {
  46. D(printk(KERN_DEBUG "set_rtc_mmss(%lu)\n", nowtime));
  47. return 0;
  48. }
  49. /* grab the time from the RTC chip */
  50. unsigned long get_cmos_time(void)
  51. {
  52. return 0;
  53. }
  54. int update_persistent_clock(struct timespec now)
  55. {
  56. return set_rtc_mmss(now.tv_sec);
  57. }
  58. void read_persistent_clock(struct timespec *ts)
  59. {
  60. ts->tv_sec = 0;
  61. ts->tv_nsec = 0;
  62. }
  63. extern void cris_profile_sample(struct pt_regs* regs);
  64. void
  65. cris_do_profile(struct pt_regs* regs)
  66. {
  67. #ifdef CONFIG_SYSTEM_PROFILER
  68. cris_profile_sample(regs);
  69. #endif
  70. #ifdef CONFIG_PROFILING
  71. profile_tick(CPU_PROFILING);
  72. #endif
  73. }
  74. unsigned long long sched_clock(void)
  75. {
  76. return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ) +
  77. get_ns_in_jiffie();
  78. }
  79. static int
  80. __init init_udelay(void)
  81. {
  82. loops_per_usec = (loops_per_jiffy * HZ) / 1000000;
  83. return 0;
  84. }
  85. __initcall(init_udelay);