OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-ppc/] [time.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
/*
2
 * Common time prototypes and such for all ppc machines.
3
 *
4
 * Written by Cort Dougan (cort@fsmlabs.com) to merge
5
 * Paul Mackerras' version and mine for PReP and Pmac.
6
 */
7
 
8
#ifdef __KERNEL__
9
#ifndef __ASM_TIME_H__
10
#define __ASM_TIME_H__
11
 
12
#include <linux/config.h>
13
#include <linux/mc146818rtc.h>
14
#include <linux/threads.h>
15
 
16
#include <asm/processor.h>
17
 
18
/* time.c */
19
extern unsigned tb_ticks_per_jiffy;
20
extern unsigned tb_to_us;
21
extern unsigned tb_last_stamp;
22
extern unsigned long disarm_decr[NR_CPUS];
23
 
24
extern void to_tm(int tim, struct rtc_time * tm);
25
extern time_t last_rtc_update;
26
 
27
extern void set_dec_cpu6(unsigned int val);
28
 
29
int via_calibrate_decr(void);
30
 
31
/* Accessor functions for the decrementer register.
32
 * The 40x doesn't even have a decrementer.  I tried to use the
33
 * generic timer interrupt code, which seems OK, with the 40x PIT
34
 * in auto-reload mode.  The problem is PIT stops counting when it
35
 * hits zero.  If it would wrap, we could use it just like a decrementer.
36
 */
37
static __inline__ unsigned int get_dec(void)
38
{
39
#if defined(CONFIG_40x)
40
        return (mfspr(SPRN_PIT));
41
#else
42
        return (mfspr(SPRN_DEC));
43
#endif
44
}
45
 
46
static __inline__ void set_dec(unsigned int val)
47
{
48
#if defined(CONFIG_40x)
49
        return;         /* Have to let it auto-reload */
50
#elif defined(CONFIG_8xx_CPU6)
51
        set_dec_cpu6(val);
52
#else
53
        mtspr(SPRN_DEC, val);
54
#endif
55
}
56
 
57
/* Accessor functions for the timebase (RTC on 601) registers. */
58
/* If one day CONFIG_POWER is added just define __USE_RTC as 1 */
59
#ifdef CONFIG_6xx
60
extern __inline__ int const __USE_RTC(void) {
61
        return (mfspr(SPRN_PVR)>>16) == 1;
62
}
63
#else
64
#define __USE_RTC() 0
65
#endif
66
 
67
extern __inline__ unsigned long get_tbl(void) {
68
        unsigned long tbl;
69
        asm volatile("mftb %0" : "=r" (tbl));
70
        return tbl;
71
}
72
 
73
extern __inline__ unsigned long get_tbu(void) {
74
        unsigned long tbl;
75
        asm volatile("mftbu %0" : "=r" (tbl));
76
        return tbl;
77
}
78
 
79
extern __inline__ void set_tb(unsigned int upper, unsigned int lower)
80
{
81
        mtspr(SPRN_TBWL, 0);
82
        mtspr(SPRN_TBWU, upper);
83
        mtspr(SPRN_TBWL, lower);
84
}
85
 
86
extern __inline__ unsigned long get_rtcl(void) {
87
        unsigned long rtcl;
88
        asm volatile("mfrtcl %0" : "=r" (rtcl));
89
        return rtcl;
90
}
91
 
92
extern __inline__ unsigned get_native_tbl(void) {
93
        if (__USE_RTC())
94
                return get_rtcl();
95
        else
96
                return get_tbl();
97
}
98
 
99
/* On machines with RTC, this function can only be used safely
100
 * after the timestamp and for 1 second. It is only used by gettimeofday
101
 * however so it should not matter.
102
 */
103
extern __inline__ unsigned tb_ticks_since(unsigned tstamp) {
104
        if (__USE_RTC()) {
105
                int delta = get_rtcl() - tstamp;
106
                return delta<0 ? delta + 1000000000 : delta;
107
        } else {
108
                return get_tbl() - tstamp;
109
        }
110
}
111
 
112
#if 0
113
extern __inline__ unsigned long get_bin_rtcl(void) {
114
      unsigned long rtcl, rtcu1, rtcu2;
115
      asm volatile("\
116
1:    mfrtcu  %0\n\
117
      mfrtcl  %1\n\
118
      mfrtcu  %2\n\
119
      cmpw    %0,%2\n\
120
      bne-    1b\n"
121
      : "=r" (rtcu1), "=r" (rtcl), "=r" (rtcu2)
122
      : : "cr0");
123
      return rtcu2*1000000000+rtcl;
124
}
125
 
126
extern __inline__ unsigned binary_tbl(void) {
127
      if (__USE_RTC())
128
              return get_bin_rtcl();
129
      else
130
              return get_tbl();
131
}
132
#endif
133
 
134
/* Use mulhwu to scale processor timebase to timeval */
135
#define mulhwu(x,y) \
136
({unsigned z; asm ("mulhwu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
137
 
138
unsigned mulhwu_scale_factor(unsigned, unsigned);
139
#endif /* __ASM_TIME_H__ */
140
#endif /* __KERNEL__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.