timer-of.h 1.3 KB

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