dc21285-timer.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * linux/arch/arm/mach-footbridge/dc21285-timer.c
  3. *
  4. * Copyright (C) 1998 Russell King.
  5. * Copyright (C) 1998 Phil Blundell
  6. */
  7. #include <linux/init.h>
  8. #include <linux/interrupt.h>
  9. #include <linux/irq.h>
  10. #include <asm/irq.h>
  11. #include <asm/hardware/dec21285.h>
  12. #include <asm/mach/time.h>
  13. #include "common.h"
  14. /*
  15. * Footbridge timer 1 support.
  16. */
  17. static unsigned long timer1_latch;
  18. static unsigned long timer1_gettimeoffset (void)
  19. {
  20. unsigned long value = timer1_latch - *CSR_TIMER1_VALUE;
  21. return ((tick_nsec / 1000) * value) / timer1_latch;
  22. }
  23. static irqreturn_t
  24. timer1_interrupt(int irq, void *dev_id)
  25. {
  26. write_seqlock(&xtime_lock);
  27. *CSR_TIMER1_CLR = 0;
  28. timer_tick();
  29. write_sequnlock(&xtime_lock);
  30. return IRQ_HANDLED;
  31. }
  32. static struct irqaction footbridge_timer_irq = {
  33. .name = "Timer1 timer tick",
  34. .handler = timer1_interrupt,
  35. .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
  36. };
  37. /*
  38. * Set up timer interrupt.
  39. */
  40. static void __init footbridge_timer_init(void)
  41. {
  42. timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
  43. *CSR_TIMER1_CLR = 0;
  44. *CSR_TIMER1_LOAD = timer1_latch;
  45. *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
  46. setup_irq(IRQ_TIMER1, &footbridge_timer_irq);
  47. isa_rtc_init();
  48. }
  49. struct sys_timer footbridge_timer = {
  50. .init = footbridge_timer_init,
  51. .offset = timer1_gettimeoffset,
  52. };