localtimer.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * linux/arch/arm/plat-versatile/localtimer.c
  3. *
  4. * Copyright (C) 2002 ARM Ltd.
  5. * All Rights Reserved
  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/init.h>
  12. #include <linux/smp.h>
  13. #include <linux/clockchips.h>
  14. #include <linux/of.h>
  15. #include <linux/of_address.h>
  16. #include <asm/smp_twd.h>
  17. #include <asm/localtimer.h>
  18. #include <mach/irqs.h>
  19. const static struct of_device_id twd_of_match[] __initconst = {
  20. { .compatible = "arm,cortex-a9-twd-timer", },
  21. { .compatible = "arm,cortex-a5-twd-timer", },
  22. { .compatible = "arm,arm11mp-twd-timer", },
  23. { },
  24. };
  25. /*
  26. * Setup the local clock events for a CPU.
  27. */
  28. int __cpuinit local_timer_setup(struct clock_event_device *evt)
  29. {
  30. #if defined(CONFIG_OF)
  31. static int dt_node_probed;
  32. /* Look for TWD node only once */
  33. if (!dt_node_probed) {
  34. struct device_node *node = of_find_matching_node(NULL,
  35. twd_of_match);
  36. if (node)
  37. twd_base = of_iomap(node, 0);
  38. dt_node_probed = 1;
  39. }
  40. #endif
  41. if (!twd_base)
  42. return -ENXIO;
  43. evt->irq = IRQ_LOCALTIMER;
  44. twd_timer_setup(evt);
  45. return 0;
  46. }