metag: Time keeping
[linux-2.6-block.git] / arch / metag / include / asm / clock.h
1 /*
2  * arch/metag/include/asm/clock.h
3  *
4  * Copyright (C) 2012 Imagination Technologies Ltd.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10
11 #ifndef _METAG_CLOCK_H_
12 #define _METAG_CLOCK_H_
13
14 #include <asm/mach/arch.h>
15
16 /**
17  * struct meta_clock_desc - Meta Core clock callbacks.
18  * @get_core_freq:      Get the frequency of the Meta core. If this is NULL, the
19  *                      core frequency will be determined like this:
20  *                      Meta 1: based on loops_per_jiffy.
21  *                      Meta 2: (EXPAND_TIMER_DIV + 1) MHz.
22  */
23 struct meta_clock_desc {
24         unsigned long           (*get_core_freq)(void);
25 };
26
27 extern struct meta_clock_desc _meta_clock;
28
29 /*
30  * Set up the default clock, ensuring all callbacks are valid - only accessible
31  * during boot.
32  */
33 void setup_meta_clocks(struct meta_clock_desc *desc);
34
35 /**
36  * get_coreclock() - Get the frequency of the Meta core clock.
37  *
38  * Returns:     The Meta core clock frequency in Hz.
39  */
40 static inline unsigned long get_coreclock(void)
41 {
42         /*
43          * Use the current clock callback. If set correctly this will provide
44          * the most accurate frequency as it can be calculated directly from the
45          * PLL configuration. otherwise a default callback will have been set
46          * instead.
47          */
48         return _meta_clock.get_core_freq();
49 }
50
51 #endif /* _METAG_CLOCK_H_ */