~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/include/asm-ppc/time.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * $Id: time.h,v 1.12 1999/08/27 04:21:23 cort Exp $
  3  * Common time prototypes and such for all ppc machines.
  4  *
  5  * Written by Cort Dougan (cort@cs.nmt.edu) to merge
  6  * Paul Mackerras' version and mine for PReP and Pmac.
  7  */
  8 
  9 #ifdef __KERNEL__
 10 #include <linux/config.h>
 11 #include <linux/mc146818rtc.h>
 12 
 13 #include <asm/processor.h>
 14 
 15 /* time.c */
 16 extern unsigned tb_ticks_per_jiffy;
 17 extern unsigned tb_to_us;
 18 extern unsigned tb_last_stamp;
 19 
 20 extern void to_tm(int tim, struct rtc_time * tm);
 21 extern time_t last_rtc_update;
 22 
 23 int via_calibrate_decr(void);
 24 
 25 /* Accessor functions for the decrementer register. */
 26 static __inline__ unsigned int get_dec(void)
 27 {
 28 #if defined(CONFIG_4xx)
 29         return (mfspr(SPRN_PIT));
 30 #else
 31         return (mfspr(SPRN_DEC));
 32 #endif
 33 }
 34 
 35 static __inline__ void set_dec(unsigned int val)
 36 {
 37 #if defined(CONFIG_4xx)
 38         mtspr(SPRN_PIT, val);
 39 #else
 40 #ifdef CONFIG_8xx_CPU6
 41         set_dec_cpu6(val);
 42 #else
 43         mtspr(SPRN_DEC, val);
 44 #endif
 45 #endif
 46 }
 47 
 48 /* Accessor functions for the timebase (RTC on 601) registers. */
 49 /* If one day CONFIG_POWER is added just define __USE_RTC as 1 */
 50 #ifdef CONFIG_6xx
 51 extern __inline__ int const __USE_RTC(void) {
 52         return (mfspr(SPRN_PVR)>>16) == 1;
 53 }
 54 #else
 55 #define __USE_RTC() 0
 56 #endif
 57 
 58 extern __inline__ unsigned long get_tbl(void) {
 59         unsigned long tbl;
 60         asm volatile("mftb %0" : "=r" (tbl));
 61         return tbl;
 62 }
 63 
 64 extern __inline__ unsigned long get_rtcl(void) {
 65         unsigned long rtcl;
 66         asm volatile("mfrtcl %0" : "=r" (rtcl));
 67         return rtcl;
 68 }
 69 
 70 extern __inline__ unsigned get_native_tbl(void) {
 71         if (__USE_RTC())
 72                 return get_rtcl();
 73         else
 74                 return get_tbl();
 75 }
 76 
 77 /* On machines with RTC, this function can only be used safely
 78  * after the timestamp and for 1 second. It is only used by gettimeofday
 79  * however so it should not matter.
 80  */
 81 extern __inline__ unsigned tb_ticks_since(unsigned tstamp) {
 82         if (__USE_RTC()) {
 83                 int delta = get_rtcl() - tstamp;
 84                 return delta<0 ? delta + 1000000000 : delta;
 85         } else {
 86                 return get_tbl() - tstamp;
 87         }
 88 }
 89 
 90 #if 0
 91 extern __inline__ unsigned long get_bin_rtcl(void) {
 92       unsigned long rtcl, rtcu1, rtcu2;
 93       asm volatile("\
 94 1:    mfrtcu  %0\n\
 95       mfrtcl  %1\n\
 96       mfrtcu  %2\n\
 97       cmpw    %0,%2\n\
 98       bne-    1b\n"
 99       : "=r" (rtcu1), "=r" (rtcl), "=r" (rtcu2)
100       : : "cr0");
101       return rtcu2*1000000000+rtcl;
102 }
103 
104 extern __inline__ unsigned binary_tbl(void) {
105       if (__USE_RTC())
106               return get_bin_rtcl();
107       else
108               return get_tbl();
109 }
110 #endif
111 
112 /* Use mulhwu to scale processor timebase to timeval */
113 #define mulhwu(x,y) \
114 ({unsigned z; asm ("mulhwu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
115 
116 unsigned mulhwu_scale_factor(unsigned, unsigned);
117 #endif /* __KERNEL__ */
118 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.