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