time.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * linux/arch/arm/mach-w90x900/time.c
  3. *
  4. * Based on linux/arch/arm/plat-s3c24xx/time.c by Ben Dooks
  5. *
  6. * Copyright (c) 2008 Nuvoton technology corporation
  7. * All rights reserved.
  8. *
  9. * Wan ZongShun <mcuos.com@gmail.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/sched.h>
  19. #include <linux/init.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/err.h>
  22. #include <linux/clk.h>
  23. #include <linux/io.h>
  24. #include <linux/leds.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/irq.h>
  27. #include <asm/mach/time.h>
  28. #include <mach/system.h>
  29. #include <mach/map.h>
  30. #include <mach/regs-timer.h>
  31. static unsigned long w90x900_gettimeoffset(void)
  32. {
  33. return 0;
  34. }
  35. /*IRQ handler for the timer*/
  36. static irqreturn_t
  37. w90x900_timer_interrupt(int irq, void *dev_id)
  38. {
  39. timer_tick();
  40. __raw_writel(0x01, REG_TISR); /* clear TIF0 */
  41. return IRQ_HANDLED;
  42. }
  43. static struct irqaction w90x900_timer_irq = {
  44. .name = "w90x900 Timer Tick",
  45. .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
  46. .handler = w90x900_timer_interrupt,
  47. };
  48. /*Set up timer reg.*/
  49. static void w90x900_timer_setup(void)
  50. {
  51. __raw_writel(0, REG_TCSR0);
  52. __raw_writel(0, REG_TCSR1);
  53. __raw_writel(0, REG_TCSR2);
  54. __raw_writel(0, REG_TCSR3);
  55. __raw_writel(0, REG_TCSR4);
  56. __raw_writel(0x1F, REG_TISR);
  57. __raw_writel(15000000/(100 * 100), REG_TICR0);
  58. __raw_writel(0x68000063, REG_TCSR0);
  59. }
  60. static void __init w90x900_timer_init(void)
  61. {
  62. w90x900_timer_setup();
  63. setup_irq(IRQ_TIMER0, &w90x900_timer_irq);
  64. }
  65. struct sys_timer w90x900_timer = {
  66. .init = w90x900_timer_init,
  67. .offset = w90x900_gettimeoffset,
  68. .resume = w90x900_timer_setup
  69. };