Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / include / asm-xtensa / timex.h
blob239f5aeadba67b339b1721604414bf8fa199d57d
1 /*
2 * include/asm-xtensa/timex.h
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
11 #ifndef _XTENSA_TIMEX_H
12 #define _XTENSA_TIMEX_H
14 #ifdef __KERNEL__
16 #include <asm/processor.h>
17 #include <linux/stringify.h>
19 #define _INTLEVEL(x) XCHAL_INT ## x ## _LEVEL
20 #define INTLEVEL(x) _INTLEVEL(x)
22 #if INTLEVEL(XCHAL_TIMER0_INTERRUPT) == 1
23 # define LINUX_TIMER 0
24 # define LINUX_TIMER_INT XCHAL_TIMER0_INTERRUPT
25 #elif INTLEVEL(XCHAL_TIMER1_INTERRUPT) == 1
26 # define LINUX_TIMER 1
27 # define LINUX_TIMER_INT XCHAL_TIMER1_INTERRUPT
28 #elif INTLEVEL(XCHAL_TIMER2_INTERRUPT) == 1
29 # define LINUX_TIMER 2
30 # define LINUX_TIMER_INT XCHAL_TIMER2_INTERRUPT
31 #else
32 # error "Bad timer number for Linux configurations!"
33 #endif
35 #define LINUX_TIMER_MASK (1L << LINUX_TIMER_INT)
37 #define CLOCK_TICK_RATE 1193180 /* (everyone is using this value) */
38 #define CLOCK_TICK_FACTOR 20 /* Factor of both 10^6 and CLOCK_TICK_RATE */
40 #ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT
41 extern unsigned long ccount_per_jiffy;
42 extern unsigned long ccount_nsec;
43 #define CCOUNT_PER_JIFFY ccount_per_jiffy
44 #define NSEC_PER_CCOUNT ccount_nsec
45 #else
46 #define CCOUNT_PER_JIFFY (CONFIG_XTENSA_CPU_CLOCK*(1000000UL/HZ))
47 #define NSEC_PER_CCOUNT (1000UL / CONFIG_XTENSA_CPU_CLOCK)
48 #endif
51 typedef unsigned long long cycles_t;
54 * Only used for SMP.
57 extern cycles_t cacheflush_time;
59 #define get_cycles() (0)
63 * Register access.
66 <<<<<<< HEAD:include/asm-xtensa/timex.h
67 #define WSR_CCOUNT(r) __asm__("wsr %0,"__stringify(CCOUNT) :: "a" (r))
68 #define RSR_CCOUNT(r) __asm__("rsr %0,"__stringify(CCOUNT) : "=a" (r))
69 #define WSR_CCOMPARE(x,r) __asm__("wsr %0,"__stringify(CCOMPARE)"+"__stringify(x) :: "a"(r))
70 #define RSR_CCOMPARE(x,r) __asm__("rsr %0,"__stringify(CCOMPARE)"+"__stringify(x) : "=a"(r))
71 =======
72 #define WSR_CCOUNT(r) asm volatile ("wsr %0,"__stringify(CCOUNT) :: "a" (r))
73 #define RSR_CCOUNT(r) asm volatile ("rsr %0,"__stringify(CCOUNT) : "=a" (r))
74 #define WSR_CCOMPARE(x,r) asm volatile ("wsr %0,"__stringify(CCOMPARE)"+"__stringify(x) :: "a"(r))
75 #define RSR_CCOMPARE(x,r) asm volatile ("rsr %0,"__stringify(CCOMPARE)"+"__stringify(x) : "=a"(r))
76 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:include/asm-xtensa/timex.h
78 static inline unsigned long get_ccount (void)
80 unsigned long ccount;
81 RSR_CCOUNT(ccount);
82 return ccount;
85 static inline void set_ccount (unsigned long ccount)
87 WSR_CCOUNT(ccount);
90 static inline unsigned long get_linux_timer (void)
92 unsigned ccompare;
93 RSR_CCOMPARE(LINUX_TIMER, ccompare);
94 return ccompare;
97 static inline void set_linux_timer (unsigned long ccompare)
99 WSR_CCOMPARE(LINUX_TIMER, ccompare);
102 #endif /* __KERNEL__ */
103 #endif /* _XTENSA_TIMEX_H */