timer.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2011
  3. *
  4. * License Terms: GNU General Public License v2
  5. * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson
  6. */
  7. #include <linux/io.h>
  8. #include <linux/clksrc-dbx500-prcmu.h>
  9. #include <asm/localtimer.h>
  10. #include <plat/mtu.h>
  11. #include <mach/setup.h>
  12. #include <mach/hardware.h>
  13. static void __init ux500_timer_init(void)
  14. {
  15. if (cpu_is_u5500()) {
  16. #ifdef CONFIG_LOCAL_TIMERS
  17. twd_base = __io_address(U5500_TWD_BASE);
  18. #endif
  19. mtu_base = __io_address(U5500_MTU0_BASE);
  20. clksrc_dbx500_timer_base = __io_address(U5500_PRCMU_TIMER_3_BASE);
  21. } else if (cpu_is_u8500()) {
  22. #ifdef CONFIG_LOCAL_TIMERS
  23. twd_base = __io_address(U8500_TWD_BASE);
  24. #endif
  25. mtu_base = __io_address(U8500_MTU0_BASE);
  26. clksrc_dbx500_timer_base = __io_address(U8500_PRCMU_TIMER_4_BASE);
  27. } else {
  28. ux500_unknown_soc();
  29. }
  30. /*
  31. * Here we register the timerblocks active in the system.
  32. * Localtimers (twd) is started when both cpu is up and running.
  33. * MTU register a clocksource, clockevent and sched_clock.
  34. * Since the MTU is located in the VAPE power domain
  35. * it will be cleared in sleep which makes it unsuitable.
  36. * We however need it as a timer tick (clockevent)
  37. * during boot to calibrate delay until twd is started.
  38. * RTC-RTT have problems as timer tick during boot since it is
  39. * depending on delay which is not yet calibrated. RTC-RTT is in the
  40. * always-on powerdomain and is used as clockevent instead of twd when
  41. * sleeping.
  42. * The PRCMU timer 4(3 for DB5500) register a clocksource and
  43. * sched_clock with higher rating then MTU since is always-on.
  44. *
  45. */
  46. nmdk_timer_init();
  47. clksrc_dbx500_prcmu_init();
  48. }
  49. struct sys_timer ux500_timer = {
  50. .init = ux500_timer_init,
  51. };