dc21285-timer.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. *CSR_TIMER1_CLR = 0;
  27. timer_tick();
  28. return IRQ_HANDLED;
  29. }
  30. static struct irqaction footbridge_timer_irq = {
  31. .name = "Timer1 timer tick",
  32. .handler = timer1_interrupt,
  33. .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
  34. };
  35. /*
  36. * Set up timer interrupt.
  37. */
  38. static void __init footbridge_timer_init(void)
  39. {
  40. timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
  41. *CSR_TIMER1_CLR = 0;
  42. *CSR_TIMER1_LOAD = timer1_latch;
  43. *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
  44. setup_irq(IRQ_TIMER1, &footbridge_timer_irq);
  45. isa_rtc_init();
  46. }
  47. struct sys_timer footbridge_timer = {
  48. .init = footbridge_timer_init,
  49. .offset = timer1_gettimeoffset,
  50. };