time.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * linux/arch/arm/mach-epxa10db/time.c
  3. *
  4. * Copyright (C) 2000 Deep Blue Solutions
  5. * Copyright (C) 2001 Altera Corporation
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/sched.h>
  15. #include <asm/hardware.h>
  16. #include <asm/system.h>
  17. #include <asm/leds.h>
  18. #include <asm/mach/time.h>
  19. #define TIMER00_TYPE (volatile unsigned int*)
  20. #include <asm/arch/timer00.h>
  21. static int epxa10db_set_rtc(void)
  22. {
  23. return 1;
  24. }
  25. static int epxa10db_rtc_init(void)
  26. {
  27. set_rtc = epxa10db_set_rtc;
  28. return 0;
  29. }
  30. __initcall(epxa10db_rtc_init);
  31. /*
  32. * IRQ handler for the timer
  33. */
  34. static irqreturn_t
  35. epxa10db_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  36. {
  37. write_seqlock(&xtime_lock);
  38. // ...clear the interrupt
  39. *TIMER0_CR(IO_ADDRESS(EXC_TIMER00_BASE))|=TIMER0_CR_CI_MSK;
  40. timer_tick(regs);
  41. write_sequnlock(&xtime_lock);
  42. return IRQ_HANDLED;
  43. }
  44. static struct irqaction epxa10db_timer_irq = {
  45. .name = "Excalibur Timer Tick",
  46. .flags = SA_INTERRUPT | SA_TIMER,
  47. .handler = epxa10db_timer_interrupt,
  48. };
  49. /*
  50. * Set up timer interrupt, and return the current time in seconds.
  51. */
  52. static void __init epxa10db_timer_init(void)
  53. {
  54. /* Start the timer */
  55. *TIMER0_LIMIT(IO_ADDRESS(EXC_TIMER00_BASE))=(unsigned int)(EXC_AHB2_CLK_FREQUENCY/200);
  56. *TIMER0_PRESCALE(IO_ADDRESS(EXC_TIMER00_BASE))=1;
  57. *TIMER0_CR(IO_ADDRESS(EXC_TIMER00_BASE))=TIMER0_CR_IE_MSK | TIMER0_CR_S_MSK;
  58. setup_irq(IRQ_TIMER0, &epxa10db_timer_irq);
  59. }
  60. struct sys_timer epxa10db_timer = {
  61. .init = epxa10db_timer_init,
  62. };