Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __TIMER_OF_H__
0003 #define __TIMER_OF_H__
0004 
0005 #include <linux/clockchips.h>
0006 
0007 #define TIMER_OF_BASE   0x1
0008 #define TIMER_OF_CLOCK  0x2
0009 #define TIMER_OF_IRQ    0x4
0010 
0011 struct of_timer_irq {
0012     int irq;
0013     int index;
0014     int percpu;
0015     const char *name;
0016     unsigned long flags;
0017     irq_handler_t handler;
0018 };
0019 
0020 struct of_timer_base {
0021     void __iomem *base;
0022     const char *name;
0023     int index;
0024 };
0025 
0026 struct of_timer_clk {
0027     struct clk *clk;
0028     const char *name;
0029     int index;
0030     unsigned long rate;
0031     unsigned long period;
0032 };
0033 
0034 struct timer_of {
0035     unsigned int flags;
0036     struct device_node *np;
0037     struct clock_event_device clkevt;
0038     struct of_timer_base of_base;
0039     struct of_timer_irq  of_irq;
0040     struct of_timer_clk  of_clk;
0041     void *private_data;
0042 };
0043 
0044 static inline struct timer_of *to_timer_of(struct clock_event_device *clkevt)
0045 {
0046     return container_of(clkevt, struct timer_of, clkevt);
0047 }
0048 
0049 static inline void __iomem *timer_of_base(struct timer_of *to)
0050 {
0051     return to->of_base.base;
0052 }
0053 
0054 static inline int timer_of_irq(struct timer_of *to)
0055 {
0056     return to->of_irq.irq;
0057 }
0058 
0059 static inline unsigned long timer_of_rate(struct timer_of *to)
0060 {
0061     return to->of_clk.rate;
0062 }
0063 
0064 static inline unsigned long timer_of_period(struct timer_of *to)
0065 {
0066     return to->of_clk.period;
0067 }
0068 
0069 extern int __init timer_of_init(struct device_node *np,
0070                 struct timer_of *to);
0071 
0072 extern void __init timer_of_cleanup(struct timer_of *to);
0073 
0074 #endif