time.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/module.h>
  12. #include <linux/kernel.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/irq.h>
  15. #include <linux/time.h>
  16. #include <linux/io.h>
  17. #include <mach/hardware.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)
  39. {
  40. TIMER_EOI = 0;
  41. timer_tick();
  42. return IRQ_HANDLED;
  43. }
  44. static struct irqaction lh7a40x_timer_irq = {
  45. .name = "LHA740x Timer Tick",
  46. .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
  47. .handler = lh7a40x_timer_interrupt,
  48. };
  49. static void __init lh7a40x_timer_init (void)
  50. {
  51. /* Stop/disable all timers */
  52. TIMER_CONTROL1 = 0;
  53. TIMER_CONTROL2 = 0;
  54. TIMER_CONTROL3 = 0;
  55. setup_irq (TIMER_IRQ, &lh7a40x_timer_irq);
  56. TIMER_LOAD = TIMER_CONSTANT;
  57. TIMER_CONTROL = TIMER_MODE;
  58. }
  59. struct sys_timer lh7a40x_timer = {
  60. .init = &lh7a40x_timer_init,
  61. };