timer.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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/errno.h>
  9. #include <linux/clksrc-dbx500-prcmu.h>
  10. #include <asm/localtimer.h>
  11. #include <plat/mtu.h>
  12. #include <mach/setup.h>
  13. #include <mach/hardware.h>
  14. static void __init ux500_timer_init(void)
  15. {
  16. void __iomem *prcmu_timer_base;
  17. if (cpu_is_u5500()) {
  18. #ifdef CONFIG_LOCAL_TIMERS
  19. twd_base = __io_address(U5500_TWD_BASE);
  20. #endif
  21. mtu_base = __io_address(U5500_MTU0_BASE);
  22. prcmu_timer_base = __io_address(U5500_PRCMU_TIMER_3_BASE);
  23. } else if (cpu_is_u8500()) {
  24. #ifdef CONFIG_LOCAL_TIMERS
  25. twd_base = __io_address(U8500_TWD_BASE);
  26. #endif
  27. mtu_base = __io_address(U8500_MTU0_BASE);
  28. prcmu_timer_base = __io_address(U8500_PRCMU_TIMER_4_BASE);
  29. } else {
  30. ux500_unknown_soc();
  31. }
  32. /*
  33. * Here we register the timerblocks active in the system.
  34. * Localtimers (twd) is started when both cpu is up and running.
  35. * MTU register a clocksource, clockevent and sched_clock.
  36. * Since the MTU is located in the VAPE power domain
  37. * it will be cleared in sleep which makes it unsuitable.
  38. * We however need it as a timer tick (clockevent)
  39. * during boot to calibrate delay until twd is started.
  40. * RTC-RTT have problems as timer tick during boot since it is
  41. * depending on delay which is not yet calibrated. RTC-RTT is in the
  42. * always-on powerdomain and is used as clockevent instead of twd when
  43. * sleeping.
  44. * The PRCMU timer 4(3 for DB5500) register a clocksource and
  45. * sched_clock with higher rating then MTU since is always-on.
  46. *
  47. */
  48. nmdk_timer_init();
  49. clksrc_dbx500_prcmu_init(prcmu_timer_base);
  50. }
  51. static void ux500_timer_reset(void)
  52. {
  53. nmdk_clkevt_reset();
  54. nmdk_clksrc_reset();
  55. }
  56. struct sys_timer ux500_timer = {
  57. .init = ux500_timer_init,
  58. .resume = ux500_timer_reset,
  59. };