timer.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * arch/sh/kernel/timers/timer.c - Common timer code
  3. *
  4. * Copyright (C) 2005 Paul Mundt
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/timer.h>
  13. #include <linux/string.h>
  14. #include <asm/timer.h>
  15. static struct sys_timer *sys_timers[] = {
  16. #ifdef CONFIG_SH_TMU
  17. &tmu_timer,
  18. #endif
  19. #ifdef CONFIG_SH_MTU2
  20. &mtu2_timer,
  21. #endif
  22. #ifdef CONFIG_SH_CMT
  23. &cmt_timer,
  24. #endif
  25. NULL,
  26. };
  27. static char timer_override[10];
  28. static int __init timer_setup(char *str)
  29. {
  30. if (str)
  31. strlcpy(timer_override, str, sizeof(timer_override));
  32. return 1;
  33. }
  34. __setup("timer=", timer_setup);
  35. struct sys_timer *get_sys_timer(void)
  36. {
  37. int i;
  38. for (i = 0; i < ARRAY_SIZE(sys_timers); i++) {
  39. struct sys_timer *t = sys_timers[i];
  40. if (unlikely(!t))
  41. break;
  42. if (unlikely(timer_override[0]))
  43. if ((strcmp(timer_override, t->name) != 0))
  44. continue;
  45. if (likely(t->ops->init() == 0))
  46. return t;
  47. }
  48. return NULL;
  49. }