hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/powerpc/include/asm/time.h
....@@ -1,13 +1,9 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Common time prototypes and such for all ppc machines.
34 *
45 * Written by Cort Dougan (cort@cs.nmt.edu) to merge
56 * 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.
117 */
128
139 #ifndef __POWERPC_TIME_H
....@@ -28,7 +24,6 @@
2824
2925
3026 extern void generic_calibrate_decr(void);
31
-extern void hdec_interrupt(struct pt_regs *regs);
3227
3328 /* Some sane defaults: 125 MHz timebase, 1GHz processor */
3429 extern unsigned long ppc_proc_freq;
....@@ -36,66 +31,17 @@
3631 extern unsigned long ppc_tb_freq;
3732 #define DEFAULT_TB_FREQ 125000000UL
3833
34
+extern bool tb_invalid;
35
+
3936 struct div_result {
4037 u64 result_high;
4138 u64 result_low;
4239 };
4340
44
-/* Accessor functions for the timebase (RTC on 601) registers. */
45
-/* If one day CONFIG_POWER is added just define __USE_RTC as 1 */
46
-#ifdef CONFIG_6xx
47
-#define __USE_RTC() (cpu_has_feature(CPU_FTR_USE_RTC))
48
-#else
49
-#define __USE_RTC() 0
50
-#endif
51
-
52
-#ifdef CONFIG_PPC64
53
-
5441 /* For compatibility, get_tbl() is defined as get_tb() on ppc64 */
55
-#define get_tbl get_tb
56
-
57
-#else
58
-
5942 static inline unsigned long get_tbl(void)
6043 {
61
-#if defined(CONFIG_403GCX)
62
- unsigned long tbl;
63
- asm volatile("mfspr %0, 0x3dd" : "=r" (tbl));
64
- return tbl;
65
-#else
66
- return mftbl();
67
-#endif
68
-}
69
-
70
-static inline unsigned int get_tbu(void)
71
-{
72
-#ifdef CONFIG_403GCX
73
- unsigned int tbu;
74
- asm volatile("mfspr %0, 0x3dc" : "=r" (tbu));
75
- return tbu;
76
-#else
77
- return mftbu();
78
-#endif
79
-}
80
-#endif /* !CONFIG_PPC64 */
81
-
82
-static inline unsigned int get_rtcl(void)
83
-{
84
- unsigned int rtcl;
85
-
86
- asm volatile("mfrtcl %0" : "=r" (rtcl));
87
- return rtcl;
88
-}
89
-
90
-static inline u64 get_rtc(void)
91
-{
92
- unsigned int hi, lo, hi2;
93
-
94
- do {
95
- asm volatile("mfrtcu %0; mfrtcl %1; mfrtcu %2"
96
- : "=r" (hi), "=r" (lo), "=r" (hi2));
97
- } while (hi2 != hi);
98
- return (u64)hi * 1000000000 + lo;
44
+ return mftb();
9945 }
10046
10147 static inline u64 get_vtb(void)
....@@ -107,29 +53,20 @@
10753 return 0;
10854 }
10955
110
-#ifdef CONFIG_PPC64
111
-static inline u64 get_tb(void)
112
-{
113
- return mftb();
114
-}
115
-#else /* CONFIG_PPC64 */
11656 static inline u64 get_tb(void)
11757 {
11858 unsigned int tbhi, tblo, tbhi2;
11959
60
+ if (IS_ENABLED(CONFIG_PPC64))
61
+ return mftb();
62
+
12063 do {
121
- tbhi = get_tbu();
122
- tblo = get_tbl();
123
- tbhi2 = get_tbu();
64
+ tbhi = mftbu();
65
+ tblo = mftb();
66
+ tbhi2 = mftbu();
12467 } while (tbhi != tbhi2);
12568
12669 return ((u64)tbhi << 32) | tblo;
127
-}
128
-#endif /* !CONFIG_PPC64 */
129
-
130
-static inline u64 get_tb_or_rtc(void)
131
-{
132
- return __USE_RTC() ? get_rtc() : get_tb();
13370 }
13471
13572 static inline void set_tb(unsigned int upper, unsigned int lower)
....@@ -147,11 +84,10 @@
14784 */
14885 static inline u64 get_dec(void)
14986 {
150
-#if defined(CONFIG_40x)
151
- return (mfspr(SPRN_PIT));
152
-#else
153
- return (mfspr(SPRN_DEC));
154
-#endif
87
+ if (IS_ENABLED(CONFIG_40x))
88
+ return mfspr(SPRN_PIT);
89
+
90
+ return mfspr(SPRN_DEC);
15591 }
15692
15793 /*
....@@ -161,23 +97,17 @@
16197 */
16298 static inline void set_dec(u64 val)
16399 {
164
-#if defined(CONFIG_40x)
165
- mtspr(SPRN_PIT, (u32) val);
166
-#else
167
-#ifndef CONFIG_BOOKE
168
- --val;
169
-#endif
170
- mtspr(SPRN_DEC, val);
171
-#endif /* not 40x */
100
+ if (IS_ENABLED(CONFIG_40x))
101
+ mtspr(SPRN_PIT, (u32)val);
102
+ else if (IS_ENABLED(CONFIG_BOOKE))
103
+ mtspr(SPRN_DEC, val);
104
+ else
105
+ mtspr(SPRN_DEC, val - 1);
172106 }
173107
174108 static inline unsigned long tb_ticks_since(unsigned long tstamp)
175109 {
176
- if (__USE_RTC()) {
177
- int delta = get_rtcl() - (unsigned int) tstamp;
178
- return delta < 0 ? delta + 1000000000 : delta;
179
- }
180
- return get_tbl() - tstamp;
110
+ return mftb() - tstamp;
181111 }
182112
183113 #define mulhwu(x,y) \
....@@ -201,5 +131,8 @@
201131 /* Convert timebase ticks to nanoseconds */
202132 unsigned long long tb_to_ns(unsigned long long tb_ticks);
203133
134
+/* SPLPAR */
135
+void accumulate_stolen_time(void);
136
+
204137 #endif /* __KERNEL__ */
205138 #endif /* __POWERPC_TIME_H */