time.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * BRIEF MODULE DESCRIPTION
  3. * Galileo EV96100 rtc routines.
  4. *
  5. * Copyright 2000 MontaVista Software Inc.
  6. * Author: MontaVista Software, Inc.
  7. * ppopov@mvista.com or source@mvista.com
  8. *
  9. * This file was derived from Carsten Langgaard's
  10. * arch/mips/mips-boards/atlas/atlas_rtc.c.
  11. *
  12. * Carsten Langgaard, carstenl@mips.com
  13. * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
  14. *
  15. * This program is free software; you can redistribute it and/or modify it
  16. * under the terms of the GNU General Public License as published by the
  17. * Free Software Foundation; either version 2 of the License, or (at your
  18. * option) any later version.
  19. *
  20. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  21. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  22. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  23. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  25. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  26. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  27. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  29. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. * You should have received a copy of the GNU General Public License along
  32. * with this program; if not, write to the Free Software Foundation, Inc.,
  33. * 675 Mass Ave, Cambridge, MA 02139, USA.
  34. */
  35. #include <linux/init.h>
  36. #include <linux/kernel_stat.h>
  37. #include <linux/module.h>
  38. #include <linux/sched.h>
  39. #include <linux/spinlock.h>
  40. #include <linux/timex.h>
  41. #include <asm/mipsregs.h>
  42. #include <asm/ptrace.h>
  43. #include <asm/time.h>
  44. #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
  45. extern volatile unsigned long wall_jiffies;
  46. unsigned long missed_heart_beats = 0;
  47. static unsigned long r4k_offset; /* Amount to increment compare reg each time */
  48. static unsigned long r4k_cur; /* What counter should be at next timer irq */
  49. static inline void ack_r4ktimer(unsigned long newval)
  50. {
  51. write_c0_compare(newval);
  52. }
  53. /*
  54. * There are a lot of conceptually broken versions of the MIPS timer interrupt
  55. * handler floating around. This one is rather different, but the algorithm
  56. * is probably more robust.
  57. */
  58. void mips_timer_interrupt(struct pt_regs *regs)
  59. {
  60. int irq = 7; /* FIX ME */
  61. if (r4k_offset == 0) {
  62. goto null;
  63. }
  64. do {
  65. kstat_this_cpu.irqs[irq]++;
  66. do_timer(regs);
  67. #ifndef CONFIG_SMP
  68. update_process_times(user_mode(regs));
  69. #endif
  70. r4k_cur += r4k_offset;
  71. ack_r4ktimer(r4k_cur);
  72. } while (((unsigned long)read_c0_count()
  73. - r4k_cur) < 0x7fffffff);
  74. return;
  75. null:
  76. ack_r4ktimer(0);
  77. }