dc21285-timer.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 <asm/irq.h>
  10. #include <asm/hardware/dec21285.h>
  11. #include <asm/mach/time.h>
  12. #include "common.h"
  13. /*
  14. * Footbridge timer 1 support.
  15. */
  16. static unsigned long timer1_latch;
  17. static unsigned long timer1_gettimeoffset (void)
  18. {
  19. unsigned long value = timer1_latch - *CSR_TIMER1_VALUE;
  20. return ((tick_nsec / 1000) * value) / timer1_latch;
  21. }
  22. static irqreturn_t
  23. timer1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  24. {
  25. write_seqlock(&xtime_lock);
  26. *CSR_TIMER1_CLR = 0;
  27. timer_tick(regs);
  28. write_sequnlock(&xtime_lock);
  29. return IRQ_HANDLED;
  30. }
  31. static struct irqaction footbridge_timer_irq = {
  32. .name = "Timer1 timer tick",
  33. .handler = timer1_interrupt,
  34. .flags = SA_INTERRUPT | SA_TIMER,
  35. };
  36. /*
  37. * Set up timer interrupt.
  38. */
  39. static void __init footbridge_timer_init(void)
  40. {
  41. timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
  42. *CSR_TIMER1_CLR = 0;
  43. *CSR_TIMER1_LOAD = timer1_latch;
  44. *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
  45. setup_irq(IRQ_TIMER1, &footbridge_timer_irq);
  46. isa_rtc_init();
  47. }
  48. struct sys_timer footbridge_timer = {
  49. .init = footbridge_timer_init,
  50. .offset = timer1_gettimeoffset,
  51. };