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