timer-of.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 device_node *np;
  31. struct clock_event_device clkevt;
  32. struct of_timer_base of_base;
  33. struct of_timer_irq of_irq;
  34. struct of_timer_clk of_clk;
  35. void *private_data;
  36. };
  37. static inline struct timer_of *to_timer_of(struct clock_event_device *clkevt)
  38. {
  39. return container_of(clkevt, struct timer_of, clkevt);
  40. }
  41. static inline void __iomem *timer_of_base(struct timer_of *to)
  42. {
  43. return to->of_base.base;
  44. }
  45. static inline int timer_of_irq(struct timer_of *to)
  46. {
  47. return to->of_irq.irq;
  48. }
  49. static inline unsigned long timer_of_rate(struct timer_of *to)
  50. {
  51. return to->of_clk.rate;
  52. }
  53. static inline unsigned long timer_of_period(struct timer_of *to)
  54. {
  55. return to->of_clk.period;
  56. }
  57. extern int timer_of_init(struct device_node *np,
  58. struct timer_of *to);
  59. extern void timer_of_cleanup(struct timer_of *to);
  60. #endif