timer-of.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef __TIMER_OF_H__
  2. #define __TIMER_OF_H__
  3. #include <linux/clockchips.h>
  4. #define TIMER_OF_BASE 0x1
  5. #define TIMER_OF_CLOCK 0x2
  6. #define TIMER_OF_IRQ 0x4
  7. struct of_timer_irq {
  8. int irq;
  9. int index;
  10. int percpu;
  11. const char *name;
  12. unsigned long flags;
  13. irq_handler_t handler;
  14. };
  15. struct of_timer_base {
  16. void __iomem *base;
  17. const char *name;
  18. int index;
  19. };
  20. struct of_timer_clk {
  21. struct clk *clk;
  22. const char *name;
  23. int index;
  24. unsigned long rate;
  25. unsigned long period;
  26. };
  27. struct timer_of {
  28. unsigned int flags;
  29. struct clock_event_device clkevt;
  30. struct of_timer_base of_base;
  31. struct of_timer_irq of_irq;
  32. struct of_timer_clk of_clk;
  33. void *private_data;
  34. };
  35. static inline struct timer_of *to_timer_of(struct clock_event_device *clkevt)
  36. {
  37. return container_of(clkevt, struct timer_of, clkevt);
  38. }
  39. static inline void __iomem *timer_of_base(struct timer_of *to)
  40. {
  41. return to->of_base.base;
  42. }
  43. static inline int timer_of_irq(struct timer_of *to)
  44. {
  45. return to->of_irq.irq;
  46. }
  47. static inline unsigned long timer_of_rate(struct timer_of *to)
  48. {
  49. return to->of_clk.rate;
  50. }
  51. static inline unsigned long timer_of_period(struct timer_of *to)
  52. {
  53. return to->of_clk.period;
  54. }
  55. extern int __init timer_of_init(struct device_node *np,
  56. struct timer_of *to);
  57. #endif