cleanup
[linux-2.4.git] / include / asm-ppc64 / time.h
1 /*
2  * Common time prototypes and such for all ppc machines.
3  *
4  * Written by Cort Dougan (cort@cs.nmt.edu) to merge
5  * Paul Mackerras' version and mine for PReP and Pmac.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version
10  * 2 of the License, or (at your option) any later version.
11  */
12
13 #ifndef __PPC64_TIME_H
14 #define __PPC64_TIME_H
15
16 #ifdef __KERNEL__
17 #include <linux/types.h>
18 #include <linux/mc146818rtc.h>
19
20 #include <asm/processor.h>
21 #include <asm/paca.h>
22 #include <asm/iSeries/HvCall.h>
23
24 /* time.c */
25 extern unsigned long tb_ticks_per_jiffy;
26 extern unsigned long tb_ticks_per_usec;
27 extern unsigned long tb_ticks_per_sec;
28 extern unsigned long tb_to_xs;
29 extern unsigned long tb_last_stamp;
30
31 struct rtc_time;
32 extern void to_tm(int tim, struct rtc_time * tm);
33 extern time_t last_rtc_update;
34
35 struct div_result {
36         unsigned long result_high;
37         unsigned long result_low;
38 };
39
40 int via_calibrate_decr(void);
41
42 static __inline__ unsigned long get_tb(void)
43 {
44         return mftb();
45 }
46
47 /* Accessor functions for the decrementer register. */
48 static __inline__ unsigned int get_dec(void)
49 {
50         return (mfspr(SPRN_DEC));
51 }
52
53 static __inline__ void set_dec(int val)
54 {
55 #ifdef CONFIG_PPC_ISERIES
56         struct paca_struct *lpaca = get_paca();
57         int cur_dec;
58
59         if (lpaca->xLpPaca.xSharedProc) {
60                 lpaca->xLpPaca.xVirtualDecr = val;
61                 cur_dec = get_dec();
62                 lpaca->xLpPaca.xSavedDecr = cur_dec;
63                 if (cur_dec > val)
64                         HvCall_setVirtualDecr();
65         } else
66 #endif
67                 mtspr(SPRN_DEC, val);
68 }
69
70 static inline unsigned long tb_ticks_since(unsigned long tstamp)
71 {
72         return get_tb() - tstamp;
73 }
74
75 #define mulhdu(x,y) \
76 ({unsigned long z; asm ("mulhdu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
77
78 void div128_by_32( unsigned long dividend_high, unsigned long dividend_low,
79                    unsigned divisor, struct div_result *dr );
80 #endif /* __KERNEL__ */
81 #endif /* __PPC64_TIME_H */