time.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * arch/arm/mach-lh7a40x/time.c
  3. *
  4. * Copyright (C) 2004 Logic Product Development
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. */
  11. #include <linux/config.h>
  12. #include <linux/module.h>
  13. #include <linux/kernel.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/time.h>
  16. #include <asm/hardware.h>
  17. #include <asm/io.h>
  18. #include <asm/irq.h>
  19. #include <asm/leds.h>
  20. #include <asm/mach/time.h>
  21. #include "common.h"
  22. #if HZ < 100
  23. # define TIMER_CONTROL TIMER_CONTROL2
  24. # define TIMER_LOAD TIMER_LOAD2
  25. # define TIMER_CONSTANT (508469/HZ)
  26. # define TIMER_MODE (TIMER_C_ENABLE | TIMER_C_PERIODIC | TIMER_C_508KHZ)
  27. # define TIMER_EOI TIMER_EOI2
  28. # define TIMER_IRQ IRQ_T2UI
  29. #else
  30. # define TIMER_CONTROL TIMER_CONTROL3
  31. # define TIMER_LOAD TIMER_LOAD3
  32. # define TIMER_CONSTANT (3686400/HZ)
  33. # define TIMER_MODE (TIMER_C_ENABLE | TIMER_C_PERIODIC)
  34. # define TIMER_EOI TIMER_EOI3
  35. # define TIMER_IRQ IRQ_T3UI
  36. #endif
  37. static irqreturn_t
  38. lh7a40x_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  39. {
  40. write_seqlock(&xtime_lock);
  41. TIMER_EOI = 0;
  42. timer_tick(regs);
  43. write_sequnlock(&xtime_lock);
  44. return IRQ_HANDLED;
  45. }
  46. static struct irqaction lh7a40x_timer_irq = {
  47. .name = "LHA740x Timer Tick",
  48. .flags = SA_INTERRUPT | SA_TIMER,
  49. .handler = lh7a40x_timer_interrupt,
  50. };
  51. static void __init lh7a40x_timer_init(void)
  52. {
  53. /* Stop/disable all timers */
  54. TIMER_CONTROL1 = 0;
  55. TIMER_CONTROL2 = 0;
  56. TIMER_CONTROL3 = 0;
  57. setup_irq (TIMER_IRQ, &lh7a40x_timer_irq);
  58. TIMER_LOAD = TIMER_CONSTANT;
  59. TIMER_CONTROL = TIMER_MODE;
  60. }
  61. struct sys_timer lh7a40x_timer = {
  62. .init = &lh7a40x_timer_init,
  63. };